1

I have bash script that returns right results when I run as user nagios manually. It fails as unknown when configured in in nagios configs.

Entries in nagios configs

 define command { 
     command_name   check_s3descrepency
     command_line /usr/lib64/nagios/plugins/check_s3descrepency $ARG1$

 }

define service{
        use                     generic-service
        service_description     Check android_event S3 descrepency
        host_name               nagios-server
        check_command       check_s3descrepency!android_event
}

[root@nagios nagios]# sudo -u nagios /usr/lib64/nagios/plugins/check_s3descrepency android_event
OK - 2014-05-07-22-00 Data size match with pre week 2014-04-30-22-00 by 102%
[root@nagios nagios]# 

Enabled the debug and following is the log

[1399529584.757820] [016.0] [pid=1089] Checking service 'Check android_event S3 descrepency' on host 'nagios-server'...
[1399529584.757839] [2320.2] [pid=1089] Raw Command Input: /usr/lib64/nagios/plugins/check_s3descrepency $ARG1$
[1399529584.757891] [2320.2] [pid=1089] Expanded Command Output: /usr/lib64/nagios/plugins/check_s3descrepency $ARG1$
[1399529584.757916] [2048.1] [pid=1089] Processing: '/usr/lib64/nagios/plugins/check_s3descrepency $ARG1$'
[1399529584.757923] [2048.2] [pid=1089]   Processing part: '/usr/lib64/nagios/plugins/check_s3descrepency '
[1399529584.757930] [2048.2] [pid=1089]   Not currently in macro.  Running output (46): '/usr/lib64/nagios/plugins/check_s3descrepency '
[1399529584.757957] [2048.2] [pid=1089]   Uncleaned macro.  Running output (66): '/usr/lib64/nagios/plugins/check_s3descrepency android_event'
[1399529584.757962] [2048.2] [pid=1089]   Just finished macro.  Running output (66): '/usr/lib64/nagios/plugins/check_s3descrepency android_event'
[1399529584.757972] [2048.2] [pid=1089]   Not currently in macro.  Running output (66): '/usr/lib64/nagios/plugins/check_s3descrepency android_event'
[1399529584.757977] [2048.1] [pid=1089]   Done.  Final output: '/usr/lib64/nagios/plugins/check_s3descrepency android_event'
[1399529586.011991] [016.1] [pid=1089] Handling check result for service 'Check android_event S3 descrepency' on host 'nagios-server'...
[1399529586.012012] [016.0] [pid=1089] ** Handling check result for service 'Check android_event S3 descrepency' on host 'nagios-server'...
[1399529586.012022] [016.1] [pid=1089] HOST: nagios-server, SERVICE: Check android_event S3 descrepency, CHECK TYPE: Active, OPTIONS: 1, SCHEDULED: Yes, RESCHEDULE: Yes, EXITED OK: Yes, RETURN CODE: 3, OUTPUT: \nUNKNOWN - 2014-05-07-22-00 Data size match with pre week 2014-04-30-22-00 by %\n
[1399529586.012170] [016.1] [pid=1089] Checking service 'Check android_event S3 descrepency' on host 'nagios-server' for flapping...
[1399529586.012267] [032.0] [pid=1089] ** Service Notification Attempt ** Host: 'nagios-server', Service: 'Check android_event S3 descrepency', Type: 0, Options: 0, Current State: 3, Last Notification: Wed Dec 31 16:00:00 1969
[1399529586.012385] [016.0] [pid=1089] Scheduling a non-forced, active check of service 'Check android_event S3 descrepency' on host 'nagios-server' @ Wed May  7 23:23:04 2014
[1399529631.103930] [008.0] [pid=1089] ** Service Check Event ==> Host: 'nagios-server', Service: 'Check android_event S3 descrepency', Options: 0, Latency: 0.103000 sec
[1399529631.103946] [016.0] [pid=1089] Attempting to run scheduled check of service 'Check android_event S3 descrepency' on host 'nagios-server': check options=0, latency=0.103000
3
  • 1
    Check your script for things related to the environment (PATH, etc). – Zoredache May 8 '14 at 6:39
  • Nagios use return code to determined the state of command (OK, Warning, critical, unknown) see documentation. Please post the return codes of the script after executed in shell. References in how-to-check-exit-status-code – masegaloeh May 8 '14 at 6:56
  • You spelled discrepancy wrong ;-) – Keith May 8 '14 at 15:56
0

Thanks Zoredache. It was env variable.

s3cmd was not in path for nagios user, Added full path in script and it worked like charm.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.