Problem with passing macro output to custom script


I’m trying to pass Nagios macro outputs to an external script for service data processing and I’m having problems. Here’s an excerpt from the nagios.debug file:

[1255636024.077307] [2048.1] [pid=23651] Processing: ‘/usr/local/nagios/libexec/ “$SERVICEOUTPUT$” “$SERVICEPERFDATA$” “$HOSTNAME$” “$SERVICEDESC$”’
[1255636024.077329] [2048.1] [pid=23651] Done. Final output: ‘/usr/local/nagios/libexec/ “RL_PWR OKAY : The RL Power is: -10” “-10” “sit-TACE” “RL Pwr”’

To me the above lines look okay. The Final output is passing four arguments (delimited by double quotes) to my script (which is what I want). In fact if I copy and paste the command directly in a terminal window (minus the single quotes) it works.

However when monitoring “ps -aux” command (running it over and over) I see this:
nagios 23996 0.0 0.0 5260 1368 ? S 15:47 0:00 /bin/ksh /usr/local/nagios/libexec/ RL_PWR OKAY : The RL Power is: -10 -10 sit-TACE RL Pwr

See how the " (quotes) have been removed ? Now it looks like 12 args are passed to my script and of course if fails.
any ideas


Using Nagios 3.2 on Fedora 11


try escaping the quotes… something like “”$SERVICEOUTPUT"" could do it…


I figured it out. I feel quite silly now.

I added some debug lines of my own in the script (just echo commands redirected to a log file). The script starts properly and all the args are passed adequately. Essentially the script will update RRD files with the said perf data for graphing via Cacti. If the RRD file doesn’t exist the script will 1st create it and then subsequently update the files later. Anyways my problem was with file/directory permissions. The user “nagios” was not allowed to write to the Cacti /rra directory. That’s now fixed and all works fine.

Sorry if I posted a bit too quick. Like I said I feel humbled now. :roll:



I think most of us passed there more than once… :slight_smile:

Thanks for sharing it anyway, always good to be reminded of the possible problems.