NAME

Net::SNMP::Util::TC - Giving Textual Convention of MIBs

SYNOPSIS

    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" });

DESCRIPTION

Module Net::SNMP::Util::TC gives the way to convert some MIB values to humans recognizable text.

EXPORT

This 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);

FUNCTIONS

isup()

    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'.

METHODS

new()

    $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 Methods

Textual conversion methods now avaiable are;

ifAdminStatus()

For conversion value of MIB ifAdminStatus.

ifOperStatus()

For conversion value of MIB ifOperStatus.

ifType()

For conversion value of MIB ifType. MIB ifType is now defined as IANAifType.

ifRcvAddressType()

For conversion value of MIB ifRcvAddressType.

TruthValue()

For conversion value of MIB TruthValue.

StorageType()

For conversion value of MIB StorageType.

METHODS

TRUE()

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.

AUTHOR

t.onodera, <cpan :: garakuta.net>

SEE ALSO

Net::SNMP::Util, Net::SNMP::Util::OID

LICENSE AND COPYRIGHT

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.