question

anupvtr avatar image
0 Votes"
anupvtr asked anupvtr commented

SCOM Powershell Monitor generated alerts for a lower threshol

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

msc-operations-manager
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

CyrAz avatar image
0 Votes"
CyrAz answered anupvtr commented

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...


· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thank you very much @CyrAz for the detailed information. This helped me.

After adding the integer to xpathquery where ever its missing. resolved the issue.

The specific property bag will logged the values -3,-2 and -1. this was for error logging in event viewer.

Thanks
Anu

0 Votes 0 ·
CyrAz avatar image
0 Votes"
CyrAz answered

Could you show us the relevant xml code?

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

StoyanChalakov avatar image
0 Votes"
StoyanChalakov answered

Hi @anupvtr,

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

Thanks!
Regards,
Stoyan

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

anupvtr avatar image
0 Votes"
anupvtr answered

@CyrAz @StoyanChalakov 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



xml.jpg (125.5 KiB)
criteria.jpg (138.4 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

CyrAz avatar image
0 Votes"
CyrAz answered anupvtr edited

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.

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thanks @CyrAz ,

The monitor is created via console. XpathQuery has no type in the first expression.

I changed the values String to integer in the following available places, Bad luck still generating alert for lower value.

198828-xml1.jpg


0 Votes 0 ·
xml1.jpg (145.3 KiB)