Sample Solutions



PowerShell-based Monitors

sectionline.gif

item.png Monitoring a Windows Service and Restarting if Stopped

This can easily be achieved by using the PowerShell monitor plug-in to PolyMon. Essentially the PowerShell script determines the state of the specified Windows Service and attempts to restart it if the service is not running.
The PowerShell script defines some parameters at the beginning of the script which you can easily modify to accomodate your specific needs. The provided sample will monitor the SQL Server Agent and attempt restart the service if it is stopped.

To set up this monitor you must first install PolyMon and the PowerShell plug-in available in the Releases section.

save.png PolyMon PowerShell Service Monitor.ps1

Once you have downloaded this file, create a new monitor of PowerShell type in the Monitor Definitions form in PolyMon Manager.

Simply paste the contents of the provided powershell script and modify the HostName, ServiceName and Timeout variables at the top of the script to specify what you wish to monitor into the monitor editor window (replacing existing content if any). Set up the rest of the monitor definition (Rules, Operators, etc) to finalize creating the new monitor.
(Contributed by Fred Baptiste - May 3, 2007)
articleline.gif

item.png Monitoring DNS Servers

This PowerShell script allows you to verify that a specific DNS server is responding to requests.
More details about this script can be found in PowerShell Monitor Script to query DNS Server.

To set up this monitor you must first install PolyMon and the PowerShell plug-in available in the Releases section.

save.png PolyMon PowerShell DNS Monitor.ps1

Once you have downloaded this file, create a new monitor of PowerShell type in the Monitor Definitions form in PolyMon Manager.

Simply paste the contents of the provided powershell script (replacing existing content if any) and modify the $myhosts and $server variables at the top of the script to specify what you wish to monitor into the monitor editor window. Set up the rest of the monitor definition (Rules, Operators, etc) to finalize creating the new monitor.
(Contributed by kghammond - May 3, 2007)
articleline.gif

item.png Disk Cleanup

This PowerShell script allows you to delete files in one or more directories and sub-directories with filename pattern match and age criteria. Counters indicate the number of files that were deleted at each run. Status information is returned and handled as usual by PolyMon.

Options include:
- File patterns (e.g. , .jpg, etc.)
- Multiple Parent Folders with
- Different Age criteria for each parent folder
- Ability to specify recursion into child folders

To set up this monitor you must first install PolyMon and the PowerShell plug-in available in the Releases section.

save.png PolyMon PowerShell Disk Cleanup.ps1

Once you have downloaded this file, create a new monitor of PowerShell type in the Monitor Definitions form in PolyMon Manager.

Simply paste the contents of the provided powershell script (replacing existing content if any) and modify variables at the top of the script as explained there. Set up the rest of the monitor definition (Rules, Operators, etc) to finalize creating the new monitor.
(Contributed by kghammond - May 7, 2007)
articleline.gif



SQL-based Monitors

sectionline.gif

item.png Monitoring Transaction and Connection Activity on MS SQL Server 2000/2005

This sample shows how you can use PolyMon's SQL Monitor plug-in to monitor transaction and connection activity on a MS SQL Server. In addition to maintaining historical information regarding # of transactions and connections, this sample also shows how to track the number of Blocked transactions and how to generate Warnings/Failures based on how long blocked transactions have been present.

To setup this monitor, you will first create a SQL Stored Procedure that will perform the monitoring activity. Once this has been done, you will set up a new monitor that will run this stored procedure against the server/database where you have installed the stored procedure.

save.png SQL Activity Monitoring.sql (Stored Procedure)
save.png SQL Monitor - Monitor Setup.txt (Monitor Definition)

First create the stored procedure by running the stored procedure script provided above on the server and database of your choice.
This will create a new stored procedure called polymon_SQLActivityMonitor.

Next, create a new monitor in the Monitor Definition form of PolyMon Manager, specifying the SQL Monitor type. Simply copy and paste the monitor definition provided in the second file above into your monitor editor window (replacing existing content if any).
You can specify the time (in milliseconds) that blocked transactions can remain blocked before raising a Fail condition by modifying the @MaxBlockWaitTime parameter value in the monitor editor.

Set up the rest of the monitor definition (Rules, Operators, etc) to finalize creating the new monitor.
(Contributed by Fred Baptiste - May 3, 2007)
articleline.gif


item.png Monitoring Job Activity on MS SQL Server 2000

This sample shows how you can use PolyMon's SQL Monitor plug-in to monitor Agent Job results on a MS SQL Server 2000.

Note: This sample applies to SQL 2000 only.

To setup this monitor, you will first create a SQL Stored Procedure that will perform the monitoring activity. Once this has been done, you will set up a new monitor that will run this stored procedure against the server/database where you have installed the stored procedure.

save.png polymon_sel_JobMonitor.sql (Stored Procedure)
save.png Job Monitor - Setup.txt (Monitor Definition)

First create the stored procedure by running the stored procedure script provided above on the msdb database of the SQL server of your choice.
This will create a new stored procedure called polymon_sel_JobMonitor in the msdb database.

Next, create a new monitor in the Monitor Definition form of PolyMon Manager, specifying the SQL Monitor type. Simply copy and paste the monitor definition provided in the second file above into your monitor editor window (replacing existing content if any).
The job to monitor is specified using the @JobName parameter value.
You can specify a job maximum job run time threshold (in seconds) using the @MaxTimeMins parameter value in the monitor editor.

Set up the rest of the monitor definition (Rules, Operators, etc) to finalize creating the new monitor.
(Contributed by Fred Baptiste - August 23, 2007)
articleline.gif


item.png Monitoring Table Utilization on MS SQL Server 2000

This sample shows how you can use PolyMon's SQL Monitor plug-in to monitor space utilization for a specified Table on a MS SQL Server 2000.

Note: This sample applies to SQL 2000 only.

To setup this monitor, you will first create a SQL Stored Procedure that will perform the monitoring activity. Once this has been done, you will set up a new monitor that will run this stored procedure against the server/database where you have installed the stored procedure.

save.png sp_PolyMonTableUsage.sql (Stored Procedure)
save.png Table Monitor - Setup.txt (Monitor Definition)

First create the stored procedure by running the stored procedure script provided above on the master database of the SQL server of your choice.
This will create a new stored procedure called sp_PolyMonTableUsage in the master database.

Next, create a new monitor in the Monitor Definition form of PolyMon Manager, specifying the SQL Monitor type. Simply copy and paste the monitor definition provided in the second file above into your monitor editor window (replacing existing content if any).
The Table to monitor is specified using the @TableName parameter value.
A maximum unused space threshold can be specified via the @UnusedSpaceThresholdKB parameter value.

Note that you can easily modify the stored procedure to include additional threshold checks on counters such as space used, space reserved,etc.

Set up the rest of the monitor definition (Rules, Operators, etc) to finalize creating the new monitor.
(Contributed by Fred Baptiste - August 23, 2007)
articleline.gif

Last edited Aug 23, 2007 at 12:07 PM by fbaptiste, version 9

Comments

No comments yet.