feat(wazuh): Add watchdog to wazuh-agent startup script
Adds a watchdog loop that checks every 60 seconds if wazuh-agentd is running and automatically restarts the Wazuh service if it stops. Fixes agent disconnection issues caused by wazuh-agentd process dying. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
f3f6eb4e4b
commit
851910e185
@ -0,0 +1,23 @@
|
||||
#!/bin/bash
|
||||
# Wazuh Agent LXC Container Startup Script
|
||||
# Includes watchdog to ensure wazuh-agentd stays running
|
||||
|
||||
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
||||
export HOME=/root
|
||||
|
||||
# DNS
|
||||
echo "nameserver 1.1.1.1" > /etc/resolv.conf
|
||||
|
||||
# Start Wazuh agent
|
||||
if [ -x /var/ossec/bin/wazuh-control ]; then
|
||||
/var/ossec/bin/wazuh-control start
|
||||
fi
|
||||
|
||||
# Watchdog - check every 60 seconds if wazuh-agentd is running
|
||||
while true; do
|
||||
sleep 60
|
||||
if ! pgrep -x wazuh-agentd > /dev/null 2>&1; then
|
||||
echo "[$(date)] WATCHDOG: wazuh-agentd not running, restarting..." >> /var/log/wazuh-watchdog.log
|
||||
/var/ossec/bin/wazuh-control restart
|
||||
fi
|
||||
done
|
||||
Loading…
Reference in New Issue
Block a user