From 5b64969bd2b6ce77b90b280abf299fcd2cf5644d Mon Sep 17 00:00:00 2001 From: Christoph Date: Thu, 14 Mar 2019 13:02:19 +0100 Subject: [PATCH] set_remote_munin_server_ip.sh: add bind address to munin configuration file /etc/munin/munin-node.conf if needed. --- set_remote_munin_server_ip.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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)"