Temptrax returns incorect data

Shane_Seidel at gwf.com.au Shane_Seidel at gwf.com.au
Tue Oct 15 05:30:25 CEST 2002



All
I am using a Temptrax 2000 digital thermometer and seeing incorrect data
reported by Nagios.

When run from the command line output seems correct.
 /usr/local/nagios/libexec/check_temptrax -w 25 -c 30 -S 2
Temp Ok: Sensor 2 = 21.6 Deg. C
 /usr/local/nagios/libexec/check_temptrax -w 25 -c 30 -S 1
Temp Warning: Sensor 1 = 25.1 Deg. C

But Nagios reports:-
Server Room Temp OK 13-09-2002 08:56:02 7d 18h 47m 6s 1/3 Temp Ok: Sensor 1 =
-17.8 Deg. C

Server Room Temp 2 OK 13-09-2002 08:57:37 7d 15h 22m 16s 1/3 Temp Ok: Sensor 2 =
-17.8 Deg. C

These values are still reported by Nagios even when the device is detatched from
the server.

I have been informed by the helpful people at Temptrax that a value of 0 deg
farenheight is being reported.

checkcommands.cfg is as follows:-
command[check_temptrax]=/usr/local/nagios/libexec/check_temptrax -w 25 -c 30 -S
1 -f 0
command[check_temptrax2]=/usr/local/nagios/libexec/./check_temptrax -w 25 -c 30
-S 2 -f 0

service.cfg is as follows:-
service[nms-GWFIS-Monitoring-System]=Server Room
Temp;0;24x7;3;5;1;gwfis-admins;240;24x7;1;1;0;;check_temptrax
service[nms-GWFIS-Monitoring-System]=Server Room Temp
2;0;24x7;3;5;1;gwfis-admins;240;24x7;1;1;0;;check_temptrax2

#!/usr/bin/perl -w
#
# TempTrax plugin for Nagios
# (c) 2001 Sensor Instruments Co., Inc.
# 41 Terrill Park Drive
# Concord, NH 03301
# http://www.temptrax.com
#

# use functions
use Getopt::Long;

# the serial port temptrax is connected to
$temptrax_device = "/dev/ttyS0";
$temptrax_file = "/usr/local/nagios/libexec/temptrax";

# initialize vars
$w="";
$c="";
$s="1";
$f="0";
$formattag="C";
$sensor1_celsius="";
$sensor2_celsius="";
$battery="";


# read options from command line
&GetOptions("w=i" => \$w,"c=i" => \$c,"S=i" => \$s,"f=i" => \$f);

# exit when there are no parameters set
if ($w eq "" || $c eq "" || $s eq "" || $f eq "")
{
  print "Invalid arguments supplied\n\n";
  print "TempTrax plugin for Nagios\n";
  print "Copyright (c) 2001-2002 Sensor Instruments Co., Inc.\n\n";
  print "   usage: check_temptrax [--help|--version]\n";
  print "          check_temptrax -w [warning temperature] -c [critical
temperature] -S [1|2] -f [0|1]\n\n";
  print "   options:\n";
  print "          -S [1|2]   : Sensor to read temp from. Default=1\n";
  print "          -f [0|1]   : Temps specified in Celsius (0) or Farenheit (1).
Default=0\n";
  exit (3);
}

# check if the required c++ program exists
if (!-e $temptrax_file)
{
  print "The temptrax executable could not be found\n\n";
  exit(0);
}

# split temperature and battery status
($sensor1, $sensor2, $battery) = split(/\r\n/, `$temptrax_file
$temptrax_device`);

# remove whitespaces from the returned temperatures
$sensor1 =~ s/ //g;
$sensor2 =~ s/ //g;


# Convert Fahrenheit into Celsius
$sensor1_celsius = sprintf("%.1f", (($sensor1-32)/9)*5);
$sensor2_celsius = sprintf("%.1f", (($sensor2-32)/9)*5);

# Convert thresholds into Celsius if they were specified in Farenheit
#(for comparison)
if ($f eq "1")
{
    $w = sprintf("%.1f", (($c-32)/9)*5);
    $c = sprintf("%.1f", (($c-32)/9)*5);
}

# What value (Celsius or Farenheit) should be displayed to the user?
if($f eq "1")
{
    $temp=${"sensor$s"};
    $formattag="F";
}
else
{
    $temp=${"sensor$s\_celsius"};
    $formattag="C";
}

# check temperature and choose exit code
if (${"sensor$s\_celsius"} eq "-73.3")
{
  print "Temp Unknown: Sensor $s not connected\n";
  exit(3);
}
elsif (${"sensor$s\_celsius"} > $c && ${"sensor$s\_celsius"} ne "-73.3")
{
  print "Temp Critical: Sensor $s = $temp Deg. $formattag\n";
  exit(2);
}
elsif (${"sensor$s\_celsius"} > $w && ${"sensor$s\_celsius"} ne "-73.3")
{
  print "Temp Warning: Sensor $s = $temp Deg. $formattag\n";
  exit(1);
}
else
{
  print "Temp Ok: Sensor $s = $temp Deg. $formattag\n";
  exit(0);
}

Nagios is v 1.0b5 on Red Hat 7.3 and compiled with default options and the
latest plugin / binary

Can someone shed some light as to why this is occuring and how to fix the
problem?

Thank
Shane




**********************************************************************************************************************************************
This document is intended solely for the named addressee.
The information contained in these pages is confidential and contains legally privileged information.
The copying or distribution of these pages or any information contained therein by any person other than the addressee is
strictly prohibited.
If you have received this communication in error, please contact the sender and delete the email.
********************************************************************



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf




More information about the Users mailing list