dat from Nagios
Message-ID: <537a1544.3Fvj43AVy7JwgTUW%mk(a)mathias-kettner.de>
User-Agent: Heirloom mailx 12.4 7/29/08
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
Module: check_mk
Branch: master
Commit: 0e83f019f9c0aa7debf6d129b5c846e5bcf4d53e
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=0e83f019f9c0aa…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Mon May 19 16:29:21 2014 +0200
Renaming hosts: also handle retention.dat from Nagios
---
doc/drafts/LIESMICH.hosts_umbenennen | 21 +++++++++------------
modules/automation.py | 16 ++++++++++++----
web/htdocs/wato.py | 2 ++
3 files changed, 23 insertions(+), 16 deletions(-)
diff --git a/doc/drafts/LIESMICH.hosts_umbenennen b/doc/drafts/LIESMICH.hosts_umbenennen
index 4dbe925..a1a0223 100644
--- a/doc/drafts/LIESMICH.hosts_umbenennen
+++ b/doc/drafts/LIESMICH.hosts_umbenennen
@@ -53,18 +53,6 @@ OMD:
==> Auch das muss mit einer Automation gehen
-ES FEHLT:
-
-* retentions.dat (analog bei CMC)
-* Stop/Start vom Core inkl. Config erzeugen zu rechter Zeit
-* Nachdenken, ob noch was fehlt.
-
-
-Beim Stoppen/Starten des Cores muss ich sicherstellen:
-
-1. Das ganze Umbenennen sollte nur dann antriggerbar sein, wenn bei der
-entsprechenden Site keine Pending Changes da sind. Ansonsten Hinweis.
-
2. Damit ein Fehler beim Konfig erzeugen ausgeschlossen werden kann, muss
ich sicherstellen, dass die IP-Adresse des neuen Namens (ebenfalls)
auflösbar ist - und zwar von der Monitoring-Site. Man könnte das zur
@@ -84,3 +72,12 @@ weiterverwendet und die automation scheitern *am Schluss* mit einem
Fehler.
- Jetzt die Konfig erzeugen und prüfen. Wenn ein Fehler auftritt, zurückrollen
- Und den Core wieder starten (beides mit automation_restart)
+-------------------------------------------------------------------------------
+ES FEHLT:
+
+* retentions.dat (analog bei CMC)
+* Problem mit Fehler bei der IP-Adresse lösen
+* Nachdenken, ob noch was fehlt.
+* BI and BI Assumptions??
+* Erlauben nur, wenn die Site sauber ist
+* Vor der automation noch einen sync erzwingen
diff --git a/modules/automation.py b/modules/automation.py
index 87c1b8f..31e21d8 100644
--- a/modules/automation.py
+++ b/modules/automation.py
@@ -978,6 +978,8 @@ def rename_host_file(basedir, oldname, newname):
# This functions could be moved out of Check_MK.
def omd_rename_host(oldname, newname):
+ oldregex = oldname.replace(".", "[.]")
+ newregex = newname.replace(".", "[.]")
actions = []
# Temporarily stop processing of performance data
@@ -996,13 +998,13 @@ def omd_rename_host(oldname, newname):
# entries of rrdcached journal
dirpath = omd_root + "/var/rrdcached/"
if not os.system("sed -i 's@/perfdata/%s/@/perfdata/%s/@' "
- "%s/var/rrdcached/rrd.journal.* 2>/dev/null" % ( oldname, newname,
omd_root)):
+ "%s/var/rrdcached/rrd.journal.* 2>/dev/null" % ( oldregex, newregex,
omd_root)):
actions.append("rrdcached")
# Spoolfiles of NPCD
if not os.system("sed -i 's/HOSTNAME::%s /HOSTNAME::%s /' "
"%s/var/pnp4nagios/perfdata.dump
%s/var/pnp4nagios/spool/perfdata.* 2>/dev/null" % (
- oldname, newname, omd_root, omd_root)):
+ oldregex, newregex, omd_root, omd_root)):
actions.append("pnpspool")
if rrdcache_running:
@@ -1019,7 +1021,7 @@ s/(INITIAL|CURRENT) (HOST|SERVICE) STATE: %(old)s;/\1 \2 STATE:
%(new)s;/
s/(HOST|SERVICE) (DOWNTIME |FLAPPING |)ALERT: %(old)s;/\1 \2ALERT: %(new)s;/
s/PASSIVE (HOST|SERVICE) CHECK: %(old)s;/PASSIVE \1 CHECK: %(new)s;/
s/(HOST|SERVICE) NOTIFICATION: ([^;]+);%(old)s;/\1 NOTIFICATION: \2;%(new)s;/
-''' % { "old" : oldname, "new" : newname }
+''' % { "old" : oldregex, "new" : newregex }
patterns = [
"var/check_mk/core/history",
"var/check_mk/core/archive/*",
@@ -1036,10 +1038,16 @@ s/(HOST|SERVICE) NOTIFICATION: ([^;]+);%(old)s;/\1 NOTIFICATION:
\2;%(new)s;/
if one_matched:
actions.append("history")
+ # State retention (important for Downtimes, Acknowledgements, etc.)
+ if monitoring_core == "nagios":
+ if not os.system("sed -ri 's/^host_name=%s$/host_name=%s/'
%s/var/nagios/retention.dat" % (
+ oldregex, newregex, omd_root)):
+ actions.append("retention")
+
# NagVis maps
if not os.system("sed -i
's/^[[:space:]]*host_name=%s[[:space:]]*$/host_name=%s/' "
"%s/etc/nagvis/maps/*.cfg 2>/dev/null" % (
- oldname, newname, omd_root)):
+ oldregex, newregex, omd_root)):
actions.append("nagvis")
return actions
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 8042398..8f23889 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -2408,6 +2408,8 @@ def rename_host(host, newname):
actions.append(_("NagVis maps"))
elif what == "history":
actions.append(_("Monitoring history entries (events and
availability)"))
+ elif what == "retention":
+ actions.append(_("The current monitoring state (including
ackowledgements and downtimes)"))