Eventscript functions: optimise ctdb_check_tcp_ports() and add debug.
authorMartin Schwenke <martin@meltin.net>
Tue, 5 Jul 2011 01:32:06 +0000 (11:32 +1000)
committerRonnie Sahlberg <ronniesahlberg@gmail.com>
Mon, 11 Jul 2011 08:02:32 +0000 (18:02 +1000)
commitf9f28ff32c3d110b2609a277aa6f71211e3eb7b6
treeb656b226c6f75d62b9d466fcc3e89cffe95acd6b
parent704550edf80031baefd0341712e60aea31b27c5c
Eventscript functions: optimise ctdb_check_tcp_ports() and add debug.

ctdb_check_tcp_ports() runs "netstat -a -t -n" in a loop for each
port.  There are 2 problems with this:

* Netstat is run on each loop iteration when it need only be run once.

* The -a option is used to list all connections but the function only
  cares about the listening ports.  There may be many thousands of
  non-listening ports to grep through.

This changes ctdb_check_tcp_ports() to run netstat with the -l option
instead of the -a option.  It also only runs netstat once before the
main loop.

When a port is found to not be listening the output of the netstat
command is now dumped to help with debugging.

Signed-off-by: Martin Schwenke <martin@meltin.net>
config/functions