7c704f218003af89cd5732c9004dd17fe3ab0e5d
[freeside.git] / torrus / perllib / Torrus / DevDiscover / Ractivity.pm
1 #  Copyright (C) 2012 Freeside Internet Services, Inc.
2 #
3 #  This program is free software; you can redistribute it and/or modify
4 #  it under the terms of the GNU General Public License as published by
5 #  the Free Software Foundation; either version 2 of the License, or
6 #  (at your option) any later version.
7 #
8 #  This program is distributed in the hope that it will be useful,
9 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
10 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 #  GNU General Public License for more details.
12 #
13 #  You should have received a copy of the GNU General Public License
14 #  along with this program; if not, write to the Free Software
15 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
16
17 # Ractivity Power Distribution Unit
18
19 package Torrus::DevDiscover::Ractivity;
20
21 use strict;
22 use Torrus::Log;
23
24 $Torrus::DevDiscover::registry{'Ractivity'} = {
25     'sequence'     => 500,
26     'checkdevtype' => \&checkdevtype,
27     'discover'     => \&discover,
28     'buildConfig'  => \&buildConfig
29 };
30
31 our %oiddef =
32 (
33     #'racktivity'           => '1.3.6.1.4.1.34097',
34     'product'              => '1.3.6.1.4.1.34097.1',
35     'name'                 => '1.3.6.1.4.1.34097.1.1',
36     'version'              => '1.3.6.1.4.1.34097.1.2',
37     'date'                 => '1.3.6.1.4.1.34097.1.3',
38     'general'              => '1.3.6.1.4.1.34097.2',
39     'Voltage'              => '1.3.6.1.4.1.34097.2.1',
40     'MaxTotCurentTime'     => '1.3.6.1.4.1.34097.2.10',
41     'TotKwh'               => '1.3.6.1.4.1.34097.2.11',
42     'Intrusion'            => '1.3.6.1.4.1.34097.2.12',
43     'Airflow'              => '1.3.6.1.4.1.34097.2.13',
44     'Beep'                 => '1.3.6.1.4.1.34097.2.14',
45     'ControllerName'       => '1.3.6.1.4.1.34097.2.15',
46     'RackPosition'         => '1.3.6.1.4.1.34097.2.16',
47     'Frequency'            => '1.3.6.1.4.1.34097.2.2',
48     'TotCurrent'           => '1.3.6.1.4.1.34097.2.3',
49     'TotPower'             => '1.3.6.1.4.1.34097.2.4',
50     'TemperatureInside'    => '1.3.6.1.4.1.34097.2.5',
51     'HumidityInside'       => '1.3.6.1.4.1.34097.2.6',
52     'MaxTotCurrentWarning' => '1.3.6.1.4.1.34097.2.7',
53     'MaxTotCurentOff'      => '1.3.6.1.4.1.34097.2.8',
54     'MaxTotCurrent'        => '1.3.6.1.4.1.34097.2.9',
55     'port'                 => '1.3.6.1.4.1.34097.3',
56     'portTable'            => '1.3.6.1.4.1.34097.3.1',
57     'portEntry'            => '1.3.6.1.4.1.34097.3.1.1',
58     'PortNr'               => '1.3.6.1.4.1.34097.3.1.1.1',
59     'MaxCurrent'           => '1.3.6.1.4.1.34097.3.1.1.10',
60     'MaxCurrentTime'       => '1.3.6.1.4.1.34097.3.1.1.11',
61     'MaxCurrentWarning'    => '1.3.6.1.4.1.34097.3.1.1.12',
62     'MaxCurrentOff'        => '1.3.6.1.4.1.34097.3.1.1.13',
63     'Priority'             => '1.3.6.1.4.1.34097.3.1.1.14',
64     'DelayOn'              => '1.3.6.1.4.1.34097.3.1.1.15',
65     'PortName'             => '1.3.6.1.4.1.34097.3.1.1.2',
66     'Current'              => '1.3.6.1.4.1.34097.3.1.1.3',
67     'RealPower'            => '1.3.6.1.4.1.34097.3.1.1.4',
68     'ApparentPower'        => '1.3.6.1.4.1.34097.3.1.1.5',
69     'PowerFactor'          => '1.3.6.1.4.1.34097.3.1.1.6',
70     'State'                => '1.3.6.1.4.1.34097.3.1.1.7',
71     'kWh'                  => '1.3.6.1.4.1.34097.3.1.1.8', #the important one
72     'kWhTime'              => '1.3.6.1.4.1.34097.3.1.1.9',
73     'temp'                 => '1.3.6.1.4.1.34097.4',
74     'tempTable'            => '1.3.6.1.4.1.34097.4.1',
75     'tempEntry'            => '1.3.6.1.4.1.34097.4.1.1',
76     'TempNr'               => '1.3.6.1.4.1.34097.4.1.1.1',
77     'Temperature'          => '1.3.6.1.4.1.34097.4.1.1.2',
78     'MaxTemp'              => '1.3.6.1.4.1.34097.4.1.1.3',
79     'MaxTempTime'          => '1.3.6.1.4.1.34097.4.1.1.4',
80     'TempWarning'          => '1.3.6.1.4.1.34097.4.1.1.5',
81 );
82
83 sub checkdevtype
84 {
85     shift->checkSnmpOID('product');
86 }
87
88 sub discover
89 {
90     my $dd = shift;
91     my $devdetails = shift;
92
93     my $data = $devdetails->data();
94
95     my $info = $dd->retrieveSnmpOIDs( 'product',
96                                       'name',
97                                       'version',
98                                       'date',
99                                     );
100
101
102     $data->{'param'}{'comment'} = join(' ', map $info->{$_},
103                                             qw( product name version )
104                                        );
105
106     $data->{'param'}{'legend'} = "Product: ". $info->{'product'}. ";\n".
107                                  "Name:    ". $info->{'name'}. ";\n".
108                                  "Version: ". $info->{'version'}. ";\n".
109                                  "Date:    ". $info->{'date'}. ";";
110
111     return 1;
112 }
113
114 sub buildConfig
115 {
116     my $devdetails = shift;
117     my $cb = shift;
118     my $devNode = shift;
119
120     $cb->addTemplateApplication( $devNode, 'Ractivity::PDU');
121
122 }
123
124 1;
125