Find the answer to your Linux question:
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 ...
  1. #1
    Just Joined!
    Join Date
    May 2007
    Posts
    14

    Unhappy 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.

  2. #2
    Linux Engineer wje_lf's Avatar
    Join Date
    Sep 2007
    Location
    Mariposa
    Posts
    1,192
    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
    Code:
    df -k
    on your system and compare it to this output from
    Code:
    df -H
    on my Linux system:
    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
    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.

    For more information, google these items:
    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
    Hope this helps.

    Would a SunOS person please step forward and give more details?

  3. #3
    Linux User
    Join Date
    Aug 2006
    Posts
    458

  4. #4
    Just 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.

  5. #5
    Just Joined!
    Join Date
    Oct 2007
    Posts
    37
    I think a lowercase h is what you probably wanted.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...