AIX

AIX

Connect with fellow AIX users and experts to gain knowledge, share insights, and solve problems.


#Power
#Power
#Operatingsystems
#Servers
 View Only
  • 1.  Error: ./diskspace.sh[17]: -: more tokens expected

    Posted 05/22/08 02:50 PM

    Originally posted by: SystemAdmin


    The below are the contents of the script I am using for this job:

    #!/bin/sh
    1. Shell script to monitor or watch the disk space
    2. It will send an email to $ADMIN, if the (free avilable) percentage
    3. of space is >= 90%
    #<hr />
    #<hr />
    1. set admin email so that you can get email
    ADMIN="gareth.knowles@firstcaribbeanbank.com"
    1. set alert level 90% is default
    #ALERT=90
    ALERT=50
    df -P | grep -vE '^Filesystem|tmpfs|cdrom' | awk '{ print $5 " " $1 }' | while r
    ead 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 $(da
    te)" |
    mail -s "Alert: Almost out of disk space $usep" $ADMIN
    fi
    done

    This is line 17: if $usep -ge $ALERT ; then

    What I am I missing here?
    #AIX-Forum


  • 2.  Re: Error: ./diskspace.sh[17]: -: more tokens expected

    Posted 05/22/08 03:41 PM

    Originally posted by: SystemAdmin


    It's really hard to read your script the way the website has formatted it. I suggest you wrap it with the markup tags for code:
    {code}your code here{code}

    It looks like line 15 is not producing the result that you are expecting. I suggest you echo the result from line 15, before using $usep in line 17, to see what it contains...for example:

    
    usep=$(echo $output | awk 
    '{ print $1}' | cut -d
    '%' -f1 ) echo $usep
    


    I see you have already done this in other places for other intermediate values....

    Message was edited by: bfveale
    #AIX-Forum


  • 3.  Re: Error: ./diskspace.sh[17]: -: more tokens expected

    Posted 05/23/08 01:02 PM
      |   view attached

    Originally posted by: SystemAdmin


    Brian Veale,

    Thanks for the advice,

    After adding the echo command as suggested - echo $usep - the below was the output received:

    55
    48
    10
    28
    14
    -
    22
    4
    24
    35
    61

    Which is exactly the output I am looking for but the IF/THEN portion of the script seemed to be having issues with data being derived by LINE 15.

    The issue still appears to be at line 18.

    I am receiving the below output with the echo of $usep included - see below:

    55
    48
    10
    28
    14
    -
    ./diskspace.sh18: -: more tokens expected
    22
    4
    24
    35
    61

    I am attaching the script for your convenience.

    The below are the partitions I am running query on:

    /dev/hd4 0.06 0.03 55% 2434 26% /
    /dev/hd2 2.12 1.11 48% 30114 11% /usr
    /dev/hd9var 1.00 0.91 10% 589 1% /var
    /dev/hd3 1.06 0.77 28% 1379 1% /tmp
    /dev/hd1 1.00 0.86 14% 4440 3% /home
    /proc - - - - - /proc
    /dev/hd10opt 0.25 0.20 22% 2001 5% /opt
    /dev/lv00 0.31 0.30 4% 19 1% /sysdata
    /dev/lv01 8.00 6.10 24% 36890 3% /apps
    fctrng_01:/code 2.00 1.31 35% 33405 10% /code
    fctrng_01:/software 98.00 38.90 61% 151478 2% /software
    Thanks,

    Gareth..
    #AIX-Forum

    Attachment(s)



  • 4.  Re: Error: ./diskspace.sh[17]: -: more tokens expected

    Posted 05/23/08 01:06 PM

    Originally posted by: orphy


    Try fixing your df line with this

    df -P | grep -vE '^Filesystem|tmpfs|cdrom|^/proc'
    Orphy
    #AIX-Forum


  • 5.  Re: Error: ./diskspace.sh[17]: -: more tokens expected

    Posted 05/23/08 01:50 PM

    Originally posted by: SystemAdmin


    Orphy,

    That seemed to have resolved the error. Because /proc partition had no space parameters to query on I would assume - see below:

    /proc - - - - - /proc

    Now I will wait for the email to see if that portion works. But the script seems to be fine now.

    Thanks much guys,

    Gareth...
    #AIX-Forum