ALERT [ This is a slightly rewritten repost from `gmane.[...].perl.beginners', where it got no responses] ------- --------- ---=--- --------- --------
My subject line is probably not really that good at describing what I want advice on but here it is: I've setup one linux (gentoo) box as a logserver running rsyslog and several other linux boxes sending syslog info to it. I want to set the server rsyslog.conf so that in addition to normal logging to /var/log/whateverlogs it also writes everything to a named pipe (fifo). Then tap into the fifo with a perl script that is written to be able to sort and write the syslog output according to various regex that may be part of startup cmd or fed in later during the running script. I think I can manage the sorting/writing and maybe reading regex into the running process. (Just by an awkward funky method of having the script reread a file on disk every 5 minutes, and put what ever regex become necessary there). There are probably cleaner better ways... and I may be back asking about that but right now, where I have no real idea is how to attach the perl script to a service like the system logger. I mean so the script starts and stops with system logger and somehow alerts the system logger (and sysadmin) if it (the script) for some reason is killed or dies on its own while the system logger is still running. I imagine getting the perl script to start/stop with the logger daemon on boot up would be simple enough by inserting something into the init script that starts the logger. >From there I'm just drawing blanks as to how a script would know if the system logger stopped, and further some kind of `trap' that would send out info to be logged by the logger and to the system admin if the script itself died or was killed. I'm slightly familiar with shell script traps but haven't encountered or had need of such in a perl script. But really I suspect I'm going at this wrong right from the start and there is a better plan to be had. I'm hoping someone with that kind of experience can outline how this might be done. I can handle most of the perl scripting but not sure about coding a `trap' style function.. That I can get from the perl.beginners group. so here I'm looking for an overview of how to go at this. I'm thinking an experienced sysadmin here will have at the top of there head.. the basic outline of how something like this might be done. So to summarize I want to: Attach a perl script to a service daemon (rsyslog) so it starts/stops with the daemon, and has some code that will put something into syslog output and notify the admin in the event the script itself is terminated unexpectedly. Something along the line of a bash/ksh exit `trap' It would also need to check when being started, that the system logger is running else fail and send notice to admin.