Operating System - HP-UX
1833877 Members
2312 Online
110063 Solutions
New Discussion

Monitoring logfile growth

 
SOLVED
Go to solution
koff
Frequent Advisor

Monitoring logfile growth

hi,
I created a logfile template with several conditions. But now, i want to monitor the size of my logfile (generate a message when the logfile is bigger than 10Mega for example).
How can I make this ?
1 - is it possible to monitor the size of the logfile in the same template logfile ?
2 - I must create a monitor template (program type) that launch a script which return the size of this file ?
Please, someone can give me an idea...
Thanks
Delphine.
8 REPLIES 8
MarkSyder
Honored Contributor
Solution

Re: Monitoring logfile growth

let testlog='ll|awk '{print $5}''
if [ "$testlog" -gt 1000 ]
then
echo "The log file is too big."

I have used the number 1000 - you can substitute any number you choose. Save this as an executable shell script and run it as a cron job as often as you need.

Mark Syder (like the drink but spelt different)
The triumph of evil requires only that good men do nothing
Robert-Jan Goossens
Honored Contributor

Re: Monitoring logfile growth

Hi Delphine,

Sam has a "routine task" for systemlog files, just fire up sam "Routine Tasks" " Systems Log Files" "action" add a logfile.

HTH,
Robert-Jan
RAC_1
Honored Contributor

Re: Monitoring logfile growth

Put the following code in your script-monitor script itself or may be a seperate script.

size=`ll "file_to_monitor"|awk '{print $5}'`
(This will be in bytes)

if [ $size -ge 10000 ]
then
mailx "your stuff" xyz@abc.com
fi
There is no substitute to HARDWORK
Karthik S S
Honored Contributor

Re: Monitoring logfile growth

These thread might help you,,

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

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

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

http://tinyurl.com/2pux9

Regards,
Karthik S S
For a list of all the ways technology has failed to improve the quality of life, please press three. - Alice Kahn
Mark Grant
Honored Contributor

Re: Monitoring logfile growth

I thought I'd do this one, just because it's perl


perl -e 'map { if(((stat $_)[7])>1048576){print "TOO BIG"}} glob "logfile*"'

It does it for all files that have the name "logfile*" and prints "TOO BIG" if they are over 10MB. You can adjust it easily.

Merijn will have this down to a three byte script any time now.
Never preceed any demonstration with anything more predictive than "watch this"
koff
Frequent Advisor

Re: Monitoring logfile growth

Thanks for all your answer
I understant now how to get the size of my logfile in a shell script.
But one more question :
What is cron and SAM ?

NB : I want to create a SPI which integrated a logfile and i want to create a monitor that control the size of this logfile...

thanks u
//(^_^)\\
Delphine.
MarkSyder
Honored Contributor

Re: Monitoring logfile growth

cron is a list of jobs that run at specified times. See the current cron jobs by typing crontab -l

SAM = system administration manager.

Type sam on the command line and sam will load.

Mark
The triumph of evil requires only that good men do nothing
Geoff Wild
Honored Contributor

Re: Monitoring logfile growth

Check out logrotate - may save you time and effort:

http://hpux.ee.ualberta.ca/hppd/hpux/Sysadmin/logrotate-2.5/

Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.