none
Easy Basic Script Monitor - Why doesn't work?

    Question

  • HI,

    I have a script which should not run on saturdays or sundays. It works when I run it outside of SCOM but not as a monitor.

    I've used

    dtmToday = Date()
    dtmDayOfWeek = DatePart("w", dtmToday)

    (look in script)

    Still it runs on Saturdays and Sundays. Help appreciated!

    SCRIPT:

    Dim filesys, Filobjekt, LastModified, strDiff, objParameters, objArgs

    Set objAPI = CreateObject("MOM.ScriptAPI")
    Set oBag = objAPI.CreateTypedPropertyBag(StateDataType)
     
    FilFullSti = Wscript.arguments(0)
    GrenseverdiTimer = CInt(Wscript.arguments(1))

     
    Set filesys = CreateObject("Scripting.FileSystemObject")
    Set FilObjekt = filesys.GetFile(FilFullSti)
    LastModified = FilObjekt.DateLastModified
    strDiff = CInt((DateDiff("h",LastModified,Now())))
    wscript.echo FilFullSti & " " & LastModified & " " & strDiff

    dtmToday = Date()
    dtmDayOfWeek = DatePart("w", dtmToday)


    If dtmDayOfWeek <> 1 OR dtmDayOfWeek <> 7 Then
    If strDiff > GrenseverdiTimer Then

    Call oBag.AddValue("State","BAD")
    Call oBag.AddValue("Path",FilFullSti)
    Call oBag.AddValue("Threshold",GrenseverdiTimer)
    Call oBag.AddValue("Fil",strDiff)
    Call objAPI.Return(oBag)
    WScript.Quit
    Else

    Call oBag.AddValue("State","GOOD")
    Call objAPI.Return(oBag)
    End If
    Else
    End If
    WScript.Quit


    Thanks in advance, Best Regards

    Wednesday, August 28, 2013 11:15 AM

Answers

All replies

  • Hi

    if you have configured script base monitor to run under default profile scom agent run script under Default action account and script will fail to run if account do not have sufficient permissions.

    Regards


    sridhar v

    Thursday, August 29, 2013 8:07 AM
  • You should implement the scheduler module to handle this, otherwise the script will always execute. There is no need to use logic in the script to determine when it should run.

    Jonathan Almquist | SCOMskills, LLC (http://scomskills.com)

    Thursday, August 29, 2013 9:22 AM
    Moderator
  • http://msdn.microsoft.com/en-us/library/ff453828.aspx

    Vladimir Zelenov | http://systemcenter4all.wordpress.com

    Tuesday, September 03, 2013 5:07 PM
  • But how to use it? Exporting the custom MP and pasting it in or creating the rule in the 2007 authoring console?  :)  Thanx


    Thanks in advance, Best Regards

    Friday, September 06, 2013 12:48 PM
  • But how to use it? Exporting the custom MP and pasting it in or creating the rule in the 2007 authoring console?  :)  Thanx


    Thanks in advance, Best Regards

    Here is an example

    Jonathan Almquist | SCOMskills, LLC (http://scomskills.com)

    Friday, September 06, 2013 6:56 PM
    Moderator
  • I am not very technical, sadly. I've got the System.Scheduler filled out like I want it. Can I use it for a monitor, if not what changes do I need, and where do I past it in the MP.XML? In the unit monitor-tag or some where else? For one who has worked with HP products it still really shocking to me how slow and intricate SCOM is to use on custom authoring.

    Here is my System.scheduler:

    <Rule ID="Microsoft.Samples.ScheduledRule" Enabled="true" Target="Windows!Microsoft.Windows.OperatingSystem" ConfirmDelivery="true" Remotable="true" Priority="Normal" DiscardLevel="100">
      <Category>Alert</Category>
      <DataSources>
        <DataSource ID="DS" TypeID="Windows!Microsoft.Windows.EventProvider">
          <ComputerName>$Target/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/NetworkName$</ComputerName>
          <LogName>Application</LogName>
          <Expression>
            <SimpleExpression>
              <ValueExpression>
                <XPathQuery Type="UnsignedInteger">EventDisplayNumber</XPathQuery>
              </ValueExpression>
              <Operator>Equal</Operator>
              <ValueExpression>
                <Value Type="UnsignedInteger">1000</Value>
              </ValueExpression>
            </SimpleExpression>
          </Expression>
        </DataSource>
      </DataSources>
      <ConditionDetection ID="Schedule" TypeID="System!System.SchedulerFilter">
        <SchedulerFilter>
          <ProcessDataMode>OnSchedule</ProcessDataMode>
          <Schedule>
            <WeeklySchedule>
              <Windows>
                <Daily>
                  <Start>00:00</Start>
                  <End>00</End>
                  <DaysOfWeekMask>62</DaysOfWeekMask>
                </Daily>
              </Windows>
            </WeeklySchedule>
            <ExcludeDates />
          </Schedule>
          <UseCurrentTime>true</UseCurrentTime>
        </SchedulerFilter>
      </ConditionDetection>
      <WriteActions>
        <WriteAction ID="Alert" TypeID="Health!System.Health.GenerateAlert">
          <Priority>1</Priority>
          <Severity>1</Severity>
          <AlertName />
          <AlertDescription />
          <AlertOwner />
          <AlertMessageId>$MPElement[Name="Mon.TestTESTSCHEDULER"]$</AlertMessageId>
          <AlertParameters />
          <Suppression />
        </WriteAction>
      </WriteActions>


    Thanks in advance, Best Regards

    Monday, September 09, 2013 8:49 AM