usr/bin/custom/watchdog-monitor aktualisiert
This commit is contained in:
@@ -35,14 +35,18 @@ update_watchdog_config() {
|
|||||||
echo "ping = $ip" | sudo tee -a "$config_file" > /dev/null
|
echo "ping = $ip" | sudo tee -a "$config_file" > /dev/null
|
||||||
done
|
done
|
||||||
echo "Configured watchdog to ping: ${ip_array[*]}" >> "$log_file"
|
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
|
fi
|
||||||
|
|
||||||
# Restart watchdog service
|
return 0 # Indicate that no 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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Main loop
|
# Main loop
|
||||||
@@ -51,7 +55,10 @@ end_time=$((start_time + 300)) # 5 minutes in seconds
|
|||||||
interval=30 # Initial interval of 30 seconds
|
interval=30 # Initial interval of 30 seconds
|
||||||
|
|
||||||
while true; do
|
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)
|
current_time=$(date +%s)
|
||||||
|
|
||||||
Reference in New Issue
Block a user