From 47e93ad3cb7e70064ac19a03c34b6e6835f19fd5 Mon Sep 17 00:00:00 2001 From: Pavel Rochnyack Date: Fri, 24 May 2019 17:56:27 +0700 Subject: [PATCH] virt plugin: Added connection state check via virConnectIsAlive() Before this fix, if libvirt daemon was stopped, Collectd starts to spam logs with lot of "failed" messages. With this fix it correctly re-establishes connection. --- src/virt.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/virt.c b/src/virt.c index 6a919929..7e7e0578 100644 --- a/src/virt.c +++ b/src/virt.c @@ -2418,6 +2418,21 @@ static int lv_read(user_data_t *ud) { return 0; } + int ret = virConnectIsAlive(conn); + if (ret == 0) { /* Connection lost */ + if (inst->id == 0) { + c_complain(LOG_ERR, &conn_complain, + PLUGIN_NAME " plugin: Lost connection."); + + if (!persistent_notification) + stop_event_loop(¬if_thread); + + lv_disconnect(); + last_refresh = 0; + } + return -1; + } + time_t t; time(&t); -- 2.11.0