I’ve been beavering away with my nagios install, and it’s all going pretty well. So I thought I’d move on to writing my own (very simple!) custom plugin.
I wrote a simple script to check whether a tape drive door is open or not. The script works fine when I run it from the command-line.
However, when I call it via check_nrpe, it always reports that a tape is inserted - even if it’s not!
So I figure I must have something wrong with how I am calling the script. Hours of web searching later I’m none the wiser, so I thought I’d ask and hope some kind soul takes pity on me!
Here is the nuts and bolts of my script -
if “/bin/mt -tf /dev/st0 status | sed -n 6p” = " DR_OPEN IM_REP_EN" ] ; then
echo "WARNING - no tape is inserted"
exit 1
else
echo "OK - tape is inserted"
exit 0
fi
The script in crontab worked when running as root, but produced no output at all when running as nagios… so I logged in as nagios, ran the script locally, and found I had no permissions on /dev/st0.
So I added the nagios user to the disk group (which owns the /dev/st0 device), and following that, running the script as the nagios user gave me the correct result.
However… check_nrpe still told me the tape was in the drive!
Eventually I got round this by changing /etc/xinetd.d/nrpe so the nrpe agent runs under the disk group, rather than the nagios group.
So it works, but I’m not convinced this is the best way to run it!
some permission issue for sure… WHAT permission issue remains open for debate
You should consider changing your script to something which evaluates an error condition… haveing the if then else only has the OK condition as fallback which isn’t the best possible choice.