1825942 Members
2526 Online
109689 Solutions
New Discussion

Re: pearl script

 
hari prasad_4
Advisor

pearl script

hi guys,

i want a pearl script which has to monitor a log file of a database, which has to send a mail weather it is growing or not, every 5 minutes once. can i get that from someone.

thanks
prasad
4 REPLIES 4
Steven E. Protter
Exalted Contributor

Re: pearl script

Shalom prasad,

What you ask for has been done to a great extent.

http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=51050

There are links in this thread to over 200 sysadmin scripts in there. One of them probably does exactly what you want.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Muthukumar_5
Honored Contributor

Re: pearl script

You can try with shell scripting itself as,

#!/bin/sh
# Change this to your log file
LOGFILE=/tmp/test.log

while [ 1 ]
do
SIZE=$(ls -l ${LOGFILE} | awk '{ print $9; }')
let OLDSIZE=SIZE

if [[ ${SIZE} -gt ${OLDSIZE} ]]
then
echo "${LOGFILE} is growing" | mailx -s "logfile size alert" mailid
else
echo "${LOGFILE} is not growing" | mailx -s "logfile size alert" mailid
fi

# Sleep time - 5 min
sleep 300
done

# END
exit 0

############

# chmod u+x script.sh
# ./script.sh 1>/tmp/logfile 2>&1 &
# tail -f /tmp/logfile

gives details.

-Muthu


Easy to suggest when don't know about the problem!
hari prasad_4
Advisor

Re: pearl script

hi,


thanks for your replies.

since it is a log file, whenever it modifies the file i need some kind of notification, the same script i wanted include in even aix server also.

prasad
Muthukumar_5
Honored Contributor

Re: pearl script

Change this lines,

echo "${LOGFILE} is growing" | mailx -s "logfile size alert" mailid
else
echo "${LOGFILE} is not growing" | mailx -s "logfile size alert" mailid


with your mail setting. It will send mails to your account.

Script will work on aix server also.

-Muthu
Easy to suggest when don't know about the problem!