From 1ffe6b39534655b35b84506ef21da68803bbd11a Mon Sep 17 00:00:00 2001 From: Keshava Bharadwaj Date: Thu, 11 Dec 2014 13:45:38 +0530 Subject: [PATCH] Adds console logging to swift-drive-audit This patch adds console logging ability to swift-drive-audit. There are cases where logging to console is necessary when drive-audit is done. This can be consumed for flagging errors in monitoring tools such as icinga. DocImpact Change-Id: Ia1e1effcbd89bd2cf6d5b8c64019f1647c736a3a --- bin/swift-drive-audit | 4 +++- etc/drive-audit.conf-sample | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/bin/swift-drive-audit b/bin/swift-drive-audit index ef49328d96..69a64031c2 100755 --- a/bin/swift-drive-audit +++ b/bin/swift-drive-audit @@ -150,6 +150,7 @@ if __name__ == '__main__': recon_cache_path = conf.get('recon_cache_path', "/var/cache/swift") log_file_pattern = conf.get('log_file_pattern', '/var/log/kern.*[!.][!g][!z]') + log_to_console = config_true_value(conf.get('log_to_console', False)) error_re = [] for conf_key in conf: if conf_key.startswith('regex_pattern_'): @@ -166,7 +167,8 @@ if __name__ == '__main__': re.compile(r'\b(sd[a-z]{1,2}\d?)\b.*\berror\b'), ] conf['log_name'] = conf.get('log_name', 'drive-audit') - logger = get_logger(conf, log_route='drive-audit') + logger = get_logger(conf, log_to_console=log_to_console, + log_route='drive-audit') devices = get_devices(device_dir, logger) logger.debug("Devices found: %s" % str(devices)) if not devices: diff --git a/etc/drive-audit.conf-sample b/etc/drive-audit.conf-sample index bc3cba8fbc..6deb7b4b9b 100644 --- a/etc/drive-audit.conf-sample +++ b/etc/drive-audit.conf-sample @@ -11,6 +11,10 @@ # recon_cache_path = /var/cache/swift # unmount_failed_device = True # +# By default, drive-audit logs only to syslog. Setting this option True +# makes drive-audit log to console in addition to syslog. +# log_to_console = False +# # Location of the log file with globbing # pattern to check against device errors. # log_file_pattern = /var/log/kern.*[!.][!g][!z]