summaryrefslogtreecommitdiffstats
path: root/remote/modules/hardware-stats
diff options
context:
space:
mode:
authorSimon Rettberg2015-12-07 17:23:47 +0100
committerSimon Rettberg2015-12-07 17:23:47 +0100
commit6be3bc0e4056e75b22526e4597dd18b7f1c89d8f (patch)
tree88c3f45c5a3a8589ecbc23e2e89cc9c71efb22cb /remote/modules/hardware-stats
parent[hardware-stats] Fix usage stats updater (diff)
downloadtm-scripts-6be3bc0e4056e75b22526e4597dd18b7f1c89d8f.tar.gz
tm-scripts-6be3bc0e4056e75b22526e4597dd18b7f1c89d8f.tar.xz
tm-scripts-6be3bc0e4056e75b22526e4597dd18b7f1c89d8f.zip
[hardware-stats] Report system shutdown
Diffstat (limited to 'remote/modules/hardware-stats')
-rw-r--r--remote/modules/hardware-stats/data/etc/systemd/system/shutdown-usage-log.service11
l---------remote/modules/hardware-stats/data/etc/systemd/system/shutdown.target.wants/shutdown-usage-log.service1
-rwxr-xr-xremote/modules/hardware-stats/data/opt/openslx/scripts/shutdown-system_usage_update12
3 files changed, 24 insertions, 0 deletions
diff --git a/remote/modules/hardware-stats/data/etc/systemd/system/shutdown-usage-log.service b/remote/modules/hardware-stats/data/etc/systemd/system/shutdown-usage-log.service
new file mode 100644
index 00000000..fc65fe9f
--- /dev/null
+++ b/remote/modules/hardware-stats/data/etc/systemd/system/shutdown-usage-log.service
@@ -0,0 +1,11 @@
+[Unit]
+Description=Gather statistics about this machine and send to boot server
+DefaultDependencies=no
+Before=shutdown.target
+RefuseManualStart=yes
+
+[Service]
+Type=oneshot
+ExecStart=/opt/openslx/scripts/shutdown-system_usage_update
+RemainAfterExit=yes
+
diff --git a/remote/modules/hardware-stats/data/etc/systemd/system/shutdown.target.wants/shutdown-usage-log.service b/remote/modules/hardware-stats/data/etc/systemd/system/shutdown.target.wants/shutdown-usage-log.service
new file mode 120000
index 00000000..d94670ed
--- /dev/null
+++ b/remote/modules/hardware-stats/data/etc/systemd/system/shutdown.target.wants/shutdown-usage-log.service
@@ -0,0 +1 @@
+../shutdown-usage-log.service \ No newline at end of file
diff --git a/remote/modules/hardware-stats/data/opt/openslx/scripts/shutdown-system_usage_update b/remote/modules/hardware-stats/data/opt/openslx/scripts/shutdown-system_usage_update
new file mode 100755
index 00000000..dc9f8f73
--- /dev/null
+++ b/remote/modules/hardware-stats/data/opt/openslx/scripts/shutdown-system_usage_update
@@ -0,0 +1,12 @@
+#!/bin/ash
+
+. /opt/openslx/config
+[ -z "$SLX_REMOTE_LOG" ] && exit 0
+
+UUID=$(cat /run/system-uuid)
+
+[ -z "$UUID" ] && exit 1
+
+curl -s --data-urlencode "type=~poweroff" --data-urlencode "uuid=$UUID" \
+ "$SLX_REMOTE_LOG" > /dev/null 2>&1
+