check_tcp

Runs check_tcp to check TCP connections. It wraps the plugin from https://github.com/taku-k/go-check-plugins/tree/master/check-tcp

Implementation

WindowsLinuxFreeBSDmacOS
✅✅✅✅

Usage

  check_tcp [OPTIONS]

Application Options:
      --service=              Service name, for example ftp, smtp, pop, or imap
  -H, --hostname=             Host name or IP address
  -4, --ipv4                  Resolve and connect using IPv4 only
  -6, --ipv6                  Resolve and connect using IPv6 only
  -p, --port=                 Port number
  -s, --send=                 String to send to the server
  -e, --expect-pattern=       Regular expression to match in the server response
  -q, --quit=                 String to send to the server to close the connection cleanly
  -S, --ssl                   Use SSL for the connection.
  -U, --unix-sock=            Unix domain socket
      --no-check-certificate  Do not check certificate
  -t, --timeout=              Seconds before connection times out (default: 10)
  -m, --maxbytes=             If the received bytes exceed this number, close the connection
  -d, --delay=                Seconds to wait after sending the string before polling for a response
  -w, --warning=              Response time to result in warning status (seconds)
  -c, --critical=             Response time to result in critical status (seconds) (default: 10)
  -E, --escape                Allow \n, \r, \t or \ in the send or quit string. Put this option before send or quit. By
                              default, send adds nothing and quit appends \r\n
  -W, --error-warning         On an unexpected error, return warning instead of the default critical status. If the
                              request succeeds, the -c option takes priority.
  -C, --expect-closed         Check that the port/unixsock is closed. If closed, return OK. If open, follow the
                              ErrWarning flag. Checks only the connection.
  -v, --verbose               Log the actions taken in verbose mode.

Help Options:
  -h, --help                  Show this help message

Examples

Default Check

Alert if the TCP connection fails:

check_tcp -H omd.consol.de -p 80
TCP OK - 0.003 seconds response time on omd.consol.de port 80

Send data and check for a specific response string:

check_tcp -H outlook.com -p 25 -s "HELO" -e "Microsoft ESMTP MAIL Service ready" -q "QUIT"
TCP OK - 0.197 seconds response time on outlook.com port 25

Example using check_snclient and Naemon

Naemon Config

define command{
    command_name         check_snclient
    command_line         $USER1$/check_snclient -k -p 'your-password' -u 'https://$HOSTADDRESS$:8443' $ARG1$ $ARG2$
}

define service {
    host_name            testhost
    service_description  check_tcp
    use                  generic-service
    check_command        check_snclient!check_tcp!'-H' 'omd.consol.de' '-p' '80'
}