From: Pavel Rochnyack Date: Fri, 24 May 2019 10:56:27 +0000 (+0700) Subject: virt plugin: Added connection state check via virConnectIsAlive() X-Git-Url: https://git.octo.it/?p=collectd.git;a=commitdiff_plain;h=47e93ad3cb7e70064ac19a03c34b6e6835f19fd5;hp=c09f8ee768891aee1222ad0a3e19c66b099cc973 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. --- 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);