Net::SNMP::Util::TC - Giving Textual Convention of MIBs
use Net::SNMP::Util; use Net::SNMP::Util::OID qw(if*); use Net::SNMP::Util::TC qw(updown iftype); $r = snmpget( snmp => { -hostname => $host }, oids => { map oidp("$_.1"), qw/ifName ifType ifAdminStatus ifOperStatus/ } ); my $tc = Net::SNMP::Util::TC->new(); printf "port:%s index:%d type:%s astat:%s ostat:%s\n", $r->{"ifName.1"}, $index, $tc->ifType($r->{"ifType.1"}), updown($r->{"ifAdminStatus.1"}), updown($r->{"ifOperStatus.1" });
Module Net::SNMP::Util::TC gives the way to convert some MIB values to humans recognizable text.
Net::SNMP::Util::TC
This module, Net::SNMP::Util::OID, exports isup() and updown() defalut which are for ifAdminStatus and ifOperStatus to check up or down simply.
Net::SNMP::Util::OID
isup()
updown()
To know status, kind or type fully, make object first and than call method with MIB value to convert like below;
$tc = Net::SNMP::Util::TC->new(); $status = $tc->ifAdminStatus($value);
isup( $value );
If $value is "1", function returns 1. If values else this returns 0.
updown( $value );
If $value is "1", function returns string 'up'. Else returns 'down'.
$tc = Net::SNMP::Util::TC->new();
First creat an object for conversion. No arguments are need for this class. Then call method, which name is same as MIB name, with passing value you want to convert. e.g.;
$type = $tc->ifType( 132 ); # "coffee"
Textual conversion methods now avaiable are;
For conversion value of MIB ifAdminStatus.
For conversion value of MIB ifOperStatus.
For conversion value of MIB ifType. MIB ifType is now defined as IANAifType.
For conversion value of MIB ifRcvAddressType.
For conversion value of MIB TruthValue.
For conversion value of MIB StorageType.
This method always returns 1 which is defined as true value in MIB TruthValue at RFC-1903.
This method always returns 2 which is defined as false value in MIB TruthValue at RFC-1903.
t.onodera, <cpan :: garakuta.net>
<cpan :: garakuta.net>
Net::SNMP::Util, Net::SNMP::Util::OID
Copyright(C) 2010 Takahiro Ondoera.
This program is free software; you may redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Net::SNMP::Util, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Net::SNMP::Util
CPAN shell
perl -MCPAN -e shell install Net::SNMP::Util
For more information on module installation, please visit the detailed CPAN module installation guide.