Hi Thwackers
I downloaded the APM template available in the Content Exchange section, for Hyper-V monitoring.
I want to analyse the up/down/other status of the VMs installed on the Hyper-V Servers. So I created a new Windows Script Monitor and put this code in :
Option Explicit
Dim WMIService
Dim VMList
Dim VM
Set WMIService = GetObject("winmgmts:\\HYPER-V_SERVER\root\virtualization")
Set VMList = WMIService.ExecQuery("SELECT * FROM Msvm_ComputerSystem WHERE ElementName = 'VM_NAME'")
For Each VM In VMList
if VM.Caption = "Virtual Machine" then
if VM.EnabledState = 2 then
Wscript.Echo "Message: " & VM.ElementName & " is Running"
Wscript.Echo "Statistic: 0"
Wscript.Quit(0)
elseif VM.EnabledState = 32769 then
Wscript.Echo "Message: " & VM.ElementName & " is Saved"
Wscript.Echo "Statistic: 2"
Wscript.Quit(2)
elseif VM.EnabledState = 3 then
Wscript.Echo "Message: " & VM.ElementName & " is Off"
Wscript.Echo "Statistic: 1"
Wscript.Quit(1)
else
Wscript.Echo "Message: " & VM.ElementName & " is in state: " & VM.EnabledState
Wscript.Echo "Statistic: 3"
Wscript.Quit(3)
end if
end if
Next
Now if the VM is in any other state than "Running", I get the message as follows :
Application Status: Application status is Down
Component Status: Component status is Down
Component Status Details: The return code is different than expected. The script returned status code DOWN. VM_NAME is Off
Component Type: Windows Script Monitor
Message: The script returned status code DOWN. VM_NAME is Off
Response Time: N/A
Statistic Data: N/A
Last Time Up 2011-06-21 13:57:50
Elapsed Time
Since Last Up 31 minutes
Next Poll Time 2011-06-21 14:34:22
Is it possible to only have the VM_NAME is Off message and remove the "The return code is different than expected. The script returned status code DOWN" part ????