Help with a filesystem monitoring script.


 
Thread Tools Search this Thread
Operating Systems AIX Help with a filesystem monitoring script.
# 1  
Old 05-05-2009
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.
# 2  
Old 05-05-2009
Search the forum and I am sure you will find many..

To get you started, here is a simple logic

Code:
ds=$( df -k | grep "filesystem" | awk '{print $5}' | sed 's/%//g')
if [ $ds -gt 90 ];
then
echo "exceeding"
mailx -s "FS Report" abc@dot.com ....
else
echo "fine"
fi


cheers,
Devaraj Takhellambam
# 3  
Old 05-05-2009
Thanks, I tried to look but maybe my search string wasnt accurate.
Is there a way to use case logic? To maybe add a few filesystem checks?
# 4  
Old 05-05-2009
Anyone know why this kicks out after the first check? I'd like it to continue to the next check regardless? Any input would be appreciated.

Code:
ds1=$( df -k | grep /dev/filesys1 | awk '{print $4}' | sed 's/%//')
if [ $ds1 -gt 75 ];
then
echo $ds1
echo "filesys1 exceeding"
continue
fi
ds2=$( df -k | grep /dev/filesys2 | awk '{print $4}' | sed 's/%//')
if [ $ds2 -gt 75 ];
then
echo $ds2
echo "filesys2 exceeding"
fi

Eventually I'd like to add more filesystems to check, but cant understand why it kicks out after first check and just displays:
Code:
78
filesys1 exceeding

And I know the 2nd check is exceeding as well.
# 5  
Old 05-06-2009
Try this

Code:
df -k | awk '$6 ~ /filesys1/||/filesys2/{print $5,$6}' | sed 's/%//g' | while read pct fs
do 
if [ $pct -gt 75 ]; then 
echo "exceeding FS for $fs: now at $pct%"
fi
done


cheers,
Devaraj Takhellambam

Last edited by devtakh; 05-06-2009 at 03:02 PM..
# 6  
Old 05-06-2009
@NycUnxer

Is the "continue" line in your script causing it to stop early? Is it correct for it to be there?
# 7  
Old 05-13-2009
Quote:
Originally Posted by garethr
@NycUnxer

Is the "continue" line in your script causing it to stop early? Is it correct for it to be there?
Its not necessary, was just trying different things.
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. UNIX for Dummies Questions & Answers

[Solved] Filesystem getting full. Need a monitoring script

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... (14 Replies)
Discussion started by: Soma Das
14 Replies

3. UNIX for Advanced & Expert Users

ldapsearch in monitoring script without bind password written in script

Hi I do a very simple monitoring of our OpenLDAP (runs in cronjob and generate alerts if unsuccessfull) $ ldapsearch -h hostname.domain -D "cn=monitor_user,ou=People,dc=organisation" -w "password" -b "dc=organisation" -x "(&(cn=monitor_user)(ou=People))" dn | grep -v version dn:... (4 Replies)
Discussion started by: slashdotweenie
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. AIX

Performance Monitoring of FileSystem

As I am new to the Unix field, I would like to get the clarification regarding the Filesystem. The scenario is.. The filesystem (/drbackup) is getting monitored and if it exceeds the threshold, we will receive an alert from it. The issue is that we receive an alert with the description of... (2 Replies)
Discussion started by: A.Srenivasan
2 Replies

7. Shell Programming and Scripting

Monitoring script

Hi, I want to write script that monitors particular ports in a server. I completed the script but.... If the server is restarted i need manually start the script.. Is there any way i can make the script start by it self after the server reboot........ Thanks, Firestar (4 Replies)
Discussion started by: firestar
4 Replies

8. Shell Programming and Scripting

Help with Monitoring script

Hi Gurus, Currently I am learning UNIX through online forums and unix blogs. I have the below requirement. I need to write a script to monitor server processes. For example, there are 3 processes currently running on the server.(java, pmrepagent, pmserver). If any of the process goes down,... (2 Replies)
Discussion started by: svajhala
2 Replies

9. 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

10. 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
Login or Register to Ask a Question