Real life question. Love Foglight for SQL but could it also help us with monitoring files? Answer Yes

So, this question came up recently with a customer. Lots of teams also have these additional questions that would make their lives so much easier.

I decided to mock up an example and document it for them. They have a process that dumps csv files in folder and all things going well the files get processed and deleted. But occasionally it breaks, and nobody notices and then their reports are out of date.

So, I’m going to use a Foglight Script Agent to allow them to monitor a folder and get them notified of a problem. For the exercise I’m using Toad Data Point to export data from an SQL Server table and dump the file into a folder, assuming some other process will take these files and import them somewhere (something Toad Data Point could also do).

The files are created every hour and I want to know if I get more than 4 files.

Here is the script:

I don’t want to repeat all the existing excellent documentation on this (just google Foglight Script Agents) but basically there is a line that finds the count of the number of files with *.csv and echos this to stdout wrapped in a format Foglight understands.

Here is the folder I want to monitor:

If I run the bat file I would get:

Let’s get started.

Locate the dashboard above and browse to the file and load that up. If you need to make changes to the script, you can upload the newer script and increase the version number.

Click Build Script Agent and then navigate to Agent Status

My Agent Manager (which will run the script) is located already on the host with the folder. So I need to deploy my agent package to this Agent Manager:

Click Finish

Once deployed click Create Agent

Click Finish

You will see the agent, select it and hit Activate.

Now create a dashboard to view the count:

Then locate the count number we need from the data tab and drag and drop to the dashboard

And we end up with this after a few hours:

If you want to monitor a remote folder, then executing an authenticated trusted script over winrm or ssh would be the way to go.

In the next blog we will review creating an alarm for reaching thresholds.

Anonymous
Related Content