Module: check_mk
Branch: master
Commit: 668495503329c05b79e11fab62747967f54951af
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=668495503329c0…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Wed Feb 8 17:34:54 2012 +0100
hpux_snmp_cs.cpu: new SNMP check for CPU utilization on HP-UX
---
ChangeLog | 2 +
checkman/hpux_snmp_cs.cpu | 15 ++++
checks/hpux_snmp_cs | 103 +++++++++++++++++++++++++++
pnp-templates/check_mk-hpux_snmp_cs.cpu.php | 48 ++++++++++++
web/plugins/perfometer/check_mk.py | 13 ++++
5 files changed, 181 insertions(+), 0 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 28f7512..f2b327f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -18,6 +18,8 @@
* added new checks for Fujitsu ETERNUS DX80 S2
(thanks to Philipp Höfflin)
* Fix Perf-O-Meter of fileage
+ * hpux_snmp_cs.cpu: new SNMP check for CPU utilization
+ on HP-UX.
Multisite:
* Added several missing localization stringsw
diff --git a/checkman/hpux_snmp_cs.cpu b/checkman/hpux_snmp_cs.cpu
new file mode 100644
index 0000000..e9be8f2
--- /dev/null
+++ b/checkman/hpux_snmp_cs.cpu
@@ -0,0 +1,15 @@
+title: Check CPU usage (utilisation) via SNMP on HP-UX
+agents: snmp
+author: Mathias Kettner <mk(a)mathias-kettner.de>
+license: GPL
+distribution: check_mk
+description:
+ This check measures the CPU utilization during the last check
+ cycle using SNMP and the HP-UX SNMP agent. It outputs values
+ for user, system, nice and idle.
+
+perfdata:
+ Four variables: The percentage of time spent in {user}, {system}, {nice} and {idle}.
+
+inventory:
+ One check per host is created if the agent supports this check.
diff --git a/checks/hpux_snmp_cs b/checks/hpux_snmp_cs
new file mode 100644
index 0000000..c32cfbe
--- /dev/null
+++ b/checks/hpux_snmp_cs
@@ -0,0 +1,103 @@
+#!/usr/bin/python
+# -*- encoding: utf-8; py-indent-offset: 4 -*-
+# +------------------------------------------------------------------+
+# | ____ _ _ __ __ _ __ |
+# | / ___| |__ ___ ___| | __ | \/ | |/ / |
+# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+# | | |___| | | | __/ (__| < | | | | . \ |
+# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+# | |
+# | Copyright Mathias Kettner 2012 mk(a)mathias-kettner.de |
+# +------------------------------------------------------------------+
+#
+# This file is part of Check_MK.
+# The official homepage is at
http://mathias-kettner.de/check_mk.
+#
+# check_mk is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation in version 2. check_mk is distributed
+# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
+# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE. See the GNU General Public License for more de-
+# ails. You should have received a copy of the GNU General Public
+# License along with GNU Make; see the file COPYING. If not, write
+# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+# Boston, MA 02110-1301 USA.
+
+
+# Some relevant OIDs are
+# sysUpTime: 1.3.6.1.4.1.11.2.3.1.1.1
+# sysUsers: 1.3.6.1.4.1.11.2.3.1.1.2
+# sysAvgJobs1: 1.3.6.1.4.1.11.2.3.1.1.3
+# sysAvgJobs5: 1.3.6.1.4.1.11.2.3.1.1.4
+# sysAvgJobs15: 1.3.6.1.4.1.11.2.3.1.1.5
+# sysMaxProcess: 1.3.6.1.4.1.11.2.3.1.1.6
+# sysFreeMemory: 1.3.6.1.4.1.11.2.3.1.1.7
+# sysPhysMemory: 1.3.6.1.4.1.11.2.3.1.1.8
+# sysMaxUserMemory: 1.3.6.1.4.1.11.2.3.1.1.9
+# sysSwapConfig: 1.3.6.1.4.1.11.2.3.1.1.10
+# sysEnabledSwap: 1.3.6.1.4.1.11.2.3.1.1.11
+# sysFreeSwap: 1.3.6.1.4.1.11.2.3.1.1.12
+# sysUserCPU: 1.3.6.1.4.1.11.2.3.1.1.13
+# sysSysCPU: 1.3.6.1.4.1.11.2.3.1.1.14
+# sysIdleCPU: 1.3.6.1.4.1.11.2.3.1.1.15
+# sysNiceCPU: 1.3.6.1.4.1.11.2.3.1.1.16
+
+# Example walk:
+# .1.3.6.1.4.1.11.2.3.1.1.1.0 215207600
+# .1.3.6.1.4.1.11.2.3.1.1.10.0 33357824
+# .1.3.6.1.4.1.11.2.3.1.1.11.0 33357824
+# .1.3.6.1.4.1.11.2.3.1.1.12.0 29350932
+# .1.3.6.1.4.1.11.2.3.1.1.13.0 52129100
+# .1.3.6.1.4.1.11.2.3.1.1.14.0 23331438
+# .1.3.6.1.4.1.11.2.3.1.1.15.0 123137168
+# .1.3.6.1.4.1.11.2.3.1.1.16.0 10
+
+
+
+def inventory_hpux_snmp_cpu(info):
+ if len(info) > 0:
+ return [(None, None)]
+
+def check_hpux_snmp_cpu(item, _no_params, info):
+ parts = dict(info)
+ some_counter_wrapped = False
+ this_time = time.time()
+ total_rate = 0
+ rates = []
+ for what, oid in [
+ ( "user", "13.0" ),
+ ( "system", "14.0" ),
+ ( "idle", "15.0" ),
+ ( "nice", "16.0" )]:
+ value = int(parts[oid])
+ try:
+ timedif, rate = get_counter("snmp_cpu_util.%s" % what, this_time,
value)
+ total_rate += rate
+ rates.append(rate)
+ except MKCounterWrapped:
+ some_counter_wrapped = True
+
+ if some_counter_wrapped:
+ raise MKCounterWrapped("", "Some counter wrapped, no data this
time")
+
+ if total_rate == 0:
+ raise MKCounterWrapped("", "No counter counted. Time has ceased to
flow.")
+
+ perfdata = []
+ infos = []
+ for what, rate in zip(["user", "system", "idle",
"nice"], rates):
+ part = rate / total_rate
+ perc = part * 100
+ perfdata.append((what, perc, None, None, 0, 100))
+ infos.append("%s: %.0f%%" % (what, perc))
+
+ return (0, "OK - " + ", ".join(infos), perfdata)
+
+
+check_info['hpux_snmp_cs.cpu'] = (check_hpux_snmp_cpu, "CPU
utilization", 1, inventory_hpux_snmp_cpu)
+
+snmp_info['hpux_snmp_cs'] = ( ".1.3.6.1.4.1.11.2.3.1", [ OID_END, 1 ])
+
+snmp_scan_functions['hpux_snmp_cs.cpu'] = \
+ lambda oid: oid(".1.3.6.1.2.1.1.1.0").startswith("HP-UX")
diff --git a/pnp-templates/check_mk-hpux_snmp_cs.cpu.php
b/pnp-templates/check_mk-hpux_snmp_cs.cpu.php
new file mode 100644
index 0000000..7f5c962
--- /dev/null
+++ b/pnp-templates/check_mk-hpux_snmp_cs.cpu.php
@@ -0,0 +1,48 @@
+<?php
+# +------------------------------------------------------------------+
+# | ____ _ _ __ __ _ __ |
+# | / ___| |__ ___ ___| | __ | \/ | |/ / |
+# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+# | | |___| | | | __/ (__| < | | | | . \ |
+# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+# | |
+# | Copyright Mathias Kettner 2012 mk(a)mathias-kettner.de |
+# +------------------------------------------------------------------+
+#
+# This file is part of Check_MK.
+# The official homepage is at
http://mathias-kettner.de/check_mk.
+#
+# check_mk is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation in version 2. check_mk is distributed
+# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
+# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE. See the GNU General Public License for more de-
+# ails. You should have received a copy of the GNU General Public
+# License along with GNU Make; see the file COPYING. If not, write
+# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+# Boston, MA 02110-1301 USA.
+
+$opt[1] = "--vertical-label 'CPU utilization %' -l0 -u 100 --title
\"CPU Utilization for $hostname\" ";
+#
+$def[1] = "DEF:user=$RRDFILE[1]:$DS[1]:AVERAGE " ;
+$def[1] .= "DEF:system=$RRDFILE[2]:$DS[2]:AVERAGE " ;
+$def[1] .= "DEF:idle=$RRDFILE[3]:$DS[3]:AVERAGE " ;
+$def[1] .= "DEF:nice=$RRDFILE[4]:$DS[4]:AVERAGE " ;
+$def[1] .= "CDEF:sum=user,system,+,nice,+ ";
+
+$def[1] .= "AREA:user#60f020:\"User\" " ;
+$def[1] .= "GPRINT:user:LAST:\"%2.1lf%%\" " ;
+
+$def[1] .= "AREA:system#ff6000:\"System\":STACK " ;
+$def[1] .= "GPRINT:system:LAST:\"%2.1lf%%\" " ;
+
+$def[1] .= "AREA:nice#00d080:\"Nice\":STACK " ;
+$def[1] .= "GPRINT:nice:LAST:\"%2.1lf%%\" " ;
+
+$def[1] .= "LINE:idle#ffffff:\"Idle\":STACK " ;
+$def[1] .= "GPRINT:idle:LAST:\"%2.1lf%%\" " ;
+
+$def[1] .= "LINE:sum#004080:\"Utilization\" " ;
+
+?>
diff --git a/web/plugins/perfometer/check_mk.py b/web/plugins/perfometer/check_mk.py
index 4fd17e5..06c1872 100644
--- a/web/plugins/perfometer/check_mk.py
+++ b/web/plugins/perfometer/check_mk.py
@@ -300,6 +300,19 @@ def perfometer_cpu_utilization(row, check_command, perf_data):
perfometers["check_mk-h3c_lanswitch_cpu"] = perfometer_cpu_utilization
perfometers["check_mk-winperf_processor.util"] = perfometer_cpu_utilization
+def perfometer_hpux_snmp_cs_cpu(row, check_command, perf_data):
+ h = '<table><tr>'
+ h += perfometer_td(float(perf_data[0][1]), "#60f020")
+ h += perfometer_td(float(perf_data[1][1]), "#ff6000")
+ h += perfometer_td(float(perf_data[2][1]), "#00d080")
+ h += perfometer_td(float(perf_data[3][1]), "#ffffff")
+ h += '</tr></table>'
+ sum = float(perf_data[0][1]) + float(perf_data[1][1]) + float(perf_data[2][1])
+ return "%.0f%%" % sum, h
+
+perfometers["check_mk-hpux_snmp_cs.cpu"] = perfometer_hpux_snmp_cs_cpu
+
+
def perfometer_check_mk_uptime(row, check_command, perf_data):
days, rest = divmod(int(perf_data[0][1]), 60*60*24)
hours, rest = divmod(rest, 60*60)