[checkmk-commits] Check_MK Git: check_mk: mkeventd: new statistics about average synchronization time

git version control git at mathias-kettner.de
Thu Nov 15 19:31:23 CET 2012


Module: check_mk
Branch: master
Commit: a7bd9c205dd3f7c7228521fb47331d67b2a29b5b
URL:    http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=a7bd9c205dd3f7c7228521fb47331d67b2a29b5b

Author: Mathias Kettner <mk at mathias-kettner.de>
Date:   Thu Nov 15 19:31:20 2012 +0100

mkeventd: new statistics about average synchronization time

---

 mkeventd/bin/mkeventd                    |   21 ++++++++++++++++-----
 mkeventd/web/plugins/sidebar/mkeventd.py |    9 +++++----
 2 files changed, 21 insertions(+), 9 deletions(-)

diff --git a/mkeventd/bin/mkeventd b/mkeventd/bin/mkeventd
index b6dbf8f..58d3599 100755
--- a/mkeventd/bin/mkeventd
+++ b/mkeventd/bin/mkeventd
@@ -575,13 +575,14 @@ class EventServer:
 
         # Replication
         headers += [ "status_replication_slavemode", "status_replication_last_sync", 
-                     "status_replication_success" ]
+                     "status_replication_success", "status_replication_average_sync_time" ]
         if is_replication_slave():
             row.append(g_slave_status["mode"])
             row.append(g_slave_status["last_sync"])
             row.append(g_slave_status["success"])
+            row.append(g_slave_status["average_sync_time"])
         else:
-            row += [ "master", 0.0, False ]
+            row += [ "master", 0.0, False, None ]
 
         return headers, [row]
 
@@ -2135,6 +2136,14 @@ def replication_pull():
 
                 save_slave_status()
 
+                # Compute statistics of the average time needed for a sync
+                sync_time = time.time() - now
+                if g_slave_status.get("average_sync_time") == None:
+                    g_slave_status["average_sync_time"] = sync_time
+                else:
+                    g_slave_status["average_sync_time"] = \
+                       g_slave_status["average_sync_time"] * 0.95 + 0.05 * sync_time
+
 # Called when we have new data from our master
 def replication_update_state(new_state):
 
@@ -2170,6 +2179,7 @@ def load_master_config():
 
 
 def get_state_from_master():
+    now = time.time()
     repl_settings = g_config["replication"]
     try:
         sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
@@ -2212,9 +2222,10 @@ def load_slave_status():
             g_slave_status = eval(file(path).read())
         except:
             g_slave_status = {
-                "last_sync"        : 0, # Time of last successfull sync 
-                "last_master_down" : None,
-                "mode"             : "sync",
+                "last_sync"         : 0, # Time of last successfull sync 
+                "last_master_down"  : None,
+                "mode"              : "sync",
+                "average_sync_time" : None,
             }
             save_slave_status()
 
diff --git a/mkeventd/web/plugins/sidebar/mkeventd.py b/mkeventd/web/plugins/sidebar/mkeventd.py
index 009b17d..83d23b1 100644
--- a/mkeventd/web/plugins/sidebar/mkeventd.py
+++ b/mkeventd/web/plugins/sidebar/mkeventd.py
@@ -40,20 +40,21 @@ def render_mkeventd_performance():
 
     raw_data = mkeventd.query("GET status")
     data = dict(zip(raw_data[0], raw_data[1]))
-
-    for what, col, format in \
-        [
+    columns = [
           (_("Received messages"), "message",   "%.2f/s"),
           (_("Rule hits"),         "rule_hit",  "%.2f/s"),
           (_("Rule tries"),        "rule_trie", "%.2f/s"),
           (_("Created events"),    "event",     "%.2f/s"),
-        ]:
+    ]
+    for what, col, format in columns:
         write_line(what, format % data["status_average_%s_rate" % col])
     try:
         write_line(_("Rule hit ratio"), "%.2f%%" % (data["status_average_rule_hit_rate"] / data["status_average_rule_trie_rate"] * 100))
     except: # division by zero
         pass
     write_line(_("Processing time per message"), "%.2f ms" %  (data["status_average_processing_time"] * 1000)) 
+    if data.get("status_replication_average_sync_time") != None:
+        write_line(_("Replication synchronization (avg)"), "%.2f ms" %  (data["status_replication_average_sync_time"] * 1000)) 
     html.write("</table>\n")
 
 if mkeventd_enabled:



More information about the checkmk-commits mailing list