- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: check filesystem usage script
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
тАО10-02-2006 01:24 AM
тАО10-02-2006 01:24 AM
I have closed a previous thread and started this one as this should be more clear for what I require.
I want to create a script that prints the output to a file to be read by another program.
I want the filesystem usage to be recorded when a critical threshold and a warning threshold have been exceed.
here is a start to what i need ( this is on Linux)
DIR=/sysadmin/scripts/admin
LOG=$DIR/msgfile.out
WARN=70
CRIT=90
CMD=`df|awk 'NR>1 && !/\/proc$/ {print $7,$4}'|sed -e s/%//g -e s/' '/:/g`
FILESYS=`echo $CMD | cut -d":" -f1`
USED=`echo $CMD | cut -d":" -f2`
how can I create the output so the file looks something like:
WARNING ###########
/ is at 78%
/home is at 89%
CRITICAL ##########
/tmp is a 98%
/var is at 92%
Solved! Go to Solution.
- Tags:
- df
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-02-2006 01:27 AM
тАО10-02-2006 01:27 AM
Solution#!/bin/ksh
DIR=/sysadmin/scripts/admin
LOG=$DIR/msgfile.out
echo "####### WARNING ###########" > $LOG
bdf | grep -v "\/proc" | awk ' {print $5 " " $6} ' | sed 's/\%//'|awk '
{
if ( $1 > 50 )
if ( $1 < 80 )
print $2 " is at " $1 "%"
} ' >> $LOG
echo "####### CRITICAL ###########" >> $LOG
bdf | grep -v "\/proc" | awk ' {print $5 " " $6} ' | sed 's/\%//'|awk '
{
if ( $1 > 80 )
print $2 " is at " $1 "%"
} ' >> $LOG
exit
Yang
- Tags:
- bdf
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-02-2006 02:17 AM
тАО10-02-2006 02:17 AM
Re: check filesystem usage script
I make use of Bill Hassell's bdfmegs script to ensure 'bdf' output contains one line per filesystem.
# cat fs_warn.awk
BEGIN {
match=0;
}
{
if (NR > 1)
{
sub(/\%/,"");
}
if ($5>=70 && $5<90)
{
if (matched==0)
{
print "####### WARNING #######";
matched=1;
}
print $6, "is at", $5"%";
}
}
# cat fs_crit.awk
BEGIN {
match=0;
}
{
if (NR > 1)
{
sub(/\%/,"");
}
if ($5>=90)
{
if (matched==0)
{
print "####### CRITICAL #######";
matched=1;
}
print $6, "is at", $5"%";
}
}
# bdfmegs.sh | awk -f fs_warn.awk > logfile
# bdfmegs.sh | awk -f fs_crit.awk >> logfile
PCS
- Tags:
- bdfmegs
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-03-2006 12:02 AM
тАО10-03-2006 12:02 AM
Re: check filesystem usage script
WARN=10
CRIT=40
df|awk 'NR>1 && !/\/proc$/ {print $7,$4}'|sed 's/\%//'|awk '
{
if ( $2 > $WARN )
if ( $2 < $CRIT )
currently i have to use :
if ( $2 > 10 )
if ( $2 < 40 )
i have created a file with the various limits for $WARN and $CRIT therefore the setting entered into the awk will not always be the case.
thanks in advance
- Tags:
- awk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-03-2006 12:32 AM
тАО10-03-2006 12:32 AM
Re: check filesystem usage script
{
if ( $2 > WARN )
if ( $2 < CRIT )
Yang
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-03-2006 01:13 AM
тАО10-03-2006 01:13 AM
Re: check filesystem usage script
WARN=10
CRIT=40
df|awk 'NR>1 && !/\/proc$/ {print $7,$4}'|sed 's/\%//'|awk -v v1=$WARN -v v2=$CRIT '
{
if ( $2 > v1 )
if ( $2 < v2 )
Yang
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-04-2006 12:35 AM
тАО10-04-2006 12:35 AM
Re: check filesystem usage script
Chris