Computing.Net > Forums > Solaris > new to scripting pls help

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

new to scripting pls help

Reply to Message Icon

Name: anthonyr
Date: February 13, 2006 at 16:33:13 Pacific
OS: solaris 9
CPU/Ram: 2GB
Product: V210
Comment:

Hi i am having this problem with one of my solaris machines. the /var slice is filling up and if i don't check on a regular basis i might miss something. So what i have done set a cron job to email me everyday the df -k,which work ok, but what i am trying to do is to email if the /var slice gets over 90% capacity. I am new to solaris and scripting, can anybody help me out there
cheers




Sponsored Link
Ads by Google

Response Number 1
Name: David Perry
Date: February 16, 2006 at 08:43:06 Pacific
Reply:

#!/bin/ksh
MAILTO="user@host.com"
echo "df -k output for `date` `uname -a`" > /tmp/df.out
case `uname -s` in
SunOS | Linux | OSF1 | UNIX_SV | FreeBSD )
if [ -s "/etc/redhat-release" ] ; then cat /etc/redhat-release >> /tmp/df.out ; fi
set -- `df -k | sed -e 's/%//g' | awk '/^\/dev/ { printf("%s %s\n", $5, $6) }'`
;;
HP-UX )
set -- `bdf | sed -e 's/%//g' | awk '/^\/dev/ { printf("%s %s\n", $5, $6) }'`
AIX )
set -- `df -k | sed -e 's/%//g' | awk '/^\/dev/ { printf("%s %s\n", $4, $7) }'`
;;
esac

while [ $# -ge 2 ] ; do
CAPACITY=$1
FS=$2
shift 2

if [ $CAPACITY -gt 90 ] ; then
echo "$FS is at $CAPACITY %" >> /tmp/df.out
fi
done
if [ `wc -l /tmp/df.out | awk '{ print $1 }'` -ge 2 ] ; then
cat /tmp/df.out | mail -s "`date`" $MAILTO
fi


0

Response Number 2
Name: anthonyr
Date: February 20, 2006 at 18:24:54 Pacific
Reply:


thank you very much for your help. Worked like a charm....


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


Solaris 8 Running out of CPU



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Solaris Forum Home


Sponsored links

Ads by Google


Results for: new to scripting pls help

script to monitor file size www.computing.net/answers/solaris/script-to-monitor-file-size-/4817.html

i'm new to this i have some questions www.computing.net/answers/solaris/im-new-to-this-i-have-some-questions/1751.html

Automatic User Number Tracking www.computing.net/answers/solaris/automatic-user-number-tracking/3268.html