Hi All,
I want to share my little script to monitor apache performance:
your have to create your "UserParameter" in /etc/zabbix/zabbix_agentd.conf"
UserParameter=apache.total_accesses,/usr/local/ackstorm/zabbix_agentd/ack_zabbix_apache.pl|cut -f1 -d":"
UserParameter=apache.total_kbytes,/usr/local/ackstorm/zabbix_agentd/ack_zabbix_apache.pl|cut -f2 -d":"
UserParameter=apache.cpuload,/usr/local/ackstorm/zabbix_agentd/ack_zabbix_apache.pl|cut -f3 -d":"
UserParameter=apache.uptime,/usr/local/ackstorm/zabbix_agentd/ack_zabbix_apache.pl|cut -f4 -d":"
UserParameter=apache.reqpersec,/usr/local/ackstorm/zabbix_agentd/ack_zabbix_apache.pl|cut -f5 -d":"
UserParameter=apache.bytespersec,/usr/local/ackstorm/zabbix_agentd/ack_zabbix_apache.pl|cut -f6 -d":"
UserParameter=apache.bytesperreq,/usr/local/ackstorm/zabbix_agentd/ack_zabbix_apache.pl|cut -f7 -d":"
UserParameter=apache.busyservers,/usr/local/ackstorm/zabbix_agentd/ack_zabbix_apache.pl|cut -f8 -d":"
UserParameter=apache.idleservers,/usr/local/ackstorm/zabbix_agentd/ack_zabbix_apache.pl|cut -f9 -d":"
source code for "ack_zabbix_apache.pl" is:
#!/usr/bin/perl
# Debian Users: apt-get install libwww-perl
use LWP::Simple;
use strict;
my($url)="http://localhost/server-status?auto";
my($server_status)=get($url);
my($total_accesses,$total_kbytes,$cpuload,$uptime, $reqpersec,$bytespersec,$bytesperreq,$busyservers, $idleservers);
if (! $server_status) {
print "Can't access $url\nCheck apache configuration\n\n";
exit(1);
}
$total_accesses = $1 if ($server_status =~ /Total\ Accesses:\ ([\d|\.]+)/ig)||0;
$total_kbytes = $1 if ($server_status =~ /Total\ kBytes:\ ([\d|\.]+)/gi);
$cpuload = $1 if ($server_status =~ /CPULoad:\ ([\d|\.]+)/gi);
$uptime = $1 if ($server_status =~ /Uptime:\ ([\d|\.]+)/gi);
$reqpersec = $1 if ($server_status =~ /ReqPerSec:\ ([\d|\.]+)/gi);
$bytespersec = $1 if ($server_status =~ /BytesPerSec:\ ([\d|\.]+)/gi);
$bytesperreq = $1 if ($server_status =~ /BytesPerReq:\ ([\d|\.]+)/gi);
$busyservers = $1 if ($server_status =~ /BusyServers:\ ([\d|\.]+)/gi);
$idleservers = $1 if ($server_status =~ /IdleServers:\ ([\d|\.]+)/gi);
printf "%i:%i:%.2f:%i:%.2f:%.2f:%.2f:%i:%i\n",$total_acce sses,$total_kbytes,$cpuload,$uptime,$reqpersec,$by tespersec,$bytesperreq,$busyservers,$idleservers;
exit(0);
I want to share my little script to monitor apache performance:
your have to create your "UserParameter" in /etc/zabbix/zabbix_agentd.conf"
UserParameter=apache.total_accesses,/usr/local/ackstorm/zabbix_agentd/ack_zabbix_apache.pl|cut -f1 -d":"
UserParameter=apache.total_kbytes,/usr/local/ackstorm/zabbix_agentd/ack_zabbix_apache.pl|cut -f2 -d":"
UserParameter=apache.cpuload,/usr/local/ackstorm/zabbix_agentd/ack_zabbix_apache.pl|cut -f3 -d":"
UserParameter=apache.uptime,/usr/local/ackstorm/zabbix_agentd/ack_zabbix_apache.pl|cut -f4 -d":"
UserParameter=apache.reqpersec,/usr/local/ackstorm/zabbix_agentd/ack_zabbix_apache.pl|cut -f5 -d":"
UserParameter=apache.bytespersec,/usr/local/ackstorm/zabbix_agentd/ack_zabbix_apache.pl|cut -f6 -d":"
UserParameter=apache.bytesperreq,/usr/local/ackstorm/zabbix_agentd/ack_zabbix_apache.pl|cut -f7 -d":"
UserParameter=apache.busyservers,/usr/local/ackstorm/zabbix_agentd/ack_zabbix_apache.pl|cut -f8 -d":"
UserParameter=apache.idleservers,/usr/local/ackstorm/zabbix_agentd/ack_zabbix_apache.pl|cut -f9 -d":"
source code for "ack_zabbix_apache.pl" is:
#!/usr/bin/perl
# Debian Users: apt-get install libwww-perl
use LWP::Simple;
use strict;
my($url)="http://localhost/server-status?auto";
my($server_status)=get($url);
my($total_accesses,$total_kbytes,$cpuload,$uptime, $reqpersec,$bytespersec,$bytesperreq,$busyservers, $idleservers);
if (! $server_status) {
print "Can't access $url\nCheck apache configuration\n\n";
exit(1);
}
$total_accesses = $1 if ($server_status =~ /Total\ Accesses:\ ([\d|\.]+)/ig)||0;
$total_kbytes = $1 if ($server_status =~ /Total\ kBytes:\ ([\d|\.]+)/gi);
$cpuload = $1 if ($server_status =~ /CPULoad:\ ([\d|\.]+)/gi);
$uptime = $1 if ($server_status =~ /Uptime:\ ([\d|\.]+)/gi);
$reqpersec = $1 if ($server_status =~ /ReqPerSec:\ ([\d|\.]+)/gi);
$bytespersec = $1 if ($server_status =~ /BytesPerSec:\ ([\d|\.]+)/gi);
$bytesperreq = $1 if ($server_status =~ /BytesPerReq:\ ([\d|\.]+)/gi);
$busyservers = $1 if ($server_status =~ /BusyServers:\ ([\d|\.]+)/gi);
$idleservers = $1 if ($server_status =~ /IdleServers:\ ([\d|\.]+)/gi);
printf "%i:%i:%.2f:%i:%.2f:%.2f:%.2f:%i:%i\n",$total_acce sses,$total_kbytes,$cpuload,$uptime,$reqpersec,$by tespersec,$bytesperreq,$busyservers,$idleservers;
exit(0);

?!
Comment