Apache-WebSNMP

 view release on metacpan or  search on metacpan

lib/Apache/WebSNMP.pm  view on Meta::CPAN


use strict;
use Apache::Constants qw(:common);

@Apache::WebSNMP::ISA = qw(DynaLoader);
$Apache::WebSNMP::VERSION = '0.11';

sub handler
{

	use SNMP;
	
	my $r=shift;

	# snmp oid map
	my %oidmap = (
		# system
		'sysDescr'	=> "1.3.6.1.2.1.1.1",
		'sysObjectID'	=> "1.3.6.1.2.1.1.2",
		'sysUpTime'	=> "1.3.6.1.2.1.1.3",
		'sysContact'	=> "1.3.6.1.2.1.1.4",
		'sysName'	=> "1.3.6.1.2.1.1.5",
		'sysLocation'	=> "1.3.6.1.2.1.1.6",
		'sysServices'	=> "1.3.6.1.2.1.1.7",
		# interface
		'ifIndex'	=> "1.3.6.1.2.1.2.2.1.1",
		'ifDescr'	=> "1.3.6.1.2.1.2.2.1.2",
        	'ifType'        => "1.3.6.1.2.1.2.2.1.3",
        	'ifMtu'         => "1.3.6.1.2.1.2.2.1.4",
        	'ifSpeed'       => "1.3.6.1.2.1.2.2.1.5",
        	'ifPhysAddress' => "1.3.6.1.2.1.2.2.1.6",
        	'ifAdminStatus' => "1.3.6.1.2.1.2.2.1.7",
        	'ifOperStatus'  => "1.3.6.1.2.1.2.2.1.8",
        	'ifLastChange'  => "1.3.6.1.2.1.2.2.1.9",
        	'ifInOctets'    => "1.3.6.1.2.1.2.2.1.10",
        	'ifInUcastPkts' => "1.3.6.1.2.1.2.2.1.11",
        	'ifInNUcastPkts'=> "1.3.6.1.2.1.2.2.1.12",
        	'ifInDiscards'  => "1.3.6.1.2.1.2.2.1.13",
        	'ifInErrors'    => "1.3.6.1.2.1.2.2.1.14",
        	'ifInUnknownProtos' => "1.3.6.1.2.1.2.2.1.15",
        	'ifOutOctets'   => "1.3.6.1.2.1.2.2.1.16",
        	'ifOutUcastPkts' => "1.3.6.1.2.1.2.2.1.17",
        	'ifOutNUcastPkts' => "1.3.6.1.2.1.2.2.1.18",
        	'ifOutDiscards' => "1.3.6.1.2.1.2.2.1.19",
        	'ifOutErrors'   => "1.3.6.1.2.1.2.2.1.20",
        	'ifOutQLen'     => "1.3.6.1.2.1.2.2.1.21",
        	'ifSpecific'    => "1.3.6.1.2.1.2.2.1.22",
		# ip
		'ipForwarding'	=> "1.3.6.1.2.4.1",
        	'ipDefaultTTL'  => "1.3.6.1.2.4.2",
        	'ipInReceives'  => "1.3.6.1.2.4.3",
        	'ipInHdrErrors' => "1.3.6.1.2.4.4",
        	'ipInAddrErrors' => "1.3.6.1.2.4.5",
        	'ipForwDatagrams' => "1.3.6.1.2.4.6",
        	'ipInUnknownProtos' => "1.3.6.1.2.4.7",
        	'ipInDiscards'  => "1.3.6.1.2.4.8",
        	'ipInDelivers'  => "1.3.6.1.2.4.9",
        	'ipOutRequests' => "1.3.6.1.2.4.10",
        	'ipOutDiscards' => "1.3.6.1.2.4.11",
        	'ipOutNoRoutes' => "1.3.6.1.2.4.12",
        	'ipReasmTimeout' => "1.3.6.1.2.4.13",
        	'ipReasmReqds'  => "1.3.6.1.2.4.14",
        	'ipReasmOKs'    => "1.3.6.1.2.4.15",
        	'ipReasmFails'  => "1.3.6.1.2.4.16",
        	'ipFragOKs'     => "1.3.6.1.2.4.17",
        	'ipFragFails'   => "1.3.6.1.2.4.18",
        	'ipFragCreates' => "1.3.6.1.2.4.19",
        	'ipAdEntAddr'   => "1.3.6.1.2.4.20.1.1",
        	'ipAdEntIfIndex' => "1.3.6.1.2.4.20.1.2",
        	'ipAdEntNetMask' => "1.3.6.1.2.4.20.1.3",
        	'ipAdEntBcastAddr' => "1.3.6.1.2.4.20.1.4",
        	'ipAdEntEntReasmMaxSize' => "1.3.6.1.2.4.20.1.5",
        	'ipRouteDest'   => "1.3.6.1.2.4.21.1.1",
		'ipRouteIfIndex' => "1.3.6.1.2.4.21.1.2",
		'ipRouteMetric1' => "1.3.6.1.2.4.21.1.3",
        	'ipRouteMetric2' => "1.3.6.1.2.4.21.1.4",
		'ipRouteMetric3' => "1.3.6.1.2.4.21.1.5",
        	'ipRouteMetric4' => "1.3.6.1.2.4.21.1.6",
		'ipRouteNextHop' => "1.3.6.1.2.4.21.1.7",
        	'ipRouteType'   => "1.3.6.1.2.4.21.1.8",
		'ipRouteProto'  => "1.3.6.1.2.4.21.1.9",
        	'ipRouteAge'    => "1.3.6.1.2.4.21.1.10",
		'ipRouteMask'   => "1.3.6.1.2.4.21.1.11",
        	'ipRouteMetric5' => "1.3.6.1.2.4.21.1.12",
		'ipRouteInfo'   => "1.3.6.1.2.4.21.1.13",
		'ipNetToMediaIfIndex' => "1.3.6.1.2.1.4.22.1.1",
        	'ipNetToMediaPhysAddress' => "1.3.6.1.2.1.4.22.1.2",
        	'ipNetToMediaNetAddress' => "1.3.6.1.2.1.4.22.1.3",
        	'ipNetToMediaType' => "1.3.6.1.2.1.4.22.1.4",
        	'ipRoutingDiscards' => "1.3.6.1.2.4.23",
		# tcp
		'tcpRtoAlgorithm' => '1.3.6.1.2.1.6.1',
        	'tcpRtoMin' 	=> '1.3.6.1.2.1.6.2',
        	'tcpRtoMax' 	=> '1.3.6.1.2.1.6.3',
        	'tcpMaxConn'	=> '1.3.6.1.2.1.6.4',
        	'tcpActiveOpens' => '1.3.6.1.2.1.6.5',
        	'tcpPassiveOpens' => '1.3.6.1.2.1.6.6',
        	'tcpAttemptFails' => '1.3.6.1.2.1.6.7',
        	'tcpEstabResets' => '1.3.6.1.2.1.6.8',
        	'tcpCurrEstab' 	=> '1.3.6.1.2.1.6.9',
        	'tcpInSegs' 	=> '1.3.6.1.2.1.6.10',
        	'tcpOutSegs' 	=> '1.3.6.1.2.1.6.11',
        	'tcpRetransSets' => '1.3.6.1.2.1.6.12',
        	'tcpConnState' 	=> '1.3.6.1.2.1.6.13.1.1',
        	'tcpConnLocalAddress' => '1.3.6.1.2.1.6.13.1.2',
        	'tcpConnLocalPort' => '1.3.6.1.2.1.6.13.1.3',
        	'tcpConnRemAddress' => '1.3.6.1.2.1.6.13.1.4',
        	'tcpConnRemPort' => '1.3.6.1.2.1.6.13.1.5',
        	'tcpInErrs' 	=> '1.3.6.1.2.1.6.14',
        	'tcpOutRsts' 	=> '1.3.6.1.2.1.6.15',
		# udp
		'udpInDatagrams' => '1.3.6.1.2.1.7.1',
        	'udpNoPorts' 	=> '1.3.6.1.2.1.7.2',
        	'udpInErrors' 	=> '1.3.6.1.2.1.7.3',
        	'udpOutDatagrams' => '1.3.6.1.2.1.7.4',
        	'udpLocalAddress' => '1.3.6.1.2.1.7.5.1.1',
        	'udpLocalPort'  => '1.3.6.1.2.1.7.5.1.2',
		# at
		'atIfIndex'	=> '1.3.6.1.2.1.3.1.1.1',
        	'atPhysAddressIfIndex' => '1.3.6.1.2.1.3.1.1.2',
        	'atNetAddress'  => '1.3.6.1.2.1.3.1.1.3',

lib/Apache/WebSNMP.pm  view on Meta::CPAN


The configuration statements allow the user the set which host to poll for SNMP information, as well as the SNMP community that the get statements will draw from.  This essentially takes the form of assigning values to the reserved variables B<host> ...
	varible_name=value

Note: there must not be any intervening whitespace between the '=' and the name and value.  Thus to set the SNMP host to machine.domain.net, we would issue the configuration statement:

	<snmp>host=machine.domain.net</snmp>

If not specified, the default host is localhost, and the default community is public.

=head1 Variable Assignments

Variables are used as temporary holding locations for information returned from SNMP calls.  The decision to use variables was made to obviate the necessity of making a different SNMP get call for each separate piece of information.  Variable assignm...
	description=ifDescr[.extension]
The OIDs currently implemented are a subset of the IETF Management MIB.  Support is available for the system, interface, ip, tcp, udp, icmp, and at modules.  A list of the currently supported OIDs, and their symbolic equivalents, is given below:

		# system
		'sysDescr'	=> "1.3.6.1.2.1.1.1",
		'sysObjectID'	=> "1.3.6.1.2.1.1.2",
		'sysUpTime'	=> "1.3.6.1.2.1.1.3",
		'sysContact'	=> "1.3.6.1.2.1.1.4",
		'sysName'	=> "1.3.6.1.2.1.1.5",
		'sysLocation'	=> "1.3.6.1.2.1.1.6",
		'sysServices'	=> "1.3.6.1.2.1.1.7",
		# interface
		'ifIndex'	=> "1.3.6.1.2.1.2.2.1.1",
		'ifDescr'	=> "1.3.6.1.2.1.2.2.1.2",
        	'ifType'        => "1.3.6.1.2.1.2.2.1.3",
        	'ifMtu'         => "1.3.6.1.2.1.2.2.1.4",
        	'ifSpeed'       => "1.3.6.1.2.1.2.2.1.5",
        	'ifPhysAddress' => "1.3.6.1.2.1.2.2.1.6",
        	'ifAdminStatus' => "1.3.6.1.2.1.2.2.1.7",
        	'ifOperStatus'  => "1.3.6.1.2.1.2.2.1.8",
        	'ifLastChange'  => "1.3.6.1.2.1.2.2.1.9",
        	'ifInOctets'    => "1.3.6.1.2.1.2.2.1.10",
        	'ifInUcastPkts' => "1.3.6.1.2.1.2.2.1.11",
        	'ifInNUcastPkts'=> "1.3.6.1.2.1.2.2.1.12",
        	'ifInDiscards'  => "1.3.6.1.2.1.2.2.1.13",
        	'ifInErrors'    => "1.3.6.1.2.1.2.2.1.14",
        	'ifInUnknownProtos' => "1.3.6.1.2.1.2.2.1.15",
        	'ifOutOctets'   => "1.3.6.1.2.1.2.2.1.16",
        	'ifOutUcastPkts' => "1.3.6.1.2.1.2.2.1.17",
        	'ifOutNUcastPkts' => "1.3.6.1.2.1.2.2.1.18",
        	'ifOutDiscards' => "1.3.6.1.2.1.2.2.1.19",
        	'ifOutErrors'   => "1.3.6.1.2.1.2.2.1.20",
        	'ifOutQLen'     => "1.3.6.1.2.1.2.2.1.21",
        	'ifSpecific'    => "1.3.6.1.2.1.2.2.1.22",
		# ip
		'ipForwarding'	=> "1.3.6.1.2.4.1",
        	'ipDefaultTTL'  => "1.3.6.1.2.4.2",
        	'ipInReceives'  => "1.3.6.1.2.4.3",
        	'ipInHdrErrors' => "1.3.6.1.2.4.4",
        	'ipInAddrErrors' => "1.3.6.1.2.4.5",
        	'ipForwDatagrams' => "1.3.6.1.2.4.6",
        	'ipInUnknownProtos' => "1.3.6.1.2.4.7",
        	'ipInDiscards'  => "1.3.6.1.2.4.8",
        	'ipInDelivers'  => "1.3.6.1.2.4.9",
        	'ipOutRequests' => "1.3.6.1.2.4.10",
        	'ipOutDiscards' => "1.3.6.1.2.4.11",
        	'ipOutNoRoutes' => "1.3.6.1.2.4.12",
        	'ipReasmTimeout' => "1.3.6.1.2.4.13",
        	'ipReasmReqds'  => "1.3.6.1.2.4.14",
        	'ipReasmOKs'    => "1.3.6.1.2.4.15",
        	'ipReasmFails'  => "1.3.6.1.2.4.16",
        	'ipFragOKs'     => "1.3.6.1.2.4.17",
        	'ipFragFails'   => "1.3.6.1.2.4.18",
        	'ipFragCreates' => "1.3.6.1.2.4.19",
        	'ipAdEntAddr'   => "1.3.6.1.2.4.20.1.1",
        	'ipAdEntIfIndex' => "1.3.6.1.2.4.20.1.2",
        	'ipAdEntNetMask' => "1.3.6.1.2.4.20.1.3",
        	'ipAdEntBcastAddr' => "1.3.6.1.2.4.20.1.4",
        	'ipAdEntEntReasmMaxSize' => "1.3.6.1.2.4.20.1.5",
        	'ipRouteDest'   => "1.3.6.1.2.4.21.1.1",
		'ipRouteIfIndex' => "1.3.6.1.2.4.21.1.2",
		'ipRouteMetric1' => "1.3.6.1.2.4.21.1.3",
        	'ipRouteMetric2' => "1.3.6.1.2.4.21.1.4",
		'ipRouteMetric3' => "1.3.6.1.2.4.21.1.5",
        	'ipRouteMetric4' => "1.3.6.1.2.4.21.1.6",
		'ipRouteNextHop' => "1.3.6.1.2.4.21.1.7",
        	'ipRouteType'   => "1.3.6.1.2.4.21.1.8",
		'ipRouteProto'  => "1.3.6.1.2.4.21.1.9",
        	'ipRouteAge'    => "1.3.6.1.2.4.21.1.10",
		'ipRouteMask'   => "1.3.6.1.2.4.21.1.11",
        	'ipRouteMetric5' => "1.3.6.1.2.4.21.1.12",
		'ipRouteInfo'   => "1.3.6.1.2.4.21.1.13",
		'ipNetToMediaIfIndex' => "1.3.6.1.2.1.4.22.1.1",
        	'ipNetToMediaPhysAddress' => "1.3.6.1.2.1.4.22.1.2",
        	'ipNetToMediaNetAddress' => "1.3.6.1.2.1.4.22.1.3",
        	'ipNetToMediaType' => "1.3.6.1.2.1.4.22.1.4",
        	'ipRoutingDiscards' => "1.3.6.1.2.4.23",
		# tcp
		'tcpRtoAlgorithm' => '1.3.6.1.2.1.6.1',
        	'tcpRtoMin' 	=> '1.3.6.1.2.1.6.2',
        	'tcpRtoMax' 	=> '1.3.6.1.2.1.6.3',
        	'tcpMaxConn'	=> '1.3.6.1.2.1.6.4',
        	'tcpActiveOpens' => '1.3.6.1.2.1.6.5',
        	'tcpPassiveOpens' => '1.3.6.1.2.1.6.6',
        	'tcpAttemptFails' => '1.3.6.1.2.1.6.7',
        	'tcpEstabResets' => '1.3.6.1.2.1.6.8',
        	'tcpCurrEstab' 	=> '1.3.6.1.2.1.6.9',
        	'tcpInSegs' 	=> '1.3.6.1.2.1.6.10',
        	'tcpOutSegs' 	=> '1.3.6.1.2.1.6.11',
        	'tcpRetransSets' => '1.3.6.1.2.1.6.12',
        	'tcpConnState' 	=> '1.3.6.1.2.1.6.13.1.1',
        	'tcpConnLocalAddress' => '1.3.6.1.2.1.6.13.1.2',
        	'tcpConnLocalPort' => '1.3.6.1.2.1.6.13.1.3',
        	'tcpConnRemAddress' => '1.3.6.1.2.1.6.13.1.4',
        	'tcpConnRemPort' => '1.3.6.1.2.1.6.13.1.5',
        	'tcpInErrs' 	=> '1.3.6.1.2.1.6.14',
        	'tcpOutRsts' 	=> '1.3.6.1.2.1.6.15',
		# udp
		'udpInDatagrams' => '1.3.6.1.2.1.7.1',
        	'udpNoPorts' 	=> '1.3.6.1.2.1.7.2',
        	'udpInErrors' 	=> '1.3.6.1.2.1.7.3',
        	'udpOutDatagrams' => '1.3.6.1.2.1.7.4',
        	'udpLocalAddress' => '1.3.6.1.2.1.7.5.1.1',
        	'udpLocalPort'  => '1.3.6.1.2.1.7.5.1.2',
		# at
		'atIfIndex'	=> '1.3.6.1.2.1.3.1.1.1',
        	'atPhysAddressIfIndex' => '1.3.6.1.2.1.3.1.1.2',
        	'atNetAddress'  => '1.3.6.1.2.1.3.1.1.3',



( run in 3.767 seconds using v1.01-cache-2.11-cpan-140bd7fdf52 )