Module: check_mk
Branch: master
Commit: 25ca0b0090761319c602aa8340ff527b081a7ae5
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=25ca0b00907613…
Author: Bastian Kuhn <bk(a)mathias-kettner.de>
Date: Fri Jan 15 16:24:13 2016 +0100
#1322 solaris_prtdiag: New Check for Solaris Hardware State based on prtdiag
---
.werks/1322 | 9 +++++
ChangeLog | 1 +
agents/check_mk_agent.solaris | 5 +++
agents/plugins/mk_inventory.solaris | 6 ----
checkman/solaris_prtdiag | 12 +++++++
checks/solaris_prtdiag | 64 +++++++++++++++++++++++++++++++++++
6 files changed, 91 insertions(+), 6 deletions(-)
diff --git a/.werks/1322 b/.werks/1322
new file mode 100644
index 0000000..8f78dc6
--- /dev/null
+++ b/.werks/1322
@@ -0,0 +1,9 @@
+Title: solaris_prtdiag: New Check for Solaris Hardware State based on prtdiag
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.2.7i4
+Date: 1452871427
+Class: feature
+
+
diff --git a/ChangeLog b/ChangeLog
index b9a65ac..de09450 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -82,6 +82,7 @@
* 2918 agent_jolokia: jolokia can now be monitored using a special agent
* 2919 hp_webmgmt_status: New check for health status of various Hewlett-Packard
devices...
* 2920 hr_cpu: this check can now also supports per-core features...
+ * 1322 solaris_prtdiag: New Check for Solaris Hardware State based on prtdiag
* 2660 FIX: fixed windows agent using the wrong working directory...
* 2664 FIX: ps: Speedup in situation with many matching processes...
* 2661 FIX: windows agent: fixed incomplete process list...
diff --git a/agents/check_mk_agent.solaris b/agents/check_mk_agent.solaris
index 499ead4..ab79199 100755
--- a/agents/check_mk_agent.solaris
+++ b/agents/check_mk_agent.solaris
@@ -244,6 +244,11 @@ then
/usr/bin/top | grep '^Memory:'
fi
+if type prtdiag >/dev/null 2>&1
+ then
+ echo '<<<solaris_prtdiag:sep(10)>>>'
+ run_cached prtdiag 300 '/usr/sbin/prtdiag -v;echo "SerialNumber: $(sneep
-t serial)";echo "PRTDIAG_OVERALL_STATE : $(echo $?)"'
+fi
# TCP Connection stats
echo '<<<tcp_conn_stats>>>'
diff --git a/agents/plugins/mk_inventory.solaris b/agents/plugins/mk_inventory.solaris
index 14d423a..222d8f4 100755
--- a/agents/plugins/mk_inventory.solaris
+++ b/agents/plugins/mk_inventory.solaris
@@ -46,12 +46,6 @@ then
echo "<<<solaris_uname:sep(61):persist($UNTIL)>>>"
uname -X
- if type prtdiag > /dev/null; then
- echo "<<<solaris_prtdiag:sep(10):persist($UNTIL)>>>"
- serial=`sneep -t serial`;echo "SerialNumber: $serial"
- prtdiag -v
- fi
-
if type psrinfo > /dev/null; then
echo "<<<solaris_psrinfo:persist($UNTIL)>>>"
psrinfo -p -v
diff --git a/checkman/solaris_prtdiag b/checkman/solaris_prtdiag
new file mode 100644
index 0000000..8db3ea9
--- /dev/null
+++ b/checkman/solaris_prtdiag
@@ -0,0 +1,12 @@
+title: Prtdiag based health check for solaris
+agents: solaris
+catalog: os/solaris
+license: GPL
+distribution: check_mk
+description:
+ This check looks for the return value of the prtdiag -v command on solaris based
systems.
+ A return value of 0 is interpreted as OK as documented in the prtdiag man page. Each
other return value
+ results in a CRITICAL state.
+ CAVEAT:
+ The extend of the hardware that is considered in the prtdiag command varies from solaris
platform to platform (i.e. huge differences between e.g. M series and T series systems.)
+ Please have a look at the documentation of prtdiag for your system.
diff --git a/checks/solaris_prtdiag b/checks/solaris_prtdiag
new file mode 100644
index 0000000..bb73b5a
--- /dev/null
+++ b/checks/solaris_prtdiag
@@ -0,0 +1,64 @@
+#!/usr/bin/python
+# -*- encoding: utf-8; py-indent-offset: 4 -*-
+# +------------------------------------------------------------------+
+# | ____ _ _ __ __ _ __ |
+# | / ___| |__ ___ ___| | __ | \/ | |/ / |
+# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+# | | |___| | | | __/ (__| < | | | | . \ |
+# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+# | |
+# | Copyright Mathias Kettner 2013 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.
+
+# Example output from agent:
+# .
+# .
+# .
+# SPARC64-VII mode
+#
+# PRTDIAG_OVERALL_STATE : 0
+# SerialNumber: BDF112567
+
+
+def inventory_solaris_prtdiag(info):
+ for line in info:
+ # We have to search in the agent section if we find
+ # that state
+ if line[0].startswith("PRTDIAG_OVERALL_STATE"):
+ return [(None, None)]
+
+def check_solaris_prtdiag(_no_item, _no_params, info):
+ for line in info:
+ if line[0].startswith("PRTDIAG_OVERALL_STATE"):
+ # 0 No failures or errors are detected in the system.
+ # 1 Failures or errors are detected in the system.
+ state = int(info[-1][0].split(':')[1])
+
+ # If we not find the status in the agent output, raise error
+ if state == 0:
+ return 0, "No failures or errors are detected in the system"
+ else:
+ return 2, "Failures or errors are detected in the system, please check
details via prtdiag -v"
+
+check_info['solaris_prtdiag'] = {
+ "inventory_function" : inventory_solaris_prtdiag,
+ "check_function" : check_solaris_prtdiag,
+ "service_description" : "Hardware Overall State"
+}
+
+
+