#!/usr/bin/perl
#!/usr/bin/perl
use Net::SNMP;
$ENV{'MIBS'}="RFC1213-MIB";
$SNMP_TARGET = "serenity";
$SNMP_COMMUNITY = "public";
$SESSION = new SNMP::Session (DestHost => $SNMP_TARGET, Community => $SNMP_COMMUNITY, Version => 1);
$VLIST = new SNMP::VarList(['ifInOctets.21'],['ifOutOctets.21']);
@INFO = $SESSION->getnext($VLIST);
print "Bytes In: ${VLIST[0]}";
print "Bytes Out: ${VLIST[1]}";#!/usr/bin/perl
use strict;
use warnings;
use SNMP;
use constant OIDsysObjectID => '.1.3.6.1.2.1.1.2.0';
my $snmp = new SNMP::Session(
DestHost => 'host.example.com',
Community => 'snmp_community_string',
Version => '2c',
UseSprintValue => 1,
);
my $sysOID = $id->get(OIDsysObjectID);
#!/usr/bin/perl -w
use strict;
use Net::SNMP;
my $session = new Net::SNMP->session (-hostname => "serenity", -community => "public");
my $ifInOctets = "ifInOctets.21";
my $ifOutOctets = "ifOutOctets.21";
my $result = $session->get_request(-varbindlist => [$ifInOctets, $ifOutOctets]);
printf ("Bytes In: %s\n Bytes Out: %s", $result->{$ifInOctets}, $result->{$ifOutOctets});
$session->close;
exit 0;