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

can i view 95 percentile line in a report graph

Votes:

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

percentile reporting sensor

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



Best Answer

Accepted Answer

Votes:

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[0].LastValue = 1
    $sensors[1].LastValue = 3
    $sensors[2].LastValue = 7
    $sensors[3].LastValue = 21
    $sensors[4].LastValue = 25
    $sensors[5].LastValue = 26
    $sensors[6].LastValue = 66
    $sensors[7].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



3 Replies

Votes:

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,
Stephan Linke, Tech Support Team

Created on Aug 30, 2018 9:35:50 AM by  Stephan Linke [Paessler Support]



Accepted Answer

Votes:

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[0].LastValue = 1
    $sensors[1].LastValue = 3
    $sensors[2].LastValue = 7
    $sensors[3].LastValue = 21
    $sensors[4].LastValue = 25
    $sensors[5].LastValue = 26
    $sensors[6].LastValue = 66
    $sensors[7].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



Votes:

0

Thanks for sharing LordMilko :-)

Created on Sep 5, 2018 5:49:41 AM by  Sven Roggenhofer [Paessler Technical 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.