NRPE: Unable to read output [check_temp] Watchport/H Sensor

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.
Locked
dlambeth
Posts: 12
Joined: Fri Jun 27, 2014 1:22 pm
Contact:

NRPE: Unable to read output [check_temp] Watchport/H Sensor

Post by dlambeth »

I have a plugin [check_temp] and a Watchport Thermal sensor that I just cannot get the plug-in working. This plug-in uses Perl and this may be the issue. When I run the command in the Linux shell, it works and I get the expected output.

Command Line:

Code: Select all

/usr/bin/perl /usr/lib/nagios/plugins/check_watchptTemp_linux.pl -w 72 -c 74
CRITICAL: Temp is at 74.2500|temp=74.2500;72;74;0;100
However when I run it in Nagios I receive the following error(s)
Temperature Notifications for this service have been disabled UNKNOWN 10-24-2016 15:25:01 0d 0h 27m 40s 4/4 NRPE: Unable to read output


Here is my entry in the "commands.cfg" file for Nagios

Code: Select all

define command {
    command_name check_temp
    command_line /usr/bin/perl /usr/lib/nagios/plugins/check_watchptTemp_linux.pl -w 82 -c 87
}
And here is my services definition in locahost.cfg:

Code: Select all

define service{
    use                                local-service
    host_name                          nagios
    service_description                Temperature
    check_command                      check_temp
}
I followed this how-to:
(https://codeplasma.com/nagios-plugins/c ... ios-how-to)

Any help would be greatly appreciated.

Thanks,
Last edited by dwhitfield on Mon Oct 24, 2016 4:00 pm, edited 1 time in total.
Reason: changed size tags to code tags
User avatar
tgriep
Madmin
Posts: 9177
Joined: Thu Oct 30, 2014 9:02 am

Re: NRPE: Unable to read output [check_temp] Watchport/H Sen

Post by tgriep »

Are you trying to run the plugin directly in the Nagios server or are you trying to run it on a remote server using NRPE?
If you are trying to run it on a remote NRPE server, can you post the nrpe.cfg file from that server?
Be sure to check out our Knowledgebase for helpful articles and solutions!
dlambeth
Posts: 12
Joined: Fri Jun 27, 2014 1:22 pm
Contact:

Re: NRPE: Unable to read output [check_temp] Watchport/H Sen

Post by dlambeth »

I am trying to run it directly from the local linux host. I have NRPE installed on the localhost as well and tried to call it up that way with the same problem.

Thanks,
dlambeth
Posts: 12
Joined: Fri Jun 27, 2014 1:22 pm
Contact:

Re: NRPE: Unable to read output [check_temp] Watchport/H Sen

Post by dlambeth »

Interestingly I'm now getting this return error in Nagios:

"Warning: Return code of 13 for check of service 'Temperature' on host 'nagios' was out of bounds."
dlambeth
Posts: 12
Joined: Fri Jun 27, 2014 1:22 pm
Contact:

Re: NRPE: Unable to read output [check_temp] Watchport/H Sen

Post by dlambeth »

Here is the plugin just to be complete.

-------------------------check_watchptTemp_linux.pl-------------------------------------------------------

#!/usr/bin/perl -w
# check_watchptTemp_linux.pl
# Copyright 2010,2011 Julius Schlosburg
#
# This script gets the temperature from a Digi Watchport Temperature Sensor.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.


use strict;
no warnings; # I added this statement to supress output errors
use Device::SerialPort;
use Getopt::Long;
my $argw;
my $argc;
my $argp;
my $argh = 0;

#get limited options set
GetOptions(
"w=i" => \$argw,
"c=i" => \$argc,
"p=s" => \$argp,
"h|help" => \$argh
);
my $exitcode = 3;
my $warning = $argw;
my $critical = $argc;
my $port = $argp;
if ($port eq ""){
$port = "/dev/ttyUSB0";
}
if ($warning == "" || $critical == "" || $argh){
print "Usage: \n /usr/bin/perl check_watchptTemp_linux.pl -w <warning temp> -c <critical temp> [-p <port(default /dev/ttyUSB0)>]\n\n";
exit;
}

my $state = 2;

#get temp
my $temp = getTemp();

if ($temp > $warning){
$state++;
}
elsif ($temp < $warning){
$state--;
}
if ($temp > $critical){
$state++;
}
elsif ($temp < $critical){
$state--;
}

if ($state eq 0){
print "OK: Temp is good at $temp";
$exitcode = '0';
}
elsif ($state < 3){
print "WARNING: Temp is at $temp";
$exitcode = '1';
}
elsif ($state eq 4){
print "CRITICAL: Temp is at $temp";
$exitcode = '2';
}

#Performance data:
print "|temp=$temp;$warning;$critical;0;100\n";
exit $exitcode;

#######################SUBS################################################

sub getTemp{
#Create Serial port object
my $ob = Device::SerialPort->new ($port) or die "CRITICAL, can't open serial port! $!";
$ob->baudrate(9600);
$ob->parity('none');
$ob->databits(8);
$ob->stopbits(1);
$ob->handshake('none');
$ob->stty_inlcr;
$ob->write_settings || undef $ob;
# Send TF command to watchport... tells device to return temp in F
$ob->write("TF\r");
$ob->read_char_time(5);
my ($count, $tempRead) = $ob->read(255);
if ($tempRead =~ /.*?([\d]+.[\d]+)/){
$tempRead = $1;
}
$ob->close;
undef $ob;
return $tempRead;
}
______________________________________________________________________________________________________________________
User avatar
tgriep
Madmin
Posts: 9177
Joined: Thu Oct 30, 2014 9:02 am

Re: NRPE: Unable to read output [check_temp] Watchport/H Sen

Post by tgriep »

Since you are running the plugin locally on the Nagios server, we don't have to worry about the NRPE part on this.

What Serial port is the sensor connected to on the Nagios server?

Can you login to the server as root, run the following commands and post the output?

Code: Select all

ls -l /usr/lib/nagios/plugins/check_watchptTemp_linux.pl
su nagios
/usr/bin/perl /usr/lib/nagios/plugins/check_watchptTemp_linux.pl -w 82 -c 87
Be sure to check out our Knowledgebase for helpful articles and solutions!
dlambeth
Posts: 12
Joined: Fri Jun 27, 2014 1:22 pm
Contact:

Re: NRPE: Unable to read output [check_temp] Watchport/H Sen

Post by dlambeth »

/dev/ttyUSB0

ls -l /usr/lib/nagios/plugins/check_watchptTemp_linux.pl
-r-xr-xr-x 1 nagios nagios 2634 Oct 25 08:06 /usr/lib/nagios/plugins/check_watchptTemp_linux.pl

/usr/bin/perl /usr/lib/nagios/plugins/check_watchptTemp_linux.pl -w 82 -c 87
CRITICAL, can't open serial port! Permission denied at /usr/lib/nagios/plugins/check_watchptTemp_linux.pl line 88.

Thank you for your help,
dlambeth
Posts: 12
Joined: Fri Jun 27, 2014 1:22 pm
Contact:

Re: NRPE: Unable to read output [check_temp] Watchport/H Sen

Post by dlambeth »

[SOLVED!]

tgriep, your questions led me where I needed to look. I simply added nagios to the (UUCP) linux group and Bam!, it's all working now. I've been on this for days (off and on) and you just saved me a lot of grief.

Nagios did not have access to /dev/ttsUSB0

Extremely Grateful,
Darwin :D
dwhitfield
Former Nagios Staff
Posts: 4583
Joined: Wed Sep 21, 2016 10:29 am
Location: NoLo, Minneapolis, MN
Contact:

Re: NRPE: Unable to read output [check_temp] Watchport/H Sen

Post by dwhitfield »

It sounds like this issue has been resolved. Is it okay if we lock this thread? Thanks for choosing the Nagios forums!
dlambeth
Posts: 12
Joined: Fri Jun 27, 2014 1:22 pm
Contact:

Re: NRPE: Unable to read output [check_temp] Watchport/H Sen

Post by dlambeth »

Yes, thank you.
Locked