I have tried to extend zabbix 1.8 running on Linux/FreeBSD to monitor apache version 2.0.x (most of the monitoring help is on version 2.2.x instead which does not really work on 2.0.x) with the following steps and problem:-
1. Enable active check on zabbix agentd with DisableActive=0 on zabbix_agentd.conf (is this step really necessary ?)
2. Modify the zabbix_agentd.conf with the following lines:-
UserParameter=apache2.CPULoadUser,/usr/sbin/apachectl status | /bin/grep
3. Create the /home/zabbix/checkWorker.awk as below:-
4. Add item apache.* (CPULoadUser, CPULoadSystem, ..., OpenSlot etc) using the UI.
5. Restart the zabbix agent.
While I cannot locate those data on the zabbix. When I tried to run the following command :-
I then tried to run the command using the zabbix user account and it works:-
I then turn on debugging by putting DebugLevel 4 inside the zabbix_agentd.conf and then restart the zabbix_agentd and found the following error message inside the log:-
BTW, zabbix user have write permission on /home/zabbix/ and all files inside the folder.
What have I done wrong? Any help is much appreciated.
1. Enable active check on zabbix agentd with DisableActive=0 on zabbix_agentd.conf (is this step really necessary ?)
2. Modify the zabbix_agentd.conf with the following lines:-
UserParameter=apache2.CPULoadUser,/usr/sbin/apachectl status | /bin/grep
Code:
"CPU load" | /bin/awk '{print $3}'
UserParameter=apache2.CPULoadSystem,/usr/sbin/apachectl status | /bin/grep "CPU load" | /bin/awk '{print $4}'
UserParameter=apache2.CPULoadPercentage,/usr/sbin/apachectl status | /bin/grep "CPU load" | /bin/awk '{print $8}'
UserParameter=apache2.RequestPerSecond,/usr/sbin/apachectl status | /bin/grep "requests/sec" | /bin/awk '{print $1}'
UserParameter=apache2.BytePerSecond,/usr/sbin/apachectl status | /bin/grep "B/second" | /bin/awk "'multiplier=1;if (substr($5,1,1)!="B") multiplier*=1024; if (substr($5,1,1)=="M") multiplier*=1024; if (substr($5,1,1)=="G") multiplier*=1024*1024; print $4*multiplier}'
UserParamter=apache2.BytePerRequest,/usr/sbin/apachectl status | /bin/grep "B/request" | /bin/awk '{multiplier=1;if (substr($8,1,1)!="B") multiplier*=1024; if (substr($8,1,1)=="M") multiplier*=1024; if (substr($8,1,1)=="G") multiplier*=1024*1024; print $7*multiplier}'
UserParameter=apache2.BusyWorker,/usr/sbin/apachectl status | /bin/grep "requests currently being processed," | /bin/awk '{print $1}'
UserParameter=apache2.IdleWorker,/usr/sbin/apachectl status | /bin/grep "idle workers" | /bin/awk '{print $6}'
UserParameter=apache2.WaitingForConnection,/usr/sbin/apachectl status | /bin/awk -f /home/zabbix/checkWorker.awk | /bin/grep "WaitingForConnection" | /bin/awk '{print $3}'
UserParameter=apache2.StartingUp,/usr/sbin/apachectl status | /bin/awk -f /home/zabbix/checkWorker.awk | /bin/grep "StartingUp" | /bin/awk '{print $3}'
UserParameter=apache2.ReadingRequest,/usr/sbin/apachectl status | /bin/awk -f /home/zabbix/checkWorker.awk | /bin/grep "ReadingRequest" | /bin/awk '{print $3}'
UserParameter=apache2.SendingReply,/usr/sbin/apachectl status | /bin/awk -f /home/zabbix/checkWorker.awk | /bin/grep "SendingReply" | /bin/awk '{print $3}'
UserParameter=apache2.Keepalive,/usr/sbin/apachectl status | /bin/awk -f checkWorker.awk | /bin/grep "Keepalive" | /bin/awk "'print $3}'
UserParameter=apache2.DNSLookup,/usr/sbin/apachectl status | /bin/awk -f /home/zabbix/checkWorker.awk | /bin/grep "DNSLookup" | /bin/awk '{print $3}'
UserParameter=apache2.ClosingConnection,/usr/sbin/apachectl status | /bin/awk -f /home/zabbix/checkWorker.awk | /bin/grep "ClosingConnection" | /bin/awk '{print $3}'
UserParameter=apache2.Logging,/usr/sbin/apachectl status | /bin/awk -f /home/zabbix/checkWorker.awk | /bin/grep "Logging" | /bin/awk '{print $3}'
UserParameter=apache2.GracefullyFinishing,/usr/sbin/apachectl status | /bin/awk -f /home/zabbix/checkWorker.awk | /bin/grep "GracefullyFinishing" | /bin/awk '{print $3}'
UserParameter=apache2.IdleCleanup,/usr/sbin/apachectl status | /bin/awk -f /home/zabbix/checkWorker.awk | /bin/grep "IdleCleanup" | /bin/awk '{print $3}'
UserParameter=apache2.OpenSlot,/usr/sbin/apachectl status | /bin/awk -f /home/zabbix/checkWorker.awk | /bin/grep "OpenSlot" | /bin/awk '{print $3}'
Code:
BEGIN {
Mode="start";
Key="_SRWKDCLGI.";
Description[0]="WaitingForConnection";
Description[1]="StartingUp";
Description[2]="ReadingRequest";
Description[3]="SendingReply";
Description[4]="Keepalive";
Description[5]="DNSLookup";
Description[6]="ClosingConnection";
Description[7]="Logging";
Description[8]="GracefullyFinishing";
Description[9]="IdleCleanup";
Description[10]="OpenSlot";
for (Position = 0 ; Position <= 10 ; Position++)
Value[Position] = 0;
}
{
if (Mode=="start") {
if (/ idle workers/)
Mode="Processing";
}
else if (Mode=="Processing") {
if (/Scoreboard Key:/)
Mode="End";
else
for (Post = 0; Post <= length;Post++) {
Slot=index(Key, substr($0, Post, 1));
if (Slot > 0)
Value[Slot-1]+=1;
}
}
}
END {
for ( Position = 0 ; Position <= 10 ; Position++)
print Description[Position] " : " Value[Position];
}
5. Restart the zabbix agent.
While I cannot locate those data on the zabbix. When I tried to run the following command :-
Code:
root@hostname #zabbix_agentd -t apache2.ReadingRequest apache2.ReadingRequest [m|ZBX_NOTSUPPORTED]
Code:
zabbix@hostname #/usr/sbin/apachectl status | /bin/awk -f /home/zabbix/checkWorker.awk | /bin/grep "ReadingRequest" | /bin/awk '{print $3}'
0
Code:
18868:20100115:094510.936 Requested [apache2.ReadingRequest]
Unable to find or create ELinks config directory. Please check if you have $HOME variable set correctly and if you have write permission to your home directory.
18868:20100115:094513.966 Before
18868:20100115:094513.966 Run remote command [/usr/sbin/apachectl status | /bin/awk -f /home/zabbix/checkWorker.awk | /bin/grep "ReadingRequest" | /bin/awk '{print $3}'] Result [1] [0]...
18868:20100115:094513.966 Sending back [0]
What have I done wrong? Any help is much appreciated.
Comment