RE:SNMP Trap Handling
"Sudhakaran, Sonu (STSD)" <[email protected]>
| Newsgroups | gmane.network.net-snmp.user |
|---|---|
| Message-ID | <F772215654420342B3D8155D0E6D67642553EC6814@GVW1103EXC.americas.hpqcorp.net> |
Hi
We can declare Asynchronous callback routine to be called while we create netsnmp session. Check the code given below.
static netsnmp_session *
snmptrapd_add_session(netsnmp_transport *t)
{
netsnmp_session sess, *session = &sess, *rc = NULL;
snmp_sess_init(session);
session->peername = SNMP_DEFAULT_PEERNAME; /* Original code had NULL here */
session->version = SNMP_DEFAULT_VERSION;
session->community_len = SNMP_DEFAULT_COMMUNITY_LEN;
session->retries = SNMP_DEFAULT_RETRIES;
session->timeout = SNMP_DEFAULT_TIMEOUT;
session->callback = snmp_trapd_input; <------ This is the trap handler which gets called.
session->callback_magic = (void *) t;
session->authenticator = NULL;
sess.isAuthoritative = SNMP_SESS_UNKNOWNAUTH;
rc = snmp_add(session, t, pre_parse, NULL);
}
Once you call this function, use the session returned to do all your trap administration. For more info, please have a look at - snmptrapd_handlers.c file under libnetsnmptrapd project files.
Cheers,
Sonu
-----Original Message-----
From: [email protected] [mailto:[email protected]]
Sent: Monday, January 19, 2009 2:35 PM
To: [email protected]
Subject: Net-snmp-users Digest, Vol 32, Issue 32
Send Net-snmp-users mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
https://lists.sourceforge.net/lists/listinfo/net-snmp-users
or, via email, send a message with subject or body 'help' to
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Net-snmp-users digest..."
Today's Topics:
1. SNMP trap handling (jayesh km)
2. Re: SNMP trap handling (Dave Shield)
3. Re: Table custom handlers (Nikos Balkanas)
4. AW: net-snmp 5.4.1 writing to deprecated OIDs (Mohr James)
5. snmpwalk not working (Shikhar Sachan)
6. Re: snmpwalk not working (Dave Shield)
7. could you please help me on this (ram k)
----------------------------------------------------------------------
Message: 1
Date: Thu, 15 Jan 2009 15:03:33 +0530 (IST)
From: jayesh km <[email protected]>
Subject: SNMP trap handling
To: net-snmp <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset="utf-8"
Hi,
I was writing a program to convert SNMP traps to some proprietary trap format.
My requirement is to parse the SNMP trap PDU and get the trap and all variables associated with the trap and store it in a structure and pass it to some routine that will generate proprietary traps.
I looked into snmaptrapd.c file and could not make much from it. I don't know where exactly the trap PDU is parsed and how the OID in trap is matched to varibale name in MIB file. Can some one please point me how can I get sarted with this? How to get an application call back when a trap is received and how to match OID to actual name and extract variables from trap PDU
Thanks in advance,
Jayesh KM
Unlimited freedom, unlimited storage. Get it now, on http://help.yahoo.com/l/in/yahoo/mail/yahoomail/tools/tools-08.html/
-------------- next part --------------
An HTML attachment was scrubbed...
------------------------------
Message: 2
Date: Thu, 15 Jan 2009 09:44:28 +0000
From: "Dave Shield" <[email protected]>
Subject: Re: SNMP trap handling
To: "jayesh km" <[email protected]>
Cc: net-snmp <[email protected]>
Message-ID:
<[email protected]>
Content-Type: text/plain; charset=ISO-8859-1
2009/1/15 jayesh km <[email protected]>:
> Can some one please point me how can I get
> sarted with this? How to get an application call back when a trap is
> received and how to match OID to actual name and extract variables from trap
> PDU
The simplest approach is probably to start with snmptrapd,
and then write your own trap handler, using something like
'print_handler' (in snmptrapd_handlers.c) as a template.
Then tweak the main routine (in snmptrapd.c) to add a call
to 'netsnmp_add_global_traphandler', specifying your new
handler. That will then invoke your code whenever a
trap is received, passing it the decoded trap PDU.
Dave
------------------------------
Message: 3
Date: Fri, 16 Jan 2009 01:44:48 +0200
From: "Nikos Balkanas" <[email protected]>
Subject: Re: Table custom handlers
To: "Dave Shield" <[email protected]>
Cc: [email protected]
Message-ID: <002401c9776b$412e5010$02b2a8c0@tardis>
Content-Type: text/plain; format=flowed; charset="windows-1253";
reply-type=original
Thanx for the tip.
Changed code to point to *table_info->indexes->val.integer
BR,
Nikos
----- Original Message -----
From: "Dave Shield" <[email protected]>
To: "Nikos Balkanas" <[email protected]>
Cc: <[email protected]>
Sent: Thursday, January 15, 2009 10:25 AM
Subject: Re: Table custom handlers
> 2009/1/14 Nikos Balkanas <[email protected]>:
>> That's great. I tried it and looks fine:
>>
>> Changed column = table_info->colnum
>> Changed row = *table_info->index_oid
>
> 'index_oid' would work as well.
> And for an integer-indexes table, it probably doesn't make
> much difference, since it's just a single integer value anyway.
>
> But in general - particularly for string- or multiple-indexed tables,
> you're better off using the 'table_info->indexes' field, where the
> index values have already been extracted for you.
>
> Dave
------------------------------
Message: 4
Date: Fri, 16 Jan 2009 13:54:32 +0100
From: "Mohr James" <[email protected]>
Subject: AW: net-snmp 5.4.1 writing to deprecated OIDs
To: <[email protected]>
Message-ID:
<[email protected]>
Content-Type: text/plain; charset="utf-8"
Thank you VERY much for that answer. I definitely learned a lot and getting it from you is about the same as reading the source code myself. ;-
A few comments below.
Regards,
Jim Mohr
> -----Urspr?ngliche Nachricht-----
> Von: [email protected]
> [mailto:[email protected]] Im Auftrag von Dave Shield
> Gesendet: Mittwoch, 14. Januar 2009 15:38
> An: Mohr James
> Cc: [email protected]
> Betreff: Re: net-snmp 5.4.1 writing to deprecated OIDs
<SNIP>
> >From a purist point of view, these objects were fundamentally broken,
> and should have be removed. But pragmatically, individual
> administrators were using them to solve real-world problems,
> and probably didn't care about the technical deficiencies.
> But they *would* care (and complain) if these objects
> disappeared and all of their scripts broke. It was easier
> for us, and better for the Net-SNMP community, to leave these
> objects working.
But working implies that "something" is being written to the OID. This definitely seems to be what is happening with 5.4.1.
> Some time later, the code to supply the raw data was
> significantly re-written, and it became straightforward to
> provide a consistent
> implementation of the average objects. At that point, the
> MIB definitions
> were clarified and updated, to agree on an explicit fixed
> time period (60s) for calculating the averages.
Although deprecated, can we say the values in the OID are more or less accurate? (or at least as accurate as this mechanism allows?) The reason I am asking is that we are using SolarWinds to monitor and report on these values, and my boss does not want to give it up. Can we continue to use the OID as a reasonable measure of CPU usage? ("should" is a different story)
> > Another machine has net-snmp 5.2.1. I create the same CPU
> activity and
> > snmpget does not indicate any change.
>
> What you are probably seeing is the difference between a
> 1-minute average (which will change noticeably over a short
> period of monitoring) and a lifetime average (which won't).
Aha! Makes sense!
> > So it is even more confusing
>
> Indeed - see the comments above about inconsistent implementations.
It is definitely reassuring to have you confirm it is confusing. ;-)
> > and seems as if this functionality has been re-added.
>
> It's not that it has been removed and re-added.
> Rather that it has recently been implemented consistently,
> using a sensible time period. (A lifetime average was of no
> practical use to the administrator!)
Can you tell me when it changed from the lifetime average to a 1-minute average? We have 5.2.1 on some machines and it seems that this is the lifetime average.
> I hope this serves to explain the history behind these objects.
Definitely!!!!
--
Diese E-Mail enth?lt vertrauliche und/oder rechtlich gesch?tzte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrt?mlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail ist nicht gestattet.
This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden.
------------------------------
Message: 5
Date: Mon, 19 Jan 2009 03:38:16 +0530
From: "Shikhar Sachan" <[email protected]>
Subject: snmpwalk not working
To: [email protected]
Message-ID:
<[email protected]>
Content-Type: text/plain; charset=ISO-8859-1
A small query by a new user.
When I use -c public localhost, then the list of MIB is retrieved
However when I query
-c public <my IP> , then no result and time out occurs.
whats the problem when I query using IP and lot loopback using
localhost/127.0.0.1
Thanks
Shikhar Sachan
------------------------------
Message: 6
Date: Mon, 19 Jan 2009 08:34:25 +0000
From: Dave Shield <[email protected]>
Subject: Re: snmpwalk not working
To: Shikhar Sachan <[email protected]>
Cc: [email protected]
Message-ID:
<[email protected]>
Content-Type: text/plain; charset=ISO-8859-1
2009/1/18 Shikhar Sachan <[email protected]>:
> A small query by a new user.
> When I use -c public localhost, then the list of MIB is retrieved
> However when I query
> -c public <my IP> , then no result and time out occurs.
> whats the problem when I query using IP and lot loopback using
> localhost/127.0.0.1
Either the agent is only listening on the loopback interface
or (more likely) you have a firewall configuration that doesn't
allow network access to port 161.
Check your firewall settings.
Dave
------------------------------
Message: 7
Date: Fri, 16 Jan 2009 12:37:05 -0500
From: "ram k" <[email protected]>
Subject: could you please help me on this
To: [email protected]
Message-ID:
<[email protected]>
Content-Type: text/plain; charset="iso-8859-1"
root@ABCX libexec]#
these issues are because First i don't know any thing about SNMP and Net:
SNMP(both from cpan.org),i thought these are part of Net-SNMP(Net-SNMP.org)
package, i didn't even realised at the time of Net: SNMP(cpan.org)
installation,i installed Net: SNMP from cpan.org,this is a Object oriented
interface to SNMP(Net-SNMP.org) and installed SNMP(cpan.org) this is Perl5
'SNMP' Extension Module for the Net-SNMP Library .
at the same time Net-SNMP(Net-SNMP.org) has its own perl module for
Net-SNMP(Net-SNMP.org) we can install it from package net-snmp-perl (yum
install net-snmp-perl)?this is my assumption please some one has correct if
any thing is worng in my asumption?
here is my file structure
[root@ABCX perl5]# pwd
/usr/lib/perl5
[root@ABCX perl5]# ll
total 48
drwxr-xr-x 3 root root 4096 Oct 23 09:41 5.8.5
drwxr-xr-x 3 root root 4096 Oct 23 09:41 5.8.6
drwxr-xr-x 3 root root 4096 Oct 23 09:41 5.8.7
drwxr-xr-x 43 root root 4096 Oct 23 09:41 5.8.8
drwxr-xr-x 6 root root 4096 Oct 23 09:41 site_perl
drwxr-xr-x 6 root root 4096 Oct 23 09:41 vendor_perl
[root@ABCX perl5]# cd site_perl/
[root@ABCX site_perl]# ll
total 32
drwxr-xr-x 3 root root 4096 Oct 23 09:41 5.8.5
drwxr-xr-x 3 root root 4096 Oct 23 09:41 5.8.6
drwxr-xr-x 3 root root 4096 Oct 23 09:41 5.8.7
drwxr-xr-x 5 root root 4096 Jan 15 11:55 5.8.8
[root@ABCX
site_perl]# cd 5.8.8
[root@ABCX 5.8.8]# ll
total 16
drwxr-xr-x 2 root root 4096 Jan 15 11:52 Digest
drwxr-xr-x 7 root root 4096 Jan 16 10:05 i386-linux-thread-multi
drwxr-xr-x 3 root root 4096 Jan 15 11:55 Net
[root@ABCX 5.8.8]# cd Net/
[root@ABCX Net]#pwd
/usr/lib/perl5/site_perl/5.8.8/Net
[root@ABCX Net]# ll
total 120
drwxr-xr-x 4 2649 daemon 4096 Oct 20 2005 SNMP
-rw-r--r-- 1 2649 daemon 112950 Oct 20 2005 SNMP.pm
If i go to i386-linux-thread-multi
[root@ABCX Net]# cd ..
[root@ABCX 5.8.8]# cd i386-linux-thread-multi/
[root@ABCX i386-linux-thread-multi]# ll
total 100
drwxr-xr-x 7 root root 4096 Jan 16 10:05 auto
drwxr-xr-x 2 root root 4096 Jan 15 11:39 Crypt
drwxr-xr-x 2 root root 4096 Jan 15 11:50 Digest
drwxr-xr-x 3 root root 4096 Jan 15 15:47 Net
drwxr-xr-x 2 root root 4096 Jan 15 18:38 NetSNMP
-r--r--r-- 1 root root 70398 Aug 9 2006 SNMP.pm
[root@ABCX i386-linux-thread-multi]# cd Net
[root@ABCX Net]# pwd
/usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/Net
[root@ABCX Net]# ll
total 120
drwxr-xr-x 4 root root 4096 Jan 15 15:47 SNMP
-r--r--r-- 1 root root 112950 Jan 15 15:47 SNMP.pm
can see Different versions of SNMP,SNMP.pm in
/usr/lib/perl5/site_perl/5.8.8/Net
and /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/Net
If i go to /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/NetSNMP
[root@ABCX NetSNMP]#
pwd
/usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/NetSNMP
[root@ABCX NetSNMP]# ll
total 12
-r--r--r-- 1 root root 9295 Jul 13 2006 default_store.pm
*If i goto /usr/lib/perl5/vendor_perl/5.8.8*
[root@ABCX 5.8.8]# pwd
/usr/lib/perl5/vendor_perl/5.8.8
[root@ABCX 5.8.8]# ll
total 76
drwxr-xr-x 2 root root 4096 Jan 15 11:23 Digest
drwxr-xr-x 2 root root 4096 Oct 23 09:46 Foomatic
drwxr-xr-x 16 root root 4096 Jan 15 19:03 i386-linux-thread-multi
drwxr-xr-x 3 root root 4096 Jan 15 12:08 Net
-r--r--r-- 1 root root 5045 May 2 2007 RRDp.pm
drwxr-xr-x 4 root root 4096 Oct 23 09:41 URI
-rw-r--r-- 1 root root 30307 Nov 5 2004 URI.pm
[root@ABCX
5.8.8]# cd Net/
[root@ABCX Net]#ll
total 120
drwxr-xr-x 4 root root 4096 Jan 15 12:08 SNMP
-r--r--r-- 1 root root 112950 Oct 20 2005 SNMP.pm
my questions are what is the difference between site_perl and vendor_perl ?
which SNMP,SNMP.pm i need to keep ?is ther any other places i need to keep
copy of these(SNMP,SNMP.pm) ?
-------------- next part --------------
An HTML attachment was scrubbed...
------------------------------
------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
------------------------------
_______________________________________________
Net-snmp-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-users
End of Net-snmp-users Digest, Vol 32, Issue 32
**********************************************
------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Net-snmp-users mailing list
[email protected]
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users