Hello!
I'm trying to use omprog to send the template parsed log to a script.
Unfortunately it doesn't seem to evaluate any parameter given.

I've tested my template with omfile and from input:
logger -p mail.info -t "postfix/smtp[150]" "337392BED58:
to=<name@email.extension>, relay=someaddress:25, delay=1.1,
delays=0.1/0.02/0.43/0.52, dsn=2.0.0, status=sent (250 2.0.0 OK  1567163956
2si4574209wmn.22)"
this is the output:
337392BED58 name@email.extension 1567171349 sent

When I use the following:
if ($programname == "postfix/smtp") then {
        action(type="omprog"
                binary="/usr/local/scripts/py/test.py"
                template="POSTFIX_FormatTo"
               output="/var/log/postfix/test/treated.log"
        )
}
test.py:
#! /usr/bin/python3
import sys # so we can use arguments
arguments = len(sys.argv) - 1
print ("the script is called with %i arguments" % (arguments))

The output of /var/log/postfix/test/treated.log is:
the script is called with 0 arguments (and no parameter is passed, although
it should have the stream 337392BED58 name@email.extension 1567171349 sent)

if I set test.py as:
#! /usr/bin/python3
import sys # so we can use arguments
arguments = len(sys.argv) - 1
print ("the script is called with %i arguments" % (arguments))
print(sys.argv[1])
And the following call on rsyslog:
if ($programname == "postfix/smtp") then {
        action(type="omprog"
                binary="/usr/local/scripts/py/test.py param1"
                template="POSTFIX_FormatTo"
               output="/var/log/postfix/test/treated.log"
        )
}
The output is:
the script is called with 1 arguments
param1

How can I get the value of param1, which should be 337392BED58?

Thank you,
Eudald

PD: I'm with 8.1908 rsyslog built.
_______________________________________________
rsyslog mailing list
http://lists.adiscon.net/mailman/listinfo/rsyslog
http://www.rsyslog.com/professional-services/
What's up with rsyslog? Follow https://twitter.com/rgerhards
NOTE WELL: This is a PUBLIC mailing list, posts are ARCHIVED by a myriad of 
sites beyond our control. PLEASE UNSUBSCRIBE and DO NOT POST if you DON'T LIKE 
THAT.

Reply via email to