none
Schedule Expression Filter RRS feed

  • Question

  • I have a powershellscript that runs on a regular basis. I need to have it not to run under a specific time-slot. I have inserted an expression filter but I cant get it to work no matter where I insert the ID for the filter.

    Where should the ID="Filter" Node go?

    <ManagementPackFragment SchemaVersion="2.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <TypeDefinitions>
        <ModuleTypes>
          <DataSourceModuleType ID="VGR.Cytobase.23.12.CheckCytobaseImportFileAge.Script.DS" Accessibility="Internal" Batching="false">
            <Configuration>
              <xsd:element name="IntervalSeconds" type="xsd:integer" minOccurs="1"/>
              <xsd:element  name="From" type="xsd:string" xmlns:xsd="http://www.w3.org/2001/XMLSchema"/>
              <xsd:element  name="To" type="xsd:string" xmlns:xsd="http://www.w3.org/2001/XMLSchema"/>
              <xsd:element  name="Days" type="xsd:int" xmlns:xsd="http://www.w3.org/2001/XMLSchema"/>
            </Configuration>
            <OverrideableParameters>
              <OverrideableParameter ID="IntervalSeconds" Selector="$Config/IntervalSeconds$" ParameterType="int"/>
              <OverrideableParameter ID="From" Selector="$Config/From$" ParameterType="string" />
              <OverrideableParameter ID="To" Selector="$Config/To$" ParameterType="string" />
              <OverrideableParameter ID="Days" Selector="$Config/Days$" ParameterType="int" />
            </OverrideableParameters>
            <ModuleImplementation Isolation="Any">
              <Composite>
                <MemberModules>
                  <DataSource ID="Schedule" TypeID="System!System.Scheduler">
                  <Scheduler>
                    <SimpleReccuringSchedule>
                      <Interval>60</Interval>
                      <SyncTime></SyncTime>
                    </SimpleReccuringSchedule>
                    <ExcludeDates />
                  </Scheduler>
                </DataSource>
                  <ProbeAction ID="Probe" TypeID="VGR.Cytobase.23.12.CheckCytobaseImportFileAge.Script.PA">
                  </ProbeAction>
                </MemberModules>
                <Composition>
                  <Node ID="Probe">
                    <Node ID="Schedule"></Node>
                  </Node>
                </Composition>
              </Composite>
            </ModuleImplementation>
            <OutputType>System!System.PropertyBagData</OutputType>
          </DataSourceModuleType>
          <ProbeActionModuleType ID="VGR.Cytobase.23.12.CheckCytobaseImportFileAge.Script.PA" Accessibility="Internal" PassThrough="false" Batching="false">
            <Configuration>
            </Configuration>
            <ModuleImplementation Isolation="Any">
              <Composite>
                <MemberModules>
                  <ProbeAction ID="PS" TypeID="Windows!Microsoft.Windows.PowerShellPropertyBagProbe">
                    <ScriptName>CheckCytobaseImportFileAge.ps1</ScriptName>
                    <ScriptBody>$IncludeFileContent/Scripts/CheckCytobaseImportFileAge.ps1$</ScriptBody>
                    <Parameters>
                    </Parameters>
                    <TimeoutSeconds>300</TimeoutSeconds>
                  </ProbeAction>
                <ConditionDetection ID="Filter" TypeID="System!System.SchedulerFilter">
                  <SchedulerFilter>
                    <ProcessDataMode>ExceptSchedule</ProcessDataMode>
                    <Schedule>
                      <WeeklySchedule>
                        <Windows>
                          <Daily>
                            <Start>$Config/From$</Start>
                            <End>$Config/To$</End>
                            <DaysOfWeekMask>$Config/Days$</DaysOfWeekMask>
                          </Daily>
                        </Windows>
                      </WeeklySchedule>
                      <ExcludeDates />
                    </Schedule>
                    <UseCurrentTime>true</UseCurrentTime>
                  </SchedulerFilter>
                </ConditionDetection>
                </MemberModules>
                <Composition>
                 <Node ID="Filter">
                  <Node ID="PS"/>
                  </Node>
                </Composition>
              </Composite>
            </ModuleImplementation>
            <OutputType>System!System.PropertyBagData</OutputType>
            <InputType>System!System.BaseData</InputType>
          </ProbeActionModuleType>
        </ModuleTypes>
        <MonitorTypes>
          <UnitMonitorType ID="VGR.Cytobase.23.12.CheckCytobaseImportFileAge.Script.MT" Accessibility="Internal">
            <MonitorTypeStates>
              <MonitorTypeState ID="Success" NoDetection="false"/>
              <MonitorTypeState ID="Error" NoDetection="false"/>
            </MonitorTypeStates>
            <Configuration>
              <xsd:element name="IntervalSeconds" type="xsd:integer" minOccurs="1"/>
              <xsd:element  name="From" type="xsd:string" xmlns:xsd="http://www.w3.org/2001/XMLSchema"/>
              <xsd:element  name="To" type="xsd:string" xmlns:xsd="http://www.w3.org/2001/XMLSchema"/>
              <xsd:element  name="Days" type="xsd:int" xmlns:xsd="http://www.w3.org/2001/XMLSchema"/>
            </Configuration>
            <OverrideableParameters>
              <OverrideableParameter ID="IntervalSeconds" Selector="$Config/IntervalSeconds$" ParameterType="int"/>
              <OverrideableParameter ID="From" Selector="$Config/From$" ParameterType="string" />
              <OverrideableParameter ID="To" Selector="$Config/To$" ParameterType="string" />
              <OverrideableParameter ID="Days" Selector="$Config/Days$" ParameterType="int" />
            </OverrideableParameters>
            <MonitorImplementation>
              <MemberModules>
                <DataSource ID="DS" TypeID="VGR.Cytobase.23.12.CheckCytobaseImportFileAge.Script.DS">
                  <IntervalSeconds>$Config/IntervalSeconds$</IntervalSeconds>
                  <From>$Config/From$</From>
                  <To>$Config/To$</To>
                  <Days>$Config/Days$</Days>
                </DataSource>
                <ConditionDetection ID="FilterSuccess" TypeID="System!System.ExpressionFilter">
                  <Expression>
                    <SimpleExpression>
                      <ValueExpression>
                        <XPathQuery Type="String">Property[@Name='ScriptResult']</XPathQuery>
                      </ValueExpression>
                      <Operator>Equal</Operator>
                      <ValueExpression>
                        <Value Type="String">GOOD</Value>
                      </ValueExpression>
                    </SimpleExpression>
                  </Expression>
                </ConditionDetection>
                <ConditionDetection ID="FilterFailure" TypeID="System!System.ExpressionFilter">
                  <Expression>
                    <SimpleExpression>
                      <ValueExpression>
                        <XPathQuery Type="String">Property[@Name='ScriptResult']</XPathQuery>
                      </ValueExpression>
                      <Operator>Equal</Operator>
                      <ValueExpression>
                        <Value Type="String">BAD</Value>
                      </ValueExpression>
                    </SimpleExpression>
                  </Expression>
                </ConditionDetection>
              </MemberModules>
              <RegularDetections>
                <RegularDetection MonitorTypeStateID="Success">
                  <Node ID="FilterSuccess">
                    <Node ID="DS"></Node>
                  </Node>
                </RegularDetection>
                <RegularDetection MonitorTypeStateID="Error">
                  <Node ID="FilterFailure">
                    <Node ID="DS"></Node>
                  </Node>
                </RegularDetection>
              </RegularDetections>
            </MonitorImplementation>
          </UnitMonitorType>
        </MonitorTypes>
      </TypeDefinitions>
      <Monitoring>
        <Monitors>
          <UnitMonitor ID="VGR.Cytobase.23.12.CheckCytobaseImportFileAge.Script.UnitMonitor" Enabled="true" TypeID="VGR.Cytobase.23.12.CheckCytobaseImportFileAge.Script.MT"
                       Target="VGR.Cytobase.23.12.CytobaseImportComputerRole.Class" Accessibility="Internal" ParentMonitorID="Health!System.Health.AvailabilityState">
            <Category>Operations</Category>
            <AlertSettings AlertMessage="VGR.Cytobase.23.12.CheckCytobaseImportFileAge.Script.UnitMonitor.AlertMessage">
              <AlertOnState>Error</AlertOnState>
              <AutoResolve>true</AutoResolve>
              <AlertPriority>Normal</AlertPriority>
              <AlertSeverity>Error</AlertSeverity>
              <AlertParameters>
                <AlertParameter1>$Data/Context/Property[@Name='ErrorMessage']$</AlertParameter1>
                <AlertParameter2>$Data/Context/Property[@Name='Logfile']$</AlertParameter2>
              </AlertParameters>
            </AlertSettings>
            <OperationalStates>
              <OperationalState ID="Unhealthy" MonitorTypeStateID="Error" HealthState="Error"/>
              <OperationalState ID="Healthy" MonitorTypeStateID="Success" HealthState="Success"/>
            </OperationalStates>
            <Configuration>
              <IntervalSeconds>900</IntervalSeconds>
              <From>04:15</From>
              <To>05:20</To>
              <Days>127</Days>
            </Configuration>
          </UnitMonitor>
        </Monitors>
      </Monitoring>
      <Presentation>
        <StringResources>
          <StringResource ID="VGR.Cytobase.23.12.CheckCytobaseImportFileAge.Script.UnitMonitor.AlertMessage"></StringResource>
        </StringResources>
      </Presentation>
      <LanguagePacks>
        <LanguagePack ID="ENU" IsDefault="true">
          <DisplayStrings>
            <DisplayString ElementID="VGR.Cytobase.23.12.CheckCytobaseImportFileAge.Script.PA" >
              <Name>CheckCytobaseImportFileAge Probe Action</Name>
              <Description>This is a probe action that runs the CheckCytobaseImportFileAge.ps1 script.</Description>
            </DisplayString>
            <DisplayString ElementID="VGR.Cytobase.23.12.CheckCytobaseImportFileAge.Script.DS">
              <Name>CheckCytobaseImportFileAge Data Source</Name>
              <Description>This is the data source that runs the CheckCytobaseImportFileAge.ps1 script.</Description>
            </DisplayString>
            <DisplayString ElementID="VGR.Cytobase.23.12.CheckCytobaseImportFileAge.Script.DS" SubElementID="IntervalSeconds">
              <Name>IntervalSeconds</Name>
              <Description>IntervalSeconds</Description>
            </DisplayString>
            <DisplayString ElementID="VGR.Cytobase.23.12.CheckCytobaseImportFileAge.Script.MT">
              <Name>CheckCytobaseImportFileAge Monitor Type</Name>
              <Description>This is the monitor type that runs the CheckCytobaseImportFileAge.ps1 script.</Description>
            </DisplayString>
            <DisplayString ElementID="VGR.Cytobase.23.12.CheckCytobaseImportFileAge.Script.UnitMonitor">
              <Name>Problem med ImportTjänsten från Cytobase Prod</Name>
              <Description>This is the monitor that runs the CheckCytobaseImportFileAge.ps1 script.</Description>
            </DisplayString>
            <DisplayString ElementID="VGR.Cytobase.23.12.CheckCytobaseImportFileAge.Script.UnitMonitor.AlertMessage">
              <Name>[Cytobase] Problem med ImportTjänsten från vgas1657.vgregion.se</Name>
              <Description>Filer har inte importerats till D:\journalia\CBrdb\RPCBRRI\IN.

    Error Message: {0}.</Description>
              <!--
                  To insert parameters from the property bag, use {x} for each parameter specified under <AlertParameters> (see further up).
                  AlertParameter1 = {0}
                  AlertParameter2 = {1}
                  ...
                -->
            </DisplayString>
          </DisplayStrings>
        </LanguagePack>
      </LanguagePacks>
    </ManagementPackFragment>

            
    Friday, August 23, 2019 12:35 PM

Answers


  • The composition is executed from the bottom up. So you should switch the nodes in order for your filter to be executed first.

    <Composition>
      <Node ID="Filter"> <!-- executed second -->
        <Node ID="PS"/> <!-- executed first -->
      </Node>
    </Composition>

    A thing to notice: In your fragment the DataSourceModuleType triggers the ProbeActionModuleType, but the parameters (From, To, Days) are not passed on to the ProbeActionModuleType.

    Personally I'd move the ConditionDetection section in the ProbeActionModuleType to the DataSourceModuleType right below the ProbeAction on line 31.

    Is there any particular reason you defined a separate ProbeActionModuleType? If not, you could also move the ProbeAction from the ProbeActionModuleType to the DataSourceModuleType, and remove the ProbeActionModuleType altogether. Then set up the Composition like this in your DataSourceModuleType:

    <Composition>
      <Node ID="Probe">
        <Node ID="Filter">
          <Node ID="Schedule" />
        </Node>
      </Node>
    </Composition>

    Hope that helps.


    Wednesday, September 4, 2019 12:19 PM

All replies

  • If you only want the script within a specific timeframe, then I'd look into the schedule module, not the condition detection module.  Never done it before though so interested to know how this unfolds.
    Friday, August 23, 2019 12:58 PM

  • The composition is executed from the bottom up. So you should switch the nodes in order for your filter to be executed first.

    <Composition>
      <Node ID="Filter"> <!-- executed second -->
        <Node ID="PS"/> <!-- executed first -->
      </Node>
    </Composition>

    A thing to notice: In your fragment the DataSourceModuleType triggers the ProbeActionModuleType, but the parameters (From, To, Days) are not passed on to the ProbeActionModuleType.

    Personally I'd move the ConditionDetection section in the ProbeActionModuleType to the DataSourceModuleType right below the ProbeAction on line 31.

    Is there any particular reason you defined a separate ProbeActionModuleType? If not, you could also move the ProbeAction from the ProbeActionModuleType to the DataSourceModuleType, and remove the ProbeActionModuleType altogether. Then set up the Composition like this in your DataSourceModuleType:

    <Composition>
      <Node ID="Probe">
        <Node ID="Filter">
          <Node ID="Schedule" />
        </Node>
      </Node>
    </Composition>

    Hope that helps.


    Wednesday, September 4, 2019 12:19 PM