Page 1 of 1

No output returned from plugin

Posted: Thu Apr 16, 2020 11:16 am
by C.Appl
Hi everyone,

Iam using Nagios Core on a Raspberry Pi with Raspbian and i want to monitor the temperature and humidity of a room.
So i installed wiring pi and dht22 for the dht22 sensor. Also i created a script for it, a command and the host with the services.
So far everything works fine and i got no problems.

When i run the script in the command line, it works, i got the values for the temperature and humidity.
But in the web interface i have the message: no output returned from plugin.
What have I do, that i can see the values also in the web interface.

Here are my scripts:
temperature

Code: Select all

#!/bin/sh
case $1 in
config)
cat <<'EOM'
graph_title Temperatur
graph_vlabel temperature
temperature.label °C
EOM
exit 0;;
esac
echo $(~/wiringpi/lol_dht22/loldht 7 | grep -i "temperature" | cut -d ' ' -f7)
echo "°"
humidity

Code: Select all

#!/bin/bash
case $1 in
config)
cat <<'EOM'
graph_title relative Luftfeuchtigkeit
graph_vlabel humidity
humidity.label r. F. %
EOM
exit 0;;
esac
echo $(~/wiringpi/lol_dht22/loldht 7 | grep -i "humidity" | cut -d ' ' -f3)
echo "%"

Re: No output returned from plugin

Posted: Thu Apr 16, 2020 1:04 pm
by gormank
I'd test by temporarily getting rid of the pipe to output the base command and redirect STDERR to STDOUT.
It's risky using untested redirects in pipes so once the check is debugged, I'd look at a redirect that tests the output and not assume it's what is expected.
Nagios typically runs commands as nagios and not necessarily the user running it to test. I don't know if that's the case here.

Re: No output returned from plugin

Posted: Thu Apr 16, 2020 3:34 pm
by tgriep
It could be a permission issue as the plugin is ran my nagios so try running it as nagios.

You can try to change to the nagios user by running

Code: Select all

su - nagios
and then run the plugin to see what happens.

Code: Select all

./dht22-humidity.sh
Or use sudo to run it as nagios.

Code: Select all

sudo -u nagios ./dht22-humidity.sh
Another suggestion, your plugin is outputting the data on 2 lines, change the first echo command and add a -n to it so it will not print a newline which will cause the output to be on one line.
Change it to this.

Code: Select all

echo -n  $(~/wiringpi/lol_dht22/loldht 7 | grep -i "humidity" | cut -d ' ' -f3)

Re: No output returned from plugin

Posted: Fri Apr 17, 2020 4:16 am
by C.Appl
I got the message: wiringPiSetup: Unable to open /dev/mem or /dev/gpiomem: Permission denied.

So i changed the permissions and now it works.
Thank you!

Re: No output returned from plugin

Posted: Fri Apr 17, 2020 7:09 am
by scottwilkerson
C.Appl wrote:I got the message: wiringPiSetup: Unable to open /dev/mem or /dev/gpiomem: Permission denied.

So i changed the permissions and now it works.
Thank you!
Great!

Locking thread