diff --git a/set_remote_munin_server_ip.sh b/set_remote_munin_server_ip.sh index 9ff2711..801f3af 100755 --- a/set_remote_munin_server_ip.sh +++ b/set_remote_munin_server_ip.sh @@ -546,6 +546,18 @@ if [[ -f "$MUNIN_CONF_FILE" ]]; then done < "${MUNIN_CONF_FILE}.BAK.${backup_date}" echo_ok + if $(grep -q -E "^\s*host\s+\*" "$MUNIN_CONF_FILE" 2>/dev/null) ; then + primary_inet4_addr="$(ip route get 1 | awk '{print $NF;exit}')" + echononl "$MUNIN_CONF_FILE: bind munin to adress '${primary_inet4_addr}'.." + perl -i -n -p -e "s/^(\s*host\s+\*.*)/#\1\nhost ${primary_inet4_addr}/" "$MUNIN_CONF_FILE" 2> $log_file + if [[ $? -eq 0 ]] ; then + echo_ok + else + echo_failed + error "$(cat $log_file)" + fi + fi + else echo_failed error "$(cat $log_file)"