Results 1 to 5 of 5
hi all,
I just found this script on net. However, im facing some problems running it.
Code:
#!/bin/bash
ALERT=70
ssh 10.61.37.176 df -H > /tmp/df.out
cat /tmp/df.out | grep -vE ...
- 10-21-2007 #1Just Joined!
- Join Date
- May 2007
- Posts
- 14
Shell script to monitor or watch the disk space.... small help needed
hi all,
I just found this script on net. However, im facing some problems running it.
Code:#!/bin/bash ALERT=70 ssh 10.61.37.176 df -H > /tmp/df.out cat /tmp/df.out | grep -vE '^Filesystem|tmpfs|cdrom' | awk '{ print $5 " " $1 }' | while read output; do #echo $output usep=$(echo $output | awk '{ print $1}' | cut -d'%' -f1 ) partition=$(echo $output | awk '{ print $2 }' ) if [ $usep -ge $ALERT ] then echo "Running out of space \"$partition ($usep%)\" on $(hostname) as on $(date)" fi done
I am using Sun OS. df -H, and grep -E options are not running.
I am getting these errors.
df: unknown option: H
Usage: df [-F FSType] [-abegklntVv] [-o FSType-specific_options] [directory | block_device | resource]
grep: illegal option -- E
Usage: grep -hblcnsviw pattern file . . .
pls help out !!
Thanks in adv.
- 10-21-2007 #2
It's been a while since I've used SunOS; I'm hoping someone who currently has access to it will jump in and help.
But.
According to the man pages, in the df command you should substitute -k for -H.
The usage of grep in the script is to weed out the lines of df output in which you're not interested. You should completely reconsider how to use grep in that situation, because I'm guessing the criteria for which to ignore certain df output lines is way, way different for your SunOS system than for a Linux system.
Furthermore, you should examine carefully the three uses of awk and the use of cut in this script, for the same reason: that the df output will be different on your system.
For purposes of comparison, you should do
on your system and compare it to this output fromCode:df -k
on my Linux system:Code:df -H
That output is likely to be in the same format for all Linux systems; I just did that df command on my ancient Slackware 9.1 system, but my wife's Kubuntu system (the latest and greatest, released for human consumption just a few days ago) shows the same output.Code:Filesystem Size Used Avail Use% Mounted on /dev/hda1 7.8G 3.2G 4.2G 44% / /dev/hda2 108G 27G 76G 26% /u /dev/hdc1 7.8G 3.4G 4.0G 47% /y /dev/hdc2 147G 19G 120G 14% /yu /dev/ram0 7.8M 16k 7.3M 1% /mr
For more information, google these items:
Hope this helps.Code:SunOS man df SunOS man grep SunOS man awk SunOS man cut Linux man df Linux man grep Linux man awk Linux man cut
Would a SunOS person please step forward and give more details?
- 10-21-2007 #3Linux User
- Join Date
- Aug 2006
- Posts
- 458
- 10-21-2007 #4Just Joined!
- Join Date
- May 2007
- Posts
- 14
hey, I got the solution.
Just replace df -H with df -k
and
grep -E with egrep
it works fine then.
thanks a lot.
- 10-21-2007 #5Just Joined!
- Join Date
- Oct 2007
- Posts
- 37
I think a lowercase h is what you probably wanted.


Reply With Quote