summaryrefslogtreecommitdiffstats
path: root/core/modules/hardware-stats
diff options
context:
space:
mode:
authorSimon Rettberg2017-11-25 23:22:03 +0100
committerSimon Rettberg2017-11-25 23:22:03 +0100
commit2010567358b37ad6bef05ebb0e57a54728683ff9 (patch)
treef4ccc2f22e75bc3ab54427aaa45a96ca58a78538 /core/modules/hardware-stats
parent[cups] Add missing ghostscript directory for Ubuntu 17.10 (diff)
downloadmltk-2010567358b37ad6bef05ebb0e57a54728683ff9.tar.gz
mltk-2010567358b37ad6bef05ebb0e57a54728683ff9.tar.xz
mltk-2010567358b37ad6bef05ebb0e57a54728683ff9.zip
[hardware-stats] Support reporting suspend/resume
Diffstat (limited to 'core/modules/hardware-stats')
-rw-r--r--core/modules/hardware-stats/data/etc/systemd/system/shutdown-usage-log.service2
l---------core/modules/hardware-stats/data/etc/systemd/system/sleep.target.wants/stats-resume.service1
l---------core/modules/hardware-stats/data/etc/systemd/system/sleep.target.wants/stats-suspend.service1
-rw-r--r--core/modules/hardware-stats/data/etc/systemd/system/stats-resume.service11
-rw-r--r--core/modules/hardware-stats/data/etc/systemd/system/stats-suspend.service11
-rwxr-xr-xcore/modules/hardware-stats/data/opt/openslx/scripts/systemd-hardware_stats1
-rwxr-xr-xcore/modules/hardware-stats/data/opt/openslx/scripts/systemd-hws_standby26
7 files changed, 52 insertions, 1 deletions
diff --git a/core/modules/hardware-stats/data/etc/systemd/system/shutdown-usage-log.service b/core/modules/hardware-stats/data/etc/systemd/system/shutdown-usage-log.service
index fc65fe9f..ef51e6f2 100644
--- a/core/modules/hardware-stats/data/etc/systemd/system/shutdown-usage-log.service
+++ b/core/modules/hardware-stats/data/etc/systemd/system/shutdown-usage-log.service
@@ -1,5 +1,5 @@
[Unit]
-Description=Gather statistics about this machine and send to boot server
+Description=Tell server we're shuttong down
DefaultDependencies=no
Before=shutdown.target
RefuseManualStart=yes
diff --git a/core/modules/hardware-stats/data/etc/systemd/system/sleep.target.wants/stats-resume.service b/core/modules/hardware-stats/data/etc/systemd/system/sleep.target.wants/stats-resume.service
new file mode 120000
index 00000000..d22600a3
--- /dev/null
+++ b/core/modules/hardware-stats/data/etc/systemd/system/sleep.target.wants/stats-resume.service
@@ -0,0 +1 @@
+../stats-resume.service \ No newline at end of file
diff --git a/core/modules/hardware-stats/data/etc/systemd/system/sleep.target.wants/stats-suspend.service b/core/modules/hardware-stats/data/etc/systemd/system/sleep.target.wants/stats-suspend.service
new file mode 120000
index 00000000..b9132bba
--- /dev/null
+++ b/core/modules/hardware-stats/data/etc/systemd/system/sleep.target.wants/stats-suspend.service
@@ -0,0 +1 @@
+../stats-suspend.service \ No newline at end of file
diff --git a/core/modules/hardware-stats/data/etc/systemd/system/stats-resume.service b/core/modules/hardware-stats/data/etc/systemd/system/stats-resume.service
new file mode 100644
index 00000000..77228f4a
--- /dev/null
+++ b/core/modules/hardware-stats/data/etc/systemd/system/stats-resume.service
@@ -0,0 +1,11 @@
+[Unit]
+Description=Tell server we woke up from suspend
+DefaultDependencies=no
+After=systemd-suspend.service systemd-hybrid-sleep.service systemd-hibernate.service
+RefuseManualStart=true
+
+[Service]
+Type=oneshot
+ExecStart=/opt/openslx/scripts/systemd-hws_standby resume
+RemainAfterExit=no
+
diff --git a/core/modules/hardware-stats/data/etc/systemd/system/stats-suspend.service b/core/modules/hardware-stats/data/etc/systemd/system/stats-suspend.service
new file mode 100644
index 00000000..cd0706cd
--- /dev/null
+++ b/core/modules/hardware-stats/data/etc/systemd/system/stats-suspend.service
@@ -0,0 +1,11 @@
+[Unit]
+Description=Tell server we're about to suspend the system
+DefaultDependencies=no
+Before=sleep.target
+RefuseManualStart=true
+
+[Service]
+Type=oneshot
+ExecStart=/opt/openslx/scripts/systemd-hws_standby suspend
+RemainAfterExit=no
+
diff --git a/core/modules/hardware-stats/data/opt/openslx/scripts/systemd-hardware_stats b/core/modules/hardware-stats/data/opt/openslx/scripts/systemd-hardware_stats
index b13b1f97..255ec9bf 100755
--- a/core/modules/hardware-stats/data/opt/openslx/scripts/systemd-hardware_stats
+++ b/core/modules/hardware-stats/data/opt/openslx/scripts/systemd-hardware_stats
@@ -86,6 +86,7 @@ fi
if [ "${#UUID}" -ne "36" ]; then
echo "Determined UUID (${UUID}) has not expected length of 36, falling back to MAC..."
UUID="000000000000001-$BOOTIF"
+ echo "$UUID" > /etc/system-uuid
fi
echo "UUID=$UUID"
diff --git a/core/modules/hardware-stats/data/opt/openslx/scripts/systemd-hws_standby b/core/modules/hardware-stats/data/opt/openslx/scripts/systemd-hws_standby
new file mode 100755
index 00000000..69276a45
--- /dev/null
+++ b/core/modules/hardware-stats/data/opt/openslx/scripts/systemd-hws_standby
@@ -0,0 +1,26 @@
+#!/bin/ash
+
+# Running as root?
+touch "/run" || exit 2
+
+ACTION=$1
+
+if [ "x$ACTION" != "xresume" ] && [ "x$ACTION" != "xsuspend" ]; then
+ echo "Expecting resume or suspend as argument!" >&2
+ exit 1
+fi
+
+UUID=$(cat /etc/system-uuid)
+
+for DELAY in 1 1 2 3 5 8 0; do
+ echo "Submitting to $SLX_REMOTE_LOG"
+ if curl --data-urlencode "type=~$ACTION" --data-urlencode "uuid=$UUID" "$SLX_REMOTE_LOG" | grep -q "RESULT=0"; then
+ echo "Success"
+ exit 0
+ fi
+ echo "Failed..."
+ sleep "$DELAY"
+done
+echo "Giving up" >&2
+exit 1
+