unRAID 哪吒探针 Agent 保活 自动重启

检测到日志里有关键词或进程不存在时, 清空日志, 重启

可以设个定时任务 */1 * * * *

#!/usr/bin/env bash

log_message() {
    local message="$1"
    echo -e "[$(date '+%Y-%m-%d %H:%M:%S')] $message"
}

send_notification() {
    local title="$1"
    local body="$2"
    local icon="$3"

    log_message "发送通知 $title\n$body"

    /usr/local/emhttp/webGui/scripts/notify \
        -e "哪吒保活 $title" \
        -s "" \
        -d "" \
        -i "$icon" \
        -m "$body" \
        -l "http://unraid.local:60080/Settings/Userscripts"
}
cd /dev/shm/nezha
if cat nezha-agent.log | grep error || ! pgrep -x nezha-agent > /dev/null; then
  echo "" > nezha-agent.log
  killall nezha-agent > /dev/null
  ./nezha-agent > ./nezha-agent.log 2>&1 &
  send_notification "⚠️ 检测到错误日志或进程不存在" "自动重启" "alert"
fi


探针合集 合集 群组 恰饭 联系推广

#哪吒探针 #nezha #agent #nezha-agent #哪吒 #探针 #监控 #IP #unraid #nas #保活 #自动重启