watergrinder
MIS
Hi all,
I use the following script to check free disk space. The bdf statement below finds capacity ($5). However, it
should also scan filsystem (/dev/vg03/lvol1) so that it will report both filesystem name and capacity.
Can you please help?
Example bdf -i output:
/dev/vol1 17776640 9496240 8151084 54% 38 517514 0% /u03
Next, When I grep for three processes, here is the output
oracle 21649 1 0 21:00:18 ? 1:42 Process1
oracle 19950 1 0 Feb 14 ? 7:23 Process2
oracle 28098 1 0 08:06:40 ? 0:16 Process3
Now, Process2's $5 is different than the rest. Sometimes, it will be same. Therefore, is there a way to grep for
processname (Process1, Process2 ...). I am using the following script now, but it fails due to the above reason.
I use the following script to check free disk space. The bdf statement below finds capacity ($5). However, it
should also scan filsystem (/dev/vg03/lvol1) so that it will report both filesystem name and capacity.
Can you please help?
Example bdf -i output:
/dev/vol1 17776640 9496240 8151084 54% 38 517514 0% /u03
Code:
MAILADD=myself@mywebsite.com
# Define the hostname of the server
SRVNM=`uname -n`
# Command that finds disk space as percentage
bdf -i | awk 'FNR > 1 {sub(/%/,"",$5); print $5}' | while read CAPACITY
do
if test $CAPACITY -gt 10; then
mail $MAILADD <<EOF
From: Yahoo
To: $MAILADD
Subject: WARNING: $SRVNM FULL
$CAPACITY% capacity on $SRVNM.
EOF
fi
done
# Exit
exit 0
Next, When I grep for three processes, here is the output
oracle 21649 1 0 21:00:18 ? 1:42 Process1
oracle 19950 1 0 Feb 14 ? 7:23 Process2
oracle 28098 1 0 08:06:40 ? 0:16 Process3
Now, Process2's $5 is different than the rest. Sometimes, it will be same. Therefore, is there a way to grep for
processname (Process1, Process2 ...). I am using the following script now, but it fails due to the above reason.
Code:
MAILADD=myself@mywebsite.com
# Server name
SRVNM=`uname -n`
# Check if the processes are active. Loop through the process dat file, take each process and check if it is active.
# When it founds an inactive process, mail will be sent.
while read PROG
do
ANSWER=`ps -ef | grep -v grep | grep $PROG | awk '{ print $8 }'`
if test "$ANSWER" = "$PROG"; then
sleep 1
else
mail $MAILADD <<EOF
From: $0
To: $MAILADD
Subject: Missing process on $SRVNM
Checking $PROG on $SRVNM... not found!
EOF
fi
done < $DIR/monprocs.dat
exit 0