I am looking to use the EXE/SCRIPT ADVANCED SENSOR to run a number of SPs but the SPs have parameters/variables. In the PRTG sensors parameter settings box how would I state my parameter/variable that the SP needs to run?
EXE/SCRIPT ADVANCED SENSOR Parameter/Variables
Votes:
0
29 Replies
Votes:
0
Just like you would call it from the command line :)
Votes:
0
Could you give an example? At the moment I use the following in the parameter box. What do I add to the end to set my parameter for the sp?
-d= database name -sp= SP name -s= server -u= username -p= password -sa
Votes:
0
Then your parameter field just has to look a little something like this:
-d=database -sp=SPname -s=%host -u=username -p=password -sa
Let me know if that works :)
Votes:
0
Yes that is currently what I have but I would like to know what I can add to the string to tell my sensor to call a parameter/variable that has been set in my sp?
I am making generic sp's and my plan is to have one or more parameters in the sp which will let me change the type of information I want as an output.
Votes:
0
Pardon, what do you mean by SP?
Votes:
0
Stored Procedure. I want to use the EXE/SCRIPT ADVANCED SENSOR to call an SP in our database but the SP has a parameter in it that needs to be stated when calling it.
Sorry for any confusion.
Votes:
0
Ah - and you want that parameter to be dynamic? You could add the necessary parameters in the sensor comments, little example:
-d=database -sp='CALL %comments' -s=%host -u=username -p=password -sa
The %comments placeholder will then be replaced with the value of the sensor comment - it can be entered by heading to the tab with the small chat bubble on the sensor page.
Created on Jul 24, 2015 8:01:14 AM by
Stephan Linke [Paessler Support]
Last change on Jul 24, 2015 8:01:24 AM by
Stephan Linke [Paessler Support]
Votes:
0
Okay thank you I see. So in the small chat bubble I state the sp name and the parameter that needs to be set?
Votes:
0
Correct :)
Votes:
0
You're very welcome :)
Votes:
0
I have now put in place my SP's but am having problems with this. I have put -d=database -sp='CALL %comments' -s=%host -u=username -p=password -sa in the setting and setup the comments tab with
EXEC SP Name and then my parameters @parameter1, @parameter2
But I get an error saying Could not find stored procedure 'CALL'. Any advise on what I'm doing wrong?
Votes:
0
Have you tried double quotes (like this: ") around the SP parameter yet?
Votes:
0
Stephan is right, if a parameter contains a white space, the OS will think that these are actually two parameters.
Keeping them together you need to use -sp="CALL %comments%"
Votes:
0
Yes I got the error Could not find stored procedure 'CALL %comments'.
Votes:
0
Are the comments entered within the sensor or the device? Strange that it's not getting replaced...
Votes:
0
Ah okay thanks. Well I have tried it like so -sp="CALL%comments%" and still get an error (Could not find stored procedure 'CALL%comments%'.)
Any chance this might be due to what I have in the comments tab?
If so what should I include in the comments tab? Currently I have it layed out as follows:
EXEC sp name @parameter1, @parameter2
Votes:
0
The correct syntax would be this:
-sp="CALL %comments"
Note the whitespace between CALL and the placeholder and that there's only one %, preceeding the placeholders. The comments have to be like this:
EXEC sp name @parameter1, @parameter2
Votes:
0
Thanks I have tried both exactly as you have suggest above but still no luck.
Votes:
0
scratch that...
Created on Aug 14, 2015 11:05:22 AM by
Stephan Linke [Paessler Support]
Last change on Aug 17, 2015 5:32:38 AM by
Stephan Linke [Paessler Support]
Votes:
0
I'm not quite sure what you mean by test button. My steps to get to this problem are:
-Add a EXE/Script Advanced sensor to my chosen Device (the device doesn't have any real config it is set to 127.0.0.1) -set the EXE/Script field to SQLspXML.exe -Input -d=database -sp="CALL %comments" -s=%host -u=username -p=password -sa in the Parameters field -click save -open the comments tab and input EXEC sp name @parameter1, @parameter2
Votes:
0
are you able to offer any further advice on this? I'm currently running the most up to date version of PRTG.
Votes:
0
Sorry, my bad - seems like %comments isn't parsed in the parameters...You might want to use a wrapper script that reads out the comment via API:
...and then executes it accordingly.
Votes:
0
okay how would I set this up? Do you have some steps to do this?
Votes:
0
Something like this: http://pastebin.com/G9t05hS3 It will read the current comment and execute your SQLspXML.exe with the given parameters, and output the result of it (it should, at least) :) The passhash can be obtained from the account settings within PRTG.
Created on Aug 18, 2015 8:49:27 AM by
Stephan Linke [Paessler Support]
Last change on Aug 18, 2015 8:49:45 AM by
Stephan Linke [Paessler Support]
Votes:
0
alright thank you. Do you have an example of the body for the wrapper script?
Votes:
0
What body do you mean?
Votes:
0
Don't worry have got this working now by using the following info:
Using the optional –cp= parameter, it is possible to pass a comma separated list of parameters to your stored procedure. Parameters and their value need to be separated by a | e.g. -cp="@Firstname|Jane,@LastName|Doe,@Age|26"
Votes:
0
Alright, glad that you got it working now :)
Add comment