Email alert and log and when log files get updated

We would like to see if we can get a script created that would send an email alert us when a specific log file is updated. Along with the alert is it possible to have the log attached to the email?

Ideally we would like to know when the file has been updated 3 times in one hour. (This is where we want to start, we may need to adjust this as we go.)

I looked at some third party tools but am not sure if this is feasible. https://www.raymond.cc/blog/3-portable-tools-monitor-files-folders-changes/
 
http://www.nirsoft.net/utils/folder_changes_view.html
 
The second has CLI options so it could be turned into a service potentially.
LVL 16
Raymond PengSystems EngineerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Bob LearnedCommented:
For the first part of the process, I could see where the .NET FileSystemWatcher could be used to monitor files changes.

Powershell FileSystemWatcher
https://gallery.technet.microsoft.com/scriptcenter/Powershell-FileSystemWatche-dfd7084b

This script uses the .net FileSystemWatcher class to subscribe to 'create', 'change' and 'delete' events on files or folders in the NTFS file system.  It can be used to monitor a folder or folders, and can be modified to perform any action upon the triggering of these events.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Steve KnightIT ConsultancyCommented:
Depending upon what languages you are wanting, just powershell or others I use this script of mine when batch/VBScript is the only option:

http://scripts.dragon-it.co.uk/links/batch-monitor-ping-email

That is used to monitor a log of failed PINGs but it is the same principal, a VBScript is scheduled every x minutes and checks for presence of log file and emails it...

http://scripts.dragon-it.co.uk/links/batch-monitor-ping-email

Whether it is this or another solution I would say questions I would have are:

1. Is this just a text file log and "updating" is appending a line to it?
2. Can the log file be renamed / moved each time so then the presence of a file, and specifically here just adding of 3 lines in the last hour is a solution.
3. Does the file grow by a specified size, i.e. if the line lengths are the same (roughly) then growing file size by 240 bytes we can know is 3 lines
4. Is it just the added lines you want emailed or the whole log

And a sample of the log file too.

Steve
Raymond PengSystems EngineerAuthor Commented:
Thanks all, it's been busy here at work but I will test both experts advice and report back as soon as I can.
Raymond PengSystems EngineerAuthor Commented:
Very good find - I was able to tweak the script to suit my needs. Much appreciated!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.