====== Nagios Script: tsm_library_path_online ====== Das folgende Skript wurde als Nagios Plugin erzeugt und ist ein einfaches Shell-Skript, welches prüft, ob alle Pfade online sind vorhanden sind. Schwellwerte: crit>=2, warn>=1 ===== Requirements ===== * bash * dsmadmc * dsm.sys * /etc/default/tsm_nagios.conf ANALYST_TSM01="analyst" ANALYPW_TSM01="password" ===== Syntax ===== * check_tsm_scratch -T -H -W -C * clientnode ist aktuell noch nicht definiert, es ist aber vorgesehen, damit das Skript auch für andere Queries verwendet werden kann. ===== Return-Codes ===== * [[http://nagiosplug.sourceforge.net/developer-guidelines.html#PLUGOUTPUT|plugin-returncodes]] ===== Skript ===== #!/bin/bash # License Information: #**************************************************** # Tivoli Storage Manager TSM Client * # check_tsm_library_state * # * # Nagios Plugin, welches prueft, ob alle Pfade * # online 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 < Check TSM Server for Information Usage:$0 -T -H -W -C Options: -h Print detailed help screen -V Print version information -T TSM Server Alias (from dsm.sys) -W Warning Threshold -C Critical Threshold -H currently not in use 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 PATH' CMD="sudo $DSMADMC -id=${DSMUSER} -pa=${DSMPASS} -se=$tsmsrv -dataonly=yes -displaymode=tab" $CMD "$QUERY" > /tmp/$(basename $0)-$$.tmp offline=$( awk 'BEGIN {offline=0} $NF !~ /Yes/ {offline++} END {print offline}' /tmp/$(basename $0)-$$.tmp ) overall_state=0 output="$offline offline" rm /tmp/$(basename $0)-$$.tmp if [ "$?" -ne 0 ]; then echo "UNKNOWN: $states" exit $UNKNOWN fi if [[ $offline -gt $warn ]]; then overall_state=$WARNING fi if [[ $offline -gt $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