<div dir="ltr">Hello,<div><br></div><div>I think you are looking for *grouping-by*, that can group together multiple messages.</div><div>You could use *kv-parse* to parse the exit child, pid=1234 and use *pid* as key to group the messages.</div><div><br><div><br></div><div>--</div><div>Kokan</div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Apr 26, 2019 at 5:25 PM Thomas Schmiedl <<a href="mailto:thomas.schmiedl@web.de">thomas.schmiedl@web.de</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hallo,<br>
<br>
for a first test, I wrote this small conf, which matches the first<br>
stream in <a href="https://github.com/clark15b/xupnpd2/blob/master/media/example.m3u" rel="noreferrer" target="_blank">https://github.com/clark15b/xupnpd2/blob/master/media/example.m3u</a>.<br>
<br>
@version: 3.20<br>
<br>
source s0 { udp(ip(0.0.0.0) port(514)); };<br>
<br>
destination d0 { file("/home/user/syslog-ng-intel/test"); };<br>
<br>
log { source(s0); filter { message(".*\[(.*)\].*strk\.stream.*"<br>
flags("store-matches")); }; destination(d0); };<br>
<br>
Is it possible to get the variable value of the stored match from the<br>
log for a second log to match "exit child, pid=<variable>"?<br>
<br>
Thanks,<br>
Thomas<br>
<br>
Am 25.04.2019 um 08:46 schrieb Péter, Kókai:<br>
> Hello,<br>
><br>
> Assuming the log file looks like this:<br>
><br>
> ```<br>
> run child, pid = 1715<br>
> using handler 'hls' for '<a href="http://localhost/" rel="noreferrer" target="_blank">http://localhost/</a>'<br>
> exit child, pid = 1715<br>
> ```<br>
><br>
> Filters and source could be something like this:<br>
> ```<br>
> @version: 3.20<br>
> @include "scl.conf"<br>
><br>
> source xupnpd2 {<br>
>    file("/tmp/xup" flags(no-parse)); # no-parse needed to set $MESSAGE, if<br>
> the file does contain only the above lines it is fine not to parse<br>
> };<br>
><br>
> log { source(xupnpd2); filter { message("run child"); }; destination(d0); };<br>
> log { source(xupnpd2); filter { message("exit child"); } ; destination(d0);<br>
> };<br>
> ```<br>
><br>
> If needed syslog-ng could parse, pid and you can transfare more structured<br>
> to the program destination.<br>
><br>
> --<br>
> Kokan<br>
><br>
> On Wed, Apr 24, 2019 at 4:15 PM Thomas Schmiedl <<a href="mailto:thomas.schmiedl@web.de" target="_blank">thomas.schmiedl@web.de</a>><br>
> wrote:<br>
><br>
>> Hello,<br>
>><br>
>> thanks Péter for your reply. Please could you write the filters<br>
>><br>
>> 1. for the start (2 lines with a variable 'pid' number):<br>
>> run child, pid = 1715<br>
>> using handler 'hls' for '... URL ...'<br>
>><br>
>> 2. for the stop:<br>
>> exit child, pid = 1715<br>
>><br>
>> Thanks,<br>
>> Thomas<br>
>><br>
>> Am 24.04.2019 um 15:05 schrieb Péter, Kókai:<br>
>>> Hello,<br>
>>><br>
>>> 'I have the question, if I could use syslog-ng to filter the start and<br>
>> stop<br>
>>> of the stream'<br>
>>> Yes, it can filter those messages (disclaimer without seeing those<br>
>>> messages).<br>
>>><br>
>>> 'and execute an action "ffmpeg stop" and "delete video segments".'<br>
>>> It was not something syslog-ng is designed to, but for example you could<br>
>>> use program destination to execute arbitrary executable (like s small<br>
>>> script to call ffmpeg stop).<br>
>>><br>
>>> You could do something like this (not tested) to have separate things to<br>
>> do<br>
>>> based on start/stop:<br>
>>><br>
>>> @version: 3.20<br>
>>> source xupnpd2 {<br>
>>>     stdin(flags(no-parse));<br>
>>> };<br>
>>><br>
>>> destination start {<br>
>>>     program("/usr/bin/do-start-magic.sh");<br>
>>> };<br>
>>><br>
>>> destination stop {<br>
>>>     program("/usr/bin/do-stop-magic.sh");<br>
>>> };<br>
>>><br>
>>> log { source(xupnpd2); filter { program("xupnpd2") AND message("start");<br>
>> };<br>
>>> destination(start); };<br>
>>> log { source(xupnpd2); filter { program("xupnpd2") AND message("stop");<br>
>> } ;<br>
>>> destination(stop); };<br>
>>><br>
>>><br>
>>> Each log/event is a single new line to the program stdin, which it should<br>
>>> process.<br>
>>><br>
>>> --<br>
>>> Kokan<br>
>>><br>
>>><br>
>>><br>
>>> On Wed, Apr 24, 2019 at 2:36 PM Thomas Schmiedl <<a href="mailto:thomas.schmiedl@web.de" target="_blank">thomas.schmiedl@web.de</a>><br>
>>> wrote:<br>
>>><br>
>>>> Hello,<br>
>>>><br>
>>>> I use the mediaserver xupnpd2 (<a href="https://github.com/clark15b/xupnpd2" rel="noreferrer" target="_blank">https://github.com/clark15b/xupnpd2</a>) on<br>
>>>> the router to show HLS streams on the TV. Unfortunately, the software is<br>
>>>> no longer maintained by the original developer (I'm not a developer<br>
>>>> myself). The HLS processing would have to be revised.<br>
>>>><br>
>>>> My idea is to start a ffmpeg and a local web server on the router, if I<br>
>>>> want to display the stream (the script xupnpd.lua will be executed,<br>
>>>> which starts ffmpeg etc.). Unfortunately there is not such a script when<br>
>>>> terminating the stream (exit ffmpeg etc.).<br>
>>>><br>
>>>> xupnpd2 uses a log where you can track the start as well as the ending<br>
>>>> of the stream. Since the router has only a small amount of internal<br>
>>>> memory to write and analyze a logfile, I have the question, if I could<br>
>>>> use syslog-ng to filter the start and stop of the stream and execute an<br>
>>>> action "ffmpeg stop" and "delete video segments". I have very little<br>
>>>> Linux knowledge, maybe you can help me.<br>
>>>><br>
>>>> Here is the excerpt from the xupnpd2 log (Loglevel 8).<br>
>>>><br>
>>>> When starting the stream:<br>
>>>> run child, pid = 1715<br>
>>>> using handler 'hls' for '... URL ...'<br>
>>>><br>
>>>> When stopping the stream:<br>
>>>> exit child, pid = 1715<br>
>>>><br>
>>>> Best regards,<br>
>>>> Thomas Schmiedl<br>
>>>><br>
>>>><br>
>> ______________________________________________________________________________<br>
>>>> Member info: <a href="https://lists.balabit.hu/mailman/listinfo/syslog-ng" rel="noreferrer" target="_blank">https://lists.balabit.hu/mailman/listinfo/syslog-ng</a><br>
>>>> Documentation:<br>
>>>> <a href="http://www.balabit.com/support/documentation/?product=syslog-ng" rel="noreferrer" target="_blank">http://www.balabit.com/support/documentation/?product=syslog-ng</a><br>
>>>> FAQ: <a href="http://www.balabit.com/wiki/syslog-ng-faq" rel="noreferrer" target="_blank">http://www.balabit.com/wiki/syslog-ng-faq</a><br>
>>>><br>
>>>><br>
>>><br>
>>><br>
>>><br>
>> ______________________________________________________________________________<br>
>>> Member info: <a href="https://lists.balabit.hu/mailman/listinfo/syslog-ng" rel="noreferrer" target="_blank">https://lists.balabit.hu/mailman/listinfo/syslog-ng</a><br>
>>> Documentation:<br>
>> <a href="http://www.balabit.com/support/documentation/?product=syslog-ng" rel="noreferrer" target="_blank">http://www.balabit.com/support/documentation/?product=syslog-ng</a><br>
>>> FAQ: <a href="http://www.balabit.com/wiki/syslog-ng-faq" rel="noreferrer" target="_blank">http://www.balabit.com/wiki/syslog-ng-faq</a><br>
>>><br>
>><br>
>> ______________________________________________________________________________<br>
>> Member info: <a href="https://lists.balabit.hu/mailman/listinfo/syslog-ng" rel="noreferrer" target="_blank">https://lists.balabit.hu/mailman/listinfo/syslog-ng</a><br>
>> Documentation:<br>
>> <a href="http://www.balabit.com/support/documentation/?product=syslog-ng" rel="noreferrer" target="_blank">http://www.balabit.com/support/documentation/?product=syslog-ng</a><br>
>> FAQ: <a href="http://www.balabit.com/wiki/syslog-ng-faq" rel="noreferrer" target="_blank">http://www.balabit.com/wiki/syslog-ng-faq</a><br>
>><br>
>><br>
><br>
><br>
> ______________________________________________________________________________<br>
> Member info: <a href="https://lists.balabit.hu/mailman/listinfo/syslog-ng" rel="noreferrer" target="_blank">https://lists.balabit.hu/mailman/listinfo/syslog-ng</a><br>
> Documentation: <a href="http://www.balabit.com/support/documentation/?product=syslog-ng" rel="noreferrer" target="_blank">http://www.balabit.com/support/documentation/?product=syslog-ng</a><br>
> FAQ: <a href="http://www.balabit.com/wiki/syslog-ng-faq" rel="noreferrer" target="_blank">http://www.balabit.com/wiki/syslog-ng-faq</a><br>
><br>
______________________________________________________________________________<br>
Member info: <a href="https://lists.balabit.hu/mailman/listinfo/syslog-ng" rel="noreferrer" target="_blank">https://lists.balabit.hu/mailman/listinfo/syslog-ng</a><br>
Documentation: <a href="http://www.balabit.com/support/documentation/?product=syslog-ng" rel="noreferrer" target="_blank">http://www.balabit.com/support/documentation/?product=syslog-ng</a><br>
FAQ: <a href="http://www.balabit.com/wiki/syslog-ng-faq" rel="noreferrer" target="_blank">http://www.balabit.com/wiki/syslog-ng-faq</a><br>
<br>
</blockquote></div>