2 # validation reporter - reports validation failures to a collection server.
3 # Copyright NLnet Labs, 2010
8 # Here is the configuration for the validation reporter
9 # it greps the failure lines out of the log and sends them to a server.
11 # The pidfile for the reporter daemon.
12 pidfile="/var/run/validation-reporter.pid"
14 # The logfile to watch for logged validation failures.
15 logfile="/var/log/unbound.log"
17 # how to notify the upstream
18 # nc is netcat, it sends tcp to given host port. It makes a tcp connection
19 # and writes one log-line to it (grepped from the logfile).
20 # the notify command can be: "nc the.server.name.org 1234"
21 # the listening daemon could be: nc -lk 127.0.0.1 1234 >> outputfile &
22 notify_cmd="nc localhost 1234"
26 # Below this line is the code for the validation reporter,
27 # first the daemon itself, then the controller for the daemon.
29 trap "rm -f \"$pidfile\"" EXIT
30 tail -F $logfile | grep --line-buffered "unbound.*info: validation failure" | \
32 echo "$x" | $notify_cmd
38 # controller for daemon.
40 echo "starting reporter"
41 nohup $0 rundaemon </dev/null >/dev/null 2>&1 &
46 echo "stopping reporter"
47 if test -s "$pidfile"; then
49 # check it is really dead
50 if kill -0 `cat "$pidfile"` >/dev/null 2>&1; then
52 while kill -0 `cat "$pidfile"` >/dev/null 2>&1; do
53 kill `cat "$pidfile"` >/dev/null 2>&1
54 echo "waiting for reporter to stop"
62 if test -s "$pidfile"; then
63 if kill -0 `cat "$pidfile"`; then
75 condrestart_daemon() {
76 if get_status_daemon; then
77 echo "reporter ("`cat "$pidfile"`") is running"
85 if get_status_daemon; then
86 echo "reporter ("`cat "$pidfile"`") is running"
89 echo "reporter is not running"
113 echo "Usage: $0 {start|stop|restart|condrestart|status}"