- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: help on scripting
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
тАО11-15-2006 09:21 PM
тАО11-15-2006 09:21 PM
I created a script to check file systems, I am struggling with getting the syntax correct where I create a control file with the limits then get the script to use this for $warn and $crit - ie:
filesystem warn crit
/home 75% 85%
/tmp 80% 90%
/usrdump 90% 96%
etc etc
how can I use the warn and crit variables in my script please?
#!/bin/ksh
# script to check the filesystem status
DIR=/sysadmin/scripts/admin
LOG=$DIR/msgfile.out
WARN=50
CRIT=70
>$DIR/msgfile.out
warning_func () {
echo "WARNING: Filesystem Alert" >> $LOG
df|awk 'NR>1 && !/\/proc$/ {print $7,$4}'|sed 's/\%//' |awk -v l1=$WARN -v l2=$CRIT '
{
if ( $2 > l1 )
if ( $2 < l2 )
print $1 " is at " $2"%"
}' >> $LOG
exit 1
}
critical_func () {
echo "CRITICAL: Filesystem Alert" >> $LOG
df|awk 'NR>1 && !/\/proc$/ {print $7,$4}'|sed 's/\%//' |awk -v l2=$CRIT '
{
if ( $2 > l2 )
print $1 " is at " $2"%"
}' >> $LOG
warning_func
}
for a in `df | awk 'NR>1 && !/\/proc$/ {print $7,$4}'| sed s/%//g | sed s/' '/:/g`
do
USED=`echo $a |cut -d":" -f2`
if [[ $USED -gt $CRIT ]] ; then
critical_func
fi
done
warning_func
Thanks guys.
chris
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-15-2006 09:33 PM
- Tags:
- while loop
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-15-2006 10:31 PM
тАО11-15-2006 10:31 PM
Re: help on scripting
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-15-2006 10:54 PM
тАО11-15-2006 10:54 PM
Re: help on scripting
cheers
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-15-2006 11:05 PM
тАО11-15-2006 11:05 PM
Re: help on scripting
see "man read"
"-r Do not treat a backslash character in any special way. Consider each backslash to be part of the input line."
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-16-2006 01:21 AM
тАО11-16-2006 01:21 AM
Re: help on scripting
Bill Hassell, sysadmin
- Tags:
- bdf
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-16-2006 01:39 AM
тАО11-16-2006 01:39 AM
Re: help on scripting
Great script btw Bill ...