### 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! 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.

View all Tags

# can i view 95 percentile line in a report graph

#### 0

hi i khonw can view data of percentile in a table with get a report but i want to view line of 95 percentile in report graph. what can i do it? thanx a lot best regard

Created on Aug 28, 2018 10:38:22 AM by

#### 1

The following PowerShell demonstrates how to generate a sensor factory definition to retrieve a one time snapshot of a specified percentile using PrtgAPI, based on the algorithm described in Paessler's support article

```# Specify the percentile to calculate, e.g. 95
function CalculatePercentile(\$sensors, \$val)
{
# 1. Sort the measurements
\$sorted = \$sensors|sort lastvalue

# 2. Calculate RN
\$n = \$sorted.Count
\$p = \$val / 100
\$rn = 1 + (\$n - 1) * \$p

Write-Verbose "RN is \$rn"

# 3. Calculate result
\$floorRN = [Math]::Floor(\$rn)
\$ceilingRN = [Math]::Ceiling(\$rn)

Write-Verbose "FloorRN is \$floorRN, CeilingRN is \$ceilingRN"

\$result = \$null

if(\$rn -eq \$floorRN -eq \$ceilingRN)
{
\$result = \$rn
}
else
{
\$floorRNVal = \$sensors[\$floorRN - 1].LastValue
\$ceilingRNVal = \$sensors[\$ceilingRN - 1].LastValue

Write-Verbose "FloorRNVal is \$floorRNVal, CeilingRNVal is \$ceilingRNVal"

\$result = \$floorRNVal + (\$rn - \$floorRN) * (\$ceilingRNVal - \$floorRNVal)
}

Write-Verbose "\$(\$val)th Percentile is \$result"

return \$result
}

function TestMath
{
\$VerbosePreference = "Continue"
\$sensors = Get-Sensor ping -count 8|sort lastvalue
\$sensors.LastValue = 1
\$sensors.LastValue = 3
\$sensors.LastValue = 7
\$sensors.LastValue = 21
\$sensors.LastValue = 25
\$sensors.LastValue = 26
\$sensors.LastValue = 66
\$sensors.LastValue = 72
\$percentile = CalculatePercentile \$sensors 95
}

\$sensors = Get-Sensor ping -count 30|sort lastvalue
\$percentile = CalculatePercentile \$sensors 95

\$sensors | New-SensorFactoryDefinition { \$_.Device } -ChannelId 0
\$sensors | New-SensorFactoryDefinition -Name { "Line at \$percentile [msec]" } -Aggregator { \$percentile } 0 -StartId (\$sensors.Count + 1)
```

By default, the script will output the channel definitions required to create a sensor factory using the first 30 Ping sensors retrieved from your PRTG as well as a horizontal line at the 95th percentile of the Ping Time channel

To apply this to a different channel or sensor type, simply modify the call to Get-Sensor, adjust the -ChannelId specified to New-SensorFactoryDefinition and modify the channel unit used for displaying the horizontal line.

To verify the implementation of Paessler's percentile calculation formula, you can optionally run the TestMath function. This will retrieve 8 sensors from your server and then plug in the values that were used in Paessler's calculation example, emitting the various variables used in calculating the formula

Regards,

lordmilko

Created on Sep 5, 2018 5:44:21 AM by

3 Replies

#### 0

Since percentile calculation is rather load intensive, it will probably not make its way into PRTG. Perhaps a Sensor Factory Sensor in combination with PRTGapi's Factory Sensor generating features would do the trick? PRTG calculates the percentiles like this. The result can then be added as a horizontal line (see the manual of the sensor for details).

Kind regards,

#### 1

The following PowerShell demonstrates how to generate a sensor factory definition to retrieve a one time snapshot of a specified percentile using PrtgAPI, based on the algorithm described in Paessler's support article

```# Specify the percentile to calculate, e.g. 95
function CalculatePercentile(\$sensors, \$val)
{
# 1. Sort the measurements
\$sorted = \$sensors|sort lastvalue

# 2. Calculate RN
\$n = \$sorted.Count
\$p = \$val / 100
\$rn = 1 + (\$n - 1) * \$p

Write-Verbose "RN is \$rn"

# 3. Calculate result
\$floorRN = [Math]::Floor(\$rn)
\$ceilingRN = [Math]::Ceiling(\$rn)

Write-Verbose "FloorRN is \$floorRN, CeilingRN is \$ceilingRN"

\$result = \$null

if(\$rn -eq \$floorRN -eq \$ceilingRN)
{
\$result = \$rn
}
else
{
\$floorRNVal = \$sensors[\$floorRN - 1].LastValue
\$ceilingRNVal = \$sensors[\$ceilingRN - 1].LastValue

Write-Verbose "FloorRNVal is \$floorRNVal, CeilingRNVal is \$ceilingRNVal"

\$result = \$floorRNVal + (\$rn - \$floorRN) * (\$ceilingRNVal - \$floorRNVal)
}

Write-Verbose "\$(\$val)th Percentile is \$result"

return \$result
}

function TestMath
{
\$VerbosePreference = "Continue"
\$sensors = Get-Sensor ping -count 8|sort lastvalue
\$sensors.LastValue = 1
\$sensors.LastValue = 3
\$sensors.LastValue = 7
\$sensors.LastValue = 21
\$sensors.LastValue = 25
\$sensors.LastValue = 26
\$sensors.LastValue = 66
\$sensors.LastValue = 72
\$percentile = CalculatePercentile \$sensors 95
}

\$sensors = Get-Sensor ping -count 30|sort lastvalue
\$percentile = CalculatePercentile \$sensors 95

\$sensors | New-SensorFactoryDefinition { \$_.Device } -ChannelId 0
\$sensors | New-SensorFactoryDefinition -Name { "Line at \$percentile [msec]" } -Aggregator { \$percentile } 0 -StartId (\$sensors.Count + 1)
```

By default, the script will output the channel definitions required to create a sensor factory using the first 30 Ping sensors retrieved from your PRTG as well as a horizontal line at the 95th percentile of the Ping Time channel

To apply this to a different channel or sensor type, simply modify the call to Get-Sensor, adjust the -ChannelId specified to New-SensorFactoryDefinition and modify the channel unit used for displaying the horizontal line.

To verify the implementation of Paessler's percentile calculation formula, you can optionally run the TestMath function. This will retrieve 8 sensors from your server and then plug in the values that were used in Paessler's calculation example, emitting the various variables used in calculating the formula

Regards,

lordmilko

Created on Sep 5, 2018 5:44:21 AM by