Mailing List Archive

Omprog parameter evaluation issue
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.
Omprog parameter evaluation issue [ In reply to ]
Hello!
Sent it before but I'm not sure if it's been posted :/

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.
Re: Omprog parameter evaluation issue [ In reply to ]
The executable specified in omprog does not receive the message on the
command line as arguments.  It must read stdin (repeatedly) and receives
one message from rsyslog per read.

See https://www.rsyslog.com/doc/v8-stable/configuration/modules/omprog.html

Regards,


On 8/30/19 5:22 PM, Eudald Valcàrcel via rsyslog wrote:
> Hello!
> Sent it before but I'm not sure if it's been posted :/
>
> 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.


_______________________________________________
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.
Re: Omprog parameter evaluation issue [ In reply to ]
John, I'm trying to understand that but I don't.
I create a log:
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)"
Which goes through my template and becomes:
337392BED58 name@email.extension 1567171349 sent
Shouldn't the above line be the stdin of my omprog execution?

Thanks,
Eudald

El sáb., 31 ago. 2019 a las 0:36, John Chivian via rsyslog (<
rsyslog@lists.adiscon.com>) escribió:

> The executable specified in omprog does not receive the message on the
> command line as arguments. It must read stdin (repeatedly) and receives
> one message from rsyslog per read.
>
> See
> https://www.rsyslog.com/doc/v8-stable/configuration/modules/omprog.html
>
> Regards,
>
>
> On 8/30/19 5:22 PM, Eudald Valcàrcel via rsyslog wrote:
> > Hello!
> > Sent it before but I'm not sure if it's been posted :/
> >
> > 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.
>
>
> _______________________________________________
> 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.
_______________________________________________
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.
Re: Omprog parameter evaluation issue [ In reply to ]
Yes, each line of output from the template is passed as a line of input
to stdin of the program.

The program should read a line, process it as desired, and repeat until
it receives an EOF from rsyslog. The program must exit on EOF.

It might help if you think of the rsyslog template ouput as a file that
the program is reading line by line until it reaches the end.

If the program exits after processing just one line, then rsyslog will
have to restart it for every message, resulting in a fairly severe
performance hit.

Regards,



On 9/2/19 9:32 AM, Eudald Valcàrcel via rsyslog wrote:
> John, I'm trying to understand that but I don't.
> I create a log:
> 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)"
> Which goes through my template and becomes:
> 337392BED58 name@email.extension 1567171349 sent
> Shouldn't the above line be the stdin of my omprog execution?
>
> Thanks,
> Eudald
>
> El sáb., 31 ago. 2019 a las 0:36, John Chivian via rsyslog (<
> rsyslog@lists.adiscon.com>) escribió:
>
>> The executable specified in omprog does not receive the message on the
>> command line as arguments. It must read stdin (repeatedly) and receives
>> one message from rsyslog per read.
>>
>> See
>> https://www.rsyslog.com/doc/v8-stable/configuration/modules/omprog.html
>>
>> Regards,
>>
>>
>> On 8/30/19 5:22 PM, Eudald Valcàrcel via rsyslog wrote:
>>> Hello!
>>> Sent it before but I'm not sure if it's been posted :/
>>>
>>> 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.
>>
>>
>> _______________________________________________
>> 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.
> _______________________________________________
> 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.


_______________________________________________
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.
Re: Omprog parameter evaluation issue [ In reply to ]
Then, based on what you say, shouldn't my script read the line:
337392BED58 name@email.extension 1567171349 sent
?
I add again below the samples I'm using, but I believe my test.py should
receive the line parsed by the template ( 337392BED58 name@email.extension
1567171349 sent ) and this line should be received by my test.py as
arguments, but it doesn't happen and the result of len(sys.argv)-1 is 0
instead of 4.
++++++++++++++++++++
postfix.conf:
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)
+++++++++++++++++++
Sorry if I'm being a monolite

Eudald

El mar., 3 sept. 2019 a las 14:51, John Chivian via rsyslog (<
rsyslog@lists.adiscon.com>) escribió:

> Yes, each line of output from the template is passed as a line of input
> to stdin of the program.
>
> The program should read a line, process it as desired, and repeat until
> it receives an EOF from rsyslog. The program must exit on EOF.
>
> It might help if you think of the rsyslog template ouput as a file that
> the program is reading line by line until it reaches the end.
>
> If the program exits after processing just one line, then rsyslog will
> have to restart it for every message, resulting in a fairly severe
> performance hit.
>
> Regards,
>
>
>
> On 9/2/19 9:32 AM, Eudald Valcàrcel via rsyslog wrote:
> > John, I'm trying to understand that but I don't.
> > I create a log:
> > 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)"
> > Which goes through my template and becomes:
> > 337392BED58 name@email.extension 1567171349 sent
> > Shouldn't the above line be the stdin of my omprog execution?
> >
> > Thanks,
> > Eudald
> >
> > El sáb., 31 ago. 2019 a las 0:36, John Chivian via rsyslog (<
> > rsyslog@lists.adiscon.com>) escribió:
> >
> >> The executable specified in omprog does not receive the message on the
> >> command line as arguments. It must read stdin (repeatedly) and receives
> >> one message from rsyslog per read.
> >>
> >> See
> >> https://www.rsyslog.com/doc/v8-stable/configuration/modules/omprog.html
> >>
> >> Regards,
> >>
> >>
> >> On 8/30/19 5:22 PM, Eudald Valcàrcel via rsyslog wrote:
> >>> Hello!
> >>> Sent it before but I'm not sure if it's been posted :/
> >>>
> >>> 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.
> >>
> >>
> >> _______________________________________________
> >> 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.
> > _______________________________________________
> > 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.
>
>
> _______________________________________________
> 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.
_______________________________________________
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.
Re: Omprog parameter evaluation issue [ In reply to ]
Your definition of "binary=" contains no command line arguments to
test.py.  Therefore your test.py, which reports the command line
arguments, correctly states that there are none.

Command line arguments are by definition passed on the command line,
they are *not* received on stdin.  The program referenced in the
"binary=" specification must read input from rsyslog on *stdin*, not
from the command line.  In Python that's something like...

line=sys.stdin.readline()

...where "line" will then contain the entire message from rsyslog.

Regards,


On 9/3/19 8:57 AM, Eudald Valcàrcel via rsyslog wrote:
> Then, based on what you say, shouldn't my script read the line:
> 337392BED58 name@email.extension 1567171349 sent
> ?
> I add again below the samples I'm using, but I believe my test.py should
> receive the line parsed by the template ( 337392BED58 name@email.extension
> 1567171349 sent ) and this line should be received by my test.py as
> arguments, but it doesn't happen and the result of len(sys.argv)-1 is 0
> instead of 4.
> ++++++++++++++++++++
> postfix.conf:
> 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)
> +++++++++++++++++++
> Sorry if I'm being a monolite
>
> Eudald
>
> El mar., 3 sept. 2019 a las 14:51, John Chivian via rsyslog (<
> rsyslog@lists.adiscon.com>) escribió:
>
>> Yes, each line of output from the template is passed as a line of input
>> to stdin of the program.
>>
>> The program should read a line, process it as desired, and repeat until
>> it receives an EOF from rsyslog. The program must exit on EOF.
>>
>> It might help if you think of the rsyslog template ouput as a file that
>> the program is reading line by line until it reaches the end.
>>
>> If the program exits after processing just one line, then rsyslog will
>> have to restart it for every message, resulting in a fairly severe
>> performance hit.
>>
>> Regards,
>>
>>
>>
>> On 9/2/19 9:32 AM, Eudald Valcàrcel via rsyslog wrote:
>>> John, I'm trying to understand that but I don't.
>>> I create a log:
>>> 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)"
>>> Which goes through my template and becomes:
>>> 337392BED58 name@email.extension 1567171349 sent
>>> Shouldn't the above line be the stdin of my omprog execution?
>>>
>>> Thanks,
>>> Eudald
>>>
>>> El sáb., 31 ago. 2019 a las 0:36, John Chivian via rsyslog (<
>>> rsyslog@lists.adiscon.com>) escribió:
>>>
>>>> The executable specified in omprog does not receive the message on the
>>>> command line as arguments. It must read stdin (repeatedly) and receives
>>>> one message from rsyslog per read.
>>>>
>>>> See
>>>> https://www.rsyslog.com/doc/v8-stable/configuration/modules/omprog.html
>>>>
>>>> Regards,
>>>>
>>>>
>>>> On 8/30/19 5:22 PM, Eudald Valcàrcel via rsyslog wrote:
>>>>> Hello!
>>>>> Sent it before but I'm not sure if it's been posted :/
>>>>>
>>>>> 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.
>>>>
>>>>
>>>> _______________________________________________
>>>> 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.
>>> _______________________________________________
>>> 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.
>>
>>
>> _______________________________________________
>> 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.
> _______________________________________________
> 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.


_______________________________________________
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.
Re: Omprog parameter evaluation issue [ In reply to ]
Alright, got it.
Sorry for messing with stdin and argument definitions.

Thank you very much John,
Eudald

El mar., 3 sept. 2019 a las 16:31, John Chivian via rsyslog (<
rsyslog@lists.adiscon.com>) escribió:

> Your definition of "binary=" contains no command line arguments to
> test.py. Therefore your test.py, which reports the command line
> arguments, correctly states that there are none.
>
> Command line arguments are by definition passed on the command line,
> they are *not* received on stdin. The program referenced in the
> "binary=" specification must read input from rsyslog on *stdin*, not
> from the command line. In Python that's something like...
>
> line=sys.stdin.readline()
>
> ...where "line" will then contain the entire message from rsyslog.
>
> Regards,
>
>
> On 9/3/19 8:57 AM, Eudald Valcàrcel via rsyslog wrote:
> > Then, based on what you say, shouldn't my script read the line:
> > 337392BED58 name@email.extension 1567171349 sent
> > ?
> > I add again below the samples I'm using, but I believe my test.py should
> > receive the line parsed by the template ( 337392BED58
> name@email.extension
> > 1567171349 sent ) and this line should be received by my test.py as
> > arguments, but it doesn't happen and the result of len(sys.argv)-1 is 0
> > instead of 4.
> > ++++++++++++++++++++
> > postfix.conf:
> > 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)
> > +++++++++++++++++++
> > Sorry if I'm being a monolite
> >
> > Eudald
> >
> > El mar., 3 sept. 2019 a las 14:51, John Chivian via rsyslog (<
> > rsyslog@lists.adiscon.com>) escribió:
> >
> >> Yes, each line of output from the template is passed as a line of input
> >> to stdin of the program.
> >>
> >> The program should read a line, process it as desired, and repeat until
> >> it receives an EOF from rsyslog. The program must exit on EOF.
> >>
> >> It might help if you think of the rsyslog template ouput as a file that
> >> the program is reading line by line until it reaches the end.
> >>
> >> If the program exits after processing just one line, then rsyslog will
> >> have to restart it for every message, resulting in a fairly severe
> >> performance hit.
> >>
> >> Regards,
> >>
> >>
> >>
> >> On 9/2/19 9:32 AM, Eudald Valcàrcel via rsyslog wrote:
> >>> John, I'm trying to understand that but I don't.
> >>> I create a log:
> >>> 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)"
> >>> Which goes through my template and becomes:
> >>> 337392BED58 name@email.extension 1567171349 sent
> >>> Shouldn't the above line be the stdin of my omprog execution?
> >>>
> >>> Thanks,
> >>> Eudald
> >>>
> >>> El sáb., 31 ago. 2019 a las 0:36, John Chivian via rsyslog (<
> >>> rsyslog@lists.adiscon.com>) escribió:
> >>>
> >>>> The executable specified in omprog does not receive the message on the
> >>>> command line as arguments. It must read stdin (repeatedly) and
> receives
> >>>> one message from rsyslog per read.
> >>>>
> >>>> See
> >>>>
> https://www.rsyslog.com/doc/v8-stable/configuration/modules/omprog.html
> >>>>
> >>>> Regards,
> >>>>
> >>>>
> >>>> On 8/30/19 5:22 PM, Eudald Valcàrcel via rsyslog wrote:
> >>>>> Hello!
> >>>>> Sent it before but I'm not sure if it's been posted :/
> >>>>>
> >>>>> 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.
> >>>>
> >>>>
> >>>> _______________________________________________
> >>>> 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.
> >>> _______________________________________________
> >>> 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.
> >>
> >>
> >> _______________________________________________
> >> 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.
> > _______________________________________________
> > 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.
>
>
> _______________________________________________
> 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.
_______________________________________________
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.
Re: Omprog parameter evaluation issue [ In reply to ]
probably too late for this discussion, but may be helpful for others
searching for the same problem:

https://www.slideshare.net/rainergerhards1/external-plugins

Rainer

El mar., 3 sept. 2019 a las 23:49, Eudald Valcàrcel via rsyslog
(<rsyslog@lists.adiscon.com>) escribió:
>
> Alright, got it.
> Sorry for messing with stdin and argument definitions.
>
> Thank you very much John,
> Eudald
>
> El mar., 3 sept. 2019 a las 16:31, John Chivian via rsyslog (<
> rsyslog@lists.adiscon.com>) escribió:
>
> > Your definition of "binary=" contains no command line arguments to
> > test.py. Therefore your test.py, which reports the command line
> > arguments, correctly states that there are none.
> >
> > Command line arguments are by definition passed on the command line,
> > they are *not* received on stdin. The program referenced in the
> > "binary=" specification must read input from rsyslog on *stdin*, not
> > from the command line. In Python that's something like...
> >
> > line=sys.stdin.readline()
> >
> > ...where "line" will then contain the entire message from rsyslog.
> >
> > Regards,
> >
> >
> > On 9/3/19 8:57 AM, Eudald Valcàrcel via rsyslog wrote:
> > > Then, based on what you say, shouldn't my script read the line:
> > > 337392BED58 name@email.extension 1567171349 sent
> > > ?
> > > I add again below the samples I'm using, but I believe my test.py should
> > > receive the line parsed by the template ( 337392BED58
> > name@email.extension
> > > 1567171349 sent ) and this line should be received by my test.py as
> > > arguments, but it doesn't happen and the result of len(sys.argv)-1 is 0
> > > instead of 4.
> > > ++++++++++++++++++++
> > > postfix.conf:
> > > 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)
> > > +++++++++++++++++++
> > > Sorry if I'm being a monolite
> > >
> > > Eudald
> > >
> > > El mar., 3 sept. 2019 a las 14:51, John Chivian via rsyslog (<
> > > rsyslog@lists.adiscon.com>) escribió:
> > >
> > >> Yes, each line of output from the template is passed as a line of input
> > >> to stdin of the program.
> > >>
> > >> The program should read a line, process it as desired, and repeat until
> > >> it receives an EOF from rsyslog. The program must exit on EOF.
> > >>
> > >> It might help if you think of the rsyslog template ouput as a file that
> > >> the program is reading line by line until it reaches the end.
> > >>
> > >> If the program exits after processing just one line, then rsyslog will
> > >> have to restart it for every message, resulting in a fairly severe
> > >> performance hit.
> > >>
> > >> Regards,
> > >>
> > >>
> > >>
> > >> On 9/2/19 9:32 AM, Eudald Valcàrcel via rsyslog wrote:
> > >>> John, I'm trying to understand that but I don't.
> > >>> I create a log:
> > >>> 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)"
> > >>> Which goes through my template and becomes:
> > >>> 337392BED58 name@email.extension 1567171349 sent
> > >>> Shouldn't the above line be the stdin of my omprog execution?
> > >>>
> > >>> Thanks,
> > >>> Eudald
> > >>>
> > >>> El sáb., 31 ago. 2019 a las 0:36, John Chivian via rsyslog (<
> > >>> rsyslog@lists.adiscon.com>) escribió:
> > >>>
> > >>>> The executable specified in omprog does not receive the message on the
> > >>>> command line as arguments. It must read stdin (repeatedly) and
> > receives
> > >>>> one message from rsyslog per read.
> > >>>>
> > >>>> See
> > >>>>
> > https://www.rsyslog.com/doc/v8-stable/configuration/modules/omprog.html
> > >>>>
> > >>>> Regards,
> > >>>>
> > >>>>
> > >>>> On 8/30/19 5:22 PM, Eudald Valcàrcel via rsyslog wrote:
> > >>>>> Hello!
> > >>>>> Sent it before but I'm not sure if it's been posted :/
> > >>>>>
> > >>>>> 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.
> > >>>>
> > >>>>
> > >>>> _______________________________________________
> > >>>> 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.
> > >>> _______________________________________________
> > >>> 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.
> > >>
> > >>
> > >> _______________________________________________
> > >> 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.
> > > _______________________________________________
> > > 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.
> >
> >
> > _______________________________________________
> > 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.
> _______________________________________________
> 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.
_______________________________________________
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.