Automating the setup of URL monitoring


One of the new things in OpsMgr is the ability to easily setup URL monitoring from multiple watcher nodes. What what if you want to monitor 500 different URLs? Setting this up manually could be pretty time consuming. Here is a script I put together that demonstrates how to automate this process using PowerShell.


There are four parameters you need to pass to this script:


1 - The URL


2 - One or more FQDNs of watcher nodes. The watcher nodes must have the OpsMgr agent installed.


3 - The display name of the type that will be created. This will appear in the authoring space where you see all the web site monitoring objects as well as when you will be creating the state view or alert view.


4 - The display name of the management pack into which all the URL monitoring logic will be stored as a result of running the script.


Here is exactly what you need to do to run this script:


1 - Open the OpsMgr Command Shell


2 - Type the following


C:\CreateUrlMonitoring.ps1 -url:"http://url.contoso.com" -watcherNodes:"watcherNode1.contoso.com","watcherNode2.contoso.com" -displayName:"Url Monitor 1" -targetMp:"WebSiteMonitoring"


Running the script with the above parameters will create the right monitoring logic to monitor "http://url.contoso.com" URL from watcherNode1.contoso.com and watcherNode2.contoso.com and store the monitoring logic in a management pack whose display name is WebSiteMonitoring.


Once you run the script, you will need to create state and alert views to see the status of the URL from the perspective of the watcher nodes.


If you find this sort of automation script useful and you want to see automation of other monitoring scenarios, please leave a comment and let me know.


The script is attached and the link is at the bottom of this post.


This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included scripts are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm


 

CreateUrlMonitoring.zip

Comments (19)

  1. timpmcfadden says:

    I really like this.  We need to setup a ton of url monitors and this will really help.

    Is it possible for you to create a script that the automate the process of setting up multiple service monitors.

  2. Check out Boris Yanushpolsky's blog ( http://blogs.msdn.com/boris_yanushpolsky ). Boris is an SCOM

  3. Capriole says:

    Is there any way of forcing the web application monitor to use a client certificate to authenticate?

    We would like to monitor an IIS website that allows certificate auth only – not Basic, Digest or IWA/NTLM.

  4. borisyan says:

    I am not sure to tell you the truth. I suggest you post a question to one of the OpsMgr newsgroups or contact CSS.

  5. Richard says:

    Hi there, I am trying to run this script and keep getting a bumch of errors, the first one being The term ‘Get-ManagementGroupConnection’ is not recognised as a cmdlet.. Any help?

  6. borisyan says:

    You need to open the OpsMgr commandshell first and then run the script.

  7. Richard says:

    Hi there, this is working 100% correctly. However saying that there is one thing that I cant work out for the life of me, I am trying to allow the checking of the following checkBox on creation of a watcher, the name is "Stop Processing the subsequent requests if any error criteria is met". How would I go about doing this?

  8. borisyan says:

    There is no easy way to do this with the script I posted as it requires manipulation of the MP objects created by the script.

  9. Roel says:

    Can we check for searchstrings (like NetIQ)? E.g.: check if the return page has a string. If it doesn’t (or not) generate an alert.

  10. borisyan says:

    You can do this, but through the UI rather than in powershell.

  11. Roel says:

    Is there no other way of doing this through a script? We need to migrate 700 NetIQ URL monitors. If this is not possible through a script the customer wont be a happy customer.

  12. Roel says:

    Hi Boris, we need to migrate 700 URL monitors from NetIQ to Operations Manager. If we are not able to script this the customer will not be happy. Is there any other way to script this except for Powershell?

  13. borisyan says:

    In theory there should be a way to do this, but there are no cmdlets for this, so it would require writing managed code.

  14. Marco Shaw says:

    @Roel,

    If you’re still looking for something, please email me directly and I will try to help: marco DOT shaw AT gmail DOT com.

  15. David says:

    Hi Roel,

    We have a tool that we wrote to do what you are looking for. We have used it to migrate hundreds of Sitescope monitors. Contact me if you would like some information.

    david.stclair AT infrontconsulting DOT com

  16. Zuro says:

    Hi,

    I tried this script on R2. it didn’t add url monitoring to Authoring -> Web application. neither the script seems to finished successfully without errors.

    moreover I export the WebSiteMonitor MP (which I created manually) and no evidence for url monitoring.

  17. Zuro says:

    Hi,

    I tried this script on R2. it didn’t add url monitoring to Authoring -> Web application. neither the script seems to finished successfully without errors.

    moreover I export the WebSiteMonitor MP (which I created manually) and no evidence for url monitoring.

  18. Mark Wolzak says:

    I've been one of the lucky guys to be able to attend the MMS 2009 in Las Vegas a few weeks ago. One

Skip to main content