lorf / zapache

Zabbix Apache Monitoring Script (from https://www.zabbix.org/wiki/Docs/howto/apache_monitoring_script#Method_3, originally from https://www.zabbix.com/forum/showthread.php?p=62457)
85 stars 44 forks source link

ZBX_NOTSUPPORTED: Unsupported item key. #2

Closed naveensnayak closed 9 years ago

naveensnayak commented 9 years ago

I have zabbix agent version 2.4.2 and trying to monitor apache 2 on Ubuntu 14.04 I have imported al the templates and made all config changes when i try to test the script using

sudo -u zabbix zabbix_get -s localhost -k zapache[Uptime]

i get the errror ZBX_NOTSUPPORTED: Unsupported item key.

any ideas ?

lorf commented 9 years ago

Zapache retrieves "http://localhost/server-status?auto", check if it works on your host.

nguiot commented 9 years ago

I have quite the same behavior with Debian Wheezy 7.0, zabbix 2.4.2, Apache 2.2.22

lamp# wget -O /tmp/output.html "http://localhost/server-status?auto"
--2014-12-09 14:23:27--  http://localhost/server-status?auto
Resolving localhost (localhost)... ::1, 127.0.0.1
Connecting to localhost (localhost)|::1|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 425 [text/plain]
Saving to: `/tmp/output.html'

100%[==========================================================================================================================================>] 425         --.-K/s   in 0s      

2014-12-09 14:23:27 (44.8 MB/s) - `/tmp/output.html' saved [425/425]

lamp# cat /tmp/output.html 
Total Accesses: 22
Total kBytes: 55
CPULoad: .0565337
Uptime: 9428
ReqPerSec: .00233347
BytesPerSec: 5.9737
BytesPerReq: 2560
BusyWorkers: 1
IdleWorkers: 5
Scoreboard: W_____..........................................................................................................................................................................................................................................................

lamp# awk '/^Total Accesses:/ {print $3}' /tmp/output.html 
22

lamp# /usr/local/bin/zabbix/zapache http://localhost/server-status TotalAccesses
ZBX_NOTSUPPORTED

I tried to add some debugging "echo" in the script, and the error is return by this test :

if [ "$rval" -ne 0 ]; then
        echo "ZBX_NOTSUPPORTED"
fi

In my case, $rval = 1, $value is empty

More debugging :

lamp# bash -x zapache http://localhost/server-status TotalAccesses
+ zapachever=1.5
+ rval=0
+ value=
+ cache_seconds=60
+ '[' '' ']'
+ TMPDIR=/tmp
+ [[ 2 == 1 ]]
+ [[ 2 == 2 ]]
+ STATUS_URL=http://localhost/server-status
+ case "$STATUS_URL" in
+ CASE_VALUE=TotalAccesses
+ case "$CASE_VALUE" in
+ cache_prefix=zapache-http___localhost_server-status
+ cache=/tmp/zapache-http___localhost_server-status.cache
+ cache_timestamp_check=/tmp/zapache-http___localhost_server-status.ts
++ date +%s
+ touch -d @1418131656 /tmp/zapache-http___localhost_server-status.ts
+ '[' /tmp/zapache-http___localhost_server-status.cache -ot /tmp/zapache-http___localhost_server-status.ts ']'
++ which curl
+ curl=
+ '[' '' ']'
++ which wget
+ wget=/usr/bin/wget
+ '[' /usr/bin/wget ']'
+ fetch_url_cmd='/usr/bin/wget --no-check-certificate --quiet -O -'
+ /usr/bin/wget --no-check-certificate --quiet -O - http://localhost/server-status
+ case "$CASE_VALUE" in
+ '[' -s /tmp/zapache-http___localhost_server-status.cache ']'
+ case "$CASE_VALUE" in
++ awk '/^Total Accesses:/ {print $3}'
+ value=
+ rval=0
+ '[' 0 -eq 0 -a -z '' ']'
+ rval=1
+ '[' 1 -ne 0 ']'
+ echo ZBX_NOTSUPPORTED
ZBX_NOTSUPPORTED
+ echo ''

+ exit 1
lorf commented 9 years ago

In debug run You need to specify URL for machine readable status page, e.g "http://localhost/server-status?auto" or awk may fail. Please check contents of resulting /tmp/zapache-http___localhost_server-status.cache file.

There also may be problems with cache file permissions, please check that. I added a check for that error in latest commit couple of minutes ago.

nguiot commented 9 years ago

OK, sorry, I had misread the manual and the code :

# zapache localhost TotalAccesses
36

 # zapache http://localhost/server-status?auto TotalAccesses
36
lorf commented 9 years ago

It's also always a good idea to check zabbix-agent logs. Script stderr will go there.