SCOM 2016 Monitor triggers on Value below the threshold.

SaltAndTilt 1 Reputation point
2021-05-19T12:23:26.143+00:00

Hello together,

I have the following problem with a scom-monitor.

It executes the following script:

Set oAPI = CreateObject("MOM.ScriptAPI")
Set oBag = oAPI.CreatePropertyBag()

pscommand = "$LastPatchDate = Get-HotFix | Sort-Object InstalledOn | Select-Object -Last 1 | Select -Expandproperty InstalledOn; ((Get-Date) - $LastPatchDate).TotalDays"

cmd = "powershell.exe -noprofile  -command " & pscommand

Set Shell = CreateObject("Wscript.Shell")
Set executor = shell.Exec(cmd)
executor.StdIn.Close
rv = executor.StdOut.ReadAll
rvl = CDbl (rv)
Call oBag.AddValue("Days",rvl)
Call oAPI.Return(oBag)

Which throws back a value, for example: 7,33342137057454

The trigger for the monitor to swap into a failed state is set to "higher or equal" 44. But the monitor still swaps to failed even with a value below the threshold.

Do i have a critical error in my thinking how the monitors work?
Or does anyone have experiences with this bug and can maybe even offer a solution?

Regards, Jakob

Operations Manager
Operations Manager
A family of System Center products that provide infrastructure monitoring, help ensure the predictable performance and availability of vital applications, and offer comprehensive monitoring for datacenters and cloud, both private and public.
1,493 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. CyrAz 5,181 Reputation points
    2021-05-19T15:16:05.443+00:00

    COuld you you show the xml for the monitortype?
    Chances are the terms of the comparison are typed as string and not as integer or double; and therefore a numerical comparison can't work

    0 comments No comments

  2. AlexZhu-MSFT 5,956 Reputation points Microsoft Vendor
    2021-05-20T05:09:59.113+00:00

    Hi,

    We can use powershell script directly, other than using VB script to call the function.

    $api = New-Object -comObject "MOM.ScriptAPI"   
    $PropertyBag = $api.CreatePropertyBag()  
      
    $LastPatchDate = Get-HotFix | Sort-Object InstalledOn | Select-Object -Last 1 | Select -Expandproperty InstalledOn  
    $rv = ((Get-Date) - $LastPatchDate).TotalDays  
      
    $PropertyBag.AddValue("Days",$rv)  
    $PropertyBag  
    

    Here's some screenshots from my lab test.

    script
    98122-scom-script-based-monitor-07.png

    criteria
    98123-scom-script-based-monitor-08.png

    alert
    98096-scom-script-based-monitor-12-alert.png

    and I've confirmed that value "255.396x" and "328.3x" did not generate the alert since the criteria is set to 400 or higher.
    98080-scom-script-based-monitor-13-verification.png

    Alex
    If the response is helpful, please click "Accept Answer" and upvote it.


  3. System Center guy 691 Reputation points
    2021-05-20T09:41:29.923+00:00

    May be your proeprty bag data type is string.

    1. Export your MP containing cutom monitor
    2. navigate the xml file and fine "XPathQuery Type" and "Value Type"
      e.g.
         <ErrorExpression>
           <SimpleExpression>
             <ValueExpression>
               <XPathQuery Type="String">Property[@Name-Status"]</XPathQuery>
             </ValueExpression>
             <Operator>Greater</Operator>
             <ValueExpression>
               <Value Type="String">34</Value>
             </ValueExpression>
           </SimpleExpression>
         </ErrorExpression>
         <SuccessExpression>
           <SimpleExpression>
             <ValueExpression>
               <XPathQuery Type="String">Property[@Name-Status"]</XPathQuery>
             </ValueExpression>
             <Operator>LessEqual</Operator>
             <ValueExpression>
               <Value Type="String">34</Value>
             </ValueExpression>
           </SimpleExpression>
         </SuccessExpression>
      

    By defaul, it is string data type, you should modify it into suitable data type
    3) possible data types
    “Boolean”
    “Integer”
    “UnsignedInteger”
    “Double”
    “Duration”
    “DateTime”
    “String”

    roger

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.