Projet

Général

Profil

Révision 6a7f7550

ID6a7f7550c142ce984d23bbf0c3c2b8f40d1c5f30
Parent bbdfbe67
Enfant b11c9944

Ajouté par Branislav Bozgai il y a presque 14 ans

Initial version

Voir les différences:

plugins/other/snmp_zyxel_zywall__sessions
1
#!/usr/bin/perl -w
2
#
3
# Copyright (C) 2009 Branislav Bozgai
4
#
5
# Munin plugin to monitor ZyXel ZyWall series routers Sessions utilization.
6
# Based on snmp__if_  plugin.
7
#
8
# This program is free software; you can redistribute it and/or
9
# modify it under the terms of the GNU General Public License
10
# as published by the Free Software Foundation; version 2 dated June,
11
# 1991.
12
#
13
# This program is distributed in the hope that it will be useful,
14
# but WITHOUT ANY WARRANTY; without even the implied warranty of
15
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
# GNU General Public License for more details.
17
#
18
# You should have received a copy of the GNU General Public License
19
# along with this program; if not, write to the Free Software
20
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
21

  
22

  
23
#%# family=snmpauto
24
#%# capabilities=snmpconf
25

  
26
use strict;
27
use Net::SNMP;
28

  
29
my $DEBUG = 0;
30

  
31
my $host      = $ENV{host}      || undef;
32
my $port      = $ENV{port}      || 161;
33
my $community = $ENV{community} || "public";
34

  
35
my $response;
36

  
37
if (defined $ARGV[0] and $ARGV[0] eq "snmpconf")
38
{
39
    print "require 1.3.6.1.4.1.890.1.6.1.1.4.0\n";
40
    exit 0;
41
}
42

  
43
if ($0 =~ /^(?:|.*\/)snmp_zyxel_zywall_([^_]+)_sessions$/)
44
{
45
    $host  = $1;
46
    if ($host =~ /^([^:]+):(\d+)$/)
47
    {
48
        $host = $1;
49
        $port = $2;
50
    }
51
}
52
elsif (!defined($host))
53
{
54
    print "# Debug: $0 -- $1\n" if $DEBUG;
55
    die "# Error: couldn't understand what I'm supposed to monitor.";
56
}
57

  
58
my $sysActiveSessions     = "1.3.6.1.4.1.890.1.6.1.1.4.0";
59

  
60
my ($session, $error) = Net::SNMP->session(
61
                -hostname  => $host,
62
                -community => $community,
63
                -port      => $port
64
        );
65

  
66

  
67
if (!defined ($session))
68
{
69
        die "Croaking: $error";
70
}
71

  
72

  
73
if ($ARGV[0] and $ARGV[0] eq "config")
74
{
75
        print "host_name $host\n";
76
        if (!defined ($response = $session->get_request($sysActiveSessions)))
77
        {
78
                die "Croaking: " . $session->error();
79
        }
80
        print "graph_title Active Sessions\n";
81
	print "graph_category system\n";
82
        print "graph_args --base 1000 --lower-limit 0\n";
83
	print "graph_vlabel Active Sessions\n";
84
	print "graph_period second\n";
85
	print "graph_info Active Sessions\n";
86
	print "sysActiveSessions.label Sessions\n";
87
        print "sysActiveSessions.draw AREA\n";
88
        exit 0;
89
}
90

  
91

  
92
if (defined ($response = $session->get_request($sysActiveSessions)))
93
{
94
        print "sysActiveSessions.value ", $response->{$sysActiveSessions}, "\n";
95
}
96
else
97
{
98
        print "sysActiveSessions.value U\n";
99
}
100

  
101
# vim:syntax=perl

Formats disponibles : Unified diff