0

I'm trying to write a script that will grab logs across a network and parse them for relevant information and perform some action (email if there's a critical issue, simply write to a log file if its a warning). I am using an AIX machine with syslogd to process the logs. Right now it is performing like usual, writing all logs to files ... a lot of files.

I was advised to use Perl and Named Pipes to implement the script. I've just spent some time reading up on named pipes and I find them quite fascinating. However, I'm stumped as to how the "flow" of information should work in this situation and how to make perl handle it.

For example, should I create a fifo outside of the script and tell syslogd to write to it by default and have my script on the other end parsing it? Can Perl do that and (for you sysadmins) is this a smart/possible option?

This is my first encounter with Perl and with named pipes.

2
  • My log management project Octopussy does that and much more. It's a full Perl project so you can take a look at the code and/or use it.
    – sebthebert
    Jul 25, 2011 at 22:21
  • Very cool idea @sebthebert. I might attempt creating my own log manager. I'll definitely be going over your code.
    – user623990
    Jul 25, 2011 at 22:48

1 Answer 1

1

You can surely create a named pipe in Perl, although it seems to me that for what you are trying to do, it is better to create the named pipe outside of perl, as you are suggesting, and then have syslogd write to it, and read the pipe from perl.

I don't know very well AIX, but this could do for creating a pipe (source):

mkfifo -p /var/adm/syslog.pipe

To have syslogd write to it, define this in /var/adm/syslog.pipe:

   *.info                        |/var/adm/syslog.pipe 

Then:

kill -HUP `cat /var/run/syslogd.pid`

You could also put all this stuff into your perl script: in case the pipe did not exist or syslogd were not using it, the script would arrange all required things for you.

Possibly you could provide some more details as to what you are trying to do, if you need more help.

1
  • I found the article which the code snippets you posted are from (softpanorama.org/Logs/Syslog/pipes_in_syslog.shtml) and it seems that I need to make a custom syslog configuration file. I'll look into that, thanks.
    – user623990
    Jul 25, 2011 at 16:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy