check_by_ssh issues running remote Python script

This forum is intended for the discussion of Nagios plugin development. Feature requests, patches, bug fixes, and all types of development-related discussions are welcome!

NOTE: The nagiosplug-devel mailing list has been deprecated in favor of this forum in order to expedite support and provide additional features not available on the old mailing list.

check_by_ssh issues running remote Python script

Postby andrewmoore » Mon Oct 29, 2018 5:24 am

Hi All,

I have a Raspberry Pi with a temperature sensor connected via GPIO. To pull the data from the sensor I use the following Python script (

Code: Select all

import sys, Adafruit_DHT

sensor = Adafruit_DHT.AM2302
pin = 4

temperature = round(Adafruit_DHT.read_retry(sensor, pin)[1],2)

if temperature is not None:
        sys.stdout.write('Temperature = {0}°C|{0};;;;'.format(temperature))
        sys.stdout.write('Failed to get reading.')

If I run the script remotely using the standard SSH command it's fine:
bash-4.2$ ssh monitoring@ -i /etc/icinga2/secure/monitoring /opt/
Temperature = 25.4°C|25.4;;;;

However, if I run it using the get_by_ssh plugin it returns exit code 1 (which isn't a valid exit code for the script):
bash-4.2$ ./check_by_ssh -l monitoring -i /etc/icinga2/secure/monitoring -C /opt/ -H -E
WARNING - check_by_ssh: Remote command '/opt/' returned status 1

I'm not familiar with how get_by_ssh operates. Why would the result be different with the 2 methods above? Any help would be appreciated.
Posts: 1
Joined: Mon Oct 29, 2018 5:06 am

Re: check_by_ssh issues running remote Python script

Postby tgriep » Mon Oct 29, 2018 1:53 pm

Can you run the following command so we can get the version of the check_by_ssh plugin you are running?
Code: Select all
./check_by_ssh  -V

Then replace the -E with -v to get a verbose output to see if there are any errors that the -E option is ignoring.
Code: Select all
./check_by_ssh -l monitoring -i /etc/icinga2/secure/monitoring -C /opt/ -H -v

I had some issues with the degree symbol that the outputs so for a test, try removing that to see if that allows the check to run.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
Posts: 8281
Joined: Thu Oct 30, 2014 9:02 am

Return to Nagios Plugin Development

Who is online

Users browsing this forum: No registered users and 0 guests