#!/bin/bash # Apache monitorization plugin for Pandora FMS agent # Author: Manuel A. GulĂ­n Bejarano # Version: 1.1 # Date: 19/03/2013 # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . function help { echo -e "Apache monitorization agent plugin for Pandora FMS agent. http://pandorafms.com" echo -e "Apache need the server status module active and accessible from localhost without password" echo -e "Syntax:" echo -e "\t\t$0 " exit } if [ $# -ne 1 ] then help exit -1 fi ## Info about server - all retrieved with one query, later it's going to be appropiately parsed ASTAT="`wget -q -O - "$@" --no-check-certificate $1?auto`" FSTAT="`wget -q -O - "$@" --no-check-certificate $1`" # Info about CPU usage AF_CPUULOAD=`echo $FSTAT | grep -o "CPU Usage: u[0-9]*.[0-9]* s[0-9]*.[0-9]*" | awk '{print $3}' | cut -d"u" -f2 | tail --lines=1` AF_CPUSLOAD=`echo $FSTAT | grep -o "CPU Usage: u[0-9]*.[0-9]* s[0-9]*.[0-9]*" | awk '{print $4}' | cut -d"s" -f2 | tail --lines=1` # Info about performance AP_REQSEC=`echo $ASTAT | grep -o "ReqPerSec: [0-9.]*" | awk '{print $2}'` AP_BPS=`echo $ASTAT | grep -o "BytesPerSec: [0-9]*" | awk '{ print $2}'` AP_TOTACC=`echo $ASTAT | grep -o "Total Accesses: [0-9]*" | awk '{print $3}'` # Info about apache processes AP_BUSY=`echo $ASTAT | grep -o "BusyWorkers: [0-9]*" | awk '{print $2}'` AP_IDLE=`echo $ASTAT | grep -o "IdleWorkers: [0-9]*" | awk '{print $2}'` # Info about uptime AP_UPTIME=`echo $ASTAT | grep -o "Uptime: [0-9]*" | grep -o [0-9]*` AF_REBOOT=`echo $FSTAT | grep -o "
Restart Time: [a-zA-Z]*, [0-9]*-[a-zA-Z]*-[0-9]* [0-9:]* [a-zA-Z]*" | grep -o "[a-zA-Z]*, [0-9]*-[a-zA-Z]*-[0-9]* [0-9:]* [a-zA-Z]*" | tail --lines=1` AF_RELOADS=`echo $FSTAT | grep -o "Parent Server Generation: [0-9]*" | grep -o [0-9]* | tail --lines=1` # Some useful info AP_TOTAL=$((AP_BUSY+AP_IDLE)) AP_TOTAL_MIN_WARN=`echo $AP_TOTAL | awk '{print ($1*0.80)}'` AP_TOTAL_MAX_WARN=`echo $AP_TOTAL | awk '{print ($1*0.89)}'` AP_TOTAL_MIN_CRIT=`echo $AP_TOTAL | awk '{print ($1*0.90)}'` ######################################################################################################### # UPTIME INFO MODULES ######################################################################################################### echo -e "\t" echo -e "\t" echo -e "\t" echo -e "\tasync_string" echo -e "\t0" echo -e "\t0" echo -e "\t" #echo -e "\t0 * * * *" echo -e "\t" echo -e "\t" echo -e "\t" echo -e "\t" echo -e "\tgeneric_data" echo -e "\t0" echo -e "\t0" echo -e "\t" echo -e "\t" echo -e "\t" echo -e "\t" echo -e "\t" echo -e "\tasync_data" echo -e "\t0" echo -e "\t0" echo -e "\t" #echo -e "\t0 * * * *" echo -e "\t" ######################################################################################################### # PERFORMANCE INFO MODULES ######################################################################################################### echo -e "\t" echo -e "\t" echo -e "\t" echo -e "\tgeneric_data" echo -e "\t0" echo -e "\t0" echo -e "\t" echo -e "\t" echo -e "\t" echo -e "\t" echo -e "\t" echo -e "\tgeneric_data" echo -e "\t0" echo -e "\t0" echo -e "\t" echo -e "\t" echo -e "\t" echo -e "\t" echo -e "\t" echo -e "\tgeneric_data" echo -e "\t0" echo -e "\t0" echo -e "\t" echo -e "\t" ######################################################################################################### # CPU USAGE INFO MODULES ######################################################################################################### echo -e "\t" echo -e "\t" echo -e "\t" echo -e "\tgeneric_data" echo -e "\t0" echo -e "\t0" echo -e "\t" echo -e "\t" echo -e "\t" echo -e "\t" echo -e "\t" echo -e "\tgeneric_data" echo -e "\t0" echo -e "\t0" echo -e "\t" echo -e "\t" ######################################################################################################### # APACHE PROCESSES INFO MODULES ######################################################################################################### echo -e "\t" echo -e "\t" echo -e "\t" echo -e "\tgeneric_data" echo -e "\t0" echo -e "\t$AP_TOTAL" echo -e "\t$AP_TOTAL_MIN_WARN" echo -e "\t$AP_TOTAL_MAX_WARN" echo -e "\t$AP_TOTAL_MIN_CRIT" echo -e "\t$AP_TOTAL" echo -e "\t0" echo -e "\t" echo -e "\t" echo -e "\t" echo -e "\t" echo -e "\t" echo -e "\tgeneric_data" echo -e "\t0" echo -e "\t$AP_TOTAL" echo -e "\t0" echo -e "\t" echo -e "\t"