summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFabiano Fidêncio <fidencio@redhat.com>2017-10-12 10:15:22 +0200
committerLukas Slebodnik <lslebodn@redhat.com>2017-10-18 21:06:24 +0200
commit1185cbce8d5dd04e539ca74d8f9564e5715a78aa (patch)
tree1f3bf1daf32fdecd9f3a21262f56c27dc858fb26
parent60ec0db015c354349af445e0ec63f8b8421343fe (diff)
downloadsssd-1185cbce8d5dd04e539ca74d8f9564e5715a78aa.tar.gz
sssd-1185cbce8d5dd04e539ca74d8f9564e5715a78aa.tar.xz
sssd-1185cbce8d5dd04e539ca74d8f9564e5715a78aa.zip
DP: Log to syslog whether it's online or offline
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 <fidencio@redhat.com> Reviewed-by: Jakub Hrozek <jhrozek@redhat.com> Reviewed-by: Pavel Březina <pbrezina@redhat.com>
-rw-r--r--src/providers/backend.h5
-rw-r--r--src/providers/data_provider_be.c9
2 files changed, 14 insertions, 0 deletions
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) {