I've written a nagios plugin using the bash scripting language. When I run this script by hand it works with no issue. Putting it into a nagios plugin however, using the same parameters, leads to heartburn.
The key line involves the bc
command. The line in my script reads like this:
total_percentage=$(bc <<<"scale=2;($numerator_count/$denominator_count)*100")
if I run the script by hand all is well and total_percentage
is calculated correctly and the script moves on.
Nagios apparently just stops cold when it runs that line. I'm not sure how to debug this, the nagios log doesn't reveal much. Are there extra flags I can set when starting the service that might help? Would anyone know what might be wrong with the line above when running under nagios?
!#/bin/bash
What is your Linux flavour ?echo $SHELL
within and outside your script ?