New Question
 
 
PRTG Network Monitor

Intuitive to Use.
Easy to manage.

300.000 administrators have chosen PRTG to monitor their network. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free PRTG
Download >>

 

What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general. You are invited to get involved by asking and answering questions!

Learn more

 

Top Tags


View all Tags


EXE/Script Advanced shows 0

Votes:

0

Your Vote:

Up

Down

Hi,

I made a simple script to show sensor channel in PRTG. It takes value (one number - it's change in file from 1-100) from TXT file and shows in PRTG. But I have a problem beacuse PRTG shows "0" in result.

SCRIPT:

$value = Get-Content .\TXT_File.txt
Write-Host "<prtg>"  
   "<result>"
        "<channel>Channel Name</channel>"
        "<value>$value</value>"
		"<mode>Absolute</mode>"
        "<float>0</float>"
    "</result>"
        "<text>$value</text>"
"</prtg>"

When I add EXE/Script Advanced powershell script it shows "0" in PRTG sensor channel.

So I try to convert string to integer

$value = Get-Content .\TXT_file.txt
$value = $value -as [int] 
Write-Host "<prtg>"  
   "<result>"
        "<channel>Channel Name</channel>"
        "<value>$value</value>"
		"<mode>Absolute</mode>"
        "<float>0</float>"
    "</result>"
        "<text>$value</text>"
"</prtg>"

The same result - PRTG show "0".

When I manually add value everyting works ok:

$value = 99
Write-Host "<prtg>"  
   "<result>"
        "<channel>Channel Name</channel>"
        "<value>$value</value>"
		"<mode>Absolute</mode>"
        "<float>0</float>"
    "</result>"
        "<text>$value</text>"
"</prtg>"

What I do wrong?

Thank You.

exe-script-advanced-sensor powershell script

Created on Apr 4, 2020 5:45:23 PM by  fascik (0) 1

Last change on Apr 6, 2020 5:01:47 AM by  Sven Roggenhofer [Paessler Technical Support]



2 Replies

Votes:

0

Your Vote:

Up

Down

Hello,

I tried to recreate the issue. With this script it was working when I add one number to my .txt file.

$value = Get-Content -Path "C:\Path Example\Test.txt" $value = $value -as [int] Write-Host "<prtg>" "<result>" "<channel>Channel Name</channel>" "<value>$value</value>" "<mode>Absolute</mode>" "<float>0</float>" "</result>" "<text>$value</text>" "</prtg>"


Kind regards

Felix Wiesneth - Team Tech Support

Created on Apr 6, 2020 2:21:32 PM by  Felix Wiesneth [Paessler Support]



Votes:

0

Your Vote:

Up

Down

Felix - thank You - You're right! :) That was my error - no full path to file. Now everything works fine.

Created on Apr 6, 2020 7:05:06 PM by  fascik (0) 1



Please log in or register to enter your reply.


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.