Athanasios Douitsis > SNMP-Class > SNMP::Class

Download:
SNMP-Class-0.15.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.15   Source  

NAME ^

SNMP::Class - A convenience class around the NetSNMP perl modules.

VERSION ^

Version 0.11

SYNOPSIS ^

This module aims to enable snmp-related tasks to be carried out with the best possible ease and expressiveness while at the same time allowing advanced features like subclassing to be used without hassle.

        use SNMP::Class;
        
        #create a session to a managed device -- 
        #community will default to public, version will be autoselected from 2,1
        my $s = SNMP::Class->new({DestHost => 'myhost'});    
        
        #modus operandi #1
        #walk the entire table
        my $ifTable = $s->walk("ifTable");
        #-more compact- 
        my $ifTable = $s->ifTable;
        
        #get the ifDescr.3
        my $if_descr_3 = $ifTable->object("ifDescr")->instance("3");
        #more compact
        my $if_descr_3 = $ifTable->object(ifDescr).3;
        
        #iterate over interface descriptions -- method senses list context and returns array
        for my $descr ($ifTable->object"ifDescr")) { 
                print $descr->get_value,"\n";
        }
        
        #get the speed of the instance for which ifDescr is en0
        my $en0_speed = $ifTable->find("ifDescr","en0")->object("ifSpeed")->get_value;  
        #
        #modus operandi #2 - list context
        while($s->ifDescr) {
                print $_->get_value;
        }

METHODS ^

new({DestHost=>$desthost,Community=>$community,Version=>$version,DestPort=>$port})

This method creates a new session with a managed device. Argument must be a hash reference (see Class::Std for that requirement). The members of the hash reference are the same with the arguments of the new method of the SNMP module. If Version is not present, the library will try to probe by querying sysName.0 from the device using version 2 and then version 1, whichever succeeds first. This method croaks if a session cannot be created. If the managed node cannot return the sysName.0 object, the method will also croak. Most people will want to use the method as follows and let the module figure out the rest.

 my $session = SNMP::Class->new({DestHost=>'myhost.mydomain'}); 

deactivate_bulkwalks

If called, this method will permanently deactivate usage of bulkwalk for the session. Mostly useful for broken agents, some buggy versions of Net-SNMP etc.

getSysName

Returns the sysname of the machine corresponding to the session

get_version

Returns the SNMP version of the session object.

walk

A generalized walk method. Takes 1 argument, which is the object to walk. Depending on whether the session object is version 1 or 2, it will respectively try to use either SNMP GETNEXT's or GETBULK. On all cases, an SNMP::Class::ResultSet is returned. If something goes wrong, the method will croak.

One should probably also take a look at SNMP::Class::ResultSet to see what's possible.

AUTHOR ^

Athanasios Douitsis, <aduitsis at cpan.org>

BUGS ^

Please report any bugs or feature requests to bug-snmp-class at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=SNMP::Class. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT ^

You can find documentation for this module with the perldoc command.

    perldoc SNMP::Class

You can also look for information at:

ACKNOWLEDGEMENTS ^

This module obviously needs the perl libraries from the excellent Net-SNMP package. Many thanks go to the people that make that package available.

COPYRIGHT & LICENSE ^

Copyright 2008 Athanasios Douitsis, all rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

syntax highlighting: