25 Oct 2024 09:12 AM
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
Solved! Go to Solution.
25 Oct 2024 12:58 PM
Hello @AntonPineiro
Hoping it adds value.
KR,
Peter
25 Oct 2024 04:55 PM
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
25 Oct 2024 03:36 PM
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.
when running this script from PowerShell you should find it in dynatrace like this
references:
https://docs.dynatrace.com/docs/shortlink/local-api#example
https://docs.dynatrace.com/docs/shortlink/metric-events
25 Oct 2024 04:58 PM - edited 25 Oct 2024 04:59 PM
Hi,
I was already thought about that but:
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
25 Oct 2024 05:15 PM
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?
25 Oct 2024 11:22 PM
strongly recommend
26 Oct 2024 02:07 PM
Thank you all!
I have just voted that product idea!
Best regards