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"
|
sudo cp "$config_file" "$config_file.bak"
|
||||||
log "Backup of $config_file created successfully."
|
log "Backup of $config_file created successfully."
|
||||||
|
|
||||||
# Clean existing configurations
|
# Write static configuration to file
|
||||||
sudo sed -i '/ping/d' "$config_file"
|
{
|
||||||
sudo sed -i '/^interval/d' "$config_file"
|
echo "realtime = yes"
|
||||||
|
echo "priority = 1"
|
||||||
# Set interval
|
echo "interface = eth0"
|
||||||
echo "interval = 58" | sudo tee -a "$config_file" > /dev/null
|
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
|
if [ ${#ip_array[@]} -eq 0 ]; then
|
||||||
log "No IP addresses found. Watchdog configuration cleared."
|
log "No IP addresses found. Watchdog configuration cleared."
|
||||||
return 1 # No IP addresses to configure
|
return 1 # No IP addresses to configure
|
||||||
else
|
else
|
||||||
# Insert IPs into config
|
# Append IPs to config
|
||||||
for ip in "${ip_array[@]}"; do
|
for ip in "${ip_array[@]}"; do
|
||||||
echo "ping = $ip" | sudo tee -a "$config_file" > /dev/null
|
echo "ping = $ip" | sudo tee -a "$config_file" > /dev/null
|
||||||
done
|
done
|
||||||
@@ -43,6 +46,14 @@ update_watchdog_config() {
|
|||||||
# Restart watchdog service
|
# Restart watchdog service
|
||||||
if sudo systemctl restart watchdog; then
|
if sudo systemctl restart watchdog; then
|
||||||
log "Watchdog service restarted successfully."
|
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
|
return 0 # Successful restart
|
||||||
else
|
else
|
||||||
log "Failed to restart watchdog service."
|
log "Failed to restart watchdog service."
|
||||||
|
|||||||
Reference in New Issue
Block a user