14.12. Monitoring TCP Connections
Problem
You're running a fairly busy web server, so you want to keep an eye on how many new TCP connections are hitting your server.
Solution
This example measures the number of new TCP connections per minute:
LoadMIBS: /usr/share/snmp/mibs/TCP-MIB.txt # # New TCP Connections per minute # Target[server.http]: tcpPassiveOpens.0&tcpActiveOpens.0:password@webserver1 RouterUptime[xena1.swap]: password@localhost Title[server.http]: New TCP Connections- Webserver1 PageTop[server.http]: <h1>New TCP Connections per minute - Webserver1</h1> MaxBytes[server.http]: 1000000000 ShortLegend[server.http]: c/s YLegend[server.http]: Connections/Min LegendI[server.http]: Incoming LegendO[server.http]: Outgoing Legend1[server.http]: New inbound connections Legend2[server.http]: New outbound connections Options[server.http]: growright,nopercent,perminute
Run these commands to load the changes:
# env LANG=C mrtg /etc/mrtg.cfg
# indexmaker --output=/var/www/mrtg/index.html /etc/mrtg.cfgMind your filepaths, because they vary on different Linux distributions, and remember to run the first command until it quits emitting error messages, which should take no more than three tries.
Discussion
This is a nice graph for keeping an eye on how hard visitors are
pummeling your web server. tcpPassiveOpens.0 counts the incoming
connections, and tcpActiveOpens.0
measures how many connections are being initiated by the server.
Netstat shows the same data, but not in a pretty graph:
$ netstat ...Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access