Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 149
  • Last Modified:

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!
0
andy_i
Asked:
andy_i
1 Solution
 
makerpCommented:
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
0
 
andy_iAuthor Commented:
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
0
 
andy_iAuthor Commented:
Have also tried to use the "comp" command however this is too indepth (byte by byte comparison) and creates high CPU loading.

0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
nomispCommented:
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.
0
 
andy_iAuthor Commented:
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
0
 
nomispCommented:
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.
0
 
andy_iAuthor Commented:
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
0
 
SpideyModCommented:
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
0
 
nomispCommented:
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.
0
 
nomispCommented:
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.
0
 
andy_iAuthor Commented:
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
http://www.experts-exchange.com/Operating_Systems/Win2000/Q_20530528.html for points for makerp

http://www.experts-exchange.com/Community_Support/Q_20530516.html
Many thanks for your help.
0
 
andy_iAuthor Commented:
All I need to do now is to try and get all this implemented!
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now