usr/bin/custom/watchdog-monitor aktualisiert

This commit is contained in:
2024-10-28 18:59:56 +01:00
parent bf0b5e857f
commit cdfd6359da

View File

@@ -35,14 +35,18 @@ update_watchdog_config() {
echo "ping = $ip" | sudo tee -a "$config_file" > /dev/null
done
echo "Configured watchdog to ping: ${ip_array[*]}" >> "$log_file"
# Restart watchdog service since IP addresses were found
if sudo systemctl restart watchdog; then
echo "Watchdog service restarted successfully." >> "$log_file"
else
echo "Failed to restart watchdog service." >> "$log_file"
fi
return 1 # Indicate that IP addresses were found
fi
# Restart watchdog service
if sudo systemctl restart watchdog; then
echo "Watchdog service restarted successfully." >> "$log_file"
else
echo "Failed to restart watchdog service." >> "$log_file"
fi
return 0 # Indicate that no IP addresses were found
}
# Main loop
@@ -51,7 +55,10 @@ end_time=$((start_time + 300)) # 5 minutes in seconds
interval=30 # Initial interval of 30 seconds
while true; do
update_watchdog_config
if update_watchdog_config; then
echo "IP addresses found and watchdog restarted. Exiting loop." >> "$log_file"
break # Exit the loop if IP addresses were found
fi
current_time=$(date +%s)