ctdb-scripts: Move current lock debugging to a function