Operating System - HP-UX
1846891 Members
3791 Online
110256 Solutions
New Discussion

Re: Script for capture bdf

 
SOLVED
Go to solution
Rene Mendez_4
Super Advisor

Script for capture bdf

Hi

I need create a script for capture the %use and name the logical volume, with this information send mail for monitoring volumen with 90% use.

Help me.

Regards
Rene
12 REPLIES 12
Helen French
Honored Contributor

Re: Script for capture bdf

Ramkumar Devanathan
Honored Contributor
Solution

Re: Script for capture bdf

#!/usr/bin/ksh
logname=/tmp/$(date +%Y%m%d).log
bdf | awk '$5 ~ "9[0-9]%|100%" {printf ("filesystem mounted at %s is running at
%s\n", $1, $5) ;}' > ${LOGNAME}

if [[ -s ${LOGNAME} ]]; then
cat ${LOGNAME} | mailx -s "Critical" mailid@yours.com
if [[ $? -eq 0 ]]; then
rm -f ${LOGNAME}
fi
fi
exit 0

HTH.
- ramd.
HPE Software Rocks!
Bill Hassell
Honored Contributor

Re: Script for capture bdf

Be careful about bdf...it has a script-unfriendly feature that breaks up very long source filesystems (ie, NFS mounts) into 2 lines. You can use the read shell-builtin to read each line and check if the second value (the total size) is "" which means the line was split, and if so, read the rest of the values in a second read.


Bill Hassell, sysadmin
hein coulier
Frequent Advisor

Re: Script for capture bdf

bdf|
tail +2|
awk '{ printf "%s", prev

if (substr($0,1,1) == "/")
{
print
}

prev=$0
}
END {
print prev
}'|
while read fs kbytes used avail pused mount
do
if [[ ${used} -ge 90 ]]
then
echo "${fs} ${used}| mailx -s "highwatermark exceeded" user@dom.com
fi
done

Mark Grant
Honored Contributor

Re: Script for capture bdf

Attached is a perl script that does it all for you including coping with bdf split over multiple lines. It also copes witht he different bdf formats of HPUX,AIX,Solaris and Linux. You define filesystem usage thresholds in a config file and it alerts when these get exceeded. You will need to change the $ALERT variable for mail and you might need to change a few hard coded paths.

I have attached an example config file as comments at the bottom of the script.
Never preceed any demonstration with anything more predictive than "watch this"
Rene Mendez_4
Super Advisor

Re: Script for capture bdf

hi Ramkumar Devanathan
run you script and output is:

#./prueba2
awk: The string filesystem cannot contain a newline character.
The source line is 1.
The error context is
$5 ~ "9[0-9]%|100%" {printf ("filesystem mounted at %s is running at >>>
<<<
syntax error The source line is 2.
awk: The statement cannot be correctly parsed.
The source line is 2.
awk: There is a missing } character.
awk: There is a missing ) character.
Regards
Rene
Ramkumar Devanathan
Honored Contributor

Re: Script for capture bdf

Try this script - no changes - removed the newline after "at ". the forums page added the newline - i didn't :D

- ramd.

HPE Software Rocks!
Rene Mendez_4
Super Advisor

Re: Script for capture bdf

Hi Ramkumar Devanathan

Script work but the nombre de lovical volumen is large and awk no take 5 colum and no work: Ejm:
/dev/vgbin/sybase12
2097152 501948 1495557 25% /sybase12
/dev/vgdb/tempdb01_log
720896 675077 42963 94% /tempdb01_log
/dev/vgdb/tempdb01_dat
2727936 2556663 160576 94% /tempdb01_dat
/dev/vgbck/deposito1
94355456 17457496 76298336 19% /deposito1
Ramkumar Devanathan
Honored Contributor

Re: Script for capture bdf

Rene,

Merci.

That's the little bit of French i know.

But I guess that you have a problem here - so please attach the output of your bdf command (as a text file) here and I'll try to provide you a fixed script which works!

- ramd.
HPE Software Rocks!
Rene Mendez_4
Super Advisor

Re: Script for capture bdf

HI

I send the dbf output the awk no capture the 5 column

Regards
Rene
Ramkumar Devanathan
Honored Contributor

Re: Script for capture bdf

Rene, try this script please.

Bill should've seen this coming - thanks.

- ramd.
HPE Software Rocks!
Rene Mendez_4
Super Advisor

Re: Script for capture bdf

HI Ramkumar Devanathan

Script work perfect.

Thanks

Regards
Rene