Projet

Général

Profil

Révision 2d2d3d60

ID2d2d3d609f4e1c2e658cbf6e16927797b026c97f
Parent 49a49e8c
Enfant cc0439f1

Ajouté par Phil! Gold il y a presque 14 ans

Initial version

Voir les différences:

plugins/other/snmp__linksys_poe
1
#!/usr/bin/ruby
2

  
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
the appropriate MIB, so I don't know the actual names of the values I'm 
37
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 "autoconf"
77
  puts "no"
78
  exit 1
79
when "snmpconf"
80
  puts "require 1.3.6.1.4.1.3955.89.108.1.1.2.1. [0-9]"
81
  puts "require 1.3.6.1.4.1.3955.89.108.1.1.5.1. [0-9]"
82
  puts "require 1.3.6.1.4.1.3955.89.108.1.1.6.1. [0-9]"
83
  exit 0;
84
when "config"
85
  host = $0.match('^(?:|.*\/)snmp_([^_]+)')[1]
86
  puts "host_name #{host}"
87
  puts "graph_title PoE Power Usage"
88
  puts "graph_vlabel Watts"
89
  puts "graph_category sensors"
90
  max_current = 0
91
  SNMP::Manager.open(:Host => host,
92
                     :Community => community,
93
                     :Version => version) do |manager|
94
    manager.walk([idx_oid, max_oid]) do |row|
95
      puts "iface_#{row[0].value}.label Port #{row[0].value}"
96
      puts "iface_#{row[0].value}.cdef iface_#{row[0].value},1000,/"
97
      puts "iface_#{row[0].value}.line #{row[1].value.to_f / 1000}"
98
      if row[1].value > max_current
99
        max_current = row[1].value
100
      end
101
    end
102
  end
103
  puts "graph_args --upper-limit #{max_current.to_f / 1000}"
104
  exit 0
105
else
106
  host = $0.match('^(?:|.*\/)snmp_([^_]+)')[1]
107
  SNMP::Manager.open(:Host => host,
108
                     :Community => community,
109
                     :Version => version) do |manager|
110
    manager.walk([idx_oid, cur_oid]) do |row|
111
      puts "iface_#{row[0].value}.value #{row[1].value}"
112
    end
113
  end
114
end

Formats disponibles : Unified diff