NAME

Monitoring::Sneck::Checks::listening - checks what ports are being listened on

VERSION

Version 0.0.1

SYNOPSIS

ssh_listening|perl:listening -p 22
web_listening|perl:listening -p tcp/80 -p tcp/443 -p udp/443
!only_expected||perl:listening -p 22 -p 25 -p udp/123 -o -L

DESCRIPTION

Checks each port given is being listened on, and with --only that nothing else is. Either is CRITICAL.

Ports are given as [protocol/][address:]port, such as 22, tcp/22, udp/53, 127.0.0.1:6379, or tcp6/[::1]:25. tcp and udp match either IP version, while tcp4, tcp6, udp4, and udp6 match only that one. No address matches any, while a address must match exactly, a wildcard listener, 0.0.0.0 or ::, counting for any address. For UDP, a bound socket not connected to anything counts as listening. That includes clients using unconnected sockets, such as for mDNS, so --only with UDP may need --ignore for those.

On Linux, sockets are read from /proc/net. On FreeBSD, sockstat -46lqn is run. Other OSes are UNKNOWN.

OPTIONS

- -p, --port :: A port that must be listened on. May be given more than once.

- -o, --only :: Nothing but --port may be listened on.

- -L, --ignore-loopback :: For --only, leave out what only listens on loopback addresses.

- -i, --ignore :: For --only, a port that may be listened on, given the same way as --port. May be given more than once.

One of --port or --only must be given.

METHODS

check

Does the check.

listeners

Returns what is listening, as hash refs of protocol, tcp4, tcp6, udp4, or udp6, address, and port. Dies if it can not be found.