collectd: sqm_collect: handle being orphaned
authorKevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
Tue, 28 Sep 2021 09:42:45 +0000 (10:42 +0100)
committerKevin Darbyshire-Bryant <6500011+ldir-EDB0@users.noreply.github.com>
Sat, 2 Oct 2021 19:37:08 +0000 (20:37 +0100)
If the master collectd instance gets shut down in an uncontrolled
manner (crashes!) then sqm_collect scripts will be left orphaned and
will run forever.

Modify script to check if it still has a parent and if not, exit.

Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
utils/collectd/Makefile
utils/collectd/files/exec-scripts/sqm_collectd.sh

index ab78064119fda6eabda581915fd1b51510f9d713..10bd70ef127fdb91be932b74b9d6bd11465431b5 100644 (file)
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=collectd
 PKG_VERSION:=5.12.0
-PKG_RELEASE:=12
+PKG_RELEASE:=13
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
 PKG_SOURCE_URL:=https://collectd.org/files/ \
index ad84fc762a1b25eeb99c46ab6581a92cd3e17383..690837017ed12c7a1ec2ab2c5c8f57e3b4b80b6a 100755 (executable)
@@ -99,7 +99,8 @@ process_qdisc() {
        json_cleanup
 }
 
-while true ; do
+# while not orphaned
+while [ $(awk '$1 ~ "^PPid:" {print $2}' /proc/$$/status) -ne 1 ] ; do
        for ifc in "$@" ; do
                process_qdisc "$ifc"
        done