Forwarding SNMP Traps
Hi, Can SCOM 2007 forward alerts generated by monitored servers to an external system e.g. ticketing system in the form snmp traps. MOM had the abillity http://msdn.microsoft.com/en-us/library/aa505290.aspx but I am not sure if it is possible with SCOM 2007. Thanks
September 30th, 2012 9:31am

Try to using the following method Create a new notification channel Full Path of the command line : C:\WINDOWS\System32\windowspowershell\v1.0\PowerShell.exe Command line parameters : C:\OpsMgrScripts\TrapGenerator\mposter.ps1 '$Data/Context/DataItem/AlertId$' Startup folder for the command line : C:\OpsMgrScripts\TrapGenerator Content of mpposter.ps1 (The mpposter.exe must be in the folder C:\OpsMgrScripts\TrapGenerator\mposter.exe) ------------------------------------------------------- ============================================================================================== # # Microsoft PowerShell Source File # # NAME: mposter.ps1 # # # COMMENT: This script will generate an SNMP trap to a given destination for alertID # # PARAMETERS: # # alertID # # ============================================================================================== #### #### # Start Ops Mgr snapin, get Alert ID ### $rootMS = 'localhost' #Initializing the Ops Mgr 2007 Powershell provider Add-PSSnapin "Microsoft.EnterpriseManagement.OperationsManager.Client" -ErrorVariable errSnapin ; Set-Location "OperationsManagerMonitoring::" -ErrorVariable errSnapin ; new-managementGroupConnection -ConnectionString:$rootMS -ErrorVariable errSnapin ; Set-Location $rootMS -ErrorVariable errSnapin ; $sAlertID = $args[0].substring(1,$args[0].Length-2) $oAlert = Get-Alert | where {$_.Id -eq $sAlertID} $sAlertID $oAlert.ID $sOrigin = 'SERVERNAME' $sCommunity = 'sc2' $sDestinations = 'x.x.x.x' $aDestinations = $sDestinations.Split(",") $sAlertURL = '' $sMessage = 'TrapGeneratorFromAlertID.ps1: ran succesfully. It generated SNMP traps with the following data: ' ForEach ($sDestination in $aDestinations) { $sCommand = 'C:\OpsMgrScripts\TrapGenerator\mposter.exe' $sFilePath = "C:\OpsMgrScripts\TrapGenerator\mposter" + $sAlertID + "." + $sDestination + ".txt" 'omRedCriticalErrorAlert;' | Out-File -filepath $sFilePath -append -noClobber -encoding ASCII If ($oAlert.Severity -eq "Warning") { 'omAlertLevel=30;' | Out-File -filepath $sFilePath -append -noClobber -encoding ASCII 'omAlertLevelName=Warning;' | Out-File -filepath $sFilePath -append -noClobber -encoding ASCII } Else { 'omAlertLevel=30;' | Out-File -filepath $sFilePath -append -noClobber -encoding ASCII 'omAlertLevelName=Error;' | Out-File -filepath $sFilePath -append -noClobber -encoding ASCII } 'omServer="' + $oAlert.NetbiosDomainName + '\\' + $oAlert.NetbiosComputerName + '";' | Out-File -filepath $sFilePath -append -noClobber -encoding ASCII 'hostname="' + $oAlert.NetbiosDomainName + '\\' + $oAlert.NetbiosComputerName + '";' | Out-File -filepath $sFilePath -append -noClobber -encoding ASCII 'omSource="' + $oAlert.Name + '";'| Out-File -filepath $sFilePath -append -noClobber -encoding ASCII 'omOwner="SCOM ' + $oAlert.Owner + '";'| Out-File -filepath $sFilePath -append -noClobber -encoding ASCII 'omDescription="' + $oAlert.MonitoringObjectFullName + ': ' + $oAlert.Description + '";'| Out-File -filepath $sFilePath -append -noClobber -encoding ASCII 'omCustomField1="' + $oAlert.CustomField1 + '";'| Out-File -filepath $sFilePath -append -noClobber -encoding ASCII 'omCustomField2="' + $oAlert.CustomField2 + '";'| Out-File -filepath $sFilePath -append -noClobber -encoding ASCII 'omCustomField3="' + $oAlert.CustomField3 + '";' | Out-File -filepath $sFilePath -append -noClobber -encoding ASCII 'omCustomField4="' + $oAlert.CustomField4 + '";' | Out-File -filepath $sFilePath -append -noClobber -encoding ASCII 'omCustomField5="' + $oAlert.CustomField5 + '";' | Out-File -filepath $sFilePath -append -noClobber -encoding ASCII 'omAlertURL="' + $sAlertURL + '";' | Out-File -filepath $sFilePath -append -noClobber -encoding ASCII 'ObjectFullName="' + $oAlert.MonitoringObjectFullName + '";' | Out-File -filepath $sFilePath -append -noClobber -encoding ASCII 'ObjectId="' + $oAlert.MonitoringObjectId + '";' | Out-File -filepath $sFilePath -append -noClobber -encoding ASCII 'ObjectClassId="' + $oAlert.MonitoringClassId + '";' | Out-File -filepath $sFilePath -append -noClobber -encoding ASCII 'ObjectDisplayName="' + $oAlert.MonitoringObjectDisplayName + '";' | Out-File -filepath $sFilePath -append -noClobber -encoding ASCII 'ObjectPath="' + $oAlert.MonitoringObjecPath + '";' | Out-File -filepath $sFilePath -append -noClobber -encoding ASCII 'Priority="' + $oAlert.Priority + '";' | Out-File -filepath $sFilePath -append -noClobber -encoding ASCII 'END' | Out-File -filepath $sFilePath -append -noClobber -encoding ASCII $sCommandParameters = '-f c:\OpsMgrScripts\TrapGenerator\mcell.dir ' + '-n snmp ' + $sFilePath $sFileContent = Get-Content $sFilePath $sMessage = $sMessage + $sFileContent + "`n" + "`n" $ProcTrap = [System.Diagnostics.Process]::Start($sCommand,$sCommandParameters) $ProcTrap.WaitForExit(); Remove-Item $sFilePath } #$oAlert.ResolutionState = 0 #$oAlert.Update("") ### # Write a successfull run event to the eventlog ### $oLog = New-Object System.Diagnostics.EventLog $oLog.Set_Log("Operations Manager") $oLog.Set_Source("Health Service Script") $oLog.WriteEntry($sMessage,"Information",99) ### # Remove the Ops Mgr PSSnapin ### Remove-PSSnapin Microsoft.EnterpriseManagement.OperationsManager.Client ------------------------------------------------------------------- Create a new Subscription, select the criteria and etc, for the channels, used the one created above. Create a new Subscriber, as addresses chosse new, Channel Type : Command, Command Chanel : the channel created above For detail pls. refer to http://social.technet.microsoft.com/Forums/en-US/operationsmanagerextensibility/thread/122f656a-5109-452a-ba1a-a17c89d347d6/ Roger
Free Windows Admin Tool Kit Click here and download it now
October 1st, 2012 2:09am

Hi, Please see if the following rule and monitor can meet your requirements: How to Create an SNMP Trap Event Collection Rule in Operations Manager 2007 http://technet.microsoft.com/en-us/library/bb381242.aspx How to Create a Monitor for SNMP Traps in Operations Manager 2007 http://technet.microsoft.com/en-us/library/bb381355.aspx Hope this helps. Thanks. Nicholas Li TechNet Community Support
October 1st, 2012 4:23am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics