Page 2 of 2
Re: Nagios will not return string from bash script
Posted: Tue Sep 11, 2012 4:50 pm
by jsmurphy
Hmmmm I don't think I've ever seen an instance where the nagios user can execute a shell script but not the nagios application... with selinux disabled. Might be time to turn on Nagios debugging in nagios/etc/nagios.cfg, by default it will create the file nagios/var/nagios.debug .
So after you have turned on debugging, start nagios, force the command to run and then turn nagios off again so that the log doesn't end up so large you can't find what you are after.
Re: Nagios will not return string from bash script
Posted: Tue Sep 11, 2012 5:02 pm
by w14219
Is this the information you were looking for?
[1347400299.366208] [008.0] [pid=18541] ** Service Check Event ==> Host: 'Mikrotik-RB411AH', Service: 'tx-ccq', Options: 1, Latency: 2.366000 sec
[1347400299.366237] [001.0] [pid=18541] run_scheduled_service_check() start
[1347400299.366243] [016.0] [pid=18541] Attempting to run scheduled check of service 'tx-ccq' on host 'Mikrotik-RB411AH': check options=1, latency=2.366000
[1347400299.366253] [001.0] [pid=18541] run_async_service_check()
[1347400299.366287] [001.0] [pid=18541] check_service_check_viability()
[1347400299.366295] [064.1] [pid=18541] Making callbacks (type 13)...
[1347400299.366300] [016.0] [pid=18541] Checking service 'tx-ccq' on host 'Mikrotik-RB411AH'...
[1347400299.366340] [001.0] [pid=18541] get_raw_command_line_r()
[1347400299.366353] [001.0] [pid=18541] process_macros_r()
[1347400299.366360] [2048.1] [pid=18541] **** BEGIN MACRO PROCESSING ***********
[1347400299.366364] [2048.1] [pid=18541] Processing: '$USER1$/check_rg411 $HOSTADDRESS $ARG3$'
[1347400299.366380] [2048.0] [pid=18541] WARNING: Could not find a macro matching 'HOSTADDRESS '!
[1347400299.366385] [2048.0] [pid=18541] WARNING: An error occurred processing macro 'HOSTADDRESS '!
[1347400299.366391] [2048.0] [pid=18541] WARNING: Could not find a macro matching ''!
[1347400299.366395] [2048.0] [pid=18541] WARNING: An error occurred processing macro ''!
[1347400299.366399] [2048.1] [pid=18541] Done. Final output: '/usr/local/nagios/libexec/check_rg411 $HOSTADDRESS $ARG3$'
[1347400299.366403] [2048.1] [pid=18541] **** END MACRO PROCESSING *************
[1347400299.366407] [064.1] [pid=18541] Making callbacks (type 13)...
[1
Re: Nagios will not return string from bash script
Posted: Tue Sep 11, 2012 5:04 pm
by jsmurphy
*slaps forehead* are you able to post your command definition for check_rg411?... I think I know what your problem is.
Re: Nagios will not return string from bash script
Posted: Tue Sep 11, 2012 5:11 pm
by w14219
#Per request Command Def!
define command{
command_name check_rg411
command_line $USER1$/check_rg411 $HOSTADDRESS $ARG3$
}
Re: Nagios will not return string from bash script
Posted: Tue Sep 11, 2012 5:18 pm
by jsmurphy
w14219 wrote:#Per request Command Def!
define command{
command_name check_rg411
command_line $USER1$/check_rg411 $HOSTADDRESS $ARG3$
}
Change your command_line to this:
Code: Select all
command_line $USER1$/check_rg411 $HOSTADDRESS$ $ARG3$
You were missing the trailing $ sign

Re: Nagios will not return string from bash script
Posted: Tue Sep 11, 2012 8:09 pm
by w14219
Thanks for catching that. I am still having issue with returning the information from the script..... so sad.
I am finding this error now in the Nagios log.
[1347400320] EXTERNAL COMMAND: SCHEDULE_FORCED_SVC_CHECK;Mikrotik-RB411AH;tx-ccq;1347400317
[1347400336] EXTERNAL COMMAND: SCHEDULE_FORCED_SVC_CHECK;Mikrotik-RB411AH;tx-ccq;1347400334
[1347400369] Caught SIGTERM, shutting down...
[1347400369] Successfully shutdown... (PID=18541)
Am trying to see what can be causing this.
Thanks
Re: Nagios will not return string from bash script
Posted: Wed Sep 12, 2012 5:09 pm
by jsmurphy
What about the debug log?
Re: Nagios will not return string from bash script
Posted: Wed Sep 12, 2012 5:24 pm
by w14219
Debug Log:
[1347397893] HOST NOTIFICATION: nagiosadmin;Singri-2008r2;DOWN;notify-host-by-email;CRITICAL - Socket timeout after 10 seconds
[1347398093] SERVICE NOTIFICATION: nagiosadmin;Mikrotik-RB411AH;tx-ccq;WARNING;notify-service-by-email;tc-ccq less than 90%=
[1347399643] Auto-save of retention data completed successfully.
[1347399693] HOST NOTIFICATION: nagiosadmin;Singri-2008r2;DOWN;notify-host-by-email;CRITICAL - Socket timeout after 10 seconds
[1347400290] Caught SIGTERM, shutting down...
[1347400290] Successfully shutdown... (PID=13765)
[1347400290] Error: NULL variable value - Line 36 of resource file '/usr/local/nagios/etc/resource.cfg'
[1347400290] Nagios 3.3.1 starting... (PID=18540)
[1347400290] Local time is Tue Sep 11 16:51:30 CDT 2012
[1347400290] LOG VERSION: 2.0
[1347400290] Error: Template 'graphed-service' specified in host definition could not be not found (config file '/usr/local/nagios/etc/objects/templates.cfg', starting on line 137)
[1347400290] Error: Template 'graphed-service' specified in host definition could not be not found (config file '/usr/local/nagios/etc/objects/templates.cfg', starting on line 100)
[1347400290] Error: Template 'graphed-service' specified in host definition could not be not found (config file '/usr/local/nagios/etc/objects/templates.cfg', starting on line 79)
[1347400290] Finished daemonizing... (New PID=18541)
[1347400299] EXTERNAL COMMAND: SCHEDULE_FORCED_SVC_CHECK;Mikrotik-RB411AH;tx-ccq;1347400297
[1347400320] EXTERNAL COMMAND: SCHEDULE_FORCED_SVC_CHECK;Mikrotik-RB411AH;tx-ccq;1347400317
[1347400336] EXTERNAL COMMAND: SCHEDULE_FORCED_SVC_CHECK;Mikrotik-RB411AH;tx-ccq;1347400334
[1347400369] Caught SIGTERM, shutting down...
[1347400369] Successfully shutdown... (PID=18541)
[1347400369] Error: NULL variable value - Line 36 of resource file '/usr/local/nagios/etc/resource.cfg'
[1347400369] Nagios 3.3.1 starting... (PID=18633)
[1347400369] Local time is Tue Sep 11 16:52:49 CDT 2012
[1347400369] LOG VERSION: 2.0
[1347400369] Error: Template 'graphed-service' specified in host definition could not be not found (config file '/usr/local/nagios/etc/objects/templates.cfg', starting on line 137)
[1347400369] Error: Template 'graphed-service' specified in host definition could not be not found (config file '/usr/local/nagios/etc/objects/templates.cfg', starting on line 100)
[1347400369] Error: Template 'graphed-service' specified in host definition could not be not found (config file '/usr/local/nagios/etc/objects/templates.cfg', starting on line 79)
[1347400369] Finished daemonizing... (New PID=18634)
^C
w14219@Nagios:/usr/local/nagios/var$ tail -f nagios.log
[1347411103] Caught SIGTERM, shutting down...
[1347411103] Successfully shutdown... (PID=25207)
[1347411103] Error: NULL variable value - Line 36 of resource file '/usr/local/nagios/etc/resource.cfg'
[1347411103] Nagios 3.3.1 starting... (PID=25303)
[1347411103] Local time is Tue Sep 11 19:51:43 CDT 2012
[1347411103] LOG VERSION: 2.0
[1347411103] Error: Template 'graphed-service' specified in host definition could not be not found (config file '/usr/local/nagios/etc/objects/templates.cfg', starting on line 137)
[1347411103] Error: Template 'graphed-service' specified in host definition could not be not found (config file '/usr/local/nagios/etc/objects/templates.cfg', starting on line 100)
[1347411103] Error: Template 'graphed-service' specified in host definition could not be not found (config file '/usr/local/nagios/etc/objects/templates.cfg', starting on line 79)
[1347411103] Finished daemonizing... (New PID=25304)
^C
w14219@Nagios:/usr/local/nagios/var$ vi nagios.log
Re: Nagios will not return string from bash script
Posted: Thu Sep 13, 2012 4:19 pm
by w14219
I was able to duplicate the same error in Nagios 3.4.1.
The debug log was able to provide me with additional details:
[1347382344.013281] [2048.1] [pid=14476] **** BEGIN MACRO PROCESSING ***********
[1347382344.013285] [2048.1] [pid=14476] Processing: '$USER1$/check_rg411 $HOSTADDRESS$ $ARG3$'
[1347382344.013304] [2048.1] [pid=14476] Done. Final output: '/usr/local/nagios/libexec/check_rg411 10.2.1.34 '
[1347382344.013309] [2048.1] [pid=14476] **** END MACRO PROCESSING *************
[1347382344.013314] [064.1] [pid=14476] Making callbacks (type 13)...
[1347382344.013422] [016.1] [pid=14476] Check result output will be written to '/usr/local/nagios/var/spool/checkresults/check2WP7Bm' (fd=7)
[1347382344.014642] [001.0] [pid=14476] handle_timed_event() end
[1347382344.014704] [008.1] [pid=14476] ** Event Check Loop
[1347382344.014740] [008.1] [pid=14476] Next High Priority Event Time: Tue Sep 11 11:52:25 2012
[1347382344.014762] [008.1] [pid=14476] Next Low Priority Event Time: Tue Sep 11 11:52:22 2012
[1347382344.014797] [008.1] [pid=14476] Current/Max Service Checks: 3/0
[1347382344.014829] [008.1] [pid=14476] Running event...
[1347382344.014837] [001.0] [pid=14476] handle_timed_event() start
[1347382344.014841] [064.1] [pid=14476] Making callbacks (type 8)...
[1347382344.014849] [008.0] [pid=14476] ** Timed Event ** Type: 0, Run Time: Tue Sep 11 11:52:22 2012
[1347382344.014873] [008.0] [pid=14476] ** Service Check Event ==> Host: 'Mikrotik-RB411AH', Service: 'tx-ccq', Options: 1, Latency: 2.014000 sec
[1347382344.014892] [001.0] [pid=14476] run_scheduled_service_check() start
[1347382344.014897] [016.0] [pid=14476] Attempting to run scheduled check of service 'tx-ccq' on host 'Mikrotik-RB411AH': check options=1, latency=2.014000
[1347382344.014918] [001.0] [pid=14476] run_async_service_check()
[1347382344.014926] [001.0] [pid=14476] check_service_check_viability()
[1347382344.014931] [064.1] [pid=14476] Making callbacks (type 13)...
[1347382344.014935] [016.0] [pid=14476] Checking service 'tx-ccq' on host 'Mikrotik-RB411AH'...
[1347382344.014992] [001.0] [pid=14476] get_raw_command_line_r()
[1347382344.015000] [001.0] [pid=14476] process_macros_r()
[1347382344.015016] [2048.1] [pid=14476] **** BEGIN MACRO PROCESSING ***********
[1347382344.015023] [2048.1] [pid=14476] Processing: '$USER1$/check_rg411 $HOSTADDRESS$ $ARG3$'
[1347382344.015062] [2048.1] [pid=14476] Done. Final output: '/usr/local/nagios/libexec/check_rg411 10.2.1.34 '
[1347382344.015069] [2048.1] [pid=14476] **** END MACRO PROCESSING *************
[
I am not sure what to make of it not returning the needed information.