#!/bin/sh # # Copyright (C) 2008-2009 Equinox Software, Inc. # Written by Dave Brown # # 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. # # # Author : Dave Brown, Sys Admin, ESI # Last Updated : Sept 5, 2009 # Purpose : Check status of file name and process from CL variables. # Usage : check_lock scriptname=$0 filetocheck=$1 proctocheck=$2 if [ -f $filetocheck ]; then if [ "$(ps aux | grep -i $proctocheck | grep -v grep | grep -v $scriptname | wc -l)" -gt 0 ]; then echo "OK: $filetocheck exists and $proctocheck running" exit 0 else echo "CRIT: $filetocheck exists but $proctocheck not running" exit 2 fi else echo "OK: $filetocheck not found" exit 0 fi