SCOM Powershell Monitor generated alerts for a lower threshol

ANU 336 Reputation points
2022-05-03T17:56:47.073+00:00

Hi All, Thanks in advance.

We are using powershell MP.

I created a custom Monitor with powershell MP. The alert is always getting generated with a lower value

Created Event login for the property bag output. The value is successfully getting captured.
the output will always an Integer

The condition to generate an alert is if the value is greater than 100.

The current property bag value is 6. Unfortunately its generating alert on the value 6.

Troubleshooting step performed:

1) Exported the MP containing custom monitor
2) navigate the xml file and fine "XPathQuery Type" and "Value Type"
By defaul, it is string data type, you should modify it into suitable data type
3) possible data types
“Boolean”
“String”

Tried with string and integer types but bad luck unfortunately still alert is generating with a lower value.
Any help will be thankful.

Thanks & regards,
Anu

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,446 questions
0 comments No comments
{count} votes

Accepted answer
  1. CyrAz 5,181 Reputation points
    2022-05-04T15:05:10.447+00:00

    You can add a type at the first xpathquery directly in XML, that won't be a problem and that's very likely the cause of your issue.
    That can actually be demonstrated easily with PowerShell :
    $counts = "6"
    $counts.GetType().Name

    String

    $counts -gt 100

    True

    $counts -gt 70

    False

    $intCounts = 6 #not using quotes here
    $intCounts.GetType().name

    Int32

    $intCounts -gt 100

    False

    That shows that when running a comparison between a string and an integer, only the first number of the integer is taken into account.
    But when the comparison is made between two integers it works properly.

    Also I don't understand why you made the expression like this... It states that the value must be greater than 100 and not equal to -3 and not equal to -2 and not equal to -1 : that doesn't make a lot of sense, anything greater than 100 can mathematically never have a value below 0 so there is no point specifiyng all this...


4 additional answers

Sort by: Most helpful
  1. CyrAz 5,181 Reputation points
    2022-05-03T22:37:14.49+00:00

    Could you show us the relevant xml code?

    0 comments No comments

  2. SChalakov 10,371 Reputation points MVP
    2022-05-04T06:36:42.137+00:00

    Hi @ANU ,

    can you please paste the script here so that we can take a look?

    Thanks!
    Regards,
    Stoyan

    0 comments No comments

  3. ANU 336 Reputation points
    2022-05-04T11:40:34.77+00:00

    @CyrAz @SChalakov unfortunately i am not able to copy paste the code over here. I can attach as a screenshot for the criteria.

    198862-xml.jpg

    198853-criteria.jpg

    0 comments No comments

  4. CyrAz 5,181 Reputation points
    2022-05-04T13:30:38.13+00:00

    Xpathquery has no type in the first expression and is typed as string in the following two expressions.
    It should work if you type it as integer.