]>
jfr.im git - munin-plugins.git/blob - snmp__swap
5 # Copyright (C) 2006 Lars Strand
7 # Munin plugin to monitor swap usage by use of SNMP.
8 # Based on the snmp__df plugin
10 # This program is free software; you can redistribute it and/or
11 # modify it under the terms of the GNU General Public License
12 # as published by the Free Software Foundation; version 2 dated June,
15 # This program is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License
21 # along with this program; if not, write to the Free Software
22 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 #%# capabilities=snmpconf
30 use Munin
::Plugin
::SNMP
;
35 if (defined $ARGV[0] and $ARGV[0] eq "snmpconf") {
36 # HOST-RESOURCES-MIB::hrStorageType
37 # HOST-RESOURCES-TYPES::hrStorageVirtualMemory
38 print "require 1.3.6.1.2.1.25.2.3.1.2. 1.3.6.1.2.1.25.2.1.3\n";
42 my $session = Munin
::Plugin
::SNMP-
>session();
44 my $hrStorage = "1.3.6.1.2.1.25.2.";
45 my $hrStorageVirtualMemory = "1.3.6.1.2.1.25.2.1.3";
46 my $hrStorageSize = "1.3.6.1.2.1.25.2.3.1.5.";
47 my $hrStorageUsed = "1.3.6.1.2.1.25.2.3.1.6.";
49 my $swap_d = $session->get_by_regex($hrStorage, $hrStorageVirtualMemory);
54 foreach my $swap (keys %$swap_d) {
55 $swapsize += $session->get_single($hrStorageSize . $swap);
56 $swapused += $session->get_single($hrStorageUsed . $swap);
59 if (defined $ARGV[0] and $ARGV[0] eq "config") {
60 my ($host) = Munin
::Plugin
::SNMP-
>config_session();
61 print "host_name $host\n" unless $host eq 'localhost';
62 print "graph_title Virtual memory usage\n";
64 print "graph_args -l 0 --base 1024 --upper-limit $swapsize\n";
66 print "graph_args -l 0 --base 1024\n";
68 print "graph_vlabel Bytes\n";
69 print "graph_category system\n";
70 print "graph_info This graph shows swap usage in bytes.\n";
71 print "swap.label swap\n";
72 print "swap.type DERIVE\n";
77 print "swap.value $swapused\n";