- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Require assistance
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-05-2007 11:29 PM
тАО06-05-2007 11:29 PM
I am trying to automate a process.
Whenever the file system in HP-UX box got more than 85% I need to send a mail to my email-ID with the percentage of that volume and name of that volume.
Note, I don't want to get all the file systems info. I want only those whih are at 85% or more.
Also, can anybuddy help in finding out how to compare percentages in Shell Script.
e.g I wana to compare whether 45% is gt 65% or not.
Solved! Go to Solution.
- Tags:
- bdf
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-05-2007 11:53 PM
тАО06-05-2007 11:53 PM
Re: Require assistance
Schedule the following to run every 5 minutes or so...
# cat check_filesystem_usage.sh
#!/usr/bin/sh
typeset -i MAXPCT=85
typeset -i TIMEOUT=1 # number of days to retain LOCKFILE
BDFMEGS=/path/to/bdfmegs.sh
TEMPFILE=/tmp/check_filesystem_usage.${$}.tmp
LOCKFILE=/tmp/check_filesystem_usage.lck
# rm ${LOCKFILE} if mtime > ${TIMEOUT}, so that duplicate reports will be generated, on occasion
find ${LOCKFILE} -type f -mtime +${TIMEOUT} -print | xargs rm -f 2> /dev/null
[ ! -f ${LOCKFILE} ] && touch ${LOCKFILE}
trap "[ -f ${TEMPFILE} ] && rm -f ${TEMPFILE}" 0 1 2 3 15
${BDFMEGS} -qglP ${MAXPCT} | grep -v '^$' > ${TEMPFILE}
if [ -s ${TEMPFILE} ]
then
$(grep -q -v -f ${LOCKFILE} ${TEMPFILE}) && \
{ grep -v -f ${LOCKFILE} ${TEMPFILE} >> ${LOCKFILE}
mailx -m -s "WARNING! FILESYSTEM(S) OVER ${MAXPCT}% FULL!" your@email.addr << EOF
File-System Gbytes Used Avail %Used Mounted on
$(cat ${TEMPFILE})
Remember to delete ${LOCKFILE} after freeing up space!
EOF
}
# exit with rc of 1 if any filesystems with utilization > ${MAXPCT} were returned
exit 1
fi
# otherwise, exit with rc of 0
exit 0
This script relies on version 4.5 of Bill Hassell's bdfmegs script, available at the bottom of this thread:
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1124262
PCS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-06-2007 12:04 AM
тАО06-06-2007 12:04 AM
Re: Require assistance
> to compare percentages in Shell Script.
> e.g I wana to compare whether 45% is gt 65%
> or not.
I assume you are using the POSIX or Korn shell. Use variable substitution to strip the trailing '%':
$ A='45%'
$ B='65%'
$ echo ${A} ${B}
45% 65%
$ A=${A%%\%}
$ B=${B%%\%}
$ echo ${A} ${B}
45 65
$ [ ${A} -lt ${B} ] && echo true || echo false
true
PCS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-06-2007 12:14 AM
тАО06-06-2007 12:14 AM
Re: Require assistance
Seems to be helpfull to me.
Will try to use the same and then check whether working or not. :)
And yes, I am using Korn Shell.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-06-2007 02:22 AM
тАО06-06-2007 02:22 AM
SolutionThe attached script will do everything for you including preventing a storm of messages. It can notify one or several people by email, log the condition into syslog.log or send a notice to OpenView's Operations Center (or all three if desired). You set a default percentage level for all filesystems, perhaps 85%, and then customize specific filesystems at a different level such as 92%. And you also specify the growth value which is the amount that the filesystem must grow beyond the limit before another message is generated. This is the key to avoiding email storms. You can also exclude filesystems from being monitored by specifying 101% as the limit.
To use, store the attached script in your sysadmin script directory, then create the config file /etc/diskspace.conf file and create the two required lines: filesystem types and default percentages:
hfs vxfs
92 2
This specifies that only vxfs and hfs will be monitored and thatt the default for all filesystems is 92% or more and 2% growth for more messages. Then add additional lines for special handling such as:
/tmp 85 5
/extra 101 100
/usr 85 3
and that's it. You can test the output of the script without sending any notifications by leaving off any parameters. In that case, the output goes directly to stdout.
Now add the script to crontab to run as often as you'd like (I would not run it more than once every 5 or 10 minutes) and specify the options for notifications:
* 0,10,20,30,40,50 * * * /usr/local/sysadmin/diskspace.sh -e diskspace.sh@mysystem -s warn
Note the use of the script's name as the address. In /etc/mail/aliases, I create an alias for every script and then add the appropriate email addresses to the alias. That way, I don't have to code anything into the script or change crontab to send to different email addresses.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-06-2007 09:31 PM
тАО06-06-2007 09:31 PM
Re: Require assistance
One more thing, I am looking for a command which can filter out all the files which have been created or modified 15 days or before from the today's date.
Can you or any buddy else help me out in this too.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-06-2007 11:23 PM
тАО06-06-2007 11:23 PM
Re: Require assistance
> One more thing, I am looking for a command which can filter out all the files which have been created or modified 15 days or before from the today's date.
Can you or any buddy else help me out in this too.
If this is a new question, i would be preferrable that you create a new post.
Anyway,
try this solution:
mfifteendaysEarlier='0705240000'
mtoday='0706072359'
touch -t $mtoday /tmp/start
touch -t $mfifteendaysEarlier /tmp/finish
find . -xdev -type f -newer /tmp/start -a ! -newer /tmp/finish | xargs rm
(this is based on one solution that JRF provided once)
hope this helps!
kind regards
yogeeraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-06-2007 11:37 PM
тАО06-06-2007 11:37 PM
Re: Require assistance
I have started a new thread for the same question. Link is as below.
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1134277
Regards,
Ashish