14.12. Monitoring TCP Connections

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.

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.cfg

Mind 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.

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 -s | egrep '(passive|active)'
	    211 active connections openings
	    230581 passive connection openings