|
NAMENet::SNMP::Util::TC - Giving Textual Convention of MIBsSYNOPSISuse 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" }); DESCRIPTIONModule "Net::SNMP::Util::TC" gives the way to convert some MIB values to humans recognizable text.EXPORTThis module, "Net::SNMP::Util::OID", exports "isup()" and "updown()" defalut which are for ifAdminStatus and ifOperStatus to check up or down simply.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); FUNCTIONSisup()isup( $value ); If $value is "1", function returns 1. If values else this returns 0. updown()updown( $value ); If $value is "1", function returns string 'up'. Else returns 'down'. METHODSnew()$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" Avaiable MethodsTextual conversion methods now avaiable are;
METHODSTRUE()This method always returns 1 which is defined as true value in MIB TruthValue at RFC-1903.FALSE()This method always returns 2 which is defined as false value in MIB TruthValue at RFC-1903.AUTHORt.onodera, "<cpan :: garakuta.net>"SEE ALSONet::SNMP::Util, Net::SNMP::Util::OIDLICENSE AND COPYRIGHTCopyright(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.
Visit the GSP FreeBSD Man Page Interface. |