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

Custom EXE/Script Sensor Error

Votes:

0

I'm running an XML Custom EXE/Script Sensor in PRTG. It is a PowerShell script, and no matter what I do, PRTG interprets the value as "0" for the channel "Open Tickets."

I've created duplicate results/channels for "New Tickets" and "In Progress Tickets", however, I haven't coded in the variable, yet. When using the hard-coded values, PRTG ingests these normally. The weird thing is the output of the PowerShell script for the variable doesn't have anything different than the hard coded values.

This is driving me crazy. Any ideas?

I'm posting the script, the PowerShell Result, and the PRTG ingest below.



PowerShell Script:

$username = "USERNAME"
$password = "PASSWORD"
$url = "https://url.com/helpdesk/api/Stats"

$pair = "$($username):$($password)"
$bytes = [System.Text.Encoding]::ASCII.GetBytes($pair)
$base64 = [System.Convert]::ToBase64String($bytes)
$basicAuthValue = "Basic $base64"
$headers = @{ Authorization = $basicAuthValue }

$response = Invoke-WebRequest -Uri $url -Method GET -Headers $headers
$content = $response.Content | ConvertFrom-Json
$unclosed = $content.Unclosed
Write-Host "
<prtg>
<result>
<channel>Open Tickets</channel>
<value>$unclosed</value>
</result>
<result>
<channel>New Tickets</channel>
<value>51</value>
</result>
<result>
<channel>In Progress Tickets</channel>
<value>5</value>
</result>
</prtg>" 

PowerShell ISE Result:

<prtg>
<result>
<channel>Open Tickets</channel>
<value>48</value>
</result>
<result>
<channel>New Tickets</channel>
<value>51</value>
</result>
<result>
<channel>In Progress Tickets</channel>
<value>5</value>
</result>
</prtg> 

PRTG Data Table from Ingest:

  • Open Tickets: 0
  • New Tickets: 51
  • In Progress Tickets: 5

custom powershell script sensor

Created on Feb 21, 2023 10:32:57 PM

Last change on Feb 22, 2023 10:45:01 AM by  Moritz Heller [Paessler Support]



1 Reply

Votes:

0

Hello,

for analysis, please open the sensor's "Settings" tab and enable the "Store Result" option.

After the next sensor scan, the result logs are written to "C:\ProgramData\Paessler\PRTG Network Monitor\Logs\sensors" on the respective probe. Could it be that this output differs from the one you get in the ISE?

Created on Feb 23, 2023 12:47:06 PM by  Arne Seifert [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.