]>
jfr.im git - munin-plugins.git/blob - snmp__if_pfsense_ppp_
6 snmp__if_ - SNMP wildcard plugin to monitor network interfaces of any networked equipment.
8 =head1 APPLICABLE SYSTEMS
10 Any SNMP capable networked computer equipment. Using a command such
11 as "munin-node-configure --snmp switch.langfeldt.net --snmpversion 2c
12 --snmpcommunity public | sh -x" should auto-detect all applicable
13 interfaces. On a typical switch you will get one plugin pr. ethernet
14 port. On a router you might get one plugin pr. VLAN interface.
18 As a rule SNMP plugins need site specific configuration. The default
19 configuration (shown here) will only work on insecure sites/devices:
25 In general SNMP is not very secure at all unless you use SNMP version
26 3 which supports authentication and privacy (encryption). But in any
27 case the community string for your devices should not be "public".
29 Please see 'perldoc Munin::Plugin::SNMP' for further configuration
34 The graph shows a stright forward "bits per second" incomming and
35 outgoing thruput. "Incomming" is towards the monitored device.
37 Note: The internal representation of the speeds is in bytes
38 pr. second. The plugin multiplies everyting by 8 to get bits
41 =head1 MIB INFORMATION
43 This plugin requires the IF-MIB the standard IETF MIB for network
44 interfaces. It reports the contents of the
45 IF-MIB::ifHCInOctets/IF-MIB::ifHCOutOctets if available,
46 IF-MIB::ifInOctets/IF-MIB::ifOutOctets if not. The former are 64 bit
47 counters only available with SNMP 2 and later. The later are 32 bit
48 counters (see FEATURES below).
53 #%# capabilities=snmpconf
65 You may get strange results if you use SNMPv1, or SNMPv2 on
66 switches that do not support 64 bit byte counters. If the interface
67 traffic exceeds about 50Mbps a 32 bit byte counter will wrap around in
68 less than 5 minutes making the graph for the interface show random
71 If you have a switch/device that supports 64 bit byte counters this plugin
72 will use them and the graph will be fine. The graph information will
73 inform about this. You must use SNMPv2c or SNMPv3 to be able to use
74 64 bit counters - if the device supports them.
76 This problem is a feature of the device SNMP implementation or your
77 usage of it, it is nothing the plugin can fix. In the future Munin
78 may be able to run the plugin more often than the counter wraps
83 Copyright (C) 2004-2009 Jimmy Olsen, Daginn Ilmari Mannsaaker.
84 Documentation, porting to Munin::Plugin::SNMP and further grooming by
87 Initial SNMPv3 support by "Confusedhacker".
97 use Munin
:: Plugin
:: SNMP
;
103 # This is the snmpwalk:
104 # .1.3.6.1.2.1.2.1.0 = INTEGER: 2
105 # .1.3.6.1.2.1.2.2.1.1.1 = INTEGER: 1
106 # .1.3.6.1.2.1.2.2.1.1.65539 = INTEGER: 65539
107 # .1.3.6.1.2.1.2.2.1.2.1 = STRING: MS TCP Loopback interface
108 # .1.3.6.1.2.1.2.2.1.2.65539 = STRING: Broadcom NetXtreme Gigabit Ethernet
109 # .1.3.6.1.2.1.2.2.1.3.1 = INTEGER: softwareLoopback(24)
110 # .1.3.6.1.2.1.2.2.1.3.65539 = INTEGER: ethernetCsmacd(6)
111 # .1.3.6.1.2.1.2.2.1.4.1 = INTEGER: 1520
112 # .1.3.6.1.2.1.2.2.1.4.65539 = INTEGER: 1500
113 # .1.3.6.1.2.1.2.2.1.5.1 = Gauge32: 10000000
114 # .1.3.6.1.2.1.2.2.1.5.65539 = Gauge32: 1000000000
115 # .1.3.6.1.2.1.2.2.1.6.1 = STRING:
116 # .1.3.6.1.2.1.2.2.1.6.65539 = STRING: 0:30:48:75:65:5e
117 # .1.3.6.1.2.1.2.2.1.7.1 = INTEGER: up(1)
118 # .1.3.6.1.2.1.2.2.1.7.65539 = INTEGER: up(1)
119 # .1.3.6.1.2.1.2.2.1.8.1 = INTEGER: up(1)
120 # .1.3.6.1.2.1.2.2.1.8.65539 = INTEGER: up(1)
123 # .1.3.6.1.2.1.31.1.1.1.6. Counter64 ifHCInOctets
124 # .1.3.6.1.2.1.31.1.1.1.10. Counter64 ifHCOutOctets
126 if ( defined $ARGV [ 0 ] and $ARGV [ 0 ] eq "snmpconf" ) {
127 print "index 1.3.6.1.2.1.2.2.1.1. \n " ;
128 print "require 1.3.6.1.2.1.2.2.1.5. [1-9] \n " ; # Speed
129 print "require 1.3.6.1.2.1.2.2.1.10. [1-9] \n " ; # ifInOctets
133 if ( $Munin :: Plugin
:: me
=~ /_if_(\d+)$/ ) {
134 # Also accept leading 0 like (snmp_router_if_01 .. snmp_router_if_24)
137 die "Could not determine interface number from " . $Munin :: Plugin
:: me
. " \n " ;
140 my $ifEntryDescr = "1.3.6.1.2.1.2.2.1.2. $iface " ;
141 my $ifEntryHiSpeed = "1.3.6.1.2.1.31.1.1.1.15. $iface " ;
142 my $ifEntrySpeed = "1.3.6.1.2.1.2.2.1.5. $iface " ;
143 my $ifEntryStatus = "1.3.6.1.2.1.2.2.1.8. $iface " ;
144 my $ifEntryInOctets = "1.3.6.1.2.1.2.2.1.10. $iface " ;
145 my $ifEntryOutOctets = "1.3.6.1.2.1.2.2.1.16. $iface " ;
147 # Only available with SNMPv2 and up.
148 my $ifEntryAlias = "1.3.6.1.2.1.31.1.1.1.18. $iface " ;
149 my $ifEntryIn64Octets = "1.3.6.1.2.1.31.1.1.1.6. $iface " ;
150 my $ifEntryOut64Octets = "1.3.6.1.2.1.31.1.1.1.10. $iface " ;
152 my ( $session , $error );
154 # SNMP needed for both config and fetch.
155 $session = Munin
:: Plugin
:: SNMP-
> session ();
156 $session -> translate ([- nosuchinstance
=> 0 ]);
158 if ( $ARGV [ 0 ] and $ARGV [ 0 ] eq "config" ) {
159 my ( $host , undef , $version ) = Munin
:: Plugin
:: SNMP-
> config_session ();
161 print "host_name $host \n " unless $host eq 'localhost' ;
163 my $alias = $session -> get_single ( $ifEntryAlias ) ||
164 $session -> get_single ( $ifEntryDescr ) ||
167 if (! ( $alias =~ /\d+/ ) ) {
168 # If there are no numbers in the $alias add the if index
169 $alias .= " (if $iface )" ;
174 if ( defined ( $response = $session -> get_single ( $ifEntryStatus ))) {
175 if ( $response == 2 ) {
177 $extrainfo .= ' The interface is currently down.'
184 if ( defined ( $speed = $session -> get_single ( $ifEntrySpeed )) && $speed != 64000 ) {
185 # ifSpeed only supports values up to 4.3Gbps, because it's a
186 # 32-bit value. For faster interfaces, e.g. 10GE or 8Gb/s FC,
187 # use ifHighSpeed instead, which contains the interface speed
188 # in Mbps (e.g. 1000 for GE).
190 # To detect whether we should use ifHighSpeed, check for an
191 # ifSpeed value of 2^32-1 (4294967295). For some reason
192 # Brocade Fabric OS returns 2^32-2 instead, so check that as
195 if ( $speed == 4294967294 || $speed == 4294967295 ) {
196 $speed = $session -> get_single ( $ifEntryHiSpeed )
200 $warn = ( $speed/10 )* 8 ;
202 # Warn at 1/8th of actuall speed? Or just remove warning?
203 # Tempted to set warning at 80%. 80% over 5 minutes is pretty
206 my $textspeed = scaleNumber
( $speed ,, 'bps' , '' ,
207 'The interface speed is %.1f %s%s .' );
209 $extrainfo .= " " . $textspeed if $textspeed ;
212 if ( defined ( $session -> get_single ( $ifEntryIn64Octets ))
213 && !( $session -> get_single ( $ifEntryIn64Octets ) eq '' )) {
215 # If we get an answer at the 64 bit OID then this switch
216 # supports the extended MIB
218 $extrainfo .= " This switch supports 64 bit byte counters and these are used by this plugin." ;
220 # If not we only have a 32 bit counter and are lost.
221 $extrainfo .= " NOTE! This switch supports only 32 bit byte counters which makes the plugin unreliable and unsuitable for most 100Mb (or faster) interfaces, where bursts are expected to exceed 50Mbps. This means that for interfaces where much traffic is sent this plugin will report false thruputs and cannot be trusted." ;
223 # unless perhaps the operator can get us snmp version 2c or 3?
224 $extrainfo .= " I notice that you use SNMP version 1 which does not support 64 bit quantities. You may get better results if you switch to SNMP version 2c or 3. Please refer to the plugin documentation."
228 print "graph_title Interface $alias traffic \n " ;
229 print "graph_order recv send \n " ;
230 print "graph_args --base 1000 \n " ;
231 print "graph_vlabel bits in (-) / out (+) per \${graph_period} \n " ;
232 print "graph_category network \n " ;
233 print "graph_info This graph shows traffic for the \" $alias \" network interface. $extrainfo \n " ;
234 print "send.info Bits sent/received by this interface. \n " ;
235 print "recv.label recv \n " ;
236 print "recv.type DERIVE \n " ;
237 print "recv.graph no \n " ;
238 print "recv.cdef recv,8,* \n " ;
239 print "recv.max $speed \n " if $speed ;
240 print "recv.min 0 \n " ;
241 print "recv.warning " , ( $warn ), " \n " if defined $warn && ( $warn != 0 );
242 print "send.label bps \n " ;
243 print "send.type DERIVE \n " ;
244 print "send.negative recv \n " ;
245 print "send.cdef send,8,* \n " ;
246 print "send.max $speed \n " if $speed ;
247 print "send.min 0 \n " ;
248 print "send.warning $warn \n " if defined $warn && ( $warn != 0 );
252 if ( defined ( $response = $session -> get_single ( $ifEntryStatus ))) {
253 if ( $response == 2 ) {
255 print "recv.value U \n " ;
256 print "send.value U \n " ;
261 if ( defined ( $response = $session -> get_single ( $ifEntryIn64Octets ) ||
262 $session -> get_single ( $ifEntryInOctets ))) {
263 print "recv.value " , $response , " \n " ;
266 print "recv.value U \n " ;
269 if ( defined ( $response = $session -> get_single ( $ifEntryOut64Octets ) ||
270 $session -> get_single ( $ifEntryOutOctets ))) {
271 print "send.value " , $response , " \n " ;
274 print "send.value U \n " ;