root / plugins / snmp / snmp__gwia_bytes_ @ e5ce7492
Historique | Voir | Annoter | Télécharger (5,22 ko)
| 1 | 50851b14 | Gabriele Pohl | #!/usr/bin/perl -w |
|---|---|---|---|
| 2 | # |
||
| 3 | # File: snmp__gwia_bytes__ |
||
| 4 | # Copyright (C) 2007 Gabriele Pohl |
||
| 5 | # |
||
| 6 | # Derived from plugin snmp__load |
||
| 7 | # Copyright (C) 2004 Jimmy Olsen, Dagfinn Ilmari Mannsaaker |
||
| 8 | # |
||
| 9 | # This program is free software; you can redistribute it and/or |
||
| 10 | # modify it under the terms of the GNU General Public License |
||
| 11 | # as published by the Free Software Foundation; version 2 dated June, |
||
| 12 | # 1991. |
||
| 13 | # |
||
| 14 | # This program is distributed in the hope that it will be useful, |
||
| 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
| 17 | # GNU General Public License for more details. |
||
| 18 | # |
||
| 19 | # You should have received a copy of the GNU General Public License |
||
| 20 | # along with this program; if not, write to the Free Software |
||
| 21 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||
| 22 | # |
||
| 23 | # ------------------------------------------------------------ |
||
| 24 | # Plugin to monitor Novell Groupwise Internet Agent (GWIA) |
||
| 25 | # ------------------------------------------------------------ |
||
| 26 | # |
||
| 27 | # Management Information Base (MIB) GWIAMIB |
||
| 28 | # |
||
| 29 | # Naming Tree: 1.3.6.1.4.1.23 |
||
| 30 | # iso(1) org(3) dod(6) internet(1) private(4) enterprises(1) novell(23) |
||
| 31 | # |
||
| 32 | # To see all values available for your GWIA, type |
||
| 33 | # snmpwalk -v1 -c public -m GWIAMIB <HOST> gwia |
||
| 34 | # |
||
| 35 | # This plugin fetches: |
||
| 36 | # |
||
| 37 | # * gwiaGatewayName - 1.3.6.1.4.1.23.2.70.1.1. |
||
| 38 | # * gwiaStatBytesIn - 1.3.6.1.4.1.23.2.70.1.6. |
||
| 39 | # * gwiaStatBytesOut - 1.3.6.1.4.1.23.2.70.1.5. |
||
| 40 | # |
||
| 41 | # Usage: |
||
| 42 | # -------------- |
||
| 43 | # Link this file snmp__gwia_bytes_ to your nodes servicedir [/etc/munin/plugins] |
||
| 44 | # |
||
| 45 | # as: |
||
| 46 | # snmp_<host>_gwia_bytes_<pos> |
||
| 47 | # |
||
| 48 | # with: |
||
| 49 | # <host> = Name or IP-Number of host |
||
| 50 | # <pos> = table index of the GWIA Object |
||
| 51 | # |
||
| 52 | # E.g. |
||
| 53 | # ln -s /usr/share/munin/plugins/snmp__gwia_bytes_ \ |
||
| 54 | # /etc/munin/plugins/snmp_foo.example.com_gwia_bytes_0 |
||
| 55 | # ...will monitor a single GWIA object on host foo.example.com. |
||
| 56 | # |
||
| 57 | # Parameters |
||
| 58 | # community - Specify wich community string to use (Default: public) |
||
| 59 | # port - Specify which port to read from (Default: 161) |
||
| 60 | # host - Specify which host to monitor (Default: Read from link in servicedir) |
||
| 61 | # pos - Specify which table Object to read (Default: Read from link in servicedir, |
||
| 62 | # |
||
| 63 | # You may adjust settings to your need via configuration in plugin-conf.d/munin-node: |
||
| 64 | # [snmp_*_gwia_bytes_*] |
||
| 65 | # env.port <your_port_number> |
||
| 66 | # env.community <your SNMP community string> |
||
| 67 | # env.pos <your objects table position. Values: 0,1,2,..> |
||
| 68 | # env.host <name or IP of your host> |
||
| 69 | # |
||
| 70 | # Parameters can also be specified on a per GWIA basis, eg: |
||
| 71 | # [snmp_example.com_gwia_bytes_1] |
||
| 72 | # env.port 166 |
||
| 73 | # env.community example |
||
| 74 | # |
||
| 75 | # $Log$ |
||
| 76 | # Revision 1.0 2007/09/06 16:49 gap |
||
| 77 | # Created by gap |
||
| 78 | # |
||
| 79 | #%# family=snmpauto |
||
| 80 | #%# capabilities=snmpconf |
||
| 81 | |||
| 82 | use strict; |
||
| 83 | use Net::SNMP; |
||
| 84 | |||
| 85 | my $DEBUG = 0; |
||
| 86 | |||
| 87 | my $host = $ENV{host} || undef;
|
||
| 88 | my $port = $ENV{port} || 161;
|
||
| 89 | my $community = $ENV{community} || "public";
|
||
| 90 | my $pos = $ENV{pos} || 0;
|
||
| 91 | |||
| 92 | my $response; |
||
| 93 | |||
| 94 | my $GRAPH_CATEGORY = "Groupwise"; |
||
| 95 | my $GRAPH_PERIOD = "minute"; |
||
| 96 | my $GRAPH_VLABEL = "bytes per $GRAPH_PERIOD in(-) / out(+)"; |
||
| 97 | my $BYTES_LABEL='Bytes'; |
||
| 98 | |||
| 99 | if (defined $ARGV[0] and $ARGV[0] eq "snmpconf") |
||
| 100 | {
|
||
| 101 | print "require 1.3.6.1.4.1.23.2.70.1.1. [.*]\n"; # gwiaGatewayName |
||
| 102 | print "require 1.3.6.1.4.1.23.2.70.1.6. [\\d*]\n"; # gwiaStatBytesIn |
||
| 103 | print "require 1.3.6.1.4.1.23.2.70.1.5. [\\d*]\n"; # gwiaStatBytesOut |
||
| 104 | |||
| 105 | exit 0; |
||
| 106 | } |
||
| 107 | |||
| 108 | if ($0 =~ /^(?:|.*\/)snmp_([^_]+)_gwia_bytes_(\d+)*$/) |
||
| 109 | {
|
||
| 110 | $host = $1; |
||
| 111 | $pos = $2; |
||
| 112 | } |
||
| 113 | elsif (!defined($host)) |
||
| 114 | {
|
||
| 115 | print "# Debug: $0 -- $1\n" if $DEBUG; |
||
| 116 | die "# Error: couldn't understand what I'm supposed to monitor."; |
||
| 117 | } |
||
| 118 | |||
| 119 | my ($session, $error) = Net::SNMP->session( |
||
| 120 | -hostname => $host, |
||
| 121 | -community => $community, |
||
| 122 | -port => $port |
||
| 123 | ); |
||
| 124 | |||
| 125 | if (!defined ($session)) |
||
| 126 | {
|
||
| 127 | die "Croaking: $error"; |
||
| 128 | } |
||
| 129 | |||
| 130 | if (defined $ARGV[0] and $ARGV[0] eq "config") |
||
| 131 | {
|
||
| 132 | |||
| 133 | # get name of Internet Agent |
||
| 134 | my $gwname = &get_single ($session, "1.3.6.1.4.1.23.2.70.1.1.$pos"); # gwiaGatewayName |
||
| 135 | # output to munin |
||
| 136 | print "host_name $host |
||
| 137 | graph_category $GRAPH_CATEGORY |
||
| 138 | graph_args --base 1000 |
||
| 139 | graph_period $GRAPH_PERIOD |
||
| 140 | graph_title GWIA byte load ($gwname) |
||
| 141 | graph_info Shows per minute activity of the Groupwise Internet Agent (GWIA), here: $gwname.<br />Outgoing data will be reported as positive value, incoming as negative value.<br />The plugin fetches the following values (GWIAMIB):<br />gwiaStatBytesOut - Size of outgoing messages in bytes.<br />gwiaStatBytesIn - Size of incoming messages in bytes. |
||
| 142 | graph_vlabel $GRAPH_VLABEL |
||
| 143 | bytes_in.label $BYTES_LABEL |
||
| 144 | bytes_in.info gwiaStatBytesIn (1.3.6.1.4.1.23.2.70.1.6.) |
||
| 145 | bytes_in.type DERIVE |
||
| 146 | bytes_in.min 0 |
||
| 147 | bytes_in.draw AREA |
||
| 148 | bytes_in.graph no |
||
| 149 | bytes_out.label $BYTES_LABEL |
||
| 150 | bytes_out.info gwiaStatBytesOut (1.3.1.4.1.23.2.70.1.5.) |
||
| 151 | bytes_out.type DERIVE |
||
| 152 | bytes_out.min 0 |
||
| 153 | bytes_out.draw AREA |
||
| 154 | bytes_out.negative bytes_in"; |
||
| 155 | |||
| 156 | exit 0; |
||
| 157 | } |
||
| 158 | # fetch the data and print |
||
| 159 | print "bytes_in.value ", &get_single ($session, "1.3.6.1.4.1.23.2.70.1.6.$pos"), "\n"; # gwiaStatBytesIn |
||
| 160 | print "bytes_out.value ", &get_single ($session, "1.3.6.1.4.1.23.2.70.1.5.$pos"), "\n"; # gwiaStatBytesOut |
||
| 161 | |||
| 162 | |||
| 163 | sub get_single |
||
| 164 | {
|
||
| 165 | my $handle = shift; |
||
| 166 | my $oid = shift; |
||
| 167 | |||
| 168 | print "# Getting single $oid...\n" if $DEBUG; |
||
| 169 | |||
| 170 | $response = $handle->get_request ($oid); |
||
| 171 | |||
| 172 | if (!defined $response->{$oid})
|
||
| 173 | {
|
||
| 174 | return undef; |
||
| 175 | } |
||
| 176 | else |
||
| 177 | {
|
||
| 178 | return $response->{$oid};
|
||
| 179 | } |
||
| 180 | } |
