summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2019-01-24 17:05:36 +0100
committerSimon Rettberg2019-01-24 17:05:36 +0100
commit04b3c572cad8a9364505650da574f13a348b1b45 (patch)
tree56f161746c5e540a7aad6c031a5a2aae8fa6adca
parent[hardware-stats] Add more memory stats to runstate report (diff)
downloadmltk-04b3c572cad8a9364505650da574f13a348b1b45.tar.gz
mltk-04b3c572cad8a9364505650da574f13a348b1b45.tar.xz
mltk-04b3c572cad8a9364505650da574f13a348b1b45.zip
[hardware-stats] Use curl --retry instead of bash for loop
-rwxr-xr-xcore/modules/hardware-stats/data/opt/openslx/scripts/shutdown-system_usage_update2
-rwxr-xr-xcore/modules/hardware-stats/data/opt/openslx/scripts/systemd-hardware_stats47
-rwxr-xr-xcore/modules/hardware-stats/data/opt/openslx/scripts/systemd-hws_standby15
3 files changed, 31 insertions, 33 deletions
diff --git a/core/modules/hardware-stats/data/opt/openslx/scripts/shutdown-system_usage_update b/core/modules/hardware-stats/data/opt/openslx/scripts/shutdown-system_usage_update
index ce474fa2..f163f39f 100755
--- a/core/modules/hardware-stats/data/opt/openslx/scripts/shutdown-system_usage_update
+++ b/core/modules/hardware-stats/data/opt/openslx/scripts/shutdown-system_usage_update
@@ -7,6 +7,6 @@ UUID=$(cat /etc/system-uuid)
[ -z "$UUID" ] && exit 1
-curl -s --data-urlencode "type=~poweroff" --data-urlencode "uuid=$UUID" \
+curl --retry 3 --retry-connrefused -s --data-urlencode "type=~poweroff" --data-urlencode "uuid=$UUID" \
"$SLX_REMOTE_LOG" > /dev/null 2>&1
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 eccb4bb5..f7cee792 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
@@ -330,33 +330,32 @@ buildlogfile() {
buildlogfile &
# Fire away
-for DELAY in 1 1 0; do
- echo "Submitting to $SLX_REMOTE_LOG"
- if curl --data-urlencode "type=~poweron" --data-urlencode "uuid=$UUID" --data-urlencode "macaddr=$MAC" \
- --data-urlencode "uptime=$UPTIME" --data-urlencode "realcores=$CPUCORES" --data-urlencode "mbram=$RAM" \
- --data-urlencode "kvmstate=$VT" --data-urlencode "cpumodel=$CPUMODEL" --data-urlencode "id44mb=$ID44" \
- --data-urlencode "badsectors=$BADSECTORS" --data-urlencode "systemmodel=$MODEL" \
- --data-urlencode "data@$DATAFILE" "$SLX_REMOTE_LOG" | grep -q "RESULT=0"; then
- echo "Success"
- rm -f -- "$DATAFILE"
- START=$(( $RANDOM % 5 ))
- DELAY=$(( $RANDOM % 15 ))
- cat > "/etc/cron.d/usage_stats" <<-EOF
- # Update usage statistics on server
+echo "Submitting to $SLX_REMOTE_LOG"
+if curl --retry 4 --retry-connrefused \
+ --data-urlencode "type=~poweron" --data-urlencode "uuid=$UUID" --data-urlencode "macaddr=$MAC" \
+ --data-urlencode "uptime=$UPTIME" --data-urlencode "realcores=$CPUCORES" --data-urlencode "mbram=$RAM" \
+ --data-urlencode "kvmstate=$VT" --data-urlencode "cpumodel=$CPUMODEL" --data-urlencode "id44mb=$ID44" \
+ --data-urlencode "badsectors=$BADSECTORS" --data-urlencode "systemmodel=$MODEL" \
+ --data-urlencode "data@$DATAFILE" "$SLX_REMOTE_LOG" | grep -q "RESULT=0"; then
+ echo "Success"
+ rm -f -- "$DATAFILE"
+ START=$(( $RANDOM % 5 ))
+ DELAY=$(( $RANDOM % 20 ))
+ cat > "/etc/cron.d/usage_stats" <<-EOF
+ # Update usage statistics on server
- SHELL=/bin/sh
- PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/opt/openslx/sbin:/opt/openslx/bin
+ SHELL=/bin/sh
+ PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/opt/openslx/sbin:/opt/openslx/bin
- ${START}-59/5 * * * * root sleep ${DELAY}; /opt/openslx/scripts/cron-system_usage_update
- EOF
- touch "/etc/cron.d" # Sometimes, aufs doesn't update the mtime of dirs when creating files,
- # so cron would not rescan the cron directory
- cleanup
- exit 0
- fi
+ ${START}-59/5 * * * * root sleep ${DELAY}; /opt/openslx/scripts/cron-system_usage_update
+ EOF
+ touch "/etc/cron.d" # Sometimes, aufs doesn't update the mtime of dirs when creating files,
+ # so cron would not rescan the cron directory
+ cleanup
+ exit 0
+else
echo "Failed..."
- sleep "$DELAY"
-done
+fi
echo "Server doesn't seem to support hardware/usage stats - disabling logging"
rm -f -- "/etc/cron.d/usage_stats"
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
index a92a004d..cee2bfd7 100755
--- a/core/modules/hardware-stats/data/opt/openslx/scripts/systemd-hws_standby
+++ b/core/modules/hardware-stats/data/opt/openslx/scripts/systemd-hws_standby
@@ -14,15 +14,14 @@ 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 "Submitting to $SLX_REMOTE_LOG"
+if curl --retry 4 --retry-connrefused --data-urlencode "type=~$ACTION" --data-urlencode "uuid=$UUID" "$SLX_REMOTE_LOG" | grep -q "RESULT=0"; then
+ echo "Success"
+ exit 0
+else
echo "Failed..."
- sleep "$DELAY"
-done
+fi
+
echo "Giving up" >&2
exit 1