#!@@PERL@@ -w
# -*- perl -*-
# vim: ft=perl

=head1 NAME

snmp__load - Munin plugin to monitor load average via SNMP.

=head1 APPLICABLE SYSTEMS

Any SNMP-capable device that reports the UCD-SNMP-MIB::laLoad.2
OID.  This includes those running the SNMPd provided by the
Net-SNMP project.

=head1 CONFIGURATION

As a rule SNMP plugins need site specific configuration.  The default
configuration (shown here) will only work on insecure sites/devices.

   [snmp_*]
	env.version 2
        env.community public

In general SNMP is not very secure at all unless you use SNMP version
3 which supports authentication and privacy (encryption).  But in any
case the community string for your devices should not be "public".

Please see 'perldoc Munin::Plugin::SNMP' for further configuration
information.

=head1 INTERPRETATION

Load average provides an indication of how many processes are
contending for the CPU.  Under normal conditions, it should be
less than or equal to the number of CPUs.  (Compare to the 'load'
Munin plugin.)

=head1 MIB INFORMATION

This plugin requires support for the UCD-SNMP-MIB, authored by the
University of California, Davis and maintained by the Net-SNMP project.
It reports the contents of the laLoad.2 OID.

=head1 MAGIC MARKERS

  #%# family=snmpauto
  #%# capabilities=snmpconf

=head1 BUGS

None known.

=head1 AUTHOR

Copyright (C) 2004 Jimmy Olsen, Dagfinn Ilmari Mannsåker

Documented and updated to use Munin::Plugin::SNMP by Matthew Boyle.

=head1 LICENSE

GPLv2.

=cut

use strict;
use Munin::Plugin::SNMP;

if (defined $ARGV[0] and $ARGV[0] eq 'snmpconf') {
	# .iso.org.dod.internet.private.enterprises.ucdavis.laTable.laEntry.laLoad.2
	# (5-minute average)
	print "require 1.3.6.1.4.1.2021.10.1.3.2 [0-9]\n";
	exit 0;
}

if (defined $ARGV[0] and $ARGV[0] eq "config") {
	my ($host) = Munin::Plugin::SNMP->config_session();

	print "host_name $host\n" unless $host eq 'localhost';
	print <<"EOC";
graph_title Load average
graph_args --base 1000 -l 0
graph_vlabel load
graph_category system
graph_info This graph shows the load average on the host. Load average is a rough way of estimating how hard the machine works. Optimally, a load average should be equal to or lower than the number of CPUs on the machine.
load.label load
load.info The load average itself. This number is an average of the last 5 minutes.
load.draw LINE2
EOC
	exit 0;
}

my $session = Munin::Plugin::SNMP->session();
print "load.value ", $session->get_single('1.3.6.1.4.1.2021.10.1.3.2'), "\n";

