nix-config/ansible/roles/elnappo.check_mk_agent/files/plugins/hpux_lunstats

93 lines
2.9 KiB
Bash
Executable File

#!/usr/bin/ksh
# Monitor status of LUNs on HP-UX
# +------------------------------------------------------------------+
# | ____ _ _ __ __ _ __ |
# | / ___| |__ ___ ___| | __ | \/ | |/ / |
# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
# | | |___| | | | __/ (__| < | | | | . \ |
# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
# | |
# | Copyright Mathias Kettner 2014 mk@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-
# tails. 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.
# Put this file into /usr/lib/check_mk_agent/plugins. Then
# reinventorize your host.
# Actually querying these stats is quite slow since they freshly update
# on each call. If you have a few 1000 luns then this will not work.
get_stats()
{
scsimgr get_stat -D $LUN | tr '\=' ':' | grep -e 'STATISTICS FOR LUN' -e 'Bytes' -e 'Total I/Os processed' -e 'I/O failure' -e 'IO failures due
to'
return $?
}
# Ex:
#LUN PATH INFORMATION FOR LUN : /dev/pt/pt2
#World Wide Identifier(WWID) =
#LUN PATH INFORMATION FOR LUN : /dev/rdisk/disk5
#World Wide Identifier(WWID) = 0x60a98000572d44745634645076556357
#LUN PATH INFORMATION FOR LUN : /dev/rdisk/disk6
get_lun_map()
{
scsimgr lun_map | egrep '^[[:space:]]*(LUN PATH|World Wide Identifier)' | tr '\=' ':'
}
main()
{
get_lun_map | while read line ; do
descr=$(echo $line | awk -F: '{print $1}')
val=$( echo $line | awk -F: '{print $2}')
case $descr in
LUN*)
if echo $val | grep /dev/rdisk 1>/dev/null; then
DMP=yes
LUN=$val
else
DMP=no
unset LUN
fi
;;
World*)
if [ $DMP = "yes" ]; then
echo "WWID: $val"
get_stats $LUN
fi
;;
*)
echo "Fehler:"
echo $line
echo $descr
echo $val
sleep 1
;;
esac
done
}
# Verify the system is using new multipath device model.
if [ -d /dev/rdisk ] && [ -d /dev/disk ]; then
echo '<<<hpux_lunstats:sep(58)>>>'
main
fi