+static int load_config(const char *key, const char *value) {
+ if (strcasecmp(key, "ReportRelative") == 0) {
+#ifdef _SC_NPROCESSORS_ONLN
+ report_relative_load = IS_TRUE(value);
+#else
+ WARNING("load plugin: The \"ReportRelative\" configuration "
+ "is not available, because I can't determine the "
+ "number of CPUS on this system. Sorry.");
+#endif
+ return 0;
+ }
+ return -1;
+}
+static void load_submit(gauge_t snum, gauge_t mnum, gauge_t lnum) {
+ int cores = 0;
+
+#ifdef _SC_NPROCESSORS_ONLN
+ if (report_relative_load) {
+ if ((cores = sysconf(_SC_NPROCESSORS_ONLN)) < 1) {
+ WARNING("load: sysconf failed : %s", STRERRNO);
+ }
+ }
+#endif
+ if (cores > 0) {
+ snum /= cores;
+ mnum /= cores;
+ lnum /= cores;
+ }
+
+ value_list_t vl = VALUE_LIST_INIT;
+ value_t values[] = {
+ {.gauge = snum},
+ {.gauge = mnum},
+ {.gauge = lnum},
+ };
+
+ vl.values = values;
+ vl.values_len = STATIC_ARRAY_SIZE(values);
+
+ sstrncpy(vl.plugin, "load", sizeof(vl.plugin));
+ sstrncpy(vl.type, "load", sizeof(vl.type));
+
+ if (cores > 0) {
+ sstrncpy(vl.type_instance, "relative", sizeof(vl.type_instance));
+ }
+
+ plugin_dispatch_values(&vl);