[GH-ISSUE #2061] [UI ISSUE] Ping checks output nonsensical #3224

Open
opened 2026-03-14 06:53:57 +03:00 by kerem · 2 comments
Owner

Originally created by @P6g9YHK6 on GitHub (Nov 4, 2024).
Original GitHub issue: https://github.com/amidaware/tacticalrmm/issues/2061

Is your feature request related to a problem? Please describe.
The outputs of ping checks are unusable at best.
There is no Y axis explanation, the output does not explain why it failed
image

Describe the solution you'd like
just like cpu and ram the output should be on a chart with the answer time as the X value
output should be readable
and it should do only 1 ping not the default 3 or set the amount and average

Describe alternatives you've considered
back to scripting this one :/

Originally created by @P6g9YHK6 on GitHub (Nov 4, 2024). Original GitHub issue: https://github.com/amidaware/tacticalrmm/issues/2061 **Is your feature request related to a problem? Please describe.** The outputs of ping checks are unusable at best. There is no Y axis explanation, the output does not explain why it failed ![image](https://github.com/user-attachments/assets/c9e6485d-4c3d-43af-b28a-7e491840329e) **Describe the solution you'd like** just like cpu and ram the output should be on a chart with the answer time as the X value output should be readable and it should do only 1 ping not the default 3 or set the amount and average **Describe alternatives you've considered** back to scripting this one :/
Author
Owner

@P6g9YHK6 commented on GitHub (Nov 8, 2024):

Here something i wiped up to patchwork this

<#
.SYNOPSIS
    A PowerShell script to check the reachability and response time of specified hosts or IP addresses.

.DESCRIPTION
    This script checks if a list of hosts or IP addresses (specified in the PING_TARGETS environment variable) is reachable by sending a single ping request.
    It outputs "OK" with the latency in milliseconds if the host is reachable, or "KO" if it is not.

.PARAMETER PING_TARGETS
    Environment variable that holds a comma-separated list of IP addresses or hostnames to ping.

.PARAMETER WarnThreshold
    The threshold in milliseconds for a warning. If the ping response time exceeds this threshold, the script will output a warning and exit with code 1.

.PARAMETER ErrorThreshold
    The threshold in milliseconds for an error. If the ping response time exceeds this threshold, the script will output an error and exit with code 2.

.NOTES
    Author: SAN
    Created: 08.11.24

.CHANGELOG
    
#>

# Set default threshold values (in ms)
$DefaultWarnThreshold = 100     # Default warning threshold in milliseconds
$DefaultErrorThreshold = 200   # Default error threshold in milliseconds

# Check for environment variables to override the default thresholds
$WarnThreshold = if ($env:PING_WARN_THRESHOLD) { [int]$env:PING_WARN_THRESHOLD } else { $DefaultWarnThreshold }
$ErrorThreshold = if ($env:PING_ERROR_THRESHOLD) { [int]$env:PING_ERROR_THRESHOLD } else { $DefaultErrorThreshold }

# Get the list of targets from the environment variable
$Targets = $env:PING_TARGETS -split ","   # Split comma-separated values into an array
$IsSingleTarget = ($Targets.Count -eq 1)  # Check if only one target is specified

if (-not $Targets) {
    Write-Output "No targets specified in the environment variable 'PING_TARGETS'. Exiting."
    exit 3
}

$ExitCode = 0   # Default exit code is 0 (success)

foreach ($Target in $Targets) {
    $Target = $Target.Trim()  # Remove any leading/trailing whitespace
    try {
        $PingResult = Test-Connection -ComputerName $Target -Count 1 -Quiet
        if ($PingResult) {
            # Calculate latency by measuring ping time manually
            $PingTime = (Measure-Command {Test-Connection -ComputerName $Target -Count 1 -Quiet}).TotalMilliseconds
            if ($IsSingleTarget) {
                Write-Output "$PingTime ms."
            } else {
                Write-Output "OK $Target $PingTime ms."
            }

            # Check for warnings and errors based on latency
            if ($PingTime -gt $ErrorThreshold) {
                Write-Output "Error: Ping time exceeded $ErrorThreshold ms."
                $ExitCode = 2  # Set exit code for error
            } elseif ($PingTime -gt $WarnThreshold) {
                Write-Output "Warning: Ping time exceeded $WarnThreshold ms."
                $ExitCode = 1  # Set exit code for warning (if error code not set)
            }
        } else {
            if ($IsSingleTarget) {
                Write-Output "KO"
            } else {
                Write-Output "KO $Target"
            }
            $ExitCode = 3  # Set exit code for failure
        }
    }
    catch {
        if ($IsSingleTarget) {
            Write-Output "KO (Error: $_)"
        } else {
            Write-Output "KO $Target (Error: $_)"
        }
        $ExitCode = 3  # Set exit code for failure
    }
}

# Exit with the determined exit code (warn = 1, error = 2, fail = 3)
$host.SetShouldExit($ExitCode)
exit $ExitCode

<!-- gh-comment-id:2464188291 --> @P6g9YHK6 commented on GitHub (Nov 8, 2024): Here something i wiped up to patchwork this ``` <# .SYNOPSIS A PowerShell script to check the reachability and response time of specified hosts or IP addresses. .DESCRIPTION This script checks if a list of hosts or IP addresses (specified in the PING_TARGETS environment variable) is reachable by sending a single ping request. It outputs "OK" with the latency in milliseconds if the host is reachable, or "KO" if it is not. .PARAMETER PING_TARGETS Environment variable that holds a comma-separated list of IP addresses or hostnames to ping. .PARAMETER WarnThreshold The threshold in milliseconds for a warning. If the ping response time exceeds this threshold, the script will output a warning and exit with code 1. .PARAMETER ErrorThreshold The threshold in milliseconds for an error. If the ping response time exceeds this threshold, the script will output an error and exit with code 2. .NOTES Author: SAN Created: 08.11.24 .CHANGELOG #> # Set default threshold values (in ms) $DefaultWarnThreshold = 100 # Default warning threshold in milliseconds $DefaultErrorThreshold = 200 # Default error threshold in milliseconds # Check for environment variables to override the default thresholds $WarnThreshold = if ($env:PING_WARN_THRESHOLD) { [int]$env:PING_WARN_THRESHOLD } else { $DefaultWarnThreshold } $ErrorThreshold = if ($env:PING_ERROR_THRESHOLD) { [int]$env:PING_ERROR_THRESHOLD } else { $DefaultErrorThreshold } # Get the list of targets from the environment variable $Targets = $env:PING_TARGETS -split "," # Split comma-separated values into an array $IsSingleTarget = ($Targets.Count -eq 1) # Check if only one target is specified if (-not $Targets) { Write-Output "No targets specified in the environment variable 'PING_TARGETS'. Exiting." exit 3 } $ExitCode = 0 # Default exit code is 0 (success) foreach ($Target in $Targets) { $Target = $Target.Trim() # Remove any leading/trailing whitespace try { $PingResult = Test-Connection -ComputerName $Target -Count 1 -Quiet if ($PingResult) { # Calculate latency by measuring ping time manually $PingTime = (Measure-Command {Test-Connection -ComputerName $Target -Count 1 -Quiet}).TotalMilliseconds if ($IsSingleTarget) { Write-Output "$PingTime ms." } else { Write-Output "OK $Target $PingTime ms." } # Check for warnings and errors based on latency if ($PingTime -gt $ErrorThreshold) { Write-Output "Error: Ping time exceeded $ErrorThreshold ms." $ExitCode = 2 # Set exit code for error } elseif ($PingTime -gt $WarnThreshold) { Write-Output "Warning: Ping time exceeded $WarnThreshold ms." $ExitCode = 1 # Set exit code for warning (if error code not set) } } else { if ($IsSingleTarget) { Write-Output "KO" } else { Write-Output "KO $Target" } $ExitCode = 3 # Set exit code for failure } } catch { if ($IsSingleTarget) { Write-Output "KO (Error: $_)" } else { Write-Output "KO $Target (Error: $_)" } $ExitCode = 3 # Set exit code for failure } } # Exit with the determined exit code (warn = 1, error = 2, fail = 3) $host.SetShouldExit($ExitCode) exit $ExitCode ```
Author
Owner

@P6g9YHK6 commented on GitHub (Nov 13, 2024):

also noticed there is no alternative to ping to the python lib's
ping3 or equivalent should be added to the standard list

<!-- gh-comment-id:2473194702 --> @P6g9YHK6 commented on GitHub (Nov 13, 2024): also noticed there is no alternative to ping to the python lib's ping3 or equivalent should be added to the standard list
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/tacticalrmm#3224
No description provided.