root/snmp__cyclades_pm_

Revision 19, 4.0 kB (checked in by ixs, 12 years ago)

cyclades pm munin plugin

  • Property svn:executable set to *
Line 
1 #!/usr/bin/perl -w
2 # -*- cperl -*-
3 #
4 # Copyright (C) 2012 Andreas Thienemann <andreas@bawue.net>
5 #
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU Library General Public License as published by
8 # the Free Software Foundation; version 2 only
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU Library General Public License for more details.
14 #
15 # You should have received a copy of the GNU Library General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 #
19
20 =head1 NAME
21
22 snmp__cyclades_pm_ - Munin plugin to retrive readings from a Cyclades
23 Power Managemen Distribution Unit connected to a Cyclades console server.
24
25 =head1 APPLICABLE SYSTEMS
26
27 Avocent/Cyclades PMXX connected to a SNMP enabled Cyclades ACS/TS.
28
29 =head1 CONFIGURATION
30
31 As a rule SNMP plugins need site specific configuration.  The default
32 configuration (shown here) will only work on insecure sites/devices.
33
34    [snmp_*]
35         env.version 2
36         env.community public
37
38 In general SNMP is not very secure at all unless you use SNMP version
39 3 which supports authentication and privacy (encryption).  But in any
40 case the community string for your devices should not be "public".
41
42 Please see 'perldoc Munin::Plugin::SNMP' for further configuration
43 information.
44
45 =head1 INTERPRETATION
46
47 The plugin reports the current fan speed readings as reported by the thecusIO
48 module.
49
50 =head1 MIB INFORMATION
51
52 Private MIB
53
54 =head1 MAGIC MARKERS
55
56   #%# family=snmpauto
57   #%# capabilities=snmpconf
58
59 =head1 VERSION
60
61   0.0.20120307
62
63 =head1 BUGS
64
65 None known.
66
67 =head1 AUTHOR
68
69 Copyright (C) 2012 Andreas Thienemann <andreas@bawue.net>
70
71 =head1 LICENSE
72
73 GPLv2 or (at your option) any later version.
74
75 =cut
76
77 use strict;
78 use Munin::Plugin;
79 use Munin::Plugin::SNMP;
80
81 my $DEBUG = $ENV{'MUNIN_DEBUG'};
82
83 my ($session, $type, $title, $vlabel, $info, $oid, $format);
84
85 sub get_pdu_ports {
86         my $result = $session->get_entries(
87                 -columns => ['1.3.6.1.4.1.2925.4.5.5.1.1']
88         );
89
90         return sort(values %$result);
91 }
92
93 sub get_pdu_id {
94         my ($port) = @_;
95         my $result = $session->get_single("1.3.6.1.4.1.2925.4.5.3.1.11.$port.1");
96         return $result;
97 }
98
99 if (defined $ARGV[0] and $ARGV[0] eq "snmpconf") {
100     print "number 1.3.6.1.4.1.2925.4.5.1\n";
101     exit 0;
102 }
103
104 $session = Munin::Plugin::SNMP->session();
105
106 my ($host,undef,$version,$tail) = Munin::Plugin::SNMP->config_session();
107
108 ($type) = ($tail =~ /cyclades_pm_(.*)$/);
109
110 if ($type =~ "volt") {
111     $title = "Voltage";
112     $vlabel = "Volt";
113     $info = "actual value of voltage in the element (V). When element does not have voltage sensor, it returns 0.";
114     $oid = "1.3.6.1.4.1.2925.4.5.5.1.7";
115     $format = "%i";
116 } elsif ($type =~ "current") {
117     $title = "Current";
118     $vlabel = "Ampere";
119     $info = "actual value of current in the element (A).";
120     $oid = "1.3.6.1.4.1.2925.4.5.5.1.3";
121     $format = "%.2f";
122 } elsif ($type =~ "power") {
123     $title = "Power";
124     $vlabel = "Watt";
125     $info = "actual value of power in the element (W).";
126     $oid = "1.3.6.1.4.1.2925.4.5.5.1.5";
127     $format = "%i";
128 } else {
129     print "Couldn't get type from $tail\n";
130     exit 1;
131 }
132
133
134 if ($ARGV[0] and $ARGV[0] eq "config") {
135     my ($host,undef,$version,$tail) = Munin::Plugin::SNMP->config_session();
136
137     print "host_name $host\n" unless $host eq 'localhost';
138
139     print "graph_title Cyclades PM $title\n";
140     print "graph_args --base 1000 -l 0\n";
141     print "graph_vlabel $vlabel\n";
142     print "graph_info This graph shows the $info\n";
143     print "graph_category Sensors\n";
144
145     foreach my $port (get_pdu_ports()) {
146         my $id = get_pdu_id($port);
147         print lc($id) . ".label $id\n";
148     }
149
150     exit(0);
151 }
152
153 foreach my $port (get_pdu_ports()) {
154     my $id = get_pdu_id($port);
155     my $val = $session->get_single("$oid.$port.1") || "U";
156     printf ("%s.value $format\n", lc($id), ($val / 10));
157 }
Note: See TracBrowser for help on using the browser.