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
SCOM 2016 Monitor triggers on Value below the threshold.
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
3 answers
Sort by: Most helpful
-
CyrAz 5,181 Reputation points
2021-05-19T15:16:05.443+00:00 -
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
criteria
alert
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.
Alex
If the response is helpful, please click "Accept Answer" and upvote it. -
System Center guy 691 Reputation points
2021-05-20T09:41:29.923+00:00 May be your proeprty bag data type is string.
- Export your MP containing cutom monitor
- 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