- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: How to configure one script to send mail alert...
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
тАО07-06-2010 05:24 AM
тАО07-06-2010 05:24 AM
I have written one script and configured that in crontab for sending mail alerts if filsystem is reaching thrushold of 90%.
For example:
1)#vi /usr/local/bin/disk_full.sh
#!/bin/sh
bdf | awk 'z[split($5,z,"%")-1]>90' | mailx -r senthil.kumar@emdiesels.com -s "$HOST Filesystems > 90%" abc@yahoo.co.in
2)crontab -e
########### Send mail alerts if any filesystem reaches thrushold 90%##########
1 * * * * /usr/local/bin/disk_full.sh
##########################################################
I have written above script to check if any of the filesystes is reaching thrush hold of 90% for every one hour and send mails if any of the filesystems is reached 90%.
It is working fine.
But I have following issues.
My Issue:
I am getting blank mail alerts even if any of filesystems is not reaching 90%. Therefore I am getting one mail from for ever one hour even if there is no filesystem is reached thrush hold of 90%.
My Requirement:
I would like to receive mail alerts only if any of the file system is reaching thrush hold of 90% but not for empty (If there is no filesystems reached 90%).
How to resolve this.
Solved! Go to Solution.
- Tags:
- bdf
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-06-2010 05:46 AM
тАО07-06-2010 05:46 AM
Re: How to configure one script to send mail alerts if filesystem is reaching 90%
As written, regardless of any output, 'mailx' is spawned by the pipe. Hence, you unconditionally get mail regardless of the utilization threshold.
You could do:
# [ -z "$(bdf|awk 'z[split($5,z,"%")-1]>90')" ] || mailx ...
...or capture the output; test the output for emptiness and email the non-empty result.
# RESULTS=$(bdf|awk 'z[split($5,z,"%")-1]>90')
# [ -z "${RESULTS}" ] || mailx ...
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-06-2010 05:55 AM
тАО07-06-2010 05:55 AM
Re: How to configure one script to send mail alerts if filesystem is reaching 90%
By the way, you have a recently growing number of questions you have asked without any point assignment whatsoever:
http://forums.itrc.hp.com/service/forums/pageList.do?userId=WW220552&listType=unassigned&forumId=1
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-06-2010 06:01 AM
тАО07-06-2010 06:01 AM
Re: How to configure one script to send mail alerts if filesystem is reaching 90%
Got so many thread see the below
http://forums11.itrc.hp.com/service/forums/questionanswer.do?admit=109447626+1278423920446+28353475&threadId=1130400
http://forums11.itrc.hp.com/service/forums/questionanswer.do?threadId=1336882
http://forums11.itrc.hp.com/service/forums/questionanswer.do?threadId=1100009
http://forums11.itrc.hp.com/service/forums/questionanswer.do?threadId=1064880
http://forums11.itrc.hp.com/service/forums/questionanswer.do?threadId=800551
here is the script i am using.
#!/usr/bin/ksh
PATH=/usr/bin:/usr/sbin
CONF_FILE=fs_check.conf.txt
# Source default env vars
. ${CONF_FILE}
# Count number of FS to check
i=${#FS[*]}
# Check each Filesystem
while [ "$(($i-1))" -ge "0" ]
do
let i=i-1
PCT=$(bdf ${FS[$i]} | awk '/\// {print $5}' | tr -d '%')
if [ ${PCT} -gt ${TRESH[$i]} ]
then
if [ "90" -le ${PCT} ]
then
echo "FATAL: Out of disk space for ${FS[$i]}!" | mailx -s FS_FATAL me@company.com
else
echo "WARNING: Threshold exceeded for ${FS[$i]}, it is now ${PCT}." | mailx -s FS_WARNING me@company.com
fi
fi
done
exit 0
Suraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-06-2010 06:56 AM
тАО07-06-2010 06:56 AM
Re: How to configure one script to send mail alerts if filesystem is reaching 90%
I have modified the file "/usr/local/bin/disk_full.sh" as following
# more /usr/local/bin/disk_full.sh
#!/bin/bash
RESULTS=$(bdf | awk 'z[split($5,z,"%")-1]>90')
[ -z "${RESULTS}" ] | mailx -r senthil.kumar@emdiesels.com -s "$HOST Filesystems > 90%" senthil.kumar@emdiesels.com
Still I am getting alerts with empty message.
How to resolve.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-06-2010 07:04 AM
тАО07-06-2010 07:04 AM
Re: How to configure one script to send mail alerts if filesystem is reaching 90%
> [ -z "${RESULTS}" ] | mailx ...
You didn't copy what I wrote and made the same mistake as you originally had. You don't want a pipe ('|') you want the logical relation ('||') as:
# [ -z "${RESULTS}" ] || mailx ...
...which says if the variable called RESULTS is not empty, run the command 'mailx'.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-06-2010 07:14 AM
тАО07-06-2010 07:14 AM
Re: How to configure one script to send mail alerts if filesystem is reaching 90%
Still the issue is not resolved.
1)# more disk.sh
#!/bin/bash
RESULTS=$(bdf | awk 'z[split($5,z,"%")-1]>90')
[ -z "${RESULTS}" ] || mailx -r abc@company.com -s "$HOST Filesystems > 90%" abc@company.com
2)# ll disk.sh
-rwxr-xr-x 1 root root 145 Jul 6 09:51 disk.sh
3)#./disk.sh
Now it is hanging , I have waited for about 10 mins. however the above script is not exectued.
So pressed "ctrl + c" , now I got follwoing output.
(Interrupt -- one more to kill letter)
Then again I pressed "ctrl + c" , now I got the prompt.
#
How to resolve.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-06-2010 07:21 AM
тАО07-06-2010 07:21 AM
Re: How to configure one script to send mail alerts if filesystem is reaching 90%
> Now it is hanging , I have waited for about 10 mins. however the above script is not exectued.
You need to provide an some input (even if this input is "empty".
You could do:
# [ -z "${RESULTS}" ] || mailx -r abc@company.com -s "$HOST Filesystems > 90%" abc@company.com < /dev/null
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-06-2010 08:47 AM
тАО07-06-2010 08:47 AM
SolutionRight. You can also echo $RESULT or read from some file:
[ -z "${RESULTS}" ] || echo "$RESULT" | mailx -r abc@company.com -s "$HOST Filesystems > 90%" abc@company.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-06-2010 09:41 AM
тАО07-06-2010 09:41 AM
Re: How to configure one script to send mail alerts if filesystem is reaching 90%
I like the concept for detecting the file systems above 90%. Note that if you have openview ITO, you can get this functionality without a script.
You might try putting your output to a file and using http://hpux.ws/mailfile2 to email the output as an attachment.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com