LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Need help in disk monitoring script in Solaris & Linux (https://www.linuxquestions.org/questions/linux-newbie-8/need-help-in-disk-monitoring-script-in-solaris-and-linux-4175487421/)

LittleMaster 12-09-2013 04:37 PM

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

berndbausch 12-09-2013 04:48 PM

Quote:

Originally Posted by LittleMaster (Post 5078104)
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.

LittleMaster 12-09-2013 04:59 PM

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$

berndbausch 12-09-2013 08:03 PM

Quote:

Originally Posted by LittleMaster (Post 5078113)
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.

jsaravana87 12-09-2013 10:51 PM

Hi


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


All times are GMT -5. The time now is 04:41 PM.