10 More Discussions You Might Find Interesting
1. IP Networking
I am having a problem with an SNMP event, and I am not sure where I should be looking to solve this problem.
Description:
There is an SNMP event in our system that for one reason or another is not getting sent out as an email because it is never getting to our SNMP agent.
I see where the... (0 Replies)
Discussion started by: broberts
0 Replies
2. Programming
hiii alll
i wrote a prgm which would take position and strand from file 1 and tries to locate a string 250 characters ahead/before that position in anothe file (based on strand 0 or 1)
open my $fhConditions, "<", "1.txt" or die "Epic Fail: $!";
open my $fhCharacters, "<", "2.txt" or die "OMG... (1 Reply)
Discussion started by: anurupa777
1 Replies
3. Web Development
Can anyone tell me how to export a variable from one perl CGI script to another perl cgi script when using a redirect.
Upon running the login.pl the user is prompted to enter user name and password. Upon entering the correct credentials (admin/admin) the user is
redirected to welcome page.
My... (3 Replies)
Discussion started by: Arun_Linux
3 Replies
4. Programming
Hi,
I'm trying to set two OID's in the same PDU (so both OIDs and values are sent in the same packet) at present I am only able to send one at a time which does not trigger the hardware response as the two specific OID's need to be set simultaneously in order to work.
I'm using perl along... (0 Replies)
Discussion started by: MCLASS
0 Replies
5. Shell Programming and Scripting
I want to have a script that takes the following:
Runs this Command:
snmpwalk -v 1 -c public devicename 1.3.2.1.15.1.1.3
which returns the following:
SNMPv2-SMI::mib-2.10.1.3.3.54.124.178.134 = INTEGER: 6
SNMPv2-SMI::mib-2.10.1.1.3.62.52.16.38 = INTEGER: 6... (1 Reply)
Discussion started by: streetfighter2
1 Replies
6. Shell Programming and Scripting
I am having trouble working with SNMP module with perl. I am trying to get SNMP version of target system. I use following code to get it however it resturns error as "Argument "v6.0.1" isn't numeric in numeric lt (<) at ./chk_env_upd.pl line 447."
Get load table
my $resultat =... (1 Reply)
Discussion started by: dynamax
1 Replies
7. IP Networking
Hi, basically I'm just looking at the O'Reilly book 'Essential SNMP' and am following one of the examples. The code in the example is:
#!/usr/bin/perl
use SNMP::Util;
my $MIB1 = $ARGV;
my $HOST = $ARGV;
($MIB1) && ($HOST) || die "Usage: $0 MIB_OID HOSTNAME";
my $value =... (0 Replies)
Discussion started by: cabaiste
0 Replies
8. Infrastructure Monitoring
Hi all
I had the server, when i run the below snmp command in the server (CNORA4/10.86.33.18), it cant give me the result.
# snmpwalk -v1 -ctestuser 10.86.33.18 hrProcessorLoad
Timeout: No Response from 10.86.33.18
but when i run another command, it seem like ok
# snmpwalk -v1 -ctestuser... (1 Reply)
Discussion started by: SmartAntz
1 Replies
9. Infrastructure Monitoring
HI,
I am facing these two errors while configuring snmp can any body guide me.
vi /var/log/snmpd.log
Error opening specified endpoint "udp:161"
Server Exiting with code 1
i also tried
bash-3.00# netstat -a | grep snm
*.snmpd Idle
bash-3.00# lsof -i :161
bash: lsof: command not... (2 Replies)
Discussion started by: nir1785
2 Replies
10. Shell Programming and Scripting
hi,,
i have perl scipt with line :
system('./try.sh $t $d $m');
in shell scipt try.sh i have the line:
echo $1
its not printing value of $t that i hav passed..y is it so..i am running it from apache web server (2 Replies)
Discussion started by: raksha.s
2 Replies
TrapReceiver(3) User Contributed Perl Documentation TrapReceiver(3)
NAME
NetSNMP::TrapReceiver - Embedded perl trap handling for Net-SNMP's snmptrapd
SYNOPSIS
Put the following lines in your snmptrapd.conf file:
perl NetSNMP::TrapReceiver::register("trapOID", &myfunc);
ABSTRACT
The NetSNMP::TrapReceiver module is used to register perl subroutines into the Net-SNMP snmptrapd process. Net-SNMP MUST have been
configured using --enable-embedded-perl. Registration of functions is then done through the snmptrapd.conf configuration file. This
module can NOT be used in a normal perl script to receive traps. It is intended solely for embedded use within the snmptrapd demon.
DESCRIPTION
Within the snmptrapd.conf file, the keyword "perl" may be used to call any perl expression and using this ability, you can use the
NetSNMP::TrapReceiver module to register functions which will be called every time a given notification (a trap or an inform) is received.
Registered functions are called with 2 arguments. The first is a reference to a hash containing information about how the trap was
received (what version of the SNMP protocol was used, where it came from, what SNMP user name or community name it was sent under, etc).
The second argument is a reference to an array containing the variable bindings (OID and value information) that define the noification
itself. Each variable is itself a reference to an array containing three values: a NetSNMP::OID object, the value that came associated
with it, and the value's numeric type (see NetSNMP::ASN for further details on SNMP typing information).
Registered functions should return one of the following values:
NETSNMPTRAPD_HANDLER_OK
Handling the trap succeeded, but lets the snmptrapd demon check for further appropriate handlers.
NETSNMPTRAPD_HANDLER_FAIL
Handling the trap failed, but lets the snmptrapd demon check for further appropriate handlers.
NETSNMPTRAPD_HANDLER_BREAK
Stops evaluating the list of handlers for this specific trap, but lets the snmptrapd demon apply global handlers.
NETSNMPTRAPD_HANDLER_FINISH
Stops searching for further appropriate handlers.
If a handler function does not return anything appropriate or even nothing at all, a return value of NETSNMPTRAPD_HANDLER_OK is assumed.
Subroutines are registered using the NetSNMP::TrapReceiver::register function, which takes two arguments. The first is a string describing
the notification you want to register for (such as "linkUp" or "MyMIB::MyTrap" or ".1.3.6.1.4.1.2021...."). Two special keywords can be
used in place of an OID: "default" and "all". The "default" keyword indicates you want your handler to be called in the case where no
other handlers are called. The "all" keyword indicates that the handler should ALWAYS be called for every notification.
EXAMPLE
As an example, put the following code into a file (say "/usr/local/share/snmp/mytrapd.pl"):
#!/usr/bin/perl
sub my_receiver {
print "********** PERL RECEIVED A NOTIFICATION:
";
# print the PDU info (a hash reference)
print "PDU INFO:
";
foreach my $k(keys(%{$_[0]})) {
if ($k eq "securityEngineID" || $k eq "contextEngineID") {
printf " %-30s 0x%s
", $k, unpack('h*', $_[0]{$k});
}
else {
printf " %-30s %s
", $k, $_[0]{$k};
}
}
# print the variable bindings:
print "VARBINDS:
";
foreach my $x (@{$_[1]}) {
printf " %-30s type=%-2d value=%s
", $x->[0], $x->[2], $x->[1];
}
}
NetSNMP::TrapReceiver::register("all", &my_receiver) ||
warn "failed to register our perl trap handler
";
print STDERR "Loaded the example perl snmptrapd handler
";
Then, put the following line in your snmprapd.conf file:
perl do "/usr/local/share/snmp/mytrapd.pl";
Start snmptrapd (as root, and the following other opions make it stay in the foreground and log to stderr):
snmptrapd -f -Le
You should see it start up and display the final message from the end of the above perl script:
Loaded the perl snmptrapd handler
2004-02-11 10:08:45 NET-SNMP version 5.2 Started.
Then, if you send yourself a fake trap using the following example command:
snmptrap -v 2c -c mycommunity localhost 0 linkUp ifIndex.1 i 1
ifAdminStatus.1 i up ifOperStatus.1 i up ifDescr s eth0
You should see the following output appear from snmptrapd as your perl code gets executed:
********** PERL RECEIVED A NOTIFICATION:
PDU INFO:
notificationtype TRAP
receivedfrom 127.0.0.1
version 1
errorstatus 0
messageid 0
community mycommunity
transactionid 2
errorindex 0
requestid 765160220
VARBINDS:
sysUpTimeInstance type=67 value=0:0:00:00.00
snmpTrapOID.0 type=6 value=linkUp
ifIndex.1 type=2 value=1
ifAdminStatus.1 type=2 value=1
ifOperStatus.1 type=2 value=1
ifDescr type=4 value="eth0"
EXPORT
None by default.
# =head2 Exportable constants
# NETSNMPTRAPD_AUTH_HANDLER # NETSNMPTRAPD_HANDLER_BREAK # NETSNMPTRAPD_HANDLER_FAIL # NETSNMPTRAPD_HANDLER_FINISH #
NETSNMPTRAPD_HANDLER_OK # NETSNMPTRAPD_POST_HANDLER # NETSNMPTRAPD_PRE_HANDLER
SEE ALSO
NetSNMP::OID, NetSNMP::ASN
snmptrapd.conf(5) for configuring the Net-SNMP trap receiver.
snmpd.conf(5) for configuring the Net-SNMP snmp agent for sending traps.
http://www.Net-SNMP.org/
AUTHOR
W. Hardaker, <hardaker@users.sourceforge.net>
COPYRIGHT AND LICENSE
Copyright 2004 by W. Hardaker
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
perl v5.16.3 2012-10-09 TrapReceiver(3)