2008-06-05 14:54:36 +02:00
|
|
|
#!/usr/bin/perl
|
|
|
|
#
|
|
|
|
# Copyright (C) 2008 Yuriy Sabov
|
2018-08-02 02:03:42 +02:00
|
|
|
# Version 0.1
|
2008-06-05 14:54:36 +02:00
|
|
|
#
|
|
|
|
# Plugin to fetch temperature from "IP Thermo 125" ethernet thermometer
|
|
|
|
# available at http://www.procontrol.hu/GyartasFejlesztes/Termekeink/IPThermoSimple/IPThermo125_eng.htm
|
|
|
|
# This version supports only one temperature sensor per server!
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# Parameters supported:
|
|
|
|
#
|
|
|
|
# config
|
|
|
|
# autoconf
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
|
|
my ($hostname, $port, $line, $telnet);
|
|
|
|
|
|
|
|
# "C" = Celsius, "F" = Fahrenheit
|
2018-08-02 02:03:42 +02:00
|
|
|
my $unit = $ENV{unit} || "C";
|
2008-06-05 14:54:36 +02:00
|
|
|
|
|
|
|
$hostname = "10.10.10.10";
|
|
|
|
$port = 23;
|
|
|
|
|
|
|
|
use Net::Telnet ();
|
|
|
|
|
|
|
|
|
|
|
|
if ($ARGV[0] and $ARGV[0] eq "autoconf")
|
|
|
|
{
|
|
|
|
print "yes\n";
|
|
|
|
exit 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (defined $ARGV[0] and $ARGV[0] eq "config")
|
|
|
|
{
|
|
|
|
print "graph_title IP Thermo 125\n";
|
|
|
|
print "graph_args --base 1000 -l 0\n";
|
|
|
|
print "graph_category sensors\n";
|
|
|
|
print "graph_info This graph shows temperature using IP Thermo 125 server.\n";
|
2018-08-02 02:03:42 +02:00
|
|
|
|
2008-06-05 14:54:36 +02:00
|
|
|
if ($unit =~ /F/)
|
|
|
|
{
|
|
|
|
print "graph_vlabel temp in °F\n";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
print "graph_vlabel temp in °C\n";
|
|
|
|
}
|
|
|
|
print "temperature.label temperature\n";
|
2018-08-02 02:03:42 +02:00
|
|
|
|
|
|
|
exit 0;
|
2008-06-05 14:54:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
$telnet = new Net::Telnet (Telnetmode => 0);
|
|
|
|
|
|
|
|
# create telnet connection to temperature server
|
|
|
|
$telnet->open(Host => $hostname, Port => $port);
|
|
|
|
|
|
|
|
# read line from server.
|
|
|
|
$line = $telnet->getline;
|
|
|
|
|
|
|
|
# get measurement of first sensor from received data
|
|
|
|
$value1 = substr(substr($line, 0, 20), -4, 4);
|
|
|
|
print "temperature.value ";
|
|
|
|
print "$value1\n";
|
|
|
|
|
|
|
|
|