Nagios Script: tsm_scratch_tapes

Das folgende Skript wurde als Nagios Plugin erzeugt und ist ein einfaches Shell-Skript, welches prüft, ob ausreichend Scratch Bänder vorhanden sind.

Requirements

  • bash
  • dsmadmc
  • dsm.sys
  • /etc/default/tsm_nagios.conf
ANALYST_TSM01="analyst"
ANALYPW_TSM01="password"

Syntax

  • check_tsm_scratch -T <tsmserveralias> -H <clientnode> -W <warn> -C <crit>
    • clientnode ist aktuell noch nicht definiert, es ist aber vorgesehen, damit das Skript auch für andere Queries verwendet werden kann.

Return-Codes

Skript

bash

#!/bin/bash

# License Information:
#****************************************************
# Tivoli Storage Manager TSM Client                 *
# tsm_nag_scratch.sh                                *
#                                                   *
# Nagios Plugin, welches prueft, wieviele Scratch   *
# Tapes in der Library eines Servers vorhanden sind *
#                                                   *
# Autor:             Thomas Baumann, tiri GmbH      *
# Letzte Aenderung:  07.12.2009                     *
# Copyright:         Thomas Baumann, tiri GmbH      *
#****************************************************

### default variables ###
prog_version=1.0
TIVPATH=/opt/tivoli/tsm/client/ba/bin
DSMADMC=$TIVPATH/dsmadmc
DSMCONF=/etc/default/tsm_nagios.conf

### Nagios Return Codes ###
OK=0
WARNING=1
CRITICAL=2
UNKNOWN=3

help(){

cat <<EOF
$(basename $0) $prog_version
Copyright (c) 2009 Thomas Baumann <tiri-gmbh@tiri.li>

Check TSM Server for Information

Usage:$0 -T <tsm_server_alias> -H <client_node_name> -W <warn> -C <crit>

Options:
          -h             Print detailed help screen
          -V             Print version information
          -W             Warning Threshold
          -C             Critical Threshold

EOF
exit 0
}

if [ "$#" -lt 4 ]; then
   echo "insufficient arguments"
   help
fi

while getopts T:VhH:C:W: opt; do
   case $opt in
      V)   echo "$0 $prog_version"
           exit;;
      H)   host=$OPTARG;;
      T)   tsmsrv=$OPTARG;;
      C)   crit=$OPTARG;;
      W)   warn=$OPTARG;;
      h)   help;;
      *)   echo "invalid option"
           exit $UNKNOWN
           ;;
   esac
done

### environment check ###
if [ ! -x $DSMADMC >/dev/null 2>&1 ]; then
   echo "UNKNOWN: - could not find $DSMADMC on this system"
   exit $UNKNOWN
fi
if [ ! -f $DSMCONF >/dev/null 2>&1 ]; then
   echo "UNKNOWN: - could not find $DSMCONF on this system"
   exit $UNKNOWN
fi

. $DSMCONF

eval $(echo DSMUSER=$( echo \$ANALYST_${tsmsrv} ))
eval $(echo DSMPASS=$( echo \$ANALYPW_${tsmsrv} ))

if [ -z $DSMUSER -o -z $DSMPASS ]; then
   echo "UNKNOWN: - could not find ANALYST_$tsmsrv config in config $DSMCONF"
   exit $UNKNOWN
fi

QUERY="Q LIBVOL"
CMD="$DSMADMC -id=${DSMUSER} -pa=${DSMPASS} -se=$tsmsrv -dataonly=yes -tab"

scratch=$(
$CMD "$QUERY" | awk 'BEGIN {scratch=0}
        $3 ~ /Scratch/ {scratch++}
        END {print scratch}'
)

overall_state=0
output="$scratch Scratch Tapes in Library"

if [ "$?" -ne 0 ]; then
   echo "UNKNOWN: $states"
   exit $UNKNOWN
fi

if [[ $scratch -le $warn ]]; then
        overall_state=$WARNING
fi
if [[ $scratch -le $crit ]]; then
        overall_state=$CRITICAL
fi

### evaluate the return code ###
if [ "$overall_state" -eq $OK ]; then
   echo "OK: $output"
   exit $OK
elif [ "$overall_state" -eq $WARNING ]; then
   echo "WARNING: $output"
   exit $WARNING
elif [ "$overall_state" -eq $CRITICAL ]; then
   echo "CRITICAL: $output"
   exit $CRITICAL
else
   echo "UNKNOWN: $output"
   exit $UNKNOWN
fi
 
wissen/nagios/nagios-tivoli-storage-manager-check-scratch-tapes.txt · Zuletzt geändert: 07.12.2009 15:14 von tirili
 
Recent changes RSS feed Donate Valid XHTML 1.0 Valid CSS Recent cached RSS feed cacert-signed web site: inhalt.serviert.de