root / plugins / snmp / snmp__gwia_msgs_ @ 149c09dd
Historique | Voir | Annoter | Télécharger (6,85 ko)
| 1 | 1d12d985 | Gabriele Pohl | #!/usr/bin/perl -w |
|---|---|---|---|
| 2 | # |
||
| 3 | # File: snmp__gwia_msgs__ |
||
| 4 | # Copyright (C) 2007 Gabriele Pohl (contact@dipohl.de) |
||
| 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 | # * gwiaStatMsgsOut - 1.3.6.1.4.1.23.2.70.1.7. |
||
| 39 | # * gwiaStatMsgsIn - 1.3.6.1.4.1.23.2.70.1.8. |
||
| 40 | # * gwiaStatStatusesOut - 1.3.6.1.4.1.23.2.70.1.9. |
||
| 41 | # * gwiaStatStatusesIn - 1.3.6.1.4.1.23.2.70.1.10. |
||
| 42 | # * gwiaStatErrorsOut - 1.3.6.1.4.1.23.2.70.1.11. |
||
| 43 | # * gwiaStatErrorsIn - 1.3.6.1.4.1.23.2.70.1.12. |
||
| 44 | # |
||
| 45 | # Usage: |
||
| 46 | # -------------- |
||
| 47 | # Link this file snmp__gwia_msgs_ to your nodes servicedir [/etc/munin/plugins] |
||
| 48 | # |
||
| 49 | # as: |
||
| 50 | # snmp_<host>_gwia_msgs_<pos> |
||
| 51 | # |
||
| 52 | # with: |
||
| 53 | # <host> = Name or IP-Number of host |
||
| 54 | # <pos> = table index of the GWIA Object |
||
| 55 | # |
||
| 56 | # E.g. |
||
| 57 | # ln -s /usr/share/munin/plugins/snmp__gwia_msgs_ \ |
||
| 58 | # /etc/munin/plugins/snmp_foo.example.com_gwia_msgs_0 |
||
| 59 | # ...will monitor a single GWIA object on host foo.example.com. |
||
| 60 | # |
||
| 61 | # Parameters |
||
| 62 | # community - Specify wich community string to use (Default: public) |
||
| 63 | # port - Specify which port to read from (Default: 161) |
||
| 64 | # host - Specify which host to monitor (Default: Read from link in servicedir) |
||
| 65 | # pos - Specify which table Object to read (Default: Read from link in servicedir, |
||
| 66 | # |
||
| 67 | # You may adjust settings to your need via configuration in plugin-conf.d/munin-node: |
||
| 68 | # [snmp_*_gwia_msgs_*] |
||
| 69 | # env.port <your_port_number> |
||
| 70 | # env.community <your SNMP community string> |
||
| 71 | # env.pos <your objects table position. Values: 0,1,2,..> |
||
| 72 | # env.host <name or IP of your host> |
||
| 73 | # |
||
| 74 | # Parameters can also be specified on a per GWIA basis, eg: |
||
| 75 | # [snmp_foo.example.com_gwia_msgs_1] |
||
| 76 | # env.port 166 |
||
| 77 | # env.community example |
||
| 78 | # |
||
| 79 | # $Log$ |
||
| 80 | # Revision 1.0 2007/09/08 16:08 gap |
||
| 81 | # Created by gap |
||
| 82 | # |
||
| 83 | #%# family=snmpauto |
||
| 84 | #%# capabilities=snmpconf |
||
| 85 | |||
| 86 | use strict; |
||
| 87 | use Net::SNMP; |
||
| 88 | |||
| 89 | my $DEBUG = 0; |
||
| 90 | |||
| 91 | my $host = $ENV{host} || undef;
|
||
| 92 | my $port = $ENV{port} || 161;
|
||
| 93 | my $community = $ENV{community} || "public";
|
||
| 94 | my $pos = $ENV{pos} || 0;
|
||
| 95 | |||
| 96 | my $response; |
||
| 97 | |||
| 98 | # fix values |
||
| 99 | my $GRAPH_CATEGORY = "Groupwise"; |
||
| 100 | my $GRAPH_PERIOD = "minute"; |
||
| 101 | my $GRAPH_VLABEL = "messages per $GRAPH_PERIOD in(-) / out(+)"; |
||
| 102 | my $MSGS_LABEL='Messages'; |
||
| 103 | my $STATS_LABEL='Status-Msgs'; |
||
| 104 | my $ERRORS_LABEL='Errors'; |
||
| 105 | my $ERRORS_CRITICAL=10; |
||
| 106 | |||
| 107 | if (defined $ARGV[0] and $ARGV[0] eq "snmpconf") |
||
| 108 | {
|
||
| 109 | print "require 1.3.6.1.4.1.23.2.70.1.1. [.*]\n"; # gwiaGatewayName |
||
| 110 | print "require 1.3.6.1.4.1.23.2.70.1.7. [\\d*]\n"; # gwiaStatMsgsOut |
||
| 111 | print "require 1.3.6.1.4.1.23.2.70.1.8. [\\d*]\n"; # gwiaStatMsgsIn |
||
| 112 | print "require 1.3.6.1.4.1.23.2.70.1.11. [\\d*]\n"; # gwiaStatErrorsOut |
||
| 113 | print "require 1.3.6.1.4.1.23.2.70.1.12. [\\d*]\n"; # gwiaStatErrorsIn |
||
| 114 | print "require 1.3.6.1.4.1.23.2.70.1.9. [\\d*]\n"; # gwiaStatStatusesOut |
||
| 115 | print "require 1.3.6.1.4.1.23.2.70.1.10. [\\d*]\n"; # gwiaStatStatusesIn |
||
| 116 | |||
| 117 | exit 0; |
||
| 118 | } |
||
| 119 | |||
| 120 | if ($0 =~ /^(?:|.*\/)snmp_([^_]+)_gwia_msgs_(\d+)*$/) |
||
| 121 | {
|
||
| 122 | $host = $1; |
||
| 123 | $pos = $2; |
||
| 124 | } |
||
| 125 | elsif (!defined($host)) |
||
| 126 | {
|
||
| 127 | print "# Debug: $0 -- $1\n" if $DEBUG; |
||
| 128 | die "# Error: couldn't understand what I'm supposed to monitor."; |
||
| 129 | } |
||
| 130 | |||
| 131 | my ($session, $error) = Net::SNMP->session( |
||
| 132 | -hostname => $host, |
||
| 133 | -community => $community, |
||
| 134 | -port => $port |
||
| 135 | ); |
||
| 136 | |||
| 137 | if (!defined ($session)) |
||
| 138 | {
|
||
| 139 | die "Croaking: $error"; |
||
| 140 | } |
||
| 141 | |||
| 142 | if (defined $ARGV[0] and $ARGV[0] eq "config") |
||
| 143 | {
|
||
| 144 | |||
| 145 | # get name of Internet Agent |
||
| 146 | my $gwname = &get_single ($session, "1.3.6.1.4.1.23.2.70.1.1.$pos"); # gwiaGatewayName |
||
| 147 | |||
| 148 | # output to munin |
||
| 149 | print "host_name $host |
||
| 150 | graph_category Groupwise |
||
| 151 | graph_args --base 1000 |
||
| 152 | graph_period $GRAPH_PERIOD |
||
| 153 | graph_title GWIA msg load ($gwname) |
||
| 154 | 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. |
||
| 155 | graph_vlabel $GRAPH_VLABEL |
||
| 156 | msgs_in.label $MSGS_LABEL |
||
| 157 | msgs_in.info gwiaStatMsgsIn (1.3.6.1.4.1.23.2.70.1.8.) |
||
| 158 | msgs_in.type DERIVE |
||
| 159 | msgs_in.min 0 |
||
| 160 | msgs_in.draw AREA |
||
| 161 | msgs_in.graph no |
||
| 162 | msgs_out.label $MSGS_LABEL |
||
| 163 | msgs_out.info gwiaStatMsgsOut (1.3.6.1.4.1.23.2.70.1.7.) |
||
| 164 | msgs_out.type DERIVE |
||
| 165 | msgs_out.min 0 |
||
| 166 | msgs_out.draw AREA |
||
| 167 | msgs_out.negative msgs_in |
||
| 168 | msgs_out.graph yes |
||
| 169 | stats_in.label $STATS_LABEL |
||
| 170 | stats_in.info gwiaStatStatusesIn (1.3.6.1.4.1.23.2.70.1.10.) |
||
| 171 | stats_in.type DERIVE |
||
| 172 | stats_in.min 0 |
||
| 173 | stats_in.draw LINE1 |
||
| 174 | stats_in.graph no |
||
| 175 | stats_out.label $STATS_LABEL |
||
| 176 | stats_out.info gwiaStatStatusesOut (1.3.6.1.4.1.23.2.70.1.9.) |
||
| 177 | stats_out.type DERIVE |
||
| 178 | stats_out.min 0 |
||
| 179 | stats_out.draw LINE1 |
||
| 180 | stats_out.negative stats_in |
||
| 181 | stats_out.graph yes |
||
| 182 | errors_in.label $ERRORS_LABEL |
||
| 183 | errors_in.info gwiaStatErrorsIn (1.3.6.1.4.1.23.2.70.1.12.) |
||
| 184 | errors_in.critical $ERRORS_CRITICAL |
||
| 185 | errors_in.type DERIVE |
||
| 186 | errors_in.min 0 |
||
| 187 | errors_in.draw LINE1 |
||
| 188 | errors_in.graph no |
||
| 189 | errors_out.label $ERRORS_LABEL |
||
| 190 | errors_out.info gwiaStatErrorsOut (1.3.6.1.4.1.23.2.70.1.11.) |
||
| 191 | errors_out.critical $ERRORS_CRITICAL |
||
| 192 | errors_out.type DERIVE |
||
| 193 | errors_out.negative errors_in |
||
| 194 | errors_out.min 0 |
||
| 195 | errors_out.draw LINE1 |
||
| 196 | errors_out.graph yes"; |
||
| 197 | |||
| 198 | exit 0; |
||
| 199 | } |
||
| 200 | # fetch the data and print |
||
| 201 | print "msgs_in.value ", &get_single ($session, "1.3.6.1.4.1.23.2.70.1.8.$pos"), "\n"; # gwiaStatMsgsIn |
||
| 202 | print "msgs_out.value ", &get_single ($session, "1.3.6.1.4.1.23.2.70.1.7.$pos"), "\n"; # gwiaStatMsgsOut |
||
| 203 | print "stats_in.value ", &get_single ($session, "1.3.6.1.4.1.23.2.70.1.10.$pos"), "\n"; # gwiaStatStatusesIn |
||
| 204 | print "stats_out.value ", &get_single ($session, "1.3.6.1.4.1.23.2.70.1.9.$pos"), "\n"; # gwiaStatStatusesOut |
||
| 205 | print "errors_in.value ", &get_single ($session, "1.3.6.1.4.1.23.2.70.1.12.$pos"), "\n"; # gwiaStatErrorsIn |
||
| 206 | print "errors_out.value ", &get_single ($session, "1.3.6.1.4.1.23.2.70.1.11.$pos"), "\n"; # gwiaStatErrorsOut |
||
| 207 | |||
| 208 | sub get_single |
||
| 209 | {
|
||
| 210 | my $handle = shift; |
||
| 211 | my $oid = shift; |
||
| 212 | |||
| 213 | print "# Getting single $oid...\n" if $DEBUG; |
||
| 214 | |||
| 215 | $response = $handle->get_request ($oid); |
||
| 216 | |||
| 217 | if (!defined $response->{$oid})
|
||
| 218 | {
|
||
| 219 | return undef; |
||
| 220 | } |
||
| 221 | else |
||
| 222 | {
|
||
| 223 | return $response->{$oid};
|
||
| 224 | } |
||
| 225 | } |
