The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Net::SNMP::Interfaces - provide simple methods to gain interface data via

SNMP

SYNOPSIS

    use Net::SNMP::Interfaces;

    my $interfaces = Net::SNMP::Interfaces->new(Hostname => 'localhost',
                                                Community => 'public' );

    my @ifnames = $interfaces->all_interfaces();

DESCRIPTION

Net::SNMP::Interfaces aims to provide simple object methods to obtain information about a host's network interfaces ( be it a server a router or whatever ). The motivation was largely to allow a programmer to use SNMP to obtain this information without needing to know a great deal about the gory details.

The module uses Net::SNMP under the hood to do the dirty work although the user shouldn't have to worry about that ( the Net::SNMP object is available though for those who might feel the need ).

The actual details for a particular interface are obtained from the methods of Net::SNMP::Interfaces::Details - objects of which type can be obtained for the methods all_interfaces() and interface().

Of course the simpler interface has its limitations and there may well be things that you would like to do which you cant do with this module - in which case I would recommend that you get a good book on SNMP and use Net::SNMP :)

The module uses blocking SNMP requests at the current time so if some of the methods are taking too long you may want to time them out yourself using alarm().

METHODS

new( HASH %args )

The constructor of the class. It takes three arguments that are passed to Net::SNMP :

Hostname

The name of the host which you want to connect to. Defaults to 'localhost'.

Community

The SNMP community string which you want to use for this session. The default is 'public'.

Port

The UDP port that the SNMP service is listening on. The default is 161.

There is a also a fourth optional argument 'RaiseError' which determines the behaviour of the module in the event there is an error while creating the SNMP. Normally new() will return undef if there was an error but if RaiseError is set to a true value it will die() printing the error string to STDERR. If this is not set and an error occurs undef will be return and the variable $Net::SNMP::Interfaces::error will contain the test of the error.

Because the interfaces are discovered in the constructor, if the module is to be used in a long running program to monitor a host where interfaces might be added or removed it is recommended that the object returned by new() is periodically destroyed and a new one constructed.

if_names()

Returns a list of the interface names.

if_indices()

Returns a list of the indices of the interfaces - this probably shouldn't be necessary but is here for completeness anyway. If you dont know what the index is for you are safe to ignore this.

error()

Returns the text of the last Net::SNMP error. This method only makes sense if the previous method call indicated an error by a false return.

session()

Returns the Net::SNMP session object for this instance. Or a false value if there is no open session. This might be used to call methods on the Net::SNMP object if some facility is needed that isnt supplied by this module.

all_interfaces()

Returns a list of Net::SNMP::Interface::Details objects corresponding to the interfaces discovered on this host. In scalar context it will return a reference to an array.

interface( SCALAR $name )

Returns a Net::SNMP::Interfaces::Details object for the named interface. Returns undef if the supplied name is not a known interface.

In addition to the methods above, you can also use the methods from Net::SNMP::Interfaces::Details but with the addition of the interface name as an argument. e.g:

      $in_octs = $self->ifInOctets('eth0');

Please see the documentation for Net::SNMP::Interfaces::Details for more on these methods.

SUPPORT

Please email any bug reports and/or feature requests directly to the author. Requests through other channels may not be seen.

AUTHOR

Jonathan Stowe <jns@gellyfish.com>

COPYRIGHT

Copyright (c) Jonathan Stowe 2000. All rights reserved. This is free software it can be ditributed and/or modified under the same terms as Perl itself.

SEE ALSO

perl(1), Net::SNMP, Net::SNMP::Interfaces::Details.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 383:

You forgot a '=back' before '=head1'