Script based monitor in SCOM

rahul vaish 70 Reputation points
2023-05-03T11:05:03.85+00:00

Hello Guys,

I have created one script based monitor to log the nic teaming status. It works though, creates the alert as well, but doesn't close it once the monitor health is "Healthy". I have added 2 lines on script which logs an event also when script runs and completes. Below is the script.

< #Load the MOMScript API and the PropertyBag Provider

$api = New-Object -ComObject "MOM.ScriptAPI"

$propertyBag = $api.CreatePropertyBag()

#Log an Event that our script is starting

$api.LogScriptEvent("Teaming12.ps1",3375,0,"Nicteaming on Hyper-V is starting")

#MainScript

$NicTeamingStatus = (Get-NetLbfoTeam -Name "Team1").status

#Log and Event that our script is complete

$api.LogScriptEvent("Teaming12.ps1",3376,0,"Nicteaming on Hyper-V is Complete - $NicTeamingStatus")

#Output the Propertybag data for Scom Consumption:

$propertyBag.AddValue("NicTeamingStatus",$NicTeamingStatus) 

$propertybag 

>

Parent Monitor: Configuration

Schedule : 5 minutes

Unhealthy expression:

Property[@Name='NicTeamingStatus'] <Operator-Does not equal> <Value- Up>

Healthy Expression:

Property[@Name='NicTeamingStatus'] <Operator-equals> <Value- Up>

** I have this Powershell 2 state monitor configured on Target "Windows Server" in disabled state, enabled it through override to target only one Physical server. I am geting alert from that physical server, monitor logs events also on that server. But doesn't closet the alert once teaming status is UP / monitor health is healthy.

Can someone help me , what i am doing wrong here.

healthy

unhealthy

Microsoft System Center | Other
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. XinGuo-MSFT 22,246 Reputation points
    2023-05-04T06:53:18.2133333+00:00

    Hi,

    To close this alert, the health state of the corresponding monitor has to be manually reset to healthy state. If autoresolve for this monitor is set to true, then the alert will be auto closed after the health state is reset. Else, the alert has to be manually closed after the health state is reset.

    https://learn.microsoft.com/en-us/system-center/scom/manage-alert-created-by-monitor?view=sc-om-2022#operations-console


  2. XinGuo-MSFT 22,246 Reputation points
    2023-05-05T07:19:45.3966667+00:00

    Please try using a simple test script with the same configuration and see if it can autoresolve.

    If it resolves automatically, it should be a script issue.


Your answer

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