There doesnt appear to be any powershell suport. I see support for scripts like VBS via batch files, but direct support of powershell would be perfect. Even indirect support via a batch file calling a powershell script would also work.
I have tested this out using a batch file calling a powershell script and the service test just reads Testing… please wait.
Powershell is so much easier to script and would make custom monitors so much easier for windows servers, especiall custom WMI scripts.
I have had success calling a Powershell script in up.time via a bat script with lines similar to the following in the bat script:
@ECHO OFF start “powershell.exe -noprofile ./script.ps1″
How would you pass values like the uptime host name and the user/pass?
I also tried using your batch file example and i still get the same issue. im just using a simple powershell script
Get-WmiObject Win32_PerfRawData_MSSQLSERVER_SQLServerBufferNode -computer SQL-PROD | measure-object -property PageLifeExpectancy -average | select -expand average write-host “PageLifeExpectancy $values”
These articles outline how to create and integrate custom monitors in up.time:http://support.uptimesoftware.com/article.php?id=66http://support.uptimesoftware.com/article.php?id=67http://support.uptimesoftware.com/article.php?id=68
Are you creating a Custom, Custom with Retained Data, or a Plugin monitor? Values will be passed to the Custom and Custom with Retained Data monitors as arguments (ie. %1) but environment variables are used for a Plugin monitor.
We will test your script internally and respond shortly with further integration suggestions.
Plugin monitor. We have done numerous with VBScript, we are trying to use Powershell now. I even tried just creating a simple custom one and calling the batch file which will return static values and it still did the same thing
The QA process does not currently include testing powershell scripts with the Custom monitor types. As you note, VBScript function properly when called from a batch script, as do most other common scripting languages. I will pass on a request for you to the Product team to investigate why a Powershell script does not behave in the same way and hopefully change that in a future release.
Thank you. It appears that since UpTime runs off java, java or poweshell hold the connection open unless you specifically close the connection to return the data.
Does this mean you were able to get the script to work by closing the connection in Powershell?
With some further testing, we've been able to run the powershell script successfully and have it return a value to up.time with the following command in the batch script:
@ECHO OFFpowershell -noprofile -noninteractive -file .testing.ps1 The key is the redirection of STDIN on the end. Please try that and let me know if you have success running your powershell script via up.time.
yup that did work this time! awesome. Now for the question of how do you pass the servername to the bat then to the PS script? Before to pass from a Bat i had use scriptname.ps1 “Servername” and then in the powershell script it was brought in like this param ([string]$server) at the top, but uptime uses the %UPTIME_SERVER% which wont go through to Powershell based on the way ive set it up. Ideas?
Sorry; I don't understand what's not working. If the line in the bat script calls the powershell script and includes the %UPTIME_SERVER% as an argument, how come that won't work?
Sorry i should have updated this thread. You have to do “%UPTIME_SERVER%” to pass in arguments to powershell
There is an issue when returning values though. I have a simple powershell script just running this: Write-host “Server”
Status: OK Message: o Servero
Output: o Server o
So then when i say for critical, Output does not match Server, it will return critical no matter what because of that extra break. This is what the test returns:Status: CRITMessage: o Output: Servero Does not match Server (Servero )
Output: o Server o
Response time: 828 ms
I believe you are calling the script through a Custom service monitor, correct? It may be better to use Custom with Retained Data or, even better, creating a Plugin monitor because these accept multiple values to be returned and won't collect the trailing new line character into the previous line.
Powered by IDERA