Can I send the ouput of a log to a command as an argument to an alternative in syslog-ng?

According to the documents I can execute a program rather thus:

destination knotifier { program('/path/to/executable'; };

And also it will certainly send the log to the stdin of the executable. Yet what happens if the program I'm implementing would certainly require the input as an argument to an alternative? Exists a means to do that? Or do I need to write a wrapper for the program I'm implementing?

2019-05-04 08:10:57
Source Share
Answers: 2

If I recognize you appropriately and also if this gets on Linux, you might attempt making use of


as the argument. This need to be a symlink to the typical input of the procedure. Equivalently, on some systems, you can make use of


which is usually simply a symlink to /proc/self/fd/0. I do not have a system with syslog-ng to examine this on, yet I assume something like the adhering to need to function :

destination knotifier { program('/path/to/executable -i /proc/self/fd/0'); };

where -i would certainly be alternatived to whatever command line switch over the executable demands if any kind of. I've additionally seen/ dev/fd/0 made use of, yet I often tend to stick to making use of/ proc straight. For even more details see man proc.

2019-05-07 23:25:17

For the majority of commands a wrapper will certainly need to be created due to the fact that Syslog-ng will just execute the command when it begins. This suggests that the command needs to properly be a daemon itself constantly approving input from stdin.

That's straightforward though ...


while read line
    /execute/my/app $line

however this manuscript does not benefit me, possibly due to the fact that it does not recognize which present to make use of. Yet if your manuscript does not require an X web server after that a straightforward layout similar to this need to function you.

Although this is no other way handy as a result of the reality that Syslog-ng will just start the program on start-up I located the reality that xargs can create positional debates from typical input intriguing.

echo 'test' | /usr/bin/xargs -I '{}' /usr/bin/kdialog --passivepopup '{}' 2
2019-05-07 22:05:08