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

Why does my adavanced custom sensor EXEXML does return 0 ?

Votes:

0

So, I've been following this tutorial on how to monitor citrix environnements via PRTG. I've based my self on Pim van Denderen's script and modified it a little bit to get all the datas i needed and to put them like i winted in PRTG :

# Import module
if (-not (Get-module prtgshell)) {
    Import-Module -Verbose prtgshell
    }
	
# Create a powershell session connection to the remote computer
$session = New-PSSession -ComputerName $citrixddc
 
# Run the commands on the remote computer
#Group-BrokerMachine gives us a count already of what we want
$result = Invoke-command -Session $session -scriptBlock {
    Add-PSSnapin Citrix*
    Group-BrokerMachine -Property SummaryState
}

# Start writing output to PRTG.
$XMLOutput = "<prtg>`n"
 
# temporary variable which gives us a table (Name,Count) so we get the count's value of Off, Available,InUse et Unregistered.
$temp = ($result | Select Name, Count)
#for each variable we get the count value
$off = ($temp | Where {$_.Name -eq "Off"}).count
$available = ($temp | Where {$_.Name -eq "Available"}).count
$inUse = ($temp | Where {$_.Name -eq "InUse"}).count
$unregistered = ($temp | Where {$_.Name -eq "Unregistered"}).count
$total = $off + $available + $inUse + $unregistered


#writing xml PRTG 
$XMLOutput += Set-PrtgResult "Desktops: Total" -Value $total -Unit "Desktops"
#Desktops Connected
$XMLOutput += Set-PrtgResult "Desktops: Connected / Active" -Value $inUse -Unit "Desktops"
#Desktops Disconnected
$XMLOutput += Set-PrtgResult "Desktops: Disconnected" $off "Desktops"
# Desktops non enregistrés
$XMLOutput += Set-PrtgResult "Desktops: Unregistered" $unregistered "Desktops"
#Desktops available
$XMLOutput += Set-PrtgResult "Desktops: Available" $available "Desktops"

# Disconnect the session
Remove-PSSession $session
 
#Finish writing to PRTG
$XMLOutput += "</prtg>"
write-host $XMLOutput

I tried to execute it in the powershell commandline and it worked perfectly fine, i gathered all the datas i wanted :
what the scripts returns
So I've made a custom sensor on PRTG on the remote probe but it looks like it doesn't get the datas bc it only show 0 for each channels i've made... Do you guys have any ideas ? I think it's comming from the account permissions but I'm not sure and I don't really know how to fix it
screen of the sensor

citrix custom-sensor monitoring powershell prtg

Created on Jun 7, 2017 10:12:08 AM

Last change on Jun 7, 2017 11:56:01 AM by  Dariusz Gorka [Paessler Support]



1 Reply

Accepted Answer

Votes:

0

Hi there,

We solved the ticket in the background via our ticketing system. The reason why the script was not working is, that the Credential-Object in the script was created incorrectly. PRTG always calls PowerShell scripts with the "-noprofile" switch, therefore no credential objects can be created via "Get-Credentials". To solve this, you have to define the credentials in the script via:

# Get variables from PRTG
Param (
    [string]$user,
    [string]$passwd,
    [string]$domain 
)

Afterwards define the following parameters (with placeholders) in the sensor settings under "Parameters":

-user "%windowsuser" -domain "%windowsdomain" -password "%windowspassword"

(Make sure that the correct credentials are entered in the device settings)

The credential object can then be created by using the following in the PowerShell script:

$securedpasswd = $passwd | ConvertTo-SecureString -AsPlainText -Force
$creds = New-Object -typename System.Management.Automation.PSCredential -argument $user,$securedpasswd



Best regards

Created on Jun 8, 2017 8:27:59 PM by  Dariusz Gorka [Paessler Support]

Last change on Jun 9, 2017 1:10:13 PM by  Felix Saure [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.