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.
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
to help for/do/done to parse the value of $filesystems as single values.
Example:
You can debug your shell scripts easily by echoing variables in between and use options like "set -x" or "set -xv".
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
to help for/do/done to parse the value of $filesystems as single values.
Example:
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...
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
in the head of your script and try again.
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)
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)
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)
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)
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)
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)
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)
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)