-
Notifications
You must be signed in to change notification settings - Fork 1
/
pi.conf
75 lines (50 loc) · 2.17 KB
/
pi.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
#@version: 3.141592647
@version: 3.14
@include "scl.conf"
#This is somewhat barbaric and overkill, but also an experimental playground so do not judge me.
block root syslog-ng-ctl(context()) {
block `context` syslog-ng-ctl-`context`(command(), ...) {
destination { unix-stream("`syslog-ng-root`/var/syslog-ng.ctl" template("`command`\n") `__VARARGS__`); };
}
};
syslog-ng-ctl(context(log));
syslog-ng-ctl(context(root));
block root pi(iteration(), digits()) {
options { time-reopen(1); };
log {
source { internal(); };
filter { message("syslog-ng starting up"); };
rewrite { set("1" value("i")); };
rewrite { set("1" value("n")); };
rewrite { set("-1" value("direction")); };
rewrite { set("$(* 3 `digits`)" value("pi")); };
destination {
unix-stream("/tmp/loop" persist-name("start") template("$(format-ewmm)\n"));
};
};
log {
source { unix-stream("/tmp/loop" flags(no-parse)); };
parser { syslog-parser(flags(syslog-protocol)); }; # For some reason this is needed for ewmm-parser()
parser { ewmm-parser(); };
rewrite { set("$(* ${direction} -1)" value("direction")); };
rewrite { set("$(+ ${i} 1)" value("i")); };
rewrite { set("$(+ ${n} 2)" value("n")); };
rewrite { set("$(+ ${n} 1)" value("n_p1")); };
rewrite { set("$(- ${n} 1)" value("n_m1")); };
rewrite { set("$(* ${n_p1} ${n_m1})" value("n_pm")); };
rewrite { set("$(* ${n_pm} ${n})" value("denominator")); };
rewrite { set("$(* 4 `digits`)" value("nominator")); };
rewrite { set("$(/ ${nominator} ${denominator})" value("abs_diverge")); };
rewrite { set("$(* ${direction} ${abs_diverge})" value("divereged")); };
rewrite { set("$(+ ${pi} ${divereged})" value("pi")); };
if ("${i}" <= "`iteration`") {
destination { file("/dev/stdout" template("iteration=${i} pi ~ ${pi}\n"));
#file("/dev/stdout" template("$(format-welf --scope nv-pairs)\n")); #debug option
unix-stream("/tmp/loop" template("$(format-ewmm)\n")); };
}
else {
syslog-ng-ctl-log(command("STOP"));
};
}
};
pi(iteration(100), digits(1000000000));