What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general.

Learn more

PRTG Network Monitor

Intuitive to Use. Easy to manage.
More than 500,000 users rely on Paessler PRTG every day. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free Download

Top Tags


View all Tags

Powershell script gives continuously value null

Votes:

0

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.

custom-sensor powershell prtg script

Created on Oct 1, 2018 2:33:04 PM



Best Answer

Accepted Answer

Votes:

0

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.

Created on Oct 3, 2018 12:23:21 PM



12 Replies

Votes:

0

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

Created on Oct 1, 2018 3:24:11 PM by  Stephan Linke [Paessler Support]



Votes:

0

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>"

Created on Oct 2, 2018 8:10:34 AM

Last change on Oct 3, 2018 1:10:52 PM by  Dariusz Gorka [Paessler Support]



Votes:

0

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

Created on Oct 2, 2018 9:36:13 AM by  Stephan Linke [Paessler Support]



Votes:

0

The option: "Use Windows credentials of parent device" is selected

Created on Oct 2, 2018 10:03:43 AM



Votes:

0

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

Created on Oct 2, 2018 11:39:06 AM by  Stephan Linke [Paessler Support]



Votes:

0

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.

Created on Oct 2, 2018 12:19:01 PM



Votes:

0

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 [email protected], referring to this thread? Thanks! :)


PRTG Scheduler | PRTGapi | Feature Requests | WMI Issues | SNMP Issues

Kind regards,
Stephan Linke, Tech Support Team

Created on Oct 2, 2018 1:10:33 PM by  Stephan Linke [Paessler Support]



Accepted Answer

Votes:

0

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.

Created on Oct 3, 2018 12:23:21 PM



Votes:

0

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!

Created on Feb 21, 2023 10:29:07 PM



Votes:

0

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.

Created on Mar 9, 2023 9:26:23 AM by  Mike Payne [Paessler Support]



Votes:

0

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.

Created on May 31, 2023 11:57:46 AM



Votes:

0

Hi there,

In which PRTG Version was this scenario tested?

Created on Jun 8, 2023 5:42:14 AM by  Moritz Heller [Paessler Support]




Disclaimer: The information in the Paessler Knowledge Base comes without warranty of any kind. Use at your own risk. Before applying any instructions please exercise proper system administrator housekeeping. You must make sure that a proper backup of all your data is available.