cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Remote TCP port monitoring

AntonPineiro
DynaMight Guru
DynaMight Guru

Hi,

I am aware of NAM but source would be Synthetic ActiveGate.

Use case would be something as a host (not Synthetic ActiveGate) has TCP connectivity against some IP + port. Does Dynatrace have something for this monitoring out-of-the-box?

Best regards

❤️ Emacs ❤️ Vim ❤️ Bash ❤️ Perl
9 REPLIES 9

Hello @AntonPineiro 

  1. As per the latest Hub technologies you can install : SNMP Autodiscovery 
  2. Then create synthetic monitors for the detected IPs and Ports.

Hoping it adds value.
KR,

Peter

Hi,

I am not sure this will work because Synthetic monitor is linked to ActiveGate. I would like to check from anothers machines that they are not ActiveGates.

But thank you!

Best regards

❤️ Emacs ❤️ Vim ❤️ Bash ❤️ Perl

MostafaHussein
Advisor

there's a work around you can use for this via local metric ingestion through OneAgent an this is a PowerShell script for doing this

 

function Test-TcpConnection {
    param(
        [string]$MetricName,
        [string]$IPAddress,
        [int]$Port,
        [System.Threading.ManualResetEvent]$StopEvent,
        [int]$Interval
    )

    while ($StopEvent.WaitOne(0)) {
        try {
            $socket = New-Object System.Net.Sockets.TcpClient
            $socket.Connect($IPAddress, $Port)
            Write-Host "TCP connection to ${IPAddress}:${Port} successful"
            $result = 1
        } catch {
            Write-Host "TCP connection to ${IPAddress}:${Port} failed: $_"
            $result = 0
        } finally {
            if ($socket) { $socket.Close() }
	    $headers = @{
    		'Content-Type' = 'text/plain; charset=utf-8'
	    }
	    Invoke-RestMethod -Uri http://localhost:14499/metrics/ingest -Method Post -Body "${MetricName},destination-address=${IPAddress},destination-port=${Port} ${result}" -Headers @{'Content-Type' = 'text/plain; charset=utf-8'}

            Start-Sleep -Seconds $Interval
        }
    }

    Write-Host "Script stopped."
}

# Create a manual reset event to control the script's execution
$stopEvent = New-Object System.Threading.ManualResetEvent False

# Function to stop the script
function Stop-Script {
    $stopEvent.Set()
}

# Call the Test-TcpConnection function
Test-TcpConnection -MetricName "host.tcp-test.status" -IPAddress 127.0.0.1 -Port 80 -StopEvent $stopEvent -Interval 20

 

 

using this approach you can ingest metrics from OneAgent on the desired machine as mentioned in the code the interval is each 20 seconds to test connectivity with <IP_ADDRESS>:<PORT> and you've status of 0 means that connection failed or 1 that connection successfully established, accordingly you can make custom event for alerting using the metric  `host.tcp-test.status` to get notified when metric value is 0, you can replace xxxx with the real host name you're ingesting your metric from if you willing to use it from multiple servers to use server name as dimension for filtering data points later.

MostafaHussein_1-1729866178943.png

 

when running this script from PowerShell you should find it in dynatrace like this

MostafaHussein_0-1729865990623.png

references:
https://docs.dynatrace.com/docs/shortlink/local-api#example

https://docs.dynatrace.com/docs/shortlink/metric-events

 

Certified Dynatrace Professional | Certified Dynatrace Services - Observability | Dynatrace Partner yourcompass.ca

Hi,

I was already thought about that but:

  • I cannot deploy custom scripts in targets, no permissions.
  • Extra cost by metrics ingestion.

I would like to see some out-the-box solution already covered by OneAgent, since agent is already there.

But thank you so much for your detailed answer.

Best regards

❤️ Emacs ❤️ Vim ❤️ Bash ❤️ Perl

I'd love for this functionality to be built-in as a feature. The OneAgent network monitor already knows the common connections that are made to/from the host and could automatically setup monitors for these with a click of a button. Should I put this in as a product idea?

strongly recommend

Certified Dynatrace Professional | Certified Dynatrace Services - Observability | Dynatrace Partner yourcompass.ca

AntonPineiro
DynaMight Guru
DynaMight Guru

Thank you all!

I have just voted that product idea!

Best regards

❤️ Emacs ❤️ Vim ❤️ Bash ❤️ Perl

All the best @AntonPineiro 

Hopefully it will be considered in upcoming releases.

KR,

Peter.

Featured Posts