On Fri, 24 Feb 2006, Robert Story wrote:
>
> On Fri, 24 Feb 2006 10:29:31 +0100 (CET) Peder wrote:
> PCN> If you work on a system with "netlink" support (a linux system, for
> PCN> instance) and don't shrink from a bit of C coding you can make a solution
> PCN> that gives the alarms immediately, and costs absolutely nothing on
> PCN> run-time. The trick is to open a netlink socket and subscribe to link
> PCN> change messages. Then generate the alarms using the net-snmp C API
> PCN> interface. There is an example in one of the tutorials, and it works, I
> PCN> have tried it. 100-200 lines of code.
>
> Do you have an example of the netlink watching code?
The "quagga" package uses netlink much the way I suggest (actually I
looked more in the "quagga" code than in the documentation when I wrote my
own piece). Look in the file zebra/rt_netlink.c. The function
netlink_link_change is the place where you recognize the ifUp/ifDown
events - but of course you also need the surrounding infrastructure - the
opening and configuration of the socket, the ordering of this specific
brand of events, the adding of the FD for the socket to the central select
loop etc etc.
I did not find netlink easy to work with - the documentation is sloppy and
complex, and the design is not impressive. It took me something like two
full weeks, with a lot of cheating = looking in kernel source, to get the
hang of it - but when you know how to work it, it works like a charm.
And for performance it really beats using /proc for almost everything.
best regards
Peder Chr. Nørgaard Senior System Developer, M. Sc.
Ericsson Denmark A/S, Telebit Division
Skanderborgvej 232 tel: +45 30 91 84 31
DK-8260 Viby J, Denmark fax: +45 89 38 51 01
e-mail: [EMAIL PROTECTED]
(old e-mail 2000-2003: [EMAIL PROTECTED])
(old e-mail 1992-2000: [EMAIL PROTECTED])
----------------------------------------------------------------
This communication is confidential and intended solely for the
addressee(s). Any unauthorized review, use, disclosure or distribution
is prohibited. If you believe this message has been sent to you in
error, please notify the sender by replying to this transmission and
delete the message without disclosing it. Thank you.
E-mail including attachments is susceptible to data corruption,
interruption, unauthorized amendment, tampering and viruses, and we
only send and receive e-mails on the basis that we are not liable for
any such corruption, interception, amendment, tampering or viruses or
any consequences thereof.
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid0944&bid$1720&dat1642
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders