On Sun, 20 Feb 2005 22:36:48 +0100 Denis wrote:
DG> > > To have the snmpd daemon send a trap as soon as
DG> > > messages containing a certain string are written
DG> > > to logfiles.
DG> > > Strings like "error" or "warning" and so on.
DG> > 
DG> > Ah. nope, we don't have anything like that. Shouldn't be too 
DG> > hard to add, though. Patches welcomed. :-)
DG> 
DG> If you were going to attempt it, how would you
DG> go about it? Through perl extensions?

I'm not a perl guru, so I'd stick to C. Start by writing a simple C program to
do the job. 

        open file
        while(!EOF)
                read chunk
                search for strings
                if found, print message

if you use simple IPC, that loop could be a thread running all the time,
blocking when it got to the end of the file, and waiting til more data was
available. when a hit is found, send a message to snmpd to send the trap.

otherwise,  you'd have to set it up as an alarm in snmpd to run periodically.

if you don't want to keep the file open, you could store the offset of the last
read to save having to parse the whole file every time.

make sure to handle the case where the log rotates...

-- 
Robert Story; NET-SNMP Junkie
Support: <http://www.net-snmp.org/> <irc://irc.freenode.net/#net-snmp>  
Archive: <http://sourceforge.net/mailarchive/forum.php?forum=net-snmp-users>

You are lost in a twisty maze of little standards, all different. 


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
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

Reply via email to