projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
README: Fix a typo.
[collectd.git]
/
src
/
libvirt.c
diff --git
a/src/libvirt.c
b/src/libvirt.c
index
6ba08fb
..
bcbf0e6
100644
(file)
--- a/
src/libvirt.c
+++ b/
src/libvirt.c
@@
-24,6
+24,7
@@
#include "plugin.h"
#include "configfile.h"
#include "utils_ignorelist.h"
#include "plugin.h"
#include "configfile.h"
#include "utils_ignorelist.h"
+#include "utils_complain.h"
#include <libvirt/libvirt.h>
#include <libvirt/virterror.h>
#include <libvirt/libvirt.h>
#include <libvirt/virterror.h>
@@
-50,7
+51,7
@@
static const char *config_keys[] = {
/* Connection. */
static virConnectPtr conn = 0;
static char *conn_string = NULL;
/* Connection. */
static virConnectPtr conn = 0;
static char *conn_string = NULL;
-static
int conn_count = 0
;
+static
c_complain_t conn_complain = C_COMPLAIN_INIT_STATIC
;
/* Seconds between list refreshes, 0 disables completely. */
static int interval = 60;
/* Seconds between list refreshes, 0 disables completely. */
static int interval = 60;
@@
-155,15
+156,13
@@
lv_config (const char *key, const char *value)
il_interface_devices = ignorelist_create (1);
if (strcasecmp (key, "Connection") == 0) {
il_interface_devices = ignorelist_create (1);
if (strcasecmp (key, "Connection") == 0) {
- if (conn_count++ != 0) {
- ERROR ("Connection may only be given once in config file");
- return 1;
- }
- conn_string = strdup(value);
- if (conn_string == NULL) {
+ char *tmp = strdup (value);
+ if (tmp == NULL) {
ERROR ("libvirt plugin: Connection strdup failed.");
ERROR ("libvirt plugin: Connection strdup failed.");
- return
-
1;
+ return 1;
}
}
+ sfree (conn_string);
+ conn_string = tmp;
return 0;
}
return 0;
}
@@
-188,9
+187,7
@@
lv_config (const char *key, const char *value)
}
if (strcasecmp (key, "IgnoreSelected") == 0) {
}
if (strcasecmp (key, "IgnoreSelected") == 0) {
- if (strcasecmp (value, "True") == 0 ||
- strcasecmp (value, "Yes") == 0 ||
- strcasecmp (value, "On") == 0)
+ if (IS_TRUE (value))
{
ignorelist_set_invert (il_domains, 0);
ignorelist_set_invert (il_block_devices, 0);
{
ignorelist_set_invert (il_domains, 0);
ignorelist_set_invert (il_block_devices, 0);
@@
-255,12
+252,17
@@
lv_read (void)
int i;
if (conn == NULL) {
int i;
if (conn == NULL) {
+ /* `conn_string == NULL' is acceptable. */
conn = virConnectOpenReadOnly (conn_string);
if (conn == NULL) {
conn = virConnectOpenReadOnly (conn_string);
if (conn == NULL) {
- ERROR ("libvirt plugin: Not connected.");
+ c_complain (LOG_ERR, &conn_complain,
+ "libvirt plugin: Unable to connect: "
+ "virConnectOpenReadOnly failed.");
return -1;
}
}
return -1;
}
}
+ c_release (LOG_NOTICE, &conn_complain,
+ "libvirt plugin: Connection established.");
time (&t);
time (&t);