We can successfully set up the SCOM notifications so that when an alert is
received in SCOM a script is executed as required. However, we are having
problems when using the command line parameter
$Data/Context/DataItem/AlertDescription$ to provide the description of the
alert.
From various tests that we have run, using a variety of DOS batch, VBS and
Powershell scripts it seems that because the alert description contains
spaces only the first word of the alert description is passed via SCOM. We
have tried using various characters wrapped around the
$Data/Context/DataItem/AlertDescription$ parameter in the SCOM Notification
Command Channel setup but are not able to get the full description passed to
the script.
However, if we manually run Powershell we are able to pass several strings
all containing spaces to our script(s).
Any ideas?
Regards,
Alex.
You can create a script using VbScript.
Use notification,
When configuring notification channel, you can add description parameters on
command line
Regards,
--
JF BERENGUER
MCSA messaging, MCSE, MCT
NEXTEC SYSTEMS
http://actelia.spaces.live.com/
I know much more about PowerShell than I do about OpsMgr. Are you able
to provide more detailed example?
Marco
--
Microsoft MVP - Windows PowerShell
http://www.microsoft.com/mvp
PowerGadgets MVP
http://www.powergadgets.com/mvp
I've not done this specifically with subscriptions but you do get the same
issue (spaces in parameters being passed) when you run a vbscript response
to a rule where you want a parameter passed to the script. This happens
because the Argument seperator is a space ... which is what you'd expect
(but sadly don't want). I got around this on the vbscript responses by using
named arguments. So in the rule response, when it asks for a parameter I
specify:
/Desc:"$Data/EventDescription$"
Then in the VBScript:
Dim oArg
Set oArg = WScript.Arguments.Named
Desc = OArg.Item("Desc")
This works ... for me at least ... might be worth a go with the
subscriptions. Hope it makes some sense ;-)
Cheers
Graham
"Alex Wright" <AlexW...@discussions.microsoft.com> wrote in message
news:781C6228-E8CC-46E2...@microsoft.com...
My problem is:
I am monitoring some servers for a 7004 event in the application log. When
this event occurs on my server I want to execute a script that has the
AlertDescription in it. Under most conditions I can do this, but for this
particular event I cannot... explanation to follow.
Here is the original text from the event description: (except I changed the
email add)
--begin--
This is an SMTP protocol error log for virtual server ID 1, connection
#15930. The remote host "172.1.2.3", responded to the SMTP command "rcpt"
with "550 5.7.1 Unable to relay for ab...@abc.com ". The full command sent
was "RCPT TO:<ab...@abc.com> ". This will probably cause the connection to
fail.
--end--
I used this as my test script
--begin--
Option Explicit
Dim colNamedArguments
Dim AlertDescription
Set colNamedArguments = Wscript.Arguments.Named
AlertDescription = colNamedArguments("desc")
Wscript.Echo "Data: " & AlertDescription
--end--
For my Command Notification Channel I pointed it to the script specified
above... and passed it one single argument:
$Data/EventDescription$
The result is that the internal nested quotes bungle it up. the quotes that
are around a single group of text do not bother it... but the internal nested
quotes that are around a group of text separated by a space... causes it to
terminate the param (truncated)... the rest of the message is read as
multiple unquoted parameters (as though they weren't qouted). (it terminates
after the "550 ) Notice that it is the first white space after the quote.
This can be demonstrated in a much more simple format as
--begin MyScript--
dim MyVar
MyVar = Wscript.Arguments(0)
Wscript.Echo MyVar
--end MyScript--
Now at the command line execute
cscript MyScript.vbs Hello World
> As expected in prints "Hello"
cscript MyScript.vbs "Hello World"
> As expected it prints "Hello World"
cscript MyScript.vbs "Hello W"orld
> Not as I expected... it prints "Hello World"
> notice that it terminates on the first white space after the 2nd quote
cscript MyScript.vbs "My favorite program is the "Hello World" program."
> it prints "My favorite program is the Hello"
> If you add vars for a second and third cmd param you would find that
> Wscript.Arguments(1) = "World"
> Wscript.Arguments(2) = "program."
I know this may be hard to follow with all my rambling... but it is really
causing me pain... any help would be greatly appreciated.
Regards,
Curtis
'VBScript File to Send Command Notifications to BEIM
'Parse Wscript.Arguments and set variables
strTotalArg = ""
for each strArgument in Wscript.Arguments
if len(strTotalArg) = 0 Then
strTotalArg = strTotalArg & strArgument
else
strTotalArg = strTotalArg & " " & strArgument
end if
next
strArgumentsToSplit = Split(strTotalArg, ",")
'Assign array elements to named variables and concatenate as needed
strAssignGroup = strArgumentsToSplit(0)
strTime = strArgumentsToSplit(1)
'strAlertDetails = replace(strArgumentsToSplit(2),"\n",chr(10)) & chr(10) & replace(strArgumentsToSplit(4),"\n",chr(10)) & chr(10) & replace(strArgumentsToSplit(8),"\n","\r")
strAlertDetails = replace(strArgumentsToSplit(2),"\n","\n") & replace(strArgumentsToSplit(4),"\n","\n") & replace(strArgumentsToSplit(8),"\n","\n")
strBaseAlert = replace(strArgumentsToSplit(2),"\n","\n")
strManagedServer = strArgumentsToSplit(3)
strSeverity = strArgumentsToSplit(5)
strPriority = strArgumentsToSplit(6)
strWebConsoleLink = strArgumentsToSplit(8)
strAlertId = strArgumentsToSplit(9)
strServiceType = "UNDEFINED"
'Set service type based on team name
if strAssignGroup = "INF-SSM Tools" then
strServiceType = "SYSTEMS MANAGEMENT"
elseif strAssignGroup = "INF-CollaborationServices" then
strServiceType = "COLLABORATION"
elseif strAssignGroup = "INF-WindowsEngineering" then
strServiceType = "SERVER WINDOWS"
else strServiceType = ""
end if
'Set Priority level
if strPriority = "0" then
strPriority = "INFORMATIONAL"
elseif strPriority = "1" then
strPriority = "WARNING"
else strPriority = "CRITICAL"
end if
'Create the string to write information to the log file The line that is commented out will write the array values to the log for testing
'strWriteToLog = strAssignGroup & " | " & strTime & " | " &strAlertDetails & " | " & strManagedServer & " | " & strSeverity & " | " & strWebConsoleLink
strWriteToLog = strArgumentsToSplit(0) & " | " & strArgumentsToSplit(1) & " | " & strArgumentsToSplit(2) & " | " & strArgumentsToSplit(3) & " | " & strArgumentsToSplit(4) & " | " & strArgumentsToSplit(5) & " | " & strArgumentsToSplit(6) & " | " & strArgumentsToSplit(7) & " | " & strServiceType
'Build the Msend expression with all variables
'strMsend = "%comspec% /c e:\beim\msend.exe -n krtest -j %MCELL_HOME%\buffer\test -a SCOM_Event -o SCOM -r " & strSeverity & " -m """ & strAlertDetails & """ -b ""action_type=[InfraOpen];action_targets_infra=[" & strAssignGroup & "];mc_host=" & strManagedServer & ";mc_location=HDC;scom_id=" & strAlertId & ";"""
strMsend = "%comspec% /c e:\beim\msend.exe -n krtest -j %MCELL_HOME%\buffer\test -a SCOM_Event -o SCOM -r " & strPriority & " -m """ & strAlertDetails & """ -b ""action_type=[InfraOpen];action_targets_infra=[" & strAssignGroup & "];mc_host=" & strManagedServer & ";mc_location=HDC;scom_id=" & strAlertId & ";scom_msg=" & strBaseAlert & ";infra_service=" & strServiceType & ";"""
'Declare Variables to be used to write to log file
Dim oFilesys, oFiletxt, sFilename, sPath
'Write a line in the logfile with all the appropriate information
Set oFilesys = CreateObject("Scripting.FileSystemObject")
Set oFiletxt = oFilesys.OpenTextFile("e:\log.txt", 8, True)
sPath = oFilesys.GetAbsolutePathName("e:\log.txt")
sFilename = oFilesys.GetFileName(sPath)
oFiletxt.WriteLine(" " & strWriteToLog )
'oFiletxt.WriteLine(" " & strMsend )
oFiletxt.Close'
'Execute command line parameters for MSEND
Set objShell = CreateObject("Wscript.Shell")
objShell.Run strmsend
AlexWrigh wrote:
Running scripts via SCOM notifications.
12-Apr-08
Any ideas?
Regards,
Alex.
EggHeadCafe - Software Developer Portal of Choice
EGGHEADCAFE.COM .NET PROGRAMMING CONTEST
http://www.eggheadcafe.com/tutorials/aspnet/bd7b83b6-606a-4709-8248-1d4ca1f97869/eggheadcafecom-net-prog.aspx