Projet

Général

Profil

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

root / plugins / router / snmp__linksys_poe @ 46e2de55

Historique | Voir | Annoter | Télécharger (2,81 ko)

1 7a37bfb1 Lars Kruse
#!/usr/bin/env ruby
2 2d2d3d60 Phil! Gold
3
"
4
=head1 NAME
5
6
snmp__linksys_poe - Munin plugin to monitor the current supplied by Linksys PoE
7
switches.
8
9
Requires ruby and the ruby SNMP library.
10
11
=head1 APPLICABLE SYSTEMS
12
13
I wrote this to query SRW2008MP switches and determined the OIDs by trial and
14
error.  There may be other Linksys devices that this will also work for.
15
16
=head1 CONFIGURATION
17
18
This plugin defaults to SNMP version 2c and a community string of 'public'.  The
19
defaults can be overridden in the usual way:
20
21
    [snmp_*]
22
        env.version 1
23
        env.community private
24
25
SNMP version 3 is not supported.
26
27
=head1 INTERPRETATION
28
29
The plugin simply reports the current being supplied on each of the device's
30
PoE ports.
31
32
=head1 MIB INFORMATION
33
34
Information is gathered from Linksys' private MIB space, so it's probably only
35
applicable to Linksys devices.  I have been unable to get an actual copy of
36 17f78427 Lars Kruse
the appropriate MIB, so I don't know the actual names of the values I'm
37 2d2d3d60 Phil! Gold
retrieving.
38
39
=head1 MAGIC MARKERS
40
41
  #%# family=snmpauto contrib
42
  #%# capabilities=snmpconf
43
44
=head1 VERSION
45
46
  1.0
47
48
=head1 BUGS
49
50
None known.
51
52
=head1 AUTHOR
53
54
Written by Phil Gold <phil_g@pobox.com>.
55
56
=head1 LICENSE
57
58
CC0 <http://creativecommons.org/publicdomain/zero/1.0/>
59
60
To the extent possible under law, all copyright and related or neighboring
61
rights to this plugin are waived.  Do with it as you wish.
62
63
=cut
64
"
65
66
require 'snmp'
67
68
idx_oid = "enterprises.3955.89.108.1.1.2"
69
max_oid = "enterprises.3955.89.108.1.1.6"
70
cur_oid = "enterprises.3955.89.108.1.1.5"
71
72
community = ENV['community'] || "public"
73
version = ENV['version'] == '1' ? :SNMPv1 : :SNMPv2c
74
75
case ARGV[0]
76
when "snmpconf"
77
  puts "require 1.3.6.1.4.1.3955.89.108.1.1.2.1. [0-9]"
78
  puts "require 1.3.6.1.4.1.3955.89.108.1.1.5.1. [0-9]"
79
  puts "require 1.3.6.1.4.1.3955.89.108.1.1.6.1. [0-9]"
80
  exit 0;
81
when "config"
82
  host = $0.match('^(?:|.*\/)snmp_([^_]+)')[1]
83
  puts "host_name #{host}"
84
  puts "graph_title PoE Power Usage"
85
  puts "graph_vlabel Watts"
86
  puts "graph_category sensors"
87
  max_current = 0
88
  SNMP::Manager.open(:Host => host,
89
                     :Community => community,
90
                     :Version => version) do |manager|
91
    manager.walk([idx_oid, max_oid]) do |row|
92
      puts "iface_#{row[0].value}.label Port #{row[0].value}"
93
      puts "iface_#{row[0].value}.cdef iface_#{row[0].value},1000,/"
94
      puts "iface_#{row[0].value}.line #{row[1].value.to_f / 1000}"
95
      if row[1].value > max_current
96
        max_current = row[1].value
97
      end
98
    end
99
  end
100
  puts "graph_args --upper-limit #{max_current.to_f / 1000}"
101
  exit 0
102
else
103
  host = $0.match('^(?:|.*\/)snmp_([^_]+)')[1]
104
  SNMP::Manager.open(:Host => host,
105
                     :Community => community,
106
                     :Version => version) do |manager|
107
    manager.walk([idx_oid, cur_oid]) do |row|
108
      puts "iface_#{row[0].value}.value #{row[1].value}"
109
    end
110
  end
111
end