Projet

Général

Profil

Révision 0e634e48

ID0e634e481377a5cd866b13bd96494fc608949f2b
Parent de2705ac
Enfant cde66ba4

Ajouté par Daniel Howard il y a plus de 11 ans

Initial commit of snmp__sentry.

Voir les différences:

plugins/snmp/snmp__sentry
1
#!/usr/bin/perl -w
2

  
3
=head1 NAME
4

  
5
Munin plugin snmp__sentry is written to monitor the Sentry line of Power Distribution Units (PDU) offered by Server Technology.
6

  
7
This plugin currently assumes a 3-phase PDU.
8

  
9
=head1 AUTHOR
10

  
11
Danny Howard <dannyman@toldme.com>
12

  
13
This plugin was created on the behalf of Quantifind, Inc.  http://www.quantifind.com
14

  
15
=head1 LICENSE
16

  
17
BSD
18

  
19
=head1 MAGIC MARKERS
20

  
21
  #%# family=snmpauto
22
  #%# capabilities=snmpconf
23

  
24
=head1 EXAMPLE MIB
25

  
26
$ wget ftp://ftp.servertech.com/pub/SNMP/sentry3/Sentry3.mib
27
$ snmpwalk -c public -v 2c -M +. -m +Sentry3-MIB 192.168.whatevs .1.3.6.1.4.1.1718.3.2.2
28
Sentry3-MIB::infeedID.1.1 = STRING: AA
29
Sentry3-MIB::infeedID.1.2 = STRING: AB
30
Sentry3-MIB::infeedID.1.3 = STRING: AC
31
Sentry3-MIB::infeedName.1.1 = STRING: Master_X
32
Sentry3-MIB::infeedName.1.2 = STRING: Master_Y
33
Sentry3-MIB::infeedName.1.3 = STRING: Master_Z
34
Sentry3-MIB::infeedCapabilities.1.1 = BITS: C6 00 onSense(0) loadSense(1) voltageSense(5) powerSense(6) 
35
Sentry3-MIB::infeedCapabilities.1.2 = BITS: C6 00 onSense(0) loadSense(1) voltageSense(5) powerSense(6) 
36
Sentry3-MIB::infeedCapabilities.1.3 = BITS: C6 00 onSense(0) loadSense(1) voltageSense(5) powerSense(6) 
37
Sentry3-MIB::infeedStatus.1.1 = INTEGER: on(1)
38
Sentry3-MIB::infeedStatus.1.2 = INTEGER: on(1)
39
Sentry3-MIB::infeedStatus.1.3 = INTEGER: on(1)
40
Sentry3-MIB::infeedLoadStatus.1.1 = INTEGER: normal(0)
41
Sentry3-MIB::infeedLoadStatus.1.2 = INTEGER: normal(0)
42
Sentry3-MIB::infeedLoadStatus.1.3 = INTEGER: normal(0)
43
Sentry3-MIB::infeedLoadValue.1.1 = INTEGER: 717 hundredth Amps
44
Sentry3-MIB::infeedLoadValue.1.2 = INTEGER: 708 hundredth Amps
45
Sentry3-MIB::infeedLoadValue.1.3 = INTEGER: 787 hundredth Amps
46
Sentry3-MIB::infeedLoadHighThresh.1.1 = INTEGER: 16 Amps
47
Sentry3-MIB::infeedLoadHighThresh.1.2 = INTEGER: 16 Amps
48
Sentry3-MIB::infeedLoadHighThresh.1.3 = INTEGER: 16 Amps
49
Sentry3-MIB::infeedOutletCount.1.1 = INTEGER: 10
50
Sentry3-MIB::infeedOutletCount.1.2 = INTEGER: 10
51
Sentry3-MIB::infeedOutletCount.1.3 = INTEGER: 10
52
Sentry3-MIB::infeedCapacity.1.1 = INTEGER: 20 Amps
53
Sentry3-MIB::infeedCapacity.1.2 = INTEGER: 20 Amps
54
Sentry3-MIB::infeedCapacity.1.3 = INTEGER: 20 Amps
55
Sentry3-MIB::infeedVoltage.1.1 = INTEGER: 2055 tenth Volts
56
Sentry3-MIB::infeedVoltage.1.2 = INTEGER: 2034 tenth Volts
57
Sentry3-MIB::infeedVoltage.1.3 = INTEGER: 2052 tenth Volts
58
Sentry3-MIB::infeedPower.1.1 = INTEGER: 726 Watts
59
Sentry3-MIB::infeedPower.1.2 = INTEGER: 809 Watts
60
Sentry3-MIB::infeedPower.1.3 = INTEGER: 874 Watts
61
Sentry3-MIB::infeedApparentPower.1.1 = INTEGER: 793 Volt-Amps
62
Sentry3-MIB::infeedApparentPower.1.2 = INTEGER: 876 Volt-Amps
63
Sentry3-MIB::infeedApparentPower.1.3 = INTEGER: 941 Volt-Amps
64
Sentry3-MIB::infeedPowerFactor.1.1 = INTEGER: 92 hundredths
65
Sentry3-MIB::infeedPowerFactor.1.2 = INTEGER: 92 hundredths
66
Sentry3-MIB::infeedPowerFactor.1.3 = INTEGER: 93 hundredths
67
Sentry3-MIB::infeedCrestFactor.1.1 = INTEGER: 18 tenths
68
Sentry3-MIB::infeedCrestFactor.1.2 = INTEGER: 17 tenths
69
Sentry3-MIB::infeedCrestFactor.1.3 = INTEGER: 17 tenths
70
Sentry3-MIB::infeedEnergy.1.1 = INTEGER: 762 tenth Kilowatt-Hours
71
Sentry3-MIB::infeedEnergy.1.2 = INTEGER: 913 tenth Kilowatt-Hours
72
Sentry3-MIB::infeedEnergy.1.3 = INTEGER: 928 tenth Kilowatt-Hours
73
Sentry3-MIB::infeedReactance.1.1 = INTEGER: capacitive(1)
74
Sentry3-MIB::infeedReactance.1.2 = INTEGER: capacitive(1)
75
Sentry3-MIB::infeedReactance.1.3 = INTEGER: capacitive(1)
76
Sentry3-MIB::infeedPhaseVoltage.1.1 = INTEGER: 2055 tenth Volts
77
Sentry3-MIB::infeedPhaseVoltage.1.2 = INTEGER: 2034 tenth Volts
78
Sentry3-MIB::infeedPhaseVoltage.1.3 = INTEGER: 2052 tenth Volts
79
Sentry3-MIB::infeedPhaseCurrent.1.1 = INTEGER: 386 hundredth Amps
80
Sentry3-MIB::infeedPhaseCurrent.1.2 = INTEGER: 431 hundredth Amps
81
Sentry3-MIB::infeedPhaseCurrent.1.3 = INTEGER: 459 hundredth Amps
82
Sentry3-MIB::infeedCapacityUsed.1.1 = INTEGER: 358 tenth percentage
83
Sentry3-MIB::infeedCapacityUsed.1.2 = INTEGER: 354 tenth percentage
84
Sentry3-MIB::infeedCapacityUsed.1.3 = INTEGER: 393 tenth percentage
85
Sentry3-MIB::infeedLineID.1.1 = STRING: A:X
86
Sentry3-MIB::infeedLineID.1.2 = STRING: A:Y
87
Sentry3-MIB::infeedLineID.1.3 = STRING: A:Z
88
Sentry3-MIB::infeedLineToLineID.1.1 = STRING: A:X-Y
89
Sentry3-MIB::infeedLineToLineID.1.2 = STRING: A:Y-Z
90
Sentry3-MIB::infeedLineToLineID.1.3 = STRING: A:Z-X
91
Sentry3-MIB::infeedPhaseID.1.1 = STRING: A:X-Y
92
Sentry3-MIB::infeedPhaseID.1.2 = STRING: A:Y-Z
93
Sentry3-MIB::infeedPhaseID.1.3 = STRING: A:Z-X
94

  
95
=cut
96

  
97
use strict;
98
use Munin::Plugin::SNMP;
99

  
100
if (defined $ARGV[0] and $ARGV[0] eq "snmpconf") {
101
        print "require 1.3.6.1.4.1.1718.3.2.2.1\n";
102
        exit 0;
103
}
104

  
105
my $session = Munin::Plugin::SNMP->session(-translate =>
106
                                           [ -timeticks => 0x0 ]);
107

  
108
my $sentry_h = $session->get_hash (
109
	-baseoid	=> ".1.3.6.1.4.1.1718.3.2.2.1",
110
	-cols		=> {
111
# maxcols 16 I guess
112
#				2	=> 'infeedID',
113
				3	=> 'infeedName',
114
#				4	=> 'infeedCapabilities',
115
#				5	=> 'infeedStatus',
116
#				6	=> 'infeedLoadStatus',
117
				7	=> 'infeedLoadValue',
118
				8	=> 'infeedLoadHighThresh',
119
#				9	=> 'infeedOutletCount',
120
				10	=> 'infeedCapacity',
121
#				11	=> 'infeedVoltage',
122
#				12	=> 'infeedPower',
123
#				13	=> 'infeedApparentPower',
124
				14	=> 'infeedPowerFactor',
125
				15	=> 'infeedCrestFactor',
126
#				16	=> 'infeedEnergy',
127
#				17	=> 'infeedReactance',
128
#				18	=> 'infeedPhaseVoltage',
129
#				19	=> 'infeedPhaseCurrent',
130
#				20	=> 'infeedCapacityUsed',
131
#				21	=> 'infeedLineID',
132
#				22	=> 'infeedLineToLineID',
133
#				23	=> 'infeedPhaseID',
134

  
135
			}
136
	);
137

  
138
if (defined $ARGV[0] and $ARGV[0] eq "config") {
139
    my ($host) = Munin::Plugin::SNMP->config_session();
140
        print "host_name $host\n" unless $host eq 'localhost';
141
        print "
142
multigraph power_amps_drawn
143
graph_title Power Draw in Amps
144
graph_args --lower-limit 0
145
graph_vlabel Amps
146
graph_category power
147
graph_scale no
148
graph_info This shows the amperage drawn on your PDU. Per NEC, a PDU should not sustain 80% of its maximum circuit capacity for more than three hours.
149

  
150
";
151

  
152
foreach my $k ( keys %{$sentry_h} ) {
153
	my $infeedName = $sentry_h->{$k}->{'infeedName'};
154
	my $critical	= ($sentry_h->{$k}->{'infeedCapacity'})*.9;	# 90% of capacity
155
	my $warning	= $sentry_h->{$k}->{'infeedLoadHighThresh'};	# 80% of capacity
156
	
157
	print "$infeedName.critical $critical\n";
158
	print "$infeedName.draw LINE1\n";
159
	print "$infeedName.label $infeedName\n";
160
	print "$infeedName.min 0\n";
161
	print "$infeedName.type GAUGE\n";
162
	print "$infeedName.warning $warning\n";
163
}
164

  
165
        print "
166
multigraph power_power_factor
167
graph_title Power Factor
168
graph_args --lower-limit 0
169
graph_vlabel Power Factor
170
graph_category power
171
graph_scale no
172
graph_info Power factor represents the efficiency of the components connected to the circuit. Power factor declines as components age, increasing the overall load on the circuit.
173

  
174
";
175

  
176
foreach my $k ( keys %{$sentry_h} ) {
177
	my $infeedName = $sentry_h->{$k}->{'infeedName'};
178
	
179
	print "$infeedName.draw LINE1\n";
180
	print "$infeedName.label $infeedName\n";
181
	print "$infeedName.type GAUGE\n";
182
}
183

  
184
        print "
185
multigraph power_crest_factor
186
graph_title Crest Factor
187
graph_args --lower-limit 0
188
graph_vlabel Crest Factor
189
graph_category power
190
graph_scale no
191
graph_info Crest factor relates the peak value of a signal to its root mean square value. For three-phase AC, a crest factor of 1.732 is expected. Low crest factor may indicate UPS overclipping and crest factors over 5 degrade monitoring accuracy.
192

  
193
";
194

  
195
foreach my $k ( keys %{$sentry_h} ) {
196
	my $infeedName = $sentry_h->{$k}->{'infeedName'};
197
	
198
	print "$infeedName.draw LINE1\n";
199
	print "$infeedName.label $infeedName\n";
200
	print "$infeedName.type GAUGE\n";
201
}
202

  
203
        exit 0;
204
}
205

  
206
print "multigraph power_amps_drawn\n";
207
foreach my $k ( keys %{$sentry_h} ) {
208
	my $infeedName = $sentry_h->{$k}->{'infeedName'};
209
	my $amps = $sentry_h->{$k}->{'infeedLoadValue'};
210
	if ( $amps ) {
211
		$amps = $amps * .01;
212
	} else {
213
		$amps = 'U';
214
	}
215
	print "$infeedName.value $amps\n";
216
}
217

  
218
print "multigraph power_power_factor\n";
219
foreach my $k ( keys %{$sentry_h} ) {
220
	my $infeedName = $sentry_h->{$k}->{'infeedName'};
221
	my $pf = $sentry_h->{$k}->{'infeedPowerFactor'};
222
	if ( $pf ) {
223
		$pf = $pf * .01;
224
	} else {
225
		$pf = 'U';
226
	}
227
	print "$infeedName.value $pf\n";
228
}
229

  
230
print "multigraph power_crest_factor\n";
231
foreach my $k ( keys %{$sentry_h} ) {
232
	my $infeedName = $sentry_h->{$k}->{'infeedName'};
233
	my $crest = $sentry_h->{$k}->{'infeedCrestFactor'};
234
	if ( $crest ) {
235
		$crest = $crest * .1;
236
	} else {
237
		$crest = 'U';
238
	}
239
	print "$infeedName.value $crest\n";
240
}

Formats disponibles : Unified diff