Testing Web Content with Monitis, Excel, and PowerShell
In the last few articles, we’ve shown you how easy it is to monitor anything with the open source Monitis PowerShell Module. Last time, we covered how to interact with web applications, and before that, you got a small taste of how working in a real scripting language like PowerShell can make it miles easier to add batches of monitors.
Today, we’re going to cover two more parameters of Add-MonitisExternalMonitor that makes it easy to build web content, and then we’re going to build a really simple way to make use an excel spreadsheet to create all of your web monitors in PowerShell.
The two new parameters you’ll want to learn are:
- ExpectedContentPattern – A regular expression you expect to find in the results
- RequiredResponseTime – the maximum amount of time it should take to get a response
To start out with, create an excel spreadsheet, and make a few columns:
Now, row by row, fill in things you’d like to test. These are going to be parameters of Add-MonitisExternalMonitor. Only Url, MonitorType, and OperationType are required. OperationType can be “Get”, “Post”, “Put” or “Delete”. MonitorType can be any number of internet protocols, but you’ll probably use ping, http, and https.
Once you’ve filled in the spreadsheet, save it as a CSV.
At this point, you can use this CSV as a way to quickly recreate all of your monitors in two lines:
Connect-Monitis -ApiKey $apiKey -SecretKey $secretKey
Import-Csv .\MyWebTest.csv | Add-MonitisExternalMonitor
The PowerShell trick that makes this work is the object pipeline. We talked some about the pipeline a couple of days ago, when we introduced how to manage your monitors. Almost all of the commands in the Monitis PowerShell module are aware of the object pipeline, and that means that when Import-CSV returns back a bunch of objects, those objects just work with Monitis.
This simple example should start to really give you a taste of what Monitis and PowerShell can do together, but we’re really just getting started. Next time, we’re going to start looking at the coolest part of Monitis, custom monitors, and show you how you can use PowerShell to monitor absolutely anything with Monitis.