Filesystem Usage Script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Filesystem Usage Script
# 1  
Old 12-05-2010
Filesystem Usage Script

Hey guys I am learning Linux and I am working on script for a college class project to check usage of file system. I pulled this from a different site but have to tweak it a little to work but I still get errors. Here is what I got so far.
Code:
ALERT=5
function main_prog() {
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 system $(hostname), $(date)" 
  fi
done
}
df -H | grep -vE "^Filesystem|tmpfs|cdrom" | awk '{print $5 " " $6}' | main_prog

This is what I get when I execute
Code:
line 22: [: : integer expression expected
line 22: [: /: integer expression expected
Running out of space "/boot (8%)" on system *.localdomain, Sun Dec  5 16:51:47 EST 2010

I just want to know how to get rid of the line 22 integer expression expected
Thanks for the help.

Last edited by Scott; 12-05-2010 at 07:18 PM.. Reason: Added code tags
# 2  
Old 12-05-2010
Don't forget to use code tag in this forum.

Code:
ALERT=5
df -k -F ufs |awk -v a=$ALERT 'int($5)>a {print "Running out of space ", $6 , $5 }'

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Space usage by top 5 users in a filesystem

I want to see top 5 users,who have occupied most amount of disk space in a filesystem. But not sure how to do it. I can get the usage for a particular user find . -user user -type f exec df -h {} \;|awk '{ s = s+$1 } END { print "Total used: ",s }' But how to get without specifying any user... (6 Replies)
Discussion started by: rka
6 Replies

2. Shell Programming and Scripting

Shell script to calculate the max cpu usage from the main script

Hi All, I have a script which does report the cpu usuage, there are few output parameter/fields displayed from the script. My problem is I have monitor the output and decide which cpu number (column 2) has maximum value (column 6). Since the output is displayed/updated every seconds, it's very... (1 Reply)
Discussion started by: Optimus81
1 Replies

3. Solaris

Solaris Filesystem usage discrepancy after "copy"

I have a query someone may be able to shed some light on... We have a Solaris 10 OS Sun V490 server Sparc. I have a SAN attached EMC Clarrion LUN which we have app data stored on. Pseudo name=emcpower0a CLARiiON ID=CK200070300470 Due to storage requirements - I need to migrate this... (4 Replies)
Discussion started by: ru4n1
4 Replies

4. AIX

Mount Filesystem in AIX Unable to read /etc/filesystem

Dear all, We are facing prolem when we are going to mount AIX filesystem, the system returned the following error 0506-307The AFopen call failed : A file or directory in the path name does not exist. But when we ls filesystems in the /etc/ directory it show -rw-r--r-- 0 root ... (2 Replies)
Discussion started by: m_raheelahmed
2 Replies

5. UNIX for Dummies Questions & Answers

hwo to find shared filesystem and local filesystem in AIX

Hi, I wanted to find out that in my database server which filesystems are shared storage and which filesystems are local. Like when I use df -k, it shows "filesystem" and "mounted on" but I want to know which one is shared and which one is local. Please tell me the commands which I can run... (2 Replies)
Discussion started by: kamranjalal
2 Replies

6. Shell Programming and Scripting

Filesystem usage with more than 80%.

Hi All, I need to display the output of rah "df -m" only for the filesysytems those are touching or crossing 80%. Im using SuSE Linux box and the output of original rah command is- /dev/NODE0001 557900 446681 83319 75% /db2fs/NODE0001 /dev/NODE0002 ... (5 Replies)
Discussion started by: NARESH1302
5 Replies

7. AIX

How to monitor the IBM AIX server for I/O usage,memory usage,CPU usage,network..?

How to monitor the IBM AIX server for I/O usage, memory usage, CPU usage, network usage, storage usage? (3 Replies)
Discussion started by: laknar
3 Replies

8. Solaris

Filesystem Usage

Hi Guys... I want to change the below script to send an alert when my file system is greater than 5G. # If any filesystem has less than 5k, issue an alert if Regards (3 Replies)
Discussion started by: Phuti
3 Replies

9. HP-UX

how can I find cpu usage memory usage swap usage and logical volume usage

how can I find cpu usage memory usage swap usage and I want to know CPU usage above X% and contiue Y times and memory usage above X % and contiue Y times my final destination is monitor process logical volume usage above X % and number of Logical voluage above can I not to... (3 Replies)
Discussion started by: alert0919
3 Replies

10. Programming

how to get filesystem usage in c

hi, everyone Can anybody tell me how to get free blocks and total blocks of filesystem in c. I am working on a hp-unix Thanks in advance. (8 Replies)
Discussion started by: mika
8 Replies
Login or Register to Ask a Question