We have defined a own sensor which is based on a script with a XML output. Still PRTG returns the value 0 all the time. If we executed our Powerschell script on the server we receive the value 61
OUTPUT Script: <prtg> <result> <channel> UsedMemory_GB </channel> <value> 61 </value> <mode>Absolute</mode> </result> </prtg>
Can anyone see the error? The value 61 is integer.
Article Comments
Param( [string]$HanaAdminUserName, [string]$HanaAdminPassword, [string]$HanaHostPort ) $ConnectionString = "server=" + $HanaHostPort + ";UserID=" + $HanaAdminUserName + ";Password=" + $HanaAdminPassword #************ Set Your Connection String Parameters here **************** # Check out http://www.connectionstrings.com/ or http://www.w3schools.com/ADO/default.asp for help on ADO # Sample for Microsoft Access Database # $myconnectionstring = "Provider = Microsoft.Jet.OLEDB.4.0; Data Source = c:\test\sample.mdb" # Sample for MS SQL Server # $myconnectionstring = "Provider=SQLOLEDB.1;Password=test;Persist Security Info=True;User ID=test;Initial Catalog=yourname;Data Source=10.1.4.105\SQLEXPRESS" #add-type -path "C:\Program Files\sap\hdbclient\ado.net\v4.5\Sap.Data.Hana.v4.5.dll" #$myconnectionstring = $dsn #************ Set Your SQL Statement Parameters here **************** # The script assumes that your database contains the table 'employees' with the field 'salary'. # According to the Database you may have to adjust the SQL statement. #Add-type -path "C:\Program Files\sap\hdbclient\ado.net\v4.5\Sap.Data.Hana.v4.5.dll" Set Culture en-US $myHDBQuery1 = "select case when count(*) is not null then count(*) else '0' end as delayed_jobs from SAPABAP2.TBTCO where STATUS = 'D'" $mytablecolumnname1="Delayed Jobs" $Connection = New-Object Sap.Data.Hana.HanaConnection $Connection.ConnectionString = $connectionstring $Connection.Open() $Command = New-Object Sap.Data.Hana.HanaCommand($myHDBQuery1, $Connection) $ds=New-Object system.Data.DataSet $da=New-Object Sap.Data.Hana.HanaDataAdapter($Command) [void]$da.fill($ds) $Connection.Close() $QueryResponse = $ds.Tables | Select-Object -Expand Rows $A = $QueryResponse[0]-as[int] # return the result write-output "<prtg>" Write-Output " <result>" Write-Output " <channel>Delayed Jobs</channel>" Write-Output " <value>"$A "</value>" Write-Output " <float>1</float>" Write-Output " </result>" Write-Output "<Text>OK</Text>" Write-Output "</prtg>"
Oct, 2018 - Permalink
Thanks for that. Did you already enable "Use credentials of parent device" in the security context of the sensor?
PRTG Scheduler |
PRTGapi |
Feature Requests |
WMI Issues |
SNMP Issues
Kind regards,
Stephan Linke, Tech Support Team
Oct, 2018 - Permalink
Does the user you're using in the device have that very module installed? What speaks against using ODBC, as in the upper part of the script?
PRTG Scheduler |
PRTGapi |
Feature Requests |
WMI Issues |
SNMP Issues
Kind regards,
Stephan Linke, Tech Support Team
Oct, 2018 - Permalink
We don't understand the question are you proposing? During executing of the script in PS we don't get any error's about ODBC.
Oct, 2018 - Permalink
Sorry if my previous reply was ambiguous. Could you please enable the Write Result To Disk option in the sensor settings, locate them in C:\ProgramData\Paessler\PRTG Network Monitor\Logs\Sensors and send them to us via support@paessler.com, referring to this thread? Thanks! :)
PRTG Scheduler |
PRTGapi |
Feature Requests |
WMI Issues |
SNMP Issues
Kind regards,
Stephan Linke, Tech Support Team
Oct, 2018 - Permalink
We found the solution. Everything in PRTG must be 32-bit. We used PS and DLL of 64-bit quality. After changing this to 32-bit it worked fine.
Oct, 2018 - Permalink
Im not sure what you mean by your solution, but I'm having the same problem. What did you change the 32 bit? Thanks in advance!
Feb, 2023 - Permalink
Hi, thanks for your question. I believe the poster above is suggesting using a 32bit PowerShell DLL? We don't have any results for this ourselves, but it's certainly worth a go here.
Mar, 2023 - Permalink
Just in case somebody else has the problem: I spent over an hour to find out that passing a parameter like
-Path "\ \someserver\somewhere\"
produces exactly that NUL output.
The backslash before the second quote seems to be interpreted as an escape which leads to Powershell failing to start up or something. Removing the backslash before the quote made it work instantly.
May, 2023 - Permalink
Could you post the entire script? Remember to remove any security relevant information.
PRTG Scheduler | PRTGapi | Feature Requests | WMI Issues | SNMP Issues
Kind regards,
Stephan Linke, Tech Support Team
Oct, 2018 - Permalink