This article applies to PRTG Network Monitor 12 or later
Debugging WMI Service Sensors
You can test the return codes of the respective WMI Services while starting with the custom script below. Copy this Visual Basic Script (VBScript) into a text editor and save it as *.vbs file. Then copy this file to the \Custom Sensors\EXE sub folder of the PRTG program directory.
Create a EXE/Script Sensor in PRTG and select this script.
The results can help our technical support team to investigate the issue. Please open a support ticket and send us the results you get.
' *********************************************************************
' PRTG Custom EXE Sensor, VB Demo Script for starting a service via WMI
' *********************************************************************
' created Feb 2013 for PRTG Network Monitor by Paessler Support Team, www.paessler.com
' This script is Open Source and comes without support and warranty
' *********************************************************************
' Provide two Parameters: computer name running the service and service name.
' Include Parameters containing spaces in quotation marks (e.g. "My Service Name")
' *********************************************************************
' You can find explanations for the result codes here:
' http://msdn.microsoft.com/en-us/library/windows/desktop/aa393660%28v=vs.85%29.aspx
if WScript.Arguments.Count <> 4 then
WScript.echo "Wrong number of Arguments." & _
" Please provide Computername,Domain\User,Password and Servicename." & _
" Include Parameters containing spaces in quotation marks (e.g. ""My Service Name""). "& _
" Leave User and Password blank (i.e. """" """") for local computer"
wscript.quit("2")
else
strNamespace = "root/cimv2"
strComputer = WScript.Arguments(0)
strUser = WScript.Arguments(1)
strPassword = WScript.Arguments(2)
strService = WScript.Arguments(3)
Set objLocator = CreateObject("WbemScripting.SWbemLocator")
Set objWMIService = objLocator.ConnectServer(strComputer,strNamespace,strUser,strPassword)
Set colServices = objWMIService.ExecQuery _
("Select * from Win32_Service where Name='" & strService & "'")
For Each objService in colServices
Return = objService.StartService()
If Return <> 0 Then
Wscript.Echo "StartService method returned error code = " & Return
wscript.quit("2")
Else
WScript.Echo "OK:0"
wscript.quit("0")
End If
Next
end if
Add comment