From ad3d1b4869e9a8216d7d7ab87264e3e3e40cdb2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A1=90=E8=AF=9D?= <49544781+xiaomeng9597@users.noreply.github.com> Date: Sun, 9 Jun 2024 16:40:21 +0800 Subject: [PATCH] Polling to check usbus service --- configfiles/ubus-status.sh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 configfiles/ubus-status.sh diff --git a/configfiles/ubus-status.sh b/configfiles/ubus-status.sh new file mode 100644 index 0000000..f3474ad --- /dev/null +++ b/configfiles/ubus-status.sh @@ -0,0 +1,23 @@ +#!/bin/sh + +while true +do + nginx_status=$(/etc/init.d/dbus status | grep -o "running") + datetime=$(date +"%Y-%m-%d %H:%M:%S") + pid2=$(pgrep "ubusd" | head -n 1) + + if [ -n "$nginx_status" ]; then + echo "$datetime / Ubus服务正在运行,一切正常。" + elif [ -z "$pid2" ]; then + echo "$datetime / Ubus服务异常,正在重启Ubus。" + /sbin/ubusd & + killall -9 rpcd + /sbin/rpcd -s /var/run/ubus/ubus.sock -t 30 & + else + echo "$datetime / Ubus服务异常,正在重启Ubus。" + killall -9 ubusd + killall -9 rpcd + /sbin/rpcd -s /var/run/ubus/ubus.sock -t 30 & + fi + sleep 60 +done