I am wanting to be able to right click on a device or sensor, then select tools and then be able to choose a script to run against that selected device or sensor. I have a test script written and it works while not going through PRTG (it just pings the device) but I cannot get PRTG to run the script from the tools submenu (right click) on the devices.
Running a Script using the Windows GUI Tools
Votes:
0
6 Replies
Votes:
0
Hello,
just to check you are referring to the PRTG WinGUI, correct? Do you get an error when you try running the script through PRTGs WinGUI? Could you please post the script here?
Best Regards.
Votes:
0
Yes I am using the PRTG WinGUI and here is the script, which now works once I put it in the right place locally, but I do not want to have to hard code the ip address, I want it as a variable that PRTG would hand off to it:
If Reachable("10.24.0.65") Then WScript.Echo "Computer is Reachable" Else WScript.Echo "Computer is Unreachable!" End If Function Reachable(strComputer) ' On Error Resume Next Dim wmiQuery, objWMIService, objPing, objStatus wmiQuery = "Select * From Win32_PingStatus Where " & _ "Address = '" & strComputer & "'" Set objWMIService = GetObject("winmgmts:\\.\root\cimv2") Set objPing = objWMIService.ExecQuery(wmiQuery) For Each objStatus in objPing If IsNull(objStatus.StatusCode) Or objStatus.Statuscode<>0 Then Reachable = False 'if computer is unreacable, return false Else Reachable = True 'if computer is reachable, return true End If Next End Function
What I would like to do is where the IP address is hard coded in the script:
--If Reachable("10.24.0.65") Then--
I would like to pass this information to the script from PRTG. So that I could use this tool on any device that has an ip address. This is just a test script, so that once I validate that I can grab the correct info from PRTG and use it, I will build a larger script that has some built in tools for daily maintenance and or changes.
Thanks for the help!
Created on Jan 18, 2011 6:03:51 PM
Last change on Jan 18, 2011 6:06:49 PM by
Torsten Lindner [Paessler Support]
Votes:
0
Have you tried using the '%host' placeholder from the WinGUI?
Votes:
0
Yes, that is what I am trying to work around now, when I put that in the script I get a VB error, is there a way to pass the %host field to a vbscript? I get an invalid character error if I use %host.
Votes:
0
You can't use the '%host' (or other placeholders) in the vbscript. You will have to pass it on to the script as a Parameter in the 'Tools'-Settings of the WinGUI, then you will have to 'catch' this parameter inside the vbscript with something like:
WScript.Arguments(0)
if it's the first parameter.
Votes:
0
Torsten,
Once I put that in and had the %host in the argument line of the custom tool it worked like a charm:
dim intIpAddress
intIpAddress = wscript.arguments(0)
If Reachable(intIpAddress) Then WScript.Echo "Computer " & intIpAddress & " is Reachable"
Thanks again for your help!
Add comment