#!/usr/bin/bash # # Written by Rob Moss, 2007-01-09 for Altinity Limited # coding@mossko.com # http://www.altinity.com # # Copyright (C) Rob Moss and Altinity Limited # This program 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; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # # $Id: check_veritas,v 1.2 2007/01/09 15:35:20 rmoss Exp $ # # check_veritas performs the following checks # - Checks the vxprint command can be run and returns with 0, or send critical # - Chceks for IPC Failure messages, sends critical # - Checks for any 'failing' warnings from vxprint, sends critical # - Checks through vxprint disks for errors, sends critical # - If all finish without errors, sends OK # vxprint=/usr/sbin/vxprint egrep=/usr/bin/egrep grep=/usr/bin/grep awk=/usr/bin/awk err=0 ipc="" ipcret="" vxprintout="" # Check if we can successfully run vxprint vxprintout="`$vxprint 2>&1`" ipcret=$? if [ $ipcret -ne 0 ]; then echo "CRITICAL: Problem running $vxprint, return code $ipcret" exit 2 fi # failing=on vxfailing=`$vxprint -a | $grep -c 'failing=on'` if [ $vxfailing -ge 1 ]; then echo "CRITICAL: Veritas volume failure!" exit 2 fi #ERROR: IPC failure ipc=`echo $vxprintout | $grep -c 'ERROR: IPC failure'` if [ $ipc -ge 1 ]; then echo "CRITICAL: IPC communication Failure!" exit 2 fi for line in `echo $vxprintout | $egrep -v -e 'ENABLED|^$' | $grep '^dm' | $awk '{print $2","$3","$7}'` do name=`echo $line | $awk -F, '{print $1}'` device=`echo $line | $awk -F, '{print $2}'` state=`echo $line | $awk -F, '{print $3}'` case $state in '-') # Safe ;; '- rootmirror') # Safe ;; '- rootdisk') # Safe ;; NOHOTUSE) # Safe ;; *) echo "CRITICAL: $name $device $state" err=2 break ;; esac done if [ $err = 0 ]; then echo "OK: All veritas volumes are clean" fi exit $err