TCP Connection Monitoring

TCP connections are a vital indicator of your server's network health and can reveal everything from normal traffic patterns to potential security threats. Server Scout's TCP connection monitoring provides insights into connection states, helping you identify issues before they impact performance.

Enabling TCP Connection Monitoring

To start monitoring TCP connections, you'll need to enable the tcp_connections metric in your Server Scout agent configuration:

  1. Open your agent configuration file (typically /opt/scout-agent/agent.env.yml)
  2. Add or uncomment the following line in the metrics section:

``yaml metrics: - tcp_connections ``

  1. Restart the Server Scout agent:

``bash sudo systemctl restart scout-agent ``

The agent will begin collecting connection data within the next monitoring cycle.

How Connection Counting Works

Server Scout's agent counts ESTABLISHED TCP connections by parsing /proc/net/tcp and /proc/net/tcp6 files on Linux systems. These pseudo-files contain real-time information about all TCP connections on your server.

The agent specifically looks for connections in the ESTABLISHED state (state code 01 in /proc/net/tcp), which represents active, fully-connected TCP sessions. This gives you an accurate count of current network activity without including transitional states like TIMEWAIT or SYNSENT.

You can manually inspect this data yourself:

# View current TCP connections
cat /proc/net/tcp | awk '$4=="01"' | wc -l

# Or use netstat for a more readable format
netstat -tn | grep ESTABLISHED | wc -l

Understanding Connection Patterns

TCP connection counts reveal several important aspects of your server's behaviour:

Normal Traffic Patterns: Web servers typically show predictable connection patterns that correlate with user activity. Database servers might maintain steady connection pools, whilst application servers may exhibit spiky patterns during batch processing.

Connection Leaks: Applications that don't properly close connections will show gradually increasing connection counts over time. This often indicates coding issues or misconfigured connection pooling.

DDoS Indicators: Sudden spikes in connection counts, especially when combined with high network throughput, can indicate distributed denial-of-service attacks or unusual traffic surges.

Resource Exhaustion: Systems approaching their connection limits (often around 65,535 per IP) will show consistently high connection counts, potentially leading to service degradation.

Viewing Connection Trends

Navigate to your server's detail page in the Server Scout dashboard to view TCP connection trends. The connection graph displays:

  • Historical connection counts over your selected time period
  • Peak and average connection levels
  • Correlation with other metrics like CPU usage and network throughput

Look for patterns such as:

  • Daily/weekly cycles that match expected usage
  • Gradual increases suggesting connection leaks
  • Sharp spikes indicating traffic surges or attacks

Setting Up Connection Alerts

Proactive monitoring requires alerts for abnormal connection behaviour:

  1. Go to your server's alert configuration page
  2. Create a new alert rule for "TCP Connections"
  3. Set thresholds based on your server's normal patterns:

- Warning threshold: 150% of normal peak connections - Critical threshold: 200% of normal peak connections

  1. Configure notification preferences (email, Slack, etc.)

For servers with highly variable traffic, consider using rate-of-change alerts instead of absolute thresholds to catch sudden spikes.

Troubleshooting with Combined Metrics

TCP connection data becomes most valuable when analysed alongside network throughput metrics. Common troubleshooting scenarios include:

High connections, low throughput: Suggests many idle connections or connection exhaustion attacks. Check for application connection leaks or implement connection limits.

High throughput, normal connections: Indicates efficient connection reuse or large data transfers per connection. Generally positive, but monitor for sustained periods that might indicate data exfiltration.

Sudden spikes in both: Classic DDoS pattern. Cross-reference with server logs and consider implementing rate limiting.

By combining TCP connection monitoring with Server Scout's other network metrics, you'll gain comprehensive visibility into your server's network behaviour and can respond quickly to both performance issues and security threats.

Frequently Asked Questions

How do I enable TCP connection monitoring in ServerScout?

Enable TCP connection monitoring by adding 'tcp_connections' to the metrics section in your agent configuration file (/opt/scout-agent/agent.env.yml), then restart the scout-agent service using sudo systemctl restart scout-agent. The agent will begin collecting connection data in the next monitoring cycle.

How does ServerScout count TCP connections?

ServerScout counts ESTABLISHED TCP connections by parsing /proc/net/tcp and /proc/net/tcp6 files on Linux systems. The agent specifically looks for connections in the ESTABLISHED state (state code 01), which represents active, fully-connected TCP sessions, excluding transitional states like TIME_WAIT or SYN_SENT.

What TCP connection patterns indicate problems?

Gradual increases over time suggest connection leaks from applications not properly closing connections. Sudden spikes combined with high network throughput can indicate DDoS attacks. Consistently high connection counts near system limits (around 65,535 per IP) signal potential resource exhaustion and service degradation.

How do I set up alerts for abnormal connection behavior?

Create TCP connection alerts by going to your server's alert configuration page, selecting 'TCP Connections', and setting thresholds based on normal patterns. Recommended thresholds are 150% of normal peak for warnings and 200% for critical alerts. For variable traffic servers, use rate-of-change alerts instead of absolute thresholds.

What does high connections with low throughput mean?

High connections with low throughput suggests many idle connections or connection exhaustion attacks. This pattern often indicates application connection leaks or the need to implement connection limits. Check your applications for proper connection handling and consider implementing connection pooling or limits.

Where can I view TCP connection trends in ServerScout?

View TCP connection trends on your server's detail page in the ServerScout dashboard. The connection graph shows historical connection counts, peak and average levels, and correlations with other metrics like CPU usage and network throughput over your selected time period.

How do I troubleshoot network issues using TCP connection data?

Analyze TCP connections alongside network throughput metrics. High throughput with normal connections indicates efficient connection reuse. Sudden spikes in both metrics suggest DDoS attacks. Cross-reference patterns with server logs and consider implementing rate limiting for suspicious traffic patterns.

Was this article helpful?