Link to home
Start Free TrialLog in
Avatar of andy_i
andy_i

asked on

Any way to monitor a log file size?

In a windows 2000 server environment - I am running a piece of server software that writes to a text based log file. The server log file grew to 9.6 Mb in 6 months (no major problem). However the system started a loop and created text entries every 0.5 second to this file.
Subsequently the log file grew to 2.25Gb in 24 hours! Major problem as this the hung the server and caused system failure.

Does anyone know of a way I can monitor the size of this filel and poll its size every 15-30 mins and if the size has increased by say 1Mb since the last poll, shut down the server services?
I run a batch script to copy of the logfile every week but being a 24/5  Helpdesk, I cant copy off while system is live, and can't shut down the software except at weekends!
Avatar of Paul Maker
Paul Maker
Flag of United Kingdom of Great Britain and Northern Ireland image

write a windows scriting host file to do it then use the AT command (or the GUI scheduler) to schedule it

Set fso = CreateObject("Scripting.FileSystemObject")
Set fileobj = fso.GetFile("filemon.vbs") ' change this to be your test log file
IF(fileobj.Size > 5000)THEN
     Set WshShell = Wscript.CreateObject("Wscript.Shell")
     WshShell.Run "NET STOP my_service_name"
END IF
Avatar of andy_i
andy_i

ASKER

Thanks for the idea,
But unfortunately cant run VBS script on the network! Rules and Regs!
Best we could hope for would be some kind of Batch script - but I don't know of anything that will allow me to do that kind of comparison
Avatar of andy_i

ASKER

Have also tried to use the "comp" command however this is too indepth (byte by byte comparison) and creates high CPU loading.

This is a bit of a work around and not perfect but it should stop your server crashing. If you create a user eg. 'logfile' and give ownership of the log file to that user you can then set Disk quotas to warn you in the event log when the file reaches a certain size and to stop it exceeding a certain size. As i said, not perfect but it does protect your system from being filled up by this file.
Avatar of andy_i

ASKER

The log file is effectively deleted at each w/e backup and a new one created when the system restarts. As the new one is created to exactly the same file name could the ownership be tricked into thinking the new file (system generated therefore owner=admin) was the old one?
Could it be possible to take ownership on an automatic basis for the newly created file?

Many thanks for the thoughts/suggestions/comments
Afraid thats a bit beyond me. I do know that you can't give ownership of a file to a user or user account, it is up to that account to take ownership. Whether this could be done programaticly i don't know.
Avatar of andy_i

ASKER

many thanks to nomisp and makerp
I'm trying to find ways to split the points and grade answers as both of you have given time/ideas/help.

Unfortunately I can't implement WSH and I'm still trying to find a way to get this file automatically owned!

May try and find a way to take ownership of the file as per nomisp's last post and instead of deleting the entire file just delete the entire contents..Hmmm could be a bit of a sticky one here!

Thanks again, points & grades on the way,
Andy
Points reduced for split.  Please post a points for expertname re 20523706 for the other expert and return back here to notify.

SpideyMod
Community Support Moderator @Experts Exchange
Just a thought, you could try running your app using 'runas /user'(see below) from a command prompt. Perhaps the log file would then be owned by the user specified in the runas command.

e.g in a command prompt type runas /user:domain\user "Path to program"

I believe that it's only the administrator account, not accounts in the administrators group that are unrestricted using disk quotas.
ASKER CERTIFIED SOLUTION
Avatar of nomisp
nomisp

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of andy_i

ASKER

program runs as a service so may work. would have to grant "logfile" user rights to start services..Hmmm can see getting into sticky zone due to tight rules and regs on server side configuration changes away from standard design. Wish I was back working in the server rooms as opposed to being a Project Manager on this one!!!

Anyway have got the points split. I'll use your answer here nomisp, and I have already posted 50 point question
https://www.experts-exchange.com/questions/20530528/Points-for-makerp.html for points for makerp

https://www.experts-exchange.com/questions/20530516/Please-assist-Need-to-split-points.html
Many thanks for your help.
Avatar of andy_i

ASKER

All I need to do now is to try and get all this implemented!