tcp — make TCP network connections

The tcp check sends a network request over TCP and asserts that the response received, if any, is expected.

Examples

Check that a local TCP port is open:

[[tcp]]
port = 8301

Check that a port is closed:

[[tcp]]
port = 8301
state = 'closed'

Check that a port is open on another machine:

[[tcp]]
port = 8301
address = '192.168.0.1'

Changing the source address

Sometimes, servers will bind to an address other than 0.0.0.0. To connect to these servers, you’ll need to send your packets from that source IP:

[[tcp]]
port = 8301
source = '10.3.4.3'

If the application has been configured to listen on an interface, looking up its IP at runtime, then Specsheet can do the same to match it:

[[tcp]]
port = 8301
source = '%eth1'

Checking the firewall

The ufw test type can be used to check whether firewall entries exist. It’s common to check that a port is open and that it’s allowed out by the firewall.

So common, in fact, that there’s a shortcut to check both at the same time. Use the ufw_allow property to test the range that this port is allowed in. This is usually the string “Anywhere”:

[[tcp]]
port = 8301
ufw = { allow = 'Anywhere' }

List of parameters

parameterstructuredescription
addressstringThe address to send the request to.
portnumberPort number.
sourcestringThe network address or interface to send from.
statestringThe state of the port. This can be 'open' or 'closed'.
ufwtableUFW check options.