usr/bin/custom/watchdog-monitor aktualisiert
This commit is contained in:
@@ -23,18 +23,21 @@ update_watchdog_config() {
|
||||
sudo cp "$config_file" "$config_file.bak"
|
||||
log "Backup of $config_file created successfully."
|
||||
|
||||
# Clean existing configurations
|
||||
sudo sed -i '/ping/d' "$config_file"
|
||||
sudo sed -i '/^interval/d' "$config_file"
|
||||
|
||||
# Set interval
|
||||
echo "interval = 58" | sudo tee -a "$config_file" > /dev/null
|
||||
# Write static configuration to file
|
||||
{
|
||||
echo "realtime = yes"
|
||||
echo "priority = 1"
|
||||
echo "interface = eth0"
|
||||
echo "interval = 58"
|
||||
echo "ping-count = 1"
|
||||
} | sudo tee "$config_file" > /dev/null
|
||||
log "Static configuration written to $config_file."
|
||||
|
||||
if [ ${#ip_array[@]} -eq 0 ]; then
|
||||
log "No IP addresses found. Watchdog configuration cleared."
|
||||
return 1 # No IP addresses to configure
|
||||
else
|
||||
# Insert IPs into config
|
||||
# Append IPs to config
|
||||
for ip in "${ip_array[@]}"; do
|
||||
echo "ping = $ip" | sudo tee -a "$config_file" > /dev/null
|
||||
done
|
||||
@@ -43,6 +46,14 @@ update_watchdog_config() {
|
||||
# Restart watchdog service
|
||||
if sudo systemctl restart watchdog; then
|
||||
log "Watchdog service restarted successfully."
|
||||
|
||||
# Stop watchdog-monitor service
|
||||
if sudo systemctl stop watchdog-monitor; then
|
||||
log "watchdog-monitor service stopped successfully."
|
||||
else
|
||||
log "Failed to stop watchdog-monitor service."
|
||||
fi
|
||||
|
||||
return 0 # Successful restart
|
||||
else
|
||||
log "Failed to restart watchdog service."
|
||||
|
||||
Reference in New Issue
Block a user