systemcentercommunity
Your community resource for Microsoft's System Center family of products

trouble with scripting and alerts

Latest post 09-25-2007 2:59 AM by marekku. 2 replies.
  • 09-24-2007 12:09 PM

    trouble with scripting and alerts

    I am new to MOM in general, and SCOM in particular, so bear with me. I have a need to run scripts periodically, and generate alerts based on their output. To test this, I have created the following script, but don't know how to set it up. What I want to do, is to schedule this to run every hour or so, raise a success event and a failure event, and generate alerts for the failure event. What is the best way to do this? Can anyone tell me how best to schedule, and monitor for the events? How do I target this so that only the management server runs this, and not all 100 servers being monitored?

    The script may be wrong, but mostly I need help figuring out how to target, schedule, and raise alerts given a script that looks like the one below. 

     

    Dim strDomain, objevent, lockedusers

    Const EVENT_TYPE_SUCCESS = 0
    Const EVENT_TYPE_ERROR   = 1
    Const EVENT_TYPE_WARNING = 2
    Const EVENT_TYPE_INFORMATION = 4
    Const EVENT_TYPE_AUDITSUCCESS = 8
    Const EVENT_TYPE_AUDITFAILURE = 16
    lockedusers = 0

    strDomain = "contoso"


    ListUsers( strDomain )


    if lockedusers = 0 then
    CreateEvent 100,EVENT_TYPE_INFORMATION,"AD_USER_Acct_Locked","The check for locked users completed normally, no locked accounts found."
    end if

    set objcomputer = nothing
    set objevent = nothing


    Sub ListUsers( strDomain )
     Set objComputer = GetObject("WinNT://" & strDomain )
     objComputer.Filter = Array( "User" )
     For Each objUser In objComputer
      

      If objuser.IsAccountLocked Then
      
      lockedusers = 1  
      CreateEvent 200,EVENT_TYPE_ERROR,"AD_User_Acct_Locked","The user account " & objuser.name & " is locked out."
      
      end if
     
     Next
    End Sub


    Sub CreateEvent(intEventNumber,intEventType,strEventSource,strEventMessage)
        Set objEvent = ScriptContext.CreateEvent()
        objEvent.EventNumber = intEventNumber
        objEvent.EventType = intEventType
        objEvent.EventSource = strEventSource
        objEvent.Message = strEventMessage
        ScriptContext.Submit objEvent
    End Sub

    the monitoring whipping boy
  • 09-24-2007 1:59 PM In reply to

    Re: trouble with scripting and alerts

    Why don't you just load the AD Management Pack.  It checks for these type of errors.

  • 09-25-2007 2:59 AM In reply to

    Re: trouble with scripting and alerts

    begin with authoring pane, create unit monitor > choose scripting > two (or three) state generic monitor and here you go ;)

Page 1 of 1 (3 items) | RSS
Copyright @ 2008 Silect Software Inc.
Powered by Community Server (Commercial Edition), by Telligent Systems
Microsoft System Center Operations Manager Management Pack Configuration Manager Configuration Pack DCM Desired Configuration Monitoring