Hi everyone,
we're currently redesign our infrastructure. Within this we will monitor it better, so we want to use our prtg more. I've googled the hole day now for looking any suggestions about monitoring XenApp/XenDesktop Provisioning Server etc with PRTG. How do you manage it? The "old" PRTG-Scripts for 6.5 won't work anymore. :(
regards, pilba
Article Comments
Hi there,
Thank you for your contribution, 19phila19.
You can find some third party scripts that may help you within the Script-World:
https://www.paessler.com/script-world/all/all/all?stats=all&fulltext=Citrix&newOnly=false&scroll=300&key=1524049638149
Best regards.
Apr, 2018 - Permalink
Thank you 19phila91 for sharing your ideas,
I'm new to citrix and citrix powershell so i'm getting hard, I will try to create a script this afternoon to get the results in PRTG, how did you manage it? Did you install the Citrix-Commandlets on your PRTG-Machine or do you connect to the Delivery Controller?
Regards, Pilba
Apr, 2018 - Permalink
Hi,
First step I store Windows credentials in PRTG - so you can use them as parameters for your script. Using these credentials you can establish a remote Powershell session. Make sure your user account has the necessary rights for remote Powershell. For example local Admin. If you are working with Citrix cmdlets make sure your user has read only rights configured in Citrix Studio.
Sensor Parameters
-server '<FQDN>' -domain '%windowsdomain' -username '%windowsuser' -password '%windowspassword'
Powershell Script
Read and store the PRTG Sensor Parameters
param (
[string]$server,
[string]$domain,
[string]$username,
[string]$password
)
With these parameters from PRTG you can store them in a variable $credentials
$credentials = New-Object System.Management.Automation.PSCredential (($domain+'\'+$username), (ConvertTo-SecureString $password -AsPlainText -Force))
There are several ways to establishing a remote Powershell session. After some tests i decided to do it with Invoke-Command and run it as a job. It gives us some performance.
$job = Invoke-Command -Computername $server -credential $credentials -ScriptBlock { ... } -asjob
Inside the ScriptBlock you can get your Data. The ScriptBlock is running on the remote Server. For example if you want to use Citrix cmdlets you can just add them to your session on a Citrix Controller.
add-pssnapin citrix*
Now you can get all your Information like
Get-BrokerServiceStatus
Worker in maintenance= Get-BrokerMachine | Select -ExpandProperty "InMaintenanceMode"
Active Session = (Get-BrokerSession | where {$_.SessionState -eq "Active" }).Count
Some cmdlets like Get-BrokerServiceStatus will give Data in Tform of text. You can substitute these to numbers and translate them back later by a value lookupskript.
Now we have our information and need them to get back to PRTG. In my Opinion its quite comfortable to put them in an Object and return it.
$Data= [PSCustomObject]@{
Data_1 = $Data_1
...
}
return $Data
Now outside of the ScriptBlock we wait for the job to complete its work and give us our Data back
Wait-Job $job | Out-Null
$Data= Receive-Job -Job $job
Now you can create the XML Output for PRTG to display by accessing your Data like
$Data.Data_1
Best regards, Phil
Apr, 2018 - Permalink
Hi 19phila19,
Thank you for your extensive answer and contribution! I have set the answer as Best Answer for this thread so it is easier to find.
Best regards.
Apr, 2018 - Permalink
Hello,
I am trying to add a similar sensor with this script:
Invoke-Command -ComputerName CTXDC2001 -ScriptBlock `
{{{ { Add-PSSnapin Citrix*
$sessies = (Get-BrokerSession -MaxRecordCount 1000 | where {$_.SessionState -eq "Active" }).count
$sessies } }}}
When I execute the scirpt i get a result.
When I add the script to PRTG with a Custom exe I get the following result.
Response not well-formed: "(164 )" (code: PE132) Where 164 is the number of active users.
Where is the script wrong? How do I get PRTG to know the right value without the failure message.
Thanks.
Dec, 2018 - Permalink
Hello Marius,
The output does not contain a PRTG-compatible sensor result.
That would be of the format
value:message
for example:
164:Message
Please change the script so that it produces a format which can be read by PRTG.
Dec, 2018 - Permalink
Thanks Isidora,
That is my question, how to I change the script that I get a format which PRTG can read.
Where is my script wrong ?
Jan, 2019 - Permalink
Hi Marius,
As Isidora tried to explain, the current output is this:
164 |
PRTG can't know what this is as it is not in the correct format. For example, this would be the correct format:
164:My sensor message |
Here PRTG knows that left of the double-point is the value and right of is the sensor message. Therefore please adapt the script output to the example above. If you don't want to transmit a specific message, then output the result like this:
164:Ok |
Best regards.
Jan, 2019 - Permalink
Hi
Thanks for the information above, I too am trying to monitor
- Current sessions (and present that back to PRTG as a number)
- Certain status of services, Like the BrokerService status, Be good to present that back to PRTG as "OK" if no errors, or "ERROR" if the service has any issues
I can run the commands manually to get what i need, but i am not sure how to put it together from PRTG, do you have a copy of the sensor, or script i could leverage off?
Do i need to install the Powershell Citrix Modules on the PRTG probe?
Jun, 2021 - Permalink
Hi,
If the powershell script needs the Citrix modules in order to retrieve the data, then you will need to install them on the probe that runs the sensor.
Maybe you can find some good examples for the script in our "PRTG Sensor Hub".
Kind regards,
Sasa Ignjatovic, Tech Support Team
Jun, 2021 - Permalink
We actualy use a custom Powershell Skript to monitor Citrix. Citrix itself provides a lot of cmdlets which you can use nearly out of the box. For better Performance run your remote powershell session as Job.
for Example:
For better Performance run your remote powershell as Job.
Apr, 2018 - Permalink