Operating System - HP-UX
1834346 Members
1832 Online
110066 Solutions
New Discussion

Re: "How to create a script to check filesystem reaching full capacity"

 
SOLVED
Go to solution
Reynaldo Torres
Advisor

"How to create a script to check filesystem reaching full capacity"

I'm trying to write a script that will check a particular filesystem or mount point to alert me is reaching a full capacity by e-mail, so I can move the oracle archives to the standby mount point. This script will be only temporary until we configured the new L class box. So far I have written part of it and works fine but I really don't want to check the mount point all the time I just want to be notified when is getting to the alert point. Kindly if anyone could help on this and give an example I will really appreciated due that my scripting skills are not that good. I'm attaching the script that so far I have wrote but I need the part where maybe an if statement will fit but I just don't know how to declare that part.


#!/bin/sh

# This is to check /u112 mount point from oracle archives

HOST=`hostname`
DATE=`date`

echo ""$HOST" ======================================== "$DATE"" > /tmp/bdf.doc
#
/usr/bin/bdf | grep u112 | /usr/bin/awk '{if ($5>=60){print $1" "$5" "$6}}' >> /tmp/bdf.doc
echo "=================================================" >> /tmp/bdf.doc
/usr/local/bin/mpack -s "Checking mount point u112" /tmp/bdf.doc torresr@hydroaire.com


Thank you so much,

Reynaldo Torres
torresr@hydroaire.com


Reynaldo Torres
11 REPLIES 11
A. Clay Stephenson
Acclaimed Contributor

Re: "How to create a script to check filesystem reaching full capacity"

Hi Reynaldo,

I think this script will get you started. I'll attach it as two replies. The first part is the script itself. I've commented where your mail command should go.


Clay
If it ain't broke, I can fix that.
A. Clay Stephenson
Acclaimed Contributor

Re: "How to create a script to check filesystem reaching full capacity"

Hi Again,

THe second attachment is the 'conf' file in which you specify the filesystems you wish to monitor and the threshhold at which you wish to issue a warning. You should probably put the script in cron and run it every so often.

Hope this gets you close, Clay
If it ain't broke, I can fix that.
MANOJ SRIVASTAVA
Honored Contributor

Re: "How to create a script to check filesystem reaching full capacity"

Hi Torress

Try thisDo the following



bdf | awk '{if ($5 > "90") print $NF,$5 }' > /tmp/test


This will create a file test in /tmp with the files sytems and the values of the usage. You can be creative in using this file as a form of mail , message etc . Run this as a part of script .

Manoj Srivastava


MANOJ SRIVASTAVA
Honored Contributor

Re: "How to create a script to check filesystem reaching full capacity"

Reynaldo Torres
Advisor

Re: "How to create a script to check filesystem reaching full capacity"

Clay and Mano I really appreciated the time you guys took to help me to create this script and think I have enough to get started with the two examples you sent me.

Thank you so much,

Reynaldo Torres.
Reynaldo Torres
Omar Vallejos
New Member

Re: "How to create a script to check filesystem reaching full capacity"

What you need is a filesystem monitor and wait for an alert. Think about a monitor named /system/filesystem/availMB. This monitor does exist and it is supported!
Have you ever tried EMS ? EMS = Event Monitor Services. It's free, it's superb. Is part of the Online Diagnostics, on HP-UX 11 you just install Online Diagnostics in minutes, no need to reboot. Then use SAM, (thru X-Windows or you'll hate it) to configure and add/remove the available space monitor. This monitor may send messages to console, syslog, text log, or send e-mail, etc. For example: console messages if availMB is less than xx MB, email if less than yy MB. If the e-mail address is that of your pager... In summary: you don't need to invest your calories checking your system. Just relax and wait for the event to call you. You may find many meesages regarding EMS and filesystem in "forums > hp-ux > system administration ".
Reynaldo Torres
Advisor

Re: "How to create a script to check filesystem reaching full capacity"

Thanks Guillermo Rodriguez for your input I will look into this tool as well to see what I can gain by installing it. Thanks again.

Reynaldo Torres
Reynaldo Torres
Omar Vallejos
New Member

Re: "How to create a script to check filesystem reaching full capacity"

I am at HP Argentina and wrote a document explaining how to get EMS software and docs., installation and a couple of hints to use it.
The bad news (or not) is that is written in Spanish...
My e-mail is: guillermo_rodriguez@hp.com
Magdi KAMAL
Respected Contributor
Solution

Re: "How to create a script to check filesystem reaching full capacity"

Hi ,

you may crete the following script:

limit=80
v0=`mount ? awk ?{print $1}?`
for mPoint in $v0
do
v1=`df -k /usr | awk '{ print $1 }'`
v2=`echo $v1 | awk '{ print $4 }'`
echo $v2
if [[ $v2 > $limit ]]
then
echo " File system $mPoint is $v2 \% used ."
fi
done


Magdi KAMAL
Respected Contributor

Re: "How to create a script to check filesystem reaching full capacity"

Hi ,

I'm sorry, the line :

v1=`df -k /usr | awk '{ print $1 }'`

must be replaced by

v1=`df -k $mPoint| awk '{ print $1 }'`


Reynaldo Torres
Advisor

Re: "How to create a script to check filesystem reaching full capacity"

This message is for Magdi Kamal, Hey!! thank you very much for the script you have sent to me it really works and now I have wrotte four different scripts with all the scripts that I got from you guys. I really appreciated and I hope my replied is not to late for you my friend.

Thanks again.

Reynaldo Torres.
Reynaldo Torres