From 8d326dbdab9cf49071814b6f5863ef318bdc3f59 Mon Sep 17 00:00:00 2001 From: David Teigland Date: Dec 18 2017 22:13:43 +0000 Subject: sanlock: add config setting for logging resource names sanlock.conf names_log_priority can be used to set the level at which each resource name+location is logged. The default level is LOG_WARNING as before, so each requested resource name is still saved in sanlock.log. With some applications, this may produce too much data, in which case names_log_priority can be set to 7 (LOG_DEBUG). Also correct the default values in help/man output for other settings. --- diff --git a/src/cmd.c b/src/cmd.c index c946591..b32a91b 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -377,7 +377,8 @@ static void cmd_acquire(struct task *task, struct cmd_args *ca) token->flags |= T_RESTRICT_SIGTERM; /* save a record of what this token_id is for later debugging */ - log_level(spi.space_id, token->token_id, NULL, LOG_WARNING, + + log_level(spi.space_id, token->token_id, NULL, com.names_log_priority, "resource %.48s:%.48s:%.256s:%llu%s for %d,%d,%d", token->r.lockspace_name, token->r.name, diff --git a/src/main.c b/src/main.c index 962486f..2bc4d1b 100644 --- a/src/main.c +++ b/src/main.c @@ -1808,7 +1808,7 @@ static void print_usage(void) printf(" -Q 0|1 quiet error messages for common lock contention (%d)\n", DEFAULT_QUIET_FAIL); printf(" -R 0|1 renewal debugging, log debug info about renewals (0)\n"); printf(" -H renewal history size (%d)\n", DEFAULT_RENEWAL_HISTORY_SIZE); - printf(" -L write logging at priority level and up to logfile (3 LOG_ERR)\n"); + printf(" -L write logging at priority level and up to logfile (4 LOG_WARNING)\n"); printf(" (use -1 for none)\n"); printf(" -S write logging at priority level and up to syslog (3 LOG_ERR)\n"); printf(" (use -1 for none)\n"); @@ -2314,6 +2314,10 @@ static void read_config_file(void) get_val_int(line, &val); log_syslog_priority = val; + } else if (!strcmp(str, "names_log_priority")) { + get_val_int(line, &val); + com.names_log_priority = val; + } else if (!strcmp(str, "use_watchdog")) { get_val_int(line, &val); com.use_watchdog = val; @@ -3245,6 +3249,7 @@ int main(int argc, char *argv[]) com.use_watchdog = DEFAULT_USE_WATCHDOG; com.high_priority = DEFAULT_HIGH_PRIORITY; com.mlock_level = DEFAULT_MLOCK_LEVEL; + com.names_log_priority = LOG_WARNING; com.max_worker_threads = DEFAULT_MAX_WORKER_THREADS; com.io_timeout_arg = DEFAULT_IO_TIMEOUT; com.aio_arg = DEFAULT_USE_AIO; diff --git a/src/sanlock.8 b/src/sanlock.8 index adeb36d..4cf607e 100644 --- a/src/sanlock.8 +++ b/src/sanlock.8 @@ -1108,7 +1108,7 @@ paxos algorithm to acquire the paxos_lease, and set a new owner. /etc/sanlock/sanlock.conf .IP \[bu] 2 -quiet_fail = 0 +quiet_fail = 1 .br See -Q @@ -1118,7 +1118,7 @@ debug_renew = 0 See -R .IP \[bu] 2 -logfile_priority = 3 +logfile_priority = 4 .br See -L @@ -1133,6 +1133,13 @@ syslog_priority = 3 See -S .IP \[bu] 2 +names_log_priority = 4 +.br +Log resource names at this priority level (uses syslog priority numbers). +If this is greater than or equal to logfile_priority, each requested resource +name and location is recorded in sanlock.log. + +.IP \[bu] 2 use_watchdog = 1 .br See -w diff --git a/src/sanlock.conf b/src/sanlock.conf index cd562d1..9cd867f 100644 --- a/src/sanlock.conf +++ b/src/sanlock.conf @@ -5,14 +5,14 @@ # # Example settings: # -# quiet_fail = 0 +# quiet_fail = 1 # command line: -Q 0|1 # # debug_renew = 0 # command line: -R 0|1 # -# logfile_priority = 3 -# command line: -L 3 +# logfile_priority = 4 +# command line: -L 4 # # logfile_use_utc = 0 # command line: n/a @@ -20,6 +20,9 @@ # syslog_priority = 3 # command line: -S 3 # +# names_log_priority = 4 +# command line: n/a +# # use_watchdog = 1 # command line: -w 1 # diff --git a/src/sanlock_internal.h b/src/sanlock_internal.h index 5140497..1a865e7 100644 --- a/src/sanlock_internal.h +++ b/src/sanlock_internal.h @@ -317,6 +317,7 @@ struct command_line { int use_watchdog; int high_priority; /* -h */ int get_hosts; /* -h */ + int names_log_priority; int mlock_level; int max_worker_threads; int aio_arg;