#!/usr/bin/perl

use SNMP;

$SNMP::use_sprint_value = 1;

my $host = "localhost";
my $community="public";

$sess = new SNMP::Session(
	'DestHost'	=> $host,
	'Community'	=> $community,
	'Version'	=>  2
	);

die "cannot create session: ${SNMP::ErrorStr}\n" unless defined $sess;

my $getvars = new SNMP::VarList(
	['sysDescr',0],
	['sysContact',0],
	['sysUpTime',0],
	['ifNumber',0],
	['ifSpeed',1],
	['ifDescr',2],
	['ifInOctets',2],
	['ifOutOctets',2]
	);

my @response = $sess->get($getvars);

print "start foreach\n";
foreach my $val (@response) {
	print "$val\n";
}
print "end foreach\n";
print "======================\n";

$ifname     = @response[5];
$ifinoctets = @response[6];
$ifoutoctets= @response[7];
$ifnumber   = @response[3];
print "there are $ifnumber interfaces\n";
print "$ifname ifinoctets = $ifinoctets\n";
print "$ifname ifoutoctets = $ifoutoctets\n";

#print "start for\n";
#for $vb (@response) {
#	print "$vb\n";
#	$oid = $$vars[$i++]->tag();
#	$num = scalar @$vb;
#	print "$num responses for oid $oid: \n"
#}
#print "end for\n";
print "======================\n";

	
