No output returned from plugin

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
C.Appl
Posts: 14
Joined: Wed Feb 26, 2020 8:03 am

No output returned from plugin

Post 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 "%"
You do not have the required permissions to view the files attached to this post.
gormank
Posts: 1114
Joined: Tue Dec 02, 2014 12:00 pm

Re: No output returned from plugin

Post 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.
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: No output returned from plugin

Post 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)
Be sure to check out our Knowledgebase for helpful articles and solutions!
C.Appl
Posts: 14
Joined: Wed Feb 26, 2020 8:03 am

Re: No output returned from plugin

Post 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!
You do not have the required permissions to view the files attached to this post.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises

Re: No output returned from plugin

Post 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
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart