Projet

Général

Profil

Paste
Télécharger au format
Statistiques
| Branche: | Révision:

root / plugins / sensors / ip_thermo_125 @ 17f78427

Historique | Voir | Annoter | Télécharger (1,36 ko)

1
#!/usr/bin/perl
2
#
3
# Copyright (C) 2008 Yuriy Sabov
4
# Version 0.1
5
#
6
# Plugin to fetch temperature from "IP Thermo 125" ethernet thermometer
7
# available at http://www.procontrol.hu/GyartasFejlesztes/Termekeink/IPThermoSimple/IPThermo125_eng.htm
8
# This version supports only one temperature sensor per server!
9
#
10
#
11
# Parameters supported:
12
#
13
#       config
14
#       autoconf
15
#
16

    
17

    
18
my ($hostname, $port, $line, $telnet);
19

    
20
# "C" = Celsius, "F" = Fahrenheit
21
my $unit  = $ENV{unit}    || "C";
22

    
23
$hostname = "10.10.10.10";
24
$port = 23;
25

    
26
use Net::Telnet ();
27

    
28

    
29
if ($ARGV[0] and $ARGV[0] eq "autoconf")
30
{
31
  print "yes\n";
32
  exit 0;
33
}
34

    
35
if (defined $ARGV[0] and $ARGV[0] eq "config")
36
{
37
  print "graph_title IP Thermo 125\n";
38
  print "graph_args --base 1000 -l 0\n";
39
  print "graph_category sensors\n";
40
  print "graph_info This graph shows temperature using IP Thermo 125 server.\n";
41

    
42
  if ($unit =~ /F/)
43
  {
44
    print "graph_vlabel temp in °F\n";
45
  }
46
  else
47
  {
48
    print "graph_vlabel temp in °C\n";
49
  }
50
    print "temperature.label temperature\n";
51

    
52
  exit 0;
53
}
54

    
55
$telnet = new Net::Telnet (Telnetmode => 0);
56

    
57
# create telnet connection to temperature server
58
$telnet->open(Host => $hostname, Port => $port);
59

    
60
# read line from server.
61
$line = $telnet->getline;
62

    
63
# get measurement of first sensor from received data
64
$value1 = substr(substr($line, 0, 20), -4, 4);
65
print "temperature.value ";
66
print "$value1\n";
67

    
68