[OpsMgr] SCOM Advanced Web Application monitoring scenarios [Part1]

Posted: November 28, 2011 in SCOM, SCOM 2007, SCOM 2012

In series of blog posts i’m going to show advanced technique of web application monitoring scenarios for SCOM.
This technique does not use standard Web Application template and is based on IE Automation.

I start from raw data for now. Later will add more details.

Part1: IE Automation.

Again, for now i’m just posting raw data.

LiveIDAutomation.vbs

  1. OpenStartPage https://login.live.com/.
  2. Check if elements User, Pass, SignIn are loaded
  3. Fill in User, Pass
  4. Click ‘SignIn’
  5. Check if ‘LiveId’ DOM element is loaded
  6. Get LiveID DOM element value and compare it with provided User
  7. Report scenario time

On each step script tries to report HTTP/Timeout errors and stops script execution.

'Author: Pavel Dzemyantsau
'Note:   Demonstrates POC of IE Automation for LiveID login.

strURL="https://login.live.com/"
strUser="User@hotmail.com"
strPass="password"

'create automation object
Set oIE = WScript.CreateObject("InternetExplorer.Application","IE_")

Timeout=60 'seconds
oIE.visible=1 : BeginTimer = Timer
oIE.Navigate strURL
i=0 : bElementsLoaded=false
Set DOM_Element_1 = Nothing : Set DOM_Element_2 = Nothing : Set DOM_Element_3 = Nothing
Do While (oIE.ReadyState<>4 Or Not(bElementsLoaded)) And i < Timeout
   WScript.Sleep(1000):i=i+1
   On Error Resume Next
      Set DOM_Element_1 = oIE.Document.getElementById("i0116")           'User
      Set DOM_Element_2 = oIE.Document.getElementById("i0118")           'Password
      Set DOM_Element_3 = oIE.Document.getElementById("idSIButton9") 'SignIn button
      If     (Not(DOM_Element_1 is Nothing)) _
         And (Not(DOM_Element_2 is Nothing)) _
         And (Not(DOM_Element_3 is Nothing)) Then
       'all elements we are going to use are loaded
        bElementsLoaded=true
      End If
   On Error Goto 0
Loop

If Not bElementsLoaded  Then
  WScript.Echo "Timeout"&Timeout&" seconds occured on action TODO:."
  WScript.Quit(-1)
End If

'Fill in User/Pass
DOM_Element_1.value=strUser 'TODO: loop to check if user has been set
DOM_Element_2.value=strPass 'TODO: loop to check if pass has been set
DOM_Element_3.Click()

Timeout=120 'seconds
i=0 : bElementsLoaded=false
Set DOM_Element_1 = Nothing
Do While (oIE.ReadyState<>4 Or Not(bElementsLoaded)) And i < Timeout
   WScript.Sleep(1000):i=i+1
   On Error Resume Next
      Set DOM_Element_1   = oIE.Document.getElementById("idWinLiveIdValue") ' LiveId
      If (Not(DOM_Element_1 is Nothing)) Then
       'element we are going to use is loaded, now is checking its attrubute 'title'
        Set DOM_Element_1_attribute_1 = DOM_Element_1.attributes.getNamedItem("title")
           If Not (DOM_Element_1_attribute_1 is Nothing) Then
              'attribute found
              If LCase(DOM_Element_1_attribute_1.value) = LCase(strUser) Then
                'attribute title has correct value
                bElementsLoaded=true
              End If
           End If
      End If
   On Error Goto 0
Loop
EndTimer = Timer

If Not bElementsLoaded  Then
  WScript.Echo "Timeout"&Timeout&" seconds occured on action TODO:."
  WScript.Quit(-1)
End If

Wscript.Echo "Scenario time(sec): "& (EndTimer-BeginTimer)

oIE.Stop : WScript.Sleep(5000) : oIE.Quit

Sub IE_NavigateError(ByVal pDisp,ByVal URL,ByVal TargetFrameName,ByVal StatusCode,ByRef Cancel)
    WScript.Echo "StatusCode="&StatusCode
    WScript.Quit(-1)
End sub
Advertisements
Comments
  1. bradc says:

    this is a little old, but i have used this technique too. some difficulties i had to overcome. IE wants to launch in an interactive session. SCOM does not want to be in an interactive session. i would love to learn more if you’re still using this method.

  2. scompro says:

    Hi Brad, yes you are right about IE. But there is a working solution for running this script under SCOM. All you need is to create windows local admin account, then log in under this account. run IE, complete start wizard, configure IE to disable popups as much as possible. E.g. “warn about certificate address mismatch”, etc.
    Then on SCOM side implement RunAs profile for you Monitor(or MonitorType or DataSource, depending on your needs) with RunAs account you have just configured.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s