summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6ca32c4)
raw | patch | inline | side by side (parent: 6ca32c4)
author | Florian Forster <octo@collectd.org> | |
Sun, 22 Oct 2017 17:59:19 +0000 (19:59 +0200) | ||
committer | Florian Forster <octo@collectd.org> | |
Mon, 23 Oct 2017 12:12:17 +0000 (14:12 +0200) |
Fixes: #2426
src/lvm.c | patch | blob | history |
diff --git a/src/lvm.c b/src/lvm.c
index 63107279be19da94f6754caf7423f2140da29114..4bb1c3409ea25f9145d0c5148b9052568f5a3429 100644 (file)
--- a/src/lvm.c
+++ b/src/lvm.c
* Benjamin Gilbert <bgilbert at backtick.net>
**/
-#include <lvm2app.h>
-
#include "collectd.h"
#include "common.h"
#include "plugin.h"
+#include <lvm2app.h>
+
+#ifdef HAVE_SYS_CAPABILITY_H
+#include <sys/capability.h>
+#endif /* HAVE_SYS_CAPABILITY_H */
+
#define NO_VALUE UINT64_MAX
#define PERCENT_SCALE_FACTOR 1e-8
return 0;
} /*lvm_read */
+static int lvm_init(void) {
+#if defined(HAVE_SYS_CAPABILITY_H) && defined(CAP_SYS_ADMIN)
+ if (check_capability(CAP_SYS_ADMIN) != 0) {
+ if (getuid() == 0)
+ WARNING("smart plugin: Running collectd as root, but the "
+ "CAP_SYS_ADMIN capability is missing. The plugin's read "
+ "function will probably fail. Is your init system dropping "
+ "capabilities?");
+ else
+ WARNING("smart plugin: collectd doesn't have the CAP_SYS_ADMIN "
+ "capability. If you don't want to run collectd as root, try "
+ "running \"setcap cap_sys_admin=ep\" on the collectd binary.");
+ }
+#endif
+ return 0;
+}
+
void module_register(void) {
+ plugin_register_init("lvm", lvm_init);
plugin_register_read("lvm", lvm_read);
} /* void module_register */