Published: May 01, 2009
One of the most annoying facts about the Microsoft System Center Operations Manager console (also known as OpsMgr) is that it is too silent… Sometimes you simply wish there was a simple beep or other sound alert coming out of it. When a new alert is triggered, anyone would expect its monitoring system to play a sound alert that would wake the computer operator from his nap.
Since this feature is not available in OpsMgr out of the box, I was happy to read a very cool tip submitted to me by Snir Hofman – One of the guys in the Smart-X experts team (visit them at www.smart-x.com). This is what Snir wrote:
I came up with a solution to play a sound on a remote computer when a new alert is triggered (or whenever you decide). This works using a VBS script as a notification method utilizing WMI to create a remote process and play a wav file using “Media Player Classic”.
Here are the steps needed to be followed:
1. Download “Medial Player Classic” from the following URL:
http://www.free-codecs.com/Media_Player_Classic_download.htm
2. Extract the exe file. (I use mplayerc because it’s stand alone and very light).
3. Get a WAV file from the web (Google it, you can use any sound you like, but please, no elephants in the servers’ room!)
4. Create a share on a central location and copy mplayerc.exe and the wav file into it (let’s call it alert.wav).
5. Copy the text from below and paste it to a VBS file (let’s call it AlertSound.vbs). Save it on the OpsMgr server in a location of your choice (let’s say D:\scripts).
6. Edit the “strCommand” to reflect the new share location and the WAV filename to what you saved.
7. In OpsMgr, create a new notification under Command Channel (I used the samples I wrote above):
a. Full Path to file: d:\scripts\AlertSound.vbs.
b. Command line parameters: the name of the PC on which you wand the alert to be heard.
c. Initial Directory: D:\scripts.
7. Then create a subscription to your needs. You’re done!!!
Note: There are a few important issues you should keep in mind:
1. The share should have at least read permissions to the user running the OpsMgr because the script will run under his credentials.
2. If you want another PC to sound alert, add another notification and change the parameter to reflect on the new PC name.
3. Don’t forget to plug in a decent set of speakers so everyone will hear it, and again, please, no elephants in the servers’ room!
The VBS Code:
=================================================
Option Explicit
‘On Error Resume Next
dim strComputer ‘target computer
dim wmiNS
dim wmiQuery, wmiQuery1
dim objWMIService
Dim objProcess
dim objProcessSU ‘holds the Process Startup Object
Dim objConfig ‘new Instance of ProcessSU object
Dim errRTN ‘rtn code from create process
Dim procID ‘process ID returned from createProcess
Dim strCommand ‘Command to launch
strComputer = wscript.arguments(0)
wmiNS = “\root\cimv2”
wmiQuery = “win32_ProcessStartUP”
wmiQuery1=”win32_process”
strCommand = “\\server\share\mplayerc.exe /close \\server\share\alert.wav” ‘app we want to launch.
Set objWMIService = GetObject(“winmgmts:\\” & strComputer & wmiNS)
Set objProcessSU = objWMIService.Get(wmiQuery)’create Process Startup object
Set objProcess = objWMIService.Get(WmiQuery1) ‘Get win32_process class
Set objConfig = objProcessSU.SpawnInstance_ ‘Create an instance of the processSU
objConfig.ShowWindow = 1 ‘normal window
objConfig.x = 5
objConfig.y = 5
errRTN = objProcess.Create(strCommand, Null, objConfig, procID)
‘WScript.echo errRTN & ” ” & procID
SubERR
Sub subERR
If errRTN <> 0 Then
WScript.echo “An error occurred while launching ” & strcommand & vbcrlf & “the error was: ” & errRTN
End If
End sub
===============================================
Thanks Snir!