Monitor Everything with Monitis – And do it easily with PowerShell – Part 2


Managing External Monitors with Monitis and PowerShell


In the last article, we got started with how to create a simple external monitor with Monitis in PowerShell.  The command you use is Add-MonitisExternalMonitor.  You’ll have to import the Monitis module first to use it (Import-Module Monitis).

Monitis lets you monitor everything, and when you manage those monitors with PowerShell life gets a lot easier.  In PowerShell, commands normally come in little families.  To see all of the other things you can do with external monitors, run:

Get-Command -Name *Monitis*External*Monitor*

You should see 5 commands:

  • Add-MonitisExternalMonitor
  • Get-MonitisExternalMonitor
  • Remove-MonitisExternalMonitor
  • Resume-MonitisExternalMonitor
  • Suspend-MonitisExternalMonitor

We’ve already taken a quick look at Add-MonitisExternalMonitor.  Get-MonitisExternalMonitor will list the monitors that exist, or get information about those monitors.   Let’s give it a try:


Take a second and notice that you don’t have to put the API Key or Secret Key in again.   Whenever you use Monitis in Powershell, the first time you use your API key it will keep it around so you don’t have to keep typing it in.

When you run Get-MonitisExternalMonitor, you get a list of items on the screen displaying a little information about the monitor.   While you’re seeing them on the screen, PowerShell’s only showing them to you because there’s nothing else in the object pipeline.  If you pipe another command in, it can use the output of the first command as input.   This is a really cool feature of PowerShell, and the Monitis module supports it very well.

Let’s show a practical example.   By piping Get-MonitisExternalMonitor into Suspend-MonitisExternalMonitor, I can suspend data collection of all of my external monitors.

Get-MonitisExternalMonitor |

So if I know there’s a downtime coming, I can avoid putting extra information into Monitis.

To turn all of my monitors back on again, I can use:

Get-MonitisExternalMonitor |

To see the results, I can use:

Get-MonitisExternalMonitor |

If I wanted to drill down on just one monitor, I can use some built in PowerShell commands to help.  Where-Object will let me filter the monitors I have to only get the monitor with a specific name.  Each Monitor returns a deep batch of information from a location, which has a property called data that contains each result.  Here’s the pipeline that will give me all of the ping times from the UK since yesterday’s article in a grid view

Get-MonitisExternalMonitor |
    Where-Object {$_.Name -eq 'MyWebSite' }  |
    Get-MonitisMonitorResult |
    Where-Object { $_.LocationName -eq 'UK' } |
    Select-Object -ExpandProperty Data |


To clear all of my monitors entirely, and remove their results, I’d do:

Get-MonitisExternalMonitor |

With PowerShell, managing your monitors has never been easier.     With PowerShell, you can take any task (even a complicated one like managing an online service in REST), and turn it into a series of easy-to-use commands with well documented and easy-to-discover parameters.

In the Part 1 we learned how to add a single monitor with Monitis.  Today, we’ve seen how we can manage any number of monitors easily in PowerShell.  Next we’ll start to explore some of the true power of the Monitis monitoring engine by showing some of the additional features of external monitors.

See also Monitor Everything with Monitis – And do it easily with PowerShell – Part 1

You might also like