LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-09-2013, 04:37 PM   #1
LittleMaster
Member
 
Registered: Jun 2012
Posts: 100
Blog Entries: 1

Rep: Reputation: Disabled
Need help in disk monitoring script in Solaris & Linux


Hi All,

I need help I could find below script works fine on all Unix Flavours except solaris .Kindly any one help me how can i make this scripts make work on all Unix Flavour

#!/bin/sh

warninglimit=40000
lowlimit=15000

filesystems="/opt/apps"

for fs in $filesystems
do
size=`df -kP $fs|grep $fs|awk '{ print $4; }'`
if [ $size -le $lowlimit ]
then
mailx -s "URGENT: Low disk space for $fs ($size)"
break
fi
if [ $size -le $warninglimit ]
then
mailx -s "WARNING: Low disk space for $fs ($size)"
fi
done
 
Old 12-09-2013, 04:48 PM   #2
berndbausch
Senior Member
 
Registered: Nov 2013
Location: Tokyo
Distribution: Redhat/Centos, Ubuntu, Raspbian, Fedora
Posts: 1,689

Rep: Reputation: 353Reputation: 353Reputation: 353Reputation: 353
Quote:
Originally Posted by LittleMaster View Post
Hi All,

I need help I could find below script works fine on all Unix Flavours except solaris .Kindly any one help me how can i make this scripts make work on all Unix Flavour
It would help if you posted the error message or whatever makes you think it doesn't work on Solaris.
 
Old 12-09-2013, 04:59 PM   #3
LittleMaster
Member
 
Registered: Jun 2012
Posts: 100
Blog Entries: 1

Original Poster
Rep: Reputation: Disabled
Error msg in Solaris .df -k seems to be working fine on solaris .How can i make my script to work on all Unix Flavours

bash-3.2$ df -kP df: unknown option: P
Usage: df [-F FSType] [-abeghklntVvZ] [-o FSType-specific_options] [directory | block_device | resource]
bash-3.2$

Last edited by LittleMaster; 12-09-2013 at 05:02 PM.
 
Old 12-09-2013, 08:03 PM   #4
berndbausch
Senior Member
 
Registered: Nov 2013
Location: Tokyo
Distribution: Redhat/Centos, Ubuntu, Raspbian, Fedora
Posts: 1,689

Rep: Reputation: 353Reputation: 353Reputation: 353Reputation: 353
Quote:
Originally Posted by LittleMaster View Post
Error msg in Solaris .df -k seems to be working fine on solaris .How can i make my script to work on all Unix Flavours

bash-3.2$ df -kP df: unknown option: P
Usage: df [-F FSType] [-abeghklntVvZ] [-o FSType-specific_options] [directory | block_device | resource]
bash-3.2$
-P means POSIX-compatible output. If this option is not available on Solaris, check what the output looks like there. Maybe you can just leave this option out.

On my Centos 6.5, df -kP has the following fields:
  1. Filesystem
  2. 1024-blocks
  3. Used
  4. Available
  5. Capacity
  6. Mounted on
Your script requires the fourth field (awk '{ print $4; }'), i.e. it checks for the amount of space available on the filesystem.

If df -k on Solaris also has the available space in the fourth field, you can just leave out the -P option. If not, you have to replace the $4 in the awk command by the correct field.
 
2 members found this post helpful.
Old 12-09-2013, 10:51 PM   #5
jsaravana87
Member
 
Registered: Aug 2011
Location: Chennai,India
Distribution: Redhat,Centos,Ubuntu,Dedian
Posts: 558
Blog Entries: 5

Rep: Reputation: Disabled
Hi


df -k works fine on all unix distribution .Alter your script using df -k

Last edited by jsaravana87; 12-09-2013 at 10:56 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell script results & memory monitoring tool happening.linux Linux - General 1 02-21-2011 06:38 AM
[SOLVED] hard disk space email notification - SOLARIS 10 - script dlugasx Solaris / OpenSolaris 1 06-24-2010 06:49 AM
Tools for monitoring disk io & io wait times Jukas Linux - Server 1 03-29-2010 08:34 PM
script for disk space monitoring jmmo1981 Red Hat 1 05-24-2008 11:25 AM
Redhat & solaris on 1 disk juby Linux - General 2 02-05-2003 03:43 AM


All times are GMT -5. The time now is 07:31 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration