Quota threshold


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Quota threshold
# 1  
Old 02-10-2009
Quota threshold

Hi,
I am trying to make a script in which the user is notified once the disk space of the environment increases a particular threshold.
I have made a script for it but I am facing an error while executing it.

Could any one here guide me further??

Script

#!/bin/sh
warninglimit=350000
lowlimit=250000

filesystems="/export /home/t2/"
for fs in $filesystems
do
size=`df -k $fs|grep $fs|awk '{ print $4; }'`
if [ $size -le $lowlimit ]
then
mailx -s "URGENT: Low disk space for $fs ($size)" -r
abc@sd.com
break
fi
if [ $size -le $warninglimit ]
then
mailx -s "WARNING: Low disk space for $fs ($size)" -r
abc@sd.com
fi
done


Error-
df: open of /export failed
test.sh[10]: test: Specify a parameter with this command.
test.sh[15]: test: Specify a parameter with this command.


Any help what so ever may be very useful for me.

Thanks ...

Taran
# 2  
Old 02-10-2009
As it already says, the df for /export fails. So the variable $size will not contain anything useful.

Checking the line where you define $size, we see your variable $fs, being part of the list $filesystems.

The problem is, that the "for" doesn't get the values of $filesystems as single elements - it takes them as one. And there is no filesystem called "/export /home/ts".

So add the line
Code:
IFS=" "

to help for/do/done to parse the value of $filesystems as single values.

Example:
Code:
root@isau02:/etc/apt> filesystems="/export /home/t2/"
root@isau02:/etc/apt> for bla in ${filesystems}; do echo ${bla}; done
/export /home/t2/                                        # it takes it as a single value, ignoring the blank
root@isau02:/etc/apt> IFS=" "
root@isau02:/etc/apt> for bla in $filesystems; do echo $bla; done
/export
/home/t2/

You can debug your shell scripts easily by echoing variables in between and use options like "set -x" or "set -xv".
# 3  
Old 02-10-2009
Quote:
Originally Posted by zaxxon
As it already says, the df for /export fails. So the variable $size will not contain anything useful.

Checking the line where you define $size, we see your variable $fs, being part of the list $filesystems.

The problem is, that the "for" doesn't get the values of $filesystems as single elements - it takes them as one. And there is no filesystem called "/export /home/ts".

So add the line
Code:
IFS=" "

to help for/do/done to parse the value of $filesystems as single values.

Example:
Code:
root@isau02:/etc/apt> filesystems="/export /home/t2/"
root@isau02:/etc/apt> for bla in ${filesystems}; do echo ${bla}; done
/export /home/t2/                                        # it takes it as a single value, ignoring the blank
root@isau02:/etc/apt> IFS=" "
root@isau02:/etc/apt> for bla in $filesystems; do echo $bla; done
/export
/home/t2/

You can debug your shell scripts easily by echoing variables in between and use options like "set -x" or "set -xv".


Hi,

thanks for replying...
I got the point that something is wrong with my loop.

Could you guide me the way around this problem which could solve my purpose...

Thanks
# 4  
Old 02-11-2009
I did not just reply, I also guided you. Which part wasn't clear?
# 5  
Old 02-11-2009
QUOTA threshold

Hi,

I didn't understand your solution for the problem.

Kindly be a bit more comprehensive...

Thanks
# 6  
Old 02-11-2009
There is no problem with your loop itself.
The value of your variable $filesystems is interpreted as 1 value, not 2 which are separated by a blank. So your for-loop will take it as 1 value instead of 2. To fix this, you can add the following line
Code:
IFS=" "

in the head of your script and try again.
# 7  
Old 02-11-2009
QUOTA Threshold

Hi ,

Thanks for the reply.

I again tried by implementing your comment ,but still I am getting the same error...
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Threshold for swap memory

hi guys the monitoring team is using a tool for monitoring linux boxes and they set an alarm for swap memory to 10%(critical) I really has no idea when swap memory usage is high.... Can someone recommend me a threshold for this? when is warning or critical and this parameters can affect... (3 Replies)
Discussion started by: karlochacon
3 Replies

2. Shell Programming and Scripting

Diff two files with threshold value

i have two big file which have thousand of line. i have to sort on two key fields then diff the file. if the interger value of one of the column is less then or greater then 1 it should ignore it. for example File1 abc|7000|jhon|2.3 xyz|9000|sam|6.7 pqr|8000|kapi|4.6 File2... (11 Replies)
Discussion started by: Nishi2011
11 Replies

3. Solaris

Rootvol above threshold

Hi there, Root filesystem is above threshold, I have search and cleared unwanted files which are filling up space. But the root fs is still above threshold. I don't know about veritas volume management. Can anyone show me how to solve this. Du shows /proc is occupying a lot of space. Most of the... (2 Replies)
Discussion started by: sundar63
2 Replies

4. UNIX for Dummies Questions & Answers

threshold

Hi, I have a table with 14 columns. How can I filter the columns 2-14, so that I get only those rows back in which the data values are >= 6 in 5 or more columns. :confused: E.g. A 6 6 3 6 7 8 B 1 2 3 4 5 5 C 2 2 2 6 7 8 Here I should only get back the row A. I would like to work from... (5 Replies)
Discussion started by: danieladna
5 Replies

5. UNIX for Dummies Questions & Answers

Load Average threshold

What should be the threshold for load average of a quad core processor? What constitutes "good" and "bad" load average values? (2 Replies)
Discussion started by: proactiveaditya
2 Replies

6. UNIX for Advanced & Expert Users

how to lessen the threshold of diskusgae %

Hi experts, I found- $ tail -f /var/adm/messages .... .... Jan 17 05:16:31 server01b last message repeated 6 times Jan 17 05:17:05 server01c ufs: NOTICE: alloc: /var/fileserver:file system full but I checked with df -k and found /var/fileserver is only 49% is used. It means... (7 Replies)
Discussion started by: thepurple
7 Replies

7. Shell Programming and Scripting

Check Quota of the Environment and mail the user if the threshold increases.

Hi All, I wish to check the quota of the system and if it increases the threshold value,I need that a mail is shot to the environment user informing hi/her about the same. I know it can be done using cron jobs and warnquota command but I am unable to implement it as I am not acquianted with... (1 Reply)
Discussion started by: Taranjeet Singh
1 Replies

8. UNIX for Advanced & Expert Users

Check Quota of the Environment and mail the user if the threshold increases.

Hi All,I wish to check the quota of the system and if it increases the threshold value,I need that a mail is shot to the environment user informing hi/her about the same.I know it can be done using cron jobs and warnquota command but I am unable to implement it as I am not acquianted with both... (1 Reply)
Discussion started by: Taranjeet Singh
1 Replies

9. Shell Programming and Scripting

apache threshold

Hi folks, how can i check apache threshold values via shell scripting and what factors need to check via shell scripting process or number of users or what. pls do advice me. Thanks, Bash (9 Replies)
Discussion started by: learnbash
9 Replies
Login or Register to Ask a Question