Net-SNMP
view release on metacpan or search on metacpan
lib/Net/SNMP.pm view on Meta::CPAN
my $result = $session->var_bind_list();
if (!defined $result) {
printf "ERROR: Get request failed for host '%s': %s.\n",
$session->hostname(), $session->error();
return;
}
printf "The sysUpTime for host '%s' is %s.\n",
$session->hostname(), $result->{$OID_sysUpTime};
# Now set the sysContact and sysLocation for the host.
$result = $session->set_request(
-varbindlist =>
[
$OID_sysContact, OCTET_STRING, 'Help Desk x911',
$OID_sysLocation, OCTET_STRING, $location,
],
-callback => \&set_callback,
);
if (!defined $result) {
printf "ERROR: Failed to queue set request for host '%s': %s.\n",
$session->hostname(), $session->error();
}
return;
}
sub set_callback
{
my ($session) = @_;
my $result = $session->var_bind_list();
if (defined $result) {
printf "The sysContact for host '%s' was set to '%s'.\n",
$session->hostname(), $result->{$OID_sysContact};
printf "The sysLocation for host '%s' was set to '%s'.\n",
$session->hostname(), $result->{$OID_sysLocation};
} else {
printf "ERROR: Set request failed for host '%s': %s.\n",
$session->hostname(), $session->error();
}
return;
}
=head1 REQUIREMENTS
=over
=item *
The Net::SNMP module uses syntax that is not supported in versions of Perl
earlier than v5.6.0.
=item *
The non-core modules F<Crypt::DES>, F<Digest::MD5>, F<Digest::SHA1>, and
F<Digest::HMAC> are required to support SNMPv3.
=item *
In order to support the AES Cipher Algorithm as a SNMPv3 privacy protocol, the
non-core module F<Crypt::Rijndael> is needed.
=item *
To use UDP/IPv6 or TCP/IPv6 as a Transport Domain, the non-core module
F<Socket6> is needed.
=back
=head1 AUTHOR
David M. Town E<lt>dtown@cpan.orgE<gt>
=head1 ACKNOWLEDGMENTS
The original concept for this module was based on F<SNMP_Session.pm>
written by Simon Leinen E<lt>simon@switch.chE<gt>.
The Abstract Syntax Notation One (ASN.1) encode and decode methods were
originally derived by example from the CMU SNMP package whose copyright
follows: Copyright (c) 1988, 1989, 1991, 1992 by Carnegie Mellon University.
All rights reserved.
=head1 LICENSE AND COPYRIGHT
Copyright (c) 1998-2010 David M. Town. All rights reserved.
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.
=cut
# ============================================================================
1; # [end Net::SNMP]
( run in 3.124 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )