aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortv <tv@shackspace.de>2014-07-15 10:57:48 +0200
committertv <tv@shackspace.de>2014-07-15 10:57:48 +0200
commit4a34debc88eda9d839584b52bfcf5fbca10ae307 (patch)
tree20aaaddc6f945c2067ffb33cfcfc053218694687
parent941bcf61dde50643304750bee87f835fdaae343d (diff)
Reaktor commands nag: POC
-rwxr-xr-xcommands/nag32
-rw-r--r--config.py5
2 files changed, 37 insertions, 0 deletions
diff --git a/commands/nag b/commands/nag
new file mode 100755
index 0000000..6803583
--- /dev/null
+++ b/commands/nag
@@ -0,0 +1,32 @@
+#! /bin/sh
+set -euf
+
+cd "$workdir"
+
+if test -e nag.hosts; then
+ echo "nag seems to run already... if not, then delete $workdir/nag.*, please"
+ exit 23
+fi
+
+trap 'rm -f nag.hosts nag.services nag.patch' EXIT INT QUIT
+
+(cd "$hostsdir" && ls | sort) > nag.hosts
+(cd "$servicesdir" && ls | sort) > nag.services
+
+diff -u nag.hosts nag.services > nag.patch || :
+
+missing_services=$(sed -n '1d;2d;s/^-\(.*\)/\1/p' nag.patch | tr '\n' ' ')
+superfluous_services=$(sed -n '1d;2d;s/^+\(.*\)/\1/p' nag.patch | tr '\n' ' ')
+
+#
+# output
+#
+if test -n "$missing_services"; then
+ echo missing services: $missing_services
+fi
+if test -n "$superfluous_services"; then
+ echo superfluous services: $superfluous_services
+fi
+if test -z "$missing_services$superfluous_services"; then
+ echo hosts and services are in sync
+fi
diff --git a/config.py b/config.py
index b115827..247838d 100644
--- a/config.py
+++ b/config.py
@@ -71,6 +71,11 @@ public_commands = [
]
commands = [
default_command('reload')
+ default_command('nag', env={
+ 'workdir': workdir,
+ 'hostsdir': '/home/tv/krebs/hosts',
+ 'servicesdir': '/home/tv/krebs/services'
+ })
]
on_join = [