[checkmk-commits] Check_MK Git: check_mk: #1996 kernel.util: Also output values for steal and guest (no PNP template yet)

Mathias Kettner mk at mathias-kettner.de
Wed Feb 18 18:13:37 CET 2015


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

Author: Mathias Kettner <mk at mathias-kettner.de>
Date:   Wed Feb 18 17:07:33 2015 +0100

#1996 kernel.util: Also output values for steal and guest (no PNP template yet)

---

 .werks/1996             |    9 +++++++++
 ChangeLog               |    1 +
 checks/cpu_util.include |   22 +++++++++++++++++++++-
 checks/kernel           |    9 ++++++---
 4 files changed, 37 insertions(+), 4 deletions(-)

diff --git a/.werks/1996 b/.werks/1996
new file mode 100644
index 0000000..a417cd9
--- /dev/null
+++ b/.werks/1996
@@ -0,0 +1,9 @@
+Title: kernel.util: Also output values for steal and guest (no PNP template yet)
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.2.7i1
+Date: 1424275634
+Class: feature
+
+
diff --git a/ChangeLog b/ChangeLog
index 89715af..2502a5b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -83,6 +83,7 @@
     * 1939 check_ftp: changed service description if the ftp port differs from 21...
             NOTE: Please refer to the migration notes!
     * 1992 df: Show usages near to zero with a higher precision - not simply as 0.00
+    * 1996 kernel.util: Also output values for steal and guest (no PNP template yet)
     * 1457 FIX: logins: new check renamed from "users" check...
             NOTE: Please refer to the migration notes!
     * 1762 FIX: lnx_thermal: Now ignoring trip points with level 0...
diff --git a/checks/cpu_util.include b/checks/cpu_util.include
index f744897..5aa4f98 100644
--- a/checks/cpu_util.include
+++ b/checks/cpu_util.include
@@ -87,6 +87,8 @@ def check_cpu_util(util, params, this_time = None):
 # - 5 - irq: servicing interrupts
 # - 6 - softirq: servicing softirqs
 # - 7 - steal: involuntary wait
+# - 8 - guest: time spent in guest OK
+# - 9 - guest_nice: time spent in niced guest OK
 def check_cpu_util_unix(values, params):
     this_time = int(time.time())
     # Compute jiffi-differences of all relevant counters
@@ -127,8 +129,26 @@ def check_cpu_util_unix(values, params):
             state = 1
     yield state, "wait: %.1f%%" % (wait_perc)
 
+    # Compute values used in virtualized environments (Xen, etc.)
+    # Only do this for counters that have counted at least one tick
+    # since the system boot. This avoids silly output in systems
+    # where these counters are not being used
+    if len(values) >= 8: #  and values[7]:
+        steal = diff_values[7]
+        steal_perc = 100.0 * float(steal) / float(sum_jiffies)
+        yield 0, "steal: %.1f%%" % steal_perc, [ ("steal", steal_perc) ]
+    else:
+        steal_perc = 0
+
+    if len(values) >= 10: # and (values[8] or values[9]):
+        guest = diff_values[8] + diff_values[9]
+        guest_perc = 100.0 * float(guest) / float(sum_jiffies)
+        yield 0, "guest: %.1f%%" % guest_perc, [ ("guest", guest_perc) ]
+    else:
+        guest_perc = 0
+
     # Total utilization
-    util_total_perc = user_perc + system_perc + wait_perc
+    util_total_perc = user_perc + system_perc + wait_perc + steal_perc + guest_perc
     state = 0
     levelstext = ""
     if "util" in params:
diff --git a/checks/kernel b/checks/kernel
index a160409..9305bc9 100644
--- a/checks/kernel
+++ b/checks/kernel
@@ -120,9 +120,12 @@ def inventory_cpu_utilization(info):
 # - iowait: waiting for I/O to complete
 # - irq: servicing interrupts
 # - softirq: servicing softirqs
-# - steal: involuntary wait
-def kernel_check_cpu_utilization(item, params, info):
+# - steal: Stolen time, which is the time spent in other operating systems
+#          when running in a virtualized environment (since Linux 2.6.11)
+# - guest: Time spent running a virtual CPU for guest operating systems (since Linux 2.6.24)
+# - guest_nice: Time spent running a niced guest (since Linux 2.6.33)
 
+def kernel_check_cpu_utilization(item, params, info):
     # Convert old style tuple-parameter to new dict
     if type(params) != dict:
         params = { "iowait": params }
@@ -139,7 +142,7 @@ def kernel_check_cpu_utilization(item, params, info):
     # line contains now the following columns:
     # 'cpu' user nice system idle wait hw-int sw-int (steal ...)
     # convert number to int
-    values = [ int(x) for x in line[1:8] ]
+    values = [ int(x) for x in line[1:] ]
     return check_cpu_util_unix(values, params)
 
 check_info["kernel.util"] = {



More information about the checkmk-commits mailing list