From 1185cbce8d5dd04e539ca74d8f9564e5715a78aa Mon Sep 17 00:00:00 2001 From: Fabiano Fidêncio Date: Thu, 12 Oct 2017 10:15:22 +0200 Subject: DP: Log to syslog whether it's online or offline MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Instead of requiring that admins enable and look at our logs, let's log to syslog what's the DP status. Resolves: https://pagure.io/SSSD/sssd/issue/3307 Signed-off-by: Fabiano Fidêncio Reviewed-by: Jakub Hrozek Reviewed-by: Pavel Březina --- src/providers/backend.h | 5 +++++ src/providers/data_provider_be.c | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/src/providers/backend.h b/src/providers/backend.h index f6c74f856..191427403 100644 --- a/src/providers/backend.h +++ b/src/providers/backend.h @@ -113,6 +113,11 @@ struct be_ctx { size_t check_online_ref_count; struct data_provider *provider; + + /* Indicates whether the last state of the DP that has been logged is + * DP_ERR_OK or DP_ERR_OFFLINE. The only usage of this var, so far, is + * to log the DP status without spamming the syslog/journal. */ + int last_dp_state; }; bool be_is_offline(struct be_ctx *ctx); diff --git a/src/providers/data_provider_be.c b/src/providers/data_provider_be.c index e564bc11d..2e55dc4e3 100644 --- a/src/providers/data_provider_be.c +++ b/src/providers/data_provider_be.c @@ -262,9 +262,17 @@ static void be_check_online_done(struct tevent_req *req) switch (reply->dp_error) { case DP_ERR_OK: + if (be_ctx->last_dp_state != DP_ERR_OK) { + be_ctx->last_dp_state = DP_ERR_OK; + sss_log(SSS_LOG_INFO, "Backend is online\n"); + } DEBUG(SSSDBG_TRACE_FUNC, "Backend is online\n"); break; case DP_ERR_OFFLINE: + if (be_ctx->last_dp_state != DP_ERR_OFFLINE) { + be_ctx->last_dp_state = DP_ERR_OFFLINE; + sss_log(SSS_LOG_INFO, "Backend is offline\n"); + } DEBUG(SSSDBG_TRACE_FUNC, "Backend is offline\n"); break; default: @@ -397,6 +405,7 @@ errno_t be_process_init(TALLOC_CTX *mem_ctx, ret = ENOMEM; goto done; } + be_ctx->last_dp_state = -1; ret = be_init_failover(be_ctx); if (ret != EOK) { -- cgit