AIX

AIX

Connect with fellow AIX users and experts to gain knowledge, share insights, and solve problems.

 View Only
Expand all | Collapse all

AIX5.3: could the syslog on AIX support named pipe as "destination"?

  • 1.  AIX5.3: could the syslog on AIX support named pipe as "destination"?

    Posted Mon May 14, 2007 11:05 PM

    Originally posted by: SystemAdmin


    HI All,

    I ran into a problem when I tried to using a named pipe as the AIX syslog "destination", if someone could give me some answer or hint, it will be appreciated.

    First, I am not sure whether syslog on AIX can support named pipe, I did not see the named pipe support in the syslog manpage. I tried to add the line "*.debug |/full/path/of/named/pipe" in /etc/syslog.conf and restarted the syslogd, but it seems that it does not work. Does someone know whether syslog on AIX can support named pipe?

    If the syslog on AIX can support named pipe, how should we configure it?

    I know that the syslog-ng can be installed and running on AIX, the syslog-ng can support the named pipe, but the syslog-ng is not what we want, unless we can find it on the "AIX Toolbox for Linux Applications" website: http://www-03.ibm.com/servers/aix/products/aixos/linux/download.html

    Thanks.


  • 2.  Re: AIX5.3: could the syslog on AIX support named pipe as "destination"?

    Posted Wed May 16, 2007 07:44 AM

    Originally posted by: SystemAdmin


    Hello,

    it is possible to make aix syslogd write to a named pipe. just create the fifo and configure it just as you would configure a normal logfile.

    code
    1. mknod /var/adm/log/logpipe p
    ls -l /var/adm/log/logpipe
    prw-r--r-- 1 root system 0 May 16 13:29 /var/adm/log/logpipe
    1. grep -v ^# /etc/syslog.conf
    *.info /var/adm/log/logpipe
    1. startsrc -s syslogd
    0513-059 The syslogd Subsystem has been started. Subsystem PID is 417850.
    1. cat /var/adm/log/logpipe &
    [1] 434302
    1. May 16 13:30:36 localhost syslogd: restart
    2. logger -p daemon.crit another test
    May 16 13:31:55 localhost testuser: another test
    [/code]

    Anyway, syslog-ng is easy to build on aix and gives you more flexibility.

    Regards,
    Joachim Gann


  • 3.  Re: AIX5.3: could the syslog on AIX support named pipe as "destination"?

    Posted Wed May 16, 2007 07:58 AM

    Originally posted by: SystemAdmin


    thanks for the response.

    We already tried what you mentioned, the first several messages can be redirected to the fifo(we can use tail to see this), but when we tried to use "open" to open the pipe, it will fail. We think the reason is that the syslog actually treat the fifo as a regular file, because we did not add any special flag to let the syslog know that it is a fifo, the syslog will open the fifo as "append" mode, so the other process can not open the fifo anymore...
    Please correct me if I am wrong.
    Here are the steps I am using:
    mknod /tmp/syslog_fifo p
    add "*.info /tmp/syslog_fifo"
    refresh -s syslogd
    logger -p crit "this is a test"

    run the script readfifo I wrote:
    #!/usr/bin/perl

    while (1)
    {
    my $fifo = "/tmp/syslog_fifo";
    local $SIG{ALRM} = sub { die "alarm\n" };
    eval {
    alarm 4;
    open(PIPE, $fifo) or die
    alarm 0;
    };
    if ($@ =~ /alarm/) { close PIPE; print "open pipe failed\n"; exit 0; }

    while (1)
    {
    my $line;
    eval {
    alarm 2;
    $line = <PIPE>;
    alarm 0;
    };
    if ($@ =~ /alarm/) { close PIPE; last; }
    chomp($line);
    if ($line eq "") {close PIPE; last;}

    print "String=\"$line\"\n";
    }
    close PIPE;
    }

    I will always get the error "open pipe failed".