Module: check_mk
Branch: master
Commit: da3b6a8ac2aba3e7a5e4b1c271e1ce68f101db57
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=da3b6a8ac2aba3…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Fri Jun 8 18:00:07 2012 +0200
New checks tsm_stgpools and tsm_drives for Linux/UNIX
---
ChangeLog | 3 +-
agents/plugins/mk_tsm | 57 +++++++++++++++++++++++++++
checks/tsm_drives | 102 +++++++++++++++++++++++++++++++++++++++++++++++++
checks/tsm_stgpools | 7 ++-
4 files changed, 166 insertions(+), 3 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 52e22dd..6eeb7f7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,7 +6,8 @@
Checks & Agents:
* FIX: diskstat: handle output 'No Devices Found' - avoiding exception
* 3ware_units: Following states now lead to WARNING state instead of
- CRITICAL: "VERIFY-PAUSED", "VERIFYING", "REBUILDING"
+ CRITICAL: "VERIFY-PAUSED", "VERIFYING", "REBUILDING"
+ * New checks tsm_stgpools and tsm_drives for Linux/UNIX
Multisite:
* FIX: fix severe exception in all views on older Python versions
diff --git a/agents/plugins/mk_tsm b/agents/plugins/mk_tsm
new file mode 100755
index 0000000..5e3dc4f
--- /dev/null
+++ b/agents/plugins/mk_tsm
@@ -0,0 +1,57 @@
+#!/usr/bin/ksh
+
+# Agent for Linux/UNIX for Tivoli Storage Manager (TSM)
+# You need to create a configuration file /etc/check_mk/tsm.cfg
+# with the following two lines:
+# TSM_USER=foo
+# TSM_PASSWORD=bar
+# If you have more than once instance, make sure that the upper
+# login works on all of them.
+
+. $MK_CONFDIR/tsm.cfg || exit 1
+
+if [ -z "$TSM_USER" -o -z "$TSM_PASSWORD" ]
+then
+ echo "Please set TSM_USER and TSM_PASSWORD in $MK_CONFDIR/tsm.cfg"
>&2
+ exit 1
+fi
+
+do_tsm_checks ()
+{
+ INST=${DSMSERV_DIR##*/}
+
+ # If we have no instance name, we take 'default'
+ if [ -z "$INST" ] ; then INST=default ; fi
+
+ dsmcmd="dsmadmc -id=$TSM_USER -pass=$TSM_PASSWORD -tab"
+
+ # Staging Pools
+ echo '<<<tsm_stgpools>>>'
+ $dsmcmd <<EOF | sed -n "/^FOO/s//$INST/p"
+select 'FOO',stgpool_name,pct_utilized from volumes where
access='READWRITE' and devclass_name<>'DISK'
+EOF
+
+ # Drive Status
+ echo '<<<tsm_drives>>>'
+ $dsmcmd <<EOF | sed -n "/^FOO/s//$INST/p"
+SELECT 'FOO', library_name, drive_name, drive_state, online, drive_serial FROM
drives
+EOF
+
+ # Occupancy
+ echo '<<<tsm_occupancy>>>'
+ $dsmcmd <<EOF | sed -n "/^FOO/s//$INST/p"
+SELECT 'FOO', type, stgpool_name, sum(logical_mb) from occupancy group by type,
stgpool_name
+EOF
+
+}
+
+# Find in the list of processes TSM daemons. Example output of 'ps xewwg'
+# 8781984 - A 127:26 dsmserv _=/usr/bin/dsmserv LANG=en_US LOGIN=root
PATH=/usr/bin:/etc:/usr/sbin:/usr/ucb:/usr/bin/X11:/sbin:/usr/java5/jre/bin:/usr/java5/bin
LC_ALL=en_US DSMSERV_CONFIG=/foobar_17g/dsmserv.opt LC__FASTMSG=true LOGNAME=root
MAIL=/var/spool/mail/root LOCPATH=/usr/lib/nls/loc DSMSERV_DIR=/foobar_17g USER=root
AUTHSTATE=compat AIXTHREAD_MNRATIO=1:1 SHELL=/usr/bin/ksh ODMDIR=/etc/objrepos HOME=/
SSH_CLIENT=192.168.21.199 37725 22 SSH_CONNECTION=192.168.21.199 37725 192.168.21.214 22
PWD=/foobar_17g TZ=Europe/Bucharest AIXTHREAD_SCOPE=S
DSMSERV_ACCOUNTING_DIR=/foobar_17g/acc
NLSPATH=/usr/lib/nls/msg/%L/%N:/usr/lib/nls/msg/%L/%N.cat
LIBPATH=/usr/local/Centera_SDK/lib/64/
+
+ps xewwg | sed -n '/ dsmserv .* DSMSERV_CONFIG=/s/^.* dsmserv //p' | \
+while read line
+do
+ # Take over all relevant environment into our own
+ eval "$(echo "$line" | tr ' ' '\n' | sed -n
'/^DSMSERV_/s/^/export /p')"
+ do_tsm_checks
+done
diff --git a/checks/tsm_drives b/checks/tsm_drives
new file mode 100644
index 0000000..ae32190
--- /dev/null
+++ b/checks/tsm_drives
@@ -0,0 +1,102 @@
+#!/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.
+
+# <<<tsm_drives>>>
+# tsmfarm3 LIBRARY3 DRIVE01 LOADED YES
000782XXXX
+# tsmfarm3 LIBRARY3 DRIVE02 LOADED YES
002348XXXX
+# tsmfarm3 LIBRARY3 DRIVE03 EMPTY YES
000783XXXX
+# tsmfarm3 LIBRARY3 DRIVE04 EMPTY NO
000784XXXX
+# tsmfarm3 LIBRARY3 DRIVE05 LOADED YES
000785XXXX
+
+# <<<tsm_drives>>>
+# default GPFSFILE GPFSFILE1 UNKNOWN YES
+# default GPFSFILE GPFSFILE10 UNKNOWN YES
+# default GPFSFILE GPFSFILE11 UNKNOWN YES
+# default GPFSFILE GPFSFILE12 UNKNOWN YES
+# default GPFSFILE GPFSFILE13 UNKNOWN YES
+
+# Possible values for state:
+# LOADED
+# EMPTY
+# UNAVAILABLE -> crit
+# UNLOADED
+# RESERVED
+# UNKNOWN -> crit
+
+# Possible values for loaded:
+# YES -> OK
+# NO
+# UNAVAILABLE_SINCE?
+# POLLING?
+
+def inventory_tsm_drives(info):
+ inventory = []
+ for line in info:
+ if len(line) == 6:
+ inst, library, drive, state, online = line[:5]
+ item = "%s / %s" % (library, drive)
+ if inst != "default":
+ item = inst + " / " + item
+ inventory.append((item, None))
+
+ return inventory
+
+def check_tsm_drives(item, params, info):
+ for line in info:
+ if len(line) >= 5:
+ inst, library, drive, state, online = line[:5]
+ libdev = "%s / %s" % (library, drive)
+ if item == libdev or item == inst + " / " + libdev:
+ if len(line) >= 6:
+ serial = line[5]
+ infotext = "[%s] " % serial
+ else:
+ serial = None
+ infotext = ""
+
+ monstate = 0
+ infotext += "state: %s" % state
+ if state in [ "UNAVAILABLE", "UNKNOWN" ]:
+ monstate = 2
+ infotext += "(!!)"
+
+ infotext += ", online: %s" % online
+ if online != "YES":
+ monstate = 2
+ infotext += "(!!)"
+
+ return (monstate, nagios_state_names[monstate] + " - " +
infotext)
+ return (3, "UNKNOWN - drive not found")
+
+
+
+check_info['tsm_drives'] = {
+ "check_function" : check_tsm_drives,
+ "inventory_function" : inventory_tsm_drives,
+ "service_description" : "TSM Drive %s",
+ "has_perfdata" : False,
+}
+
diff --git a/checks/tsm_stgpools b/checks/tsm_stgpools
index 45d798b..e313ab1 100644
--- a/checks/tsm_stgpools
+++ b/checks/tsm_stgpools
@@ -45,7 +45,10 @@ factory_settings["tsm_stgpools_default_levels"] = {
def inventory_tsm_stgpools(info):
items = set([])
for inst, pool, util in info:
- items.add(inst + " / " + pool)
+ if inst == "default":
+ items.add(pool)
+ else:
+ items.add(inst + " / " + pool)
return [ (item, "tsm_stgpools_default_levels") for item in items ]
def check_tsm_stgpools(item, params, info):
@@ -53,7 +56,7 @@ def check_tsm_stgpools(item, params, info):
num_free_tapes = 0
utilization = 0.0 # in relation to one tape size
for inst, pool, util in info:
- if inst + " / " + pool == item:
+ if inst + " / " + pool == item or pool == item:
util = float(util) / 100.0
utilization += util
num_tapes += 1