[Solved] Filesystem getting full. Need a monitoring script


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers [Solved] Filesystem getting full. Need a monitoring script
# 8  
Old 09-13-2012
According to the man page "k"or "M" can be used for kilobytes and megabytes in
Code:
-size

option.

By default it is byet block if nothing is specified.
I wanna know how to use these "k" or "M" options because i am getting error while using them.
# 9  
Old 09-13-2012
well on my HP-UX11.11 I get the same message as you.. but it works on AIX... Now my man (HPUX...) says:
Code:
    
 -size n[c]               True if the file is n blocks long (512 bytes
                               per block).  If n is followed by a c, the
                               size is in bytes.

# 10  
Old 09-13-2012
Yes that is correct. I have wrote down the the script for filesystem full

Code:
#!/bin/sh
count1= df -k /home |awk 'FNR == 4 { print $1 }'
if [$count1 -gt 80]
then
echo "file system full"
#mailx -s "File System full" mailid@domain.com
fi

but it is giving me an error xxxx.sh[3]: test: A ] character is missing.
i am not able to find what it means, can you advise.
# 11  
Old 09-13-2012
By cron ?

Quote:
Originally Posted by Soma Das
Hi,

I am new to shell scripting in unix HP-UX.

I need to determine how much a perticular file system is full and if it goes over 80% it should notify through mail about which are the files which are greater than 1 GB size.

I used df -k command it is showing the alloocated KB and the %used in that FS. But how to get it through script and find the files > 1 GB.

Can anybody advise?
Hello,
for HP-UX 11i server i use this script with cron to monitor a special mount point.

Code:
#!/usr/bin/sh
#BD20081020 at rp3410 HP-UX 11i 96%

used_space=0
mount_point=/daten/tmp
#threshold=80
threshold=96

used_space=`df -k $mount_point | grep % | sed 's/  */ /g' | sed 's/% allocation
used//g'`

#echo "At $mount_point $used_space % Used"


#echo "Free space at $mount_point ist `expr 100 - $used_space`%.\n"

if [ "$used_space" -gt "$threshold" ]

then

#echo "Diskspace at $mount_point has grown over $threshold %
!"

echo  "Diskspace at $mount_point has reached $threshold %
!" > /home/ba_scripts/mountpoint

mailx -s "Warning !" user1@domain.com < /home/ba_scripts/mountpoint
mailx -s "Warning !" user2@domain.com < /home/ba_scripts/mountpoint
mailx -s "Warning !" user3@domain.com < /home/ba_scripts/mountpoint

fi

This User Gave Thanks to bdittmar For This Post:
# 12  
Old 09-13-2012
Hi, i used your code. But it is giving me an error
Code:
sed: Function s/% allocation cannot be parsed.

do u have any idea how it can be resolve?
# 13  
Old 09-13-2012
Code:
used_space=`df -k $mount_point | grep % | sed 's/  */ /g' | sed 's/% allocation used//g'`

Works perfectly.. I tried...

Bdittmar is someone I remember from the time I was on ITRC I trust...

Last edited by vbe; 09-13-2012 at 12:24 PM..
This User Gave Thanks to vbe For This Post:
# 14  
Old 09-13-2012
Thanks it working now.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Script for Monitoring Root Filesystem

I am on SCO UNIX, I need to write a script to monitor root file system. For some reason it's not working for me. #!/bin/sh df -B / | awk '{ print $5 " " $1 }' | while read output; do echo $output if ; then echo "Running out of space \ HOSTNAME" # mail -s "Alert: Almost out of... (8 Replies)
Discussion started by: samnyc
8 Replies

2. Solaris

Filesystem Full

In our shop we have to run a batch cycle. Every so often while we are running batch we get a filesystem full situation that causes batch to stop or slow down. Anyway, the practiced procedure is to look for large files and zip them. This takes a lot of time. We are in a sun solaris environment. What... (1 Reply)
Discussion started by: Harleyrci
1 Replies

3. Shell Programming and Scripting

[Solved] File System Monitoring Script

Hello Scripts Guru I had created a shell script to monitor the threshold of the file system, but some where it is not giving the correct output. Request to all to hel me out I am getting the following output /dev/vg00/lvol3 mounted on 1865224 10% / is 2097152% /dev/vg00/lvol1 mounted on... (2 Replies)
Discussion started by: indrajit_renu
2 Replies

4. Shell Programming and Scripting

Monitoring Script - filesystem

Hi all, I got an error when running this script (from BigAdmin community) the error is test: argument expected my server version is SunOS XXX 5.8 Generic_117350-46 sun4u sparc SUNW,Sun-Fire-V890 any idea on it? #! /usr/bin/ksh ### ### This script can be run from cron to... (9 Replies)
Discussion started by: SmartAntz
9 Replies

5. AIX

Help with a filesystem monitoring script.

I'd like to create a cron script that checks filesystems. For example if it reaches 95% USED, I'd like it to send me an email. Can this be possible for up to say 4 filesystems using the df -k command? Any samples to get me started would be much appreciated. (7 Replies)
Discussion started by: NycUnxer
7 Replies

6. UNIX for Dummies Questions & Answers

filesystem is full

Hello everybody, a very basic question. Inspite of me deleting huge files in a filesystem(AIX 5.3) in oracle folder, the filesystem when i check using df -k still shows 100% full. Does that mean there is a process still pointing to the files which i deleted. how do i work around this. Thanks!... (3 Replies)
Discussion started by: karthikosu
3 Replies

7. UNIX for Dummies Questions & Answers

filesystem full

my root filesystem is eventually full "/dev/rdsk/c1d0s0" as a result i cannot boot to the operating system, i booted into the fail safe mode to check the space using df -h command i discover that it is eventually full. Also to my amazement i found that i cannot see the filesystem which mounted on... (1 Reply)
Discussion started by: seyiisq
1 Replies

8. Shell Programming and Scripting

Filesystem Monitoring script problems

Hi there all, #!/usr/bin/ksh Set -x MIN_MB_FREE="100MB" # Min. MB of Free FS Space MAX_PERCENT="85%" # Max. FS percentage value FSTRIGGER="1000MB" # Trigger to switch from % Used to MB Free WORKFILE="/tmp/df.work" # Holds filesystem data >$WORKFILE #... (0 Replies)
Discussion started by: draco
0 Replies

9. UNIX for Dummies Questions & Answers

Filesystem Full

I noticed that whenever something is printed from my workstation, the available disk space in the /dev/dsk/c0t0d0s0 decreases considerably. Hence, after using my workstation for sometime, I encounter an error message: "Filesystem Full" that prevents me from printing any further. Is there a way to... (16 Replies)
Discussion started by: ilak1008
16 Replies

10. UNIX for Dummies Questions & Answers

need a unix script to let me know by email or pager when the filesystem is 80% full.

Does anyone have a script to check disk space usage. My backup directory keeps filling up with archivelog files and I need a script to let me know by email or pager when the filesystem is 80% full. Thank you! (1 Reply)
Discussion started by: jzjy0r
1 Replies
Login or Register to Ask a Question