-
Notifications
You must be signed in to change notification settings - Fork 1
/
sum.conf
82 lines (63 loc) · 1.59 KB
/
sum.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
@version: 3.21
@include "scl.conf"
@define loop-socket-path "/tmp/state.sock"
options { time-reopen(5); };
python {
import time
class Wait(object):
def parse(self, log_message):
time.sleep(1)
return True
};
block parser sleep()
{
python( class(Wait) );
};
block source state()
{
channel {
source { unix-stream("/tmp/state.sock" flags(no-parse)); };
parser { syslog-parser(flags(syslog-protocol)); }; # For some reason this is needed for ewmm-parser()
parser { ewmm-parser(); };
}
};
log {
source { example-msg-generator( num(1) ); };
rewrite { set("1" value(".sum")); };
destination { unix-stream("/tmp/state.sock" template("$(format-ewmm)") persist-name("1")); };
};
block source input()
{
channel {
source { stdin(flags(no-parse)); };
rewrite { set("1" value(".input")); };
}
};
log {
source { input(); };
source { state(); };
parser { kv-parser(prefix(".")); };
parser {
grouping-by(
key("")
aggregate(
value(".pass-throu" "1")
)
trigger( match("1", value(".input")) )
timeout(9999999) #hopefully never
);
};
if {
filter { message("reset") };
rewrite { set("0" value(".sum")); };
}
else {
rewrite { set("$(+ ${.sum} $MESSAGE)" value(".sum")); };
};
filter { match("1" value(".pass-throu")); };
rewrite { set("0" value(".pass-throu")); };
rewrite { set("0" value(".input")); };
rewrite { set("0" value("MESSAGE")); };
destination { file("/dev/stdout" template("SUM=${.sum}\n")); };
destination { unix-stream("/tmp/state.sock" template("$(format-ewmm)")); };
};