Merge pull request #3241 from ffontaine/master
authorMatthias Runge <mrunge@redhat.com>
Wed, 21 Aug 2019 09:15:57 +0000 (11:15 +0200)
committerGitHub <noreply@github.com>
Wed, 21 Aug 2019 09:15:57 +0000 (11:15 +0200)
configure.ac: fix activation of snmp_agent

13 files changed:
bindings/perl/lib/Collectd/Plugins/OpenVZ.pm
contrib/collectd_network.py
contrib/collection3/share/navigate.js
contrib/php-collection/browser.js
src/daemon/plugin.c
src/daemon/utils_random.h
src/intel_rdt.c
src/netlink.c
src/utils/common/common.c
src/utils/latency/latency.h
src/utils/proc_pids/proc_pids.h
src/utils_tail_match.h
src/zfs_arc.c

index 4c7c3fe..66359da 100644 (file)
@@ -110,9 +110,9 @@ sub cpu_read {
             $v{'type_instance'} = $cpu_instances[$key];
             $v{'values'} = [ $counters[$key] ];
             plugin_dispatch_values(\%v);
+        }
     }
 }
-}
 
 sub df_read {
     my $veid = shift;
@@ -137,7 +137,7 @@ sub df_read {
         $v{'type_instance'} = $val;
         $v{'values'} = [ $parts[5] * ($parts[6] - $parts[7]), $parts[5] * $parts[7] ];
         plugin_dispatch_values(\%v);
-}
+    }
 }
 
 sub load_read {
@@ -180,7 +180,7 @@ sub processes_read {
         $v{'type_instance'} = $key;
         $v{'values'} = [ $ps_states->{$key} ];
         plugin_dispatch_values(\%v);
-}
+    }
 }
 
 sub users_read {
index 809f19d..cb328f2 100644 (file)
@@ -16,7 +16,7 @@
 Collectd network protocol implementation.
 """
 
-import socket,struct,sys
+import socket,struct
 import platform
 if platform.python_version() < '2.8.0':
     # Python 2.7 and below io.StringIO does not like unicode
index 3bfe56e..0cf1513 100644 (file)
@@ -183,12 +183,11 @@ function nav_calculate_offset_x (obj)
 function nav_calculate_event_x (e)
 {
   var pos = 0;
-  var off = 0;
 
   if (!e || !e.target)
     return;
   
-  off = nav_calculate_offset_x (e.target);
+  nav_calculate_offset_x (e.target);
 
   if (e.pageX || e.pageY)
   {
index 4ddc424..09673da 100644 (file)
@@ -106,8 +106,8 @@ function refillSelect(options, select) {
                newOption.setAttribute('style', 'font-style: italic');
                newOption.appendChild(document.createTextNode('- please select -'));
                select.appendChild(newOption);
-               for (i = 0; i < optCnt; i++) {
-                       newOption = document.createElement("option");
+               for (var i = 0; i < optCnt; i++) {
+                       var newOption = document.createElement("option");
                        newOption.value = options[i].firstChild ? options[i].firstChild.data : '';
                        if (keepSelection && newOption.value == oldValue)
                                newOption.setAttribute('selected', 'selected');
@@ -311,7 +311,7 @@ function GraphAppend() {
 function ListOfGraph(response) {
        var graphs = response ? response.getElementsByTagName('graph') : null;
        if (graphs && graphs.length > 0) {
-               for (i = 0; i < graphs.length; i++)
+               for (var i = 0; i < graphs.length; i++)
                        GraphDoAppend(graphs[i].getAttribute('host'), graphs[i].getAttribute('plugin'), graphs[i].getAttribute('plugin_instance'),
                                      graphs[i].getAttribute('type'), graphs[i].getAttribute('type_instance'), graphs[i].getAttribute('timespan'),
                                      graphs[i].getAttribute('tinyLegend') == '1', graphs[i].getAttribute('logarithmic') == '1');
@@ -326,7 +326,7 @@ function GraphDoAppend(host, plugin, pinst, type, tinst, timespan, tinyLegend, l
                var graph_id   = 'graph_'+nextGraphId++;
                var graph_src  = graph_url+'?host='+encodeURIComponent(host)+'&plugin='+encodeURIComponent(plugin)+'&plugin_instance='+encodeURIComponent(pinst)+'&type='+encodeURIComponent(type);
                var graph_alt  = '';
-               var grap_title = '';
+               var graph_title = '';
                if (tinst == '@') {
                        graph_alt   = host+'/'+plugin+(pinst.length > 0 ? '-'+pinst : '')+'/'+type;
                        graph_title = type+' of '+plugin+(pinst.length > 0 ? '-'+pinst : '')+' plugin for '+host;
@@ -346,11 +346,11 @@ function GraphDoAppend(host, plugin, pinst, type, tinst, timespan, tinyLegend, l
                graphList.push(graph_id+' '+encodeURIComponent(graph_alt)+(logarithmic ? '&logarithmic=1' : '')+(tinyLegend ? '&tinylegend=1' : '')+'&timespan='+encodeURIComponent(timespan));
 
                // Graph container
-               newGraph = document.createElement('div');
+               var newGraph = document.createElement('div');
                newGraph.setAttribute('class', 'graph');
                newGraph.setAttribute('id', graph_id);
                // Graph cell + graph
-               newImg = document.createElement('img');
+               var newImg = document.createElement('img');
                newImg.setAttribute('src', graph_src);
                newImg.setAttribute('alt', graph_alt);
                newImg.setAttribute('title', graph_title);
@@ -397,7 +397,7 @@ function GraphToggleTools(graph) {
                document.getElementById('ge_graphid').value = graph;
                document.getElementById('ge_tinylegend').checked = src_url.match(/&tinylegend=1/);
                document.getElementById('ge_logarithmic').checked = src_url.match(/&logarithmic=1/);
-               for (i = 0; i < ts_sel.options.length; i++)
+               for (var i = 0; i < ts_sel.options.length; i++)
                        if (ts_sel.options[i].value == ts) {
                                ts_sel.selectedIndex = i;
                                break;
@@ -513,7 +513,7 @@ function GraphAdjust(graph) {
                                imgs[imgCnt].setAttribute('src', newSrc);
 
                                var myList = Array();
-                               for (i = 0; i < graphList.length; i++)
+                               for (var i = 0; i < graphList.length; i++)
                                        if (graphList[i].substring(0, graphId.length) == graphId && graphList[i].charAt(graphId.length) == ' ') {
                                                newSrc = graphList[i];
                                                newSrc = newSrc.replace(/&logarithmic=[^&]*/, '');
@@ -544,7 +544,7 @@ function GraphRemove(graph) {
                        document.getElementById('nograph').style.display = 'block';
 
                var myList = Array();
-               for (i = 0; i < graphList.length; i++)
+               for (var i = 0; i < graphList.length; i++)
                        if (graphList[i].substring(0, graphId.length) == graphId && graphList[i].charAt(graphId.length) == ' ')
                                continue;
                        else
@@ -558,7 +558,7 @@ function GraphMoveUp(graph) {
        var graphId   = graph == null ? document.getElementById('ge_graphid').value : graph;
        var childCnt  = graphs.childNodes.length;
        var prevGraph = null;
-       for (i = 0; i < childCnt; i++)
+       for (var i = 0; i < childCnt; i++)
                if (graphs.childNodes[i].nodeName == 'div' || graphs.childNodes[i].nodeName == 'DIV') {
                        if (graphs.childNodes[i].id == 'nograph') {
                                // Skip
@@ -590,7 +590,7 @@ function GraphMoveDown(graph) {
        var childCnt  = graphs.childNodes.length;
        var nextGraph = null;
        var myGraph   = null;
-       for (i = 0; i < childCnt; i++)
+       for (var i = 0; i < childCnt; i++)
                if (graphs.childNodes[i].nodeName == 'div' || graphs.childNodes[i].nodeName == 'DIV') {
                        if (graphs.childNodes[i].id == 'nograph') {
                                // Skip
@@ -603,12 +603,12 @@ function GraphMoveDown(graph) {
                                break;
                        }
                }
-       for (i = 0; i < graphList.length; i++)
-               if (graphList[i].substring(0, graphId.length) == graphId && graphList[i].charAt(graphId.length) == ' ') {
-                       if (i+1 < graphList.length) {
-                               var tmp = graphList[i+1];
-                               graphList[i+1] = graphList[i];
-                               graphList[i]   = tmp;
+       for (var j = 0; j < graphList.length; j++)
+               if (graphList[j].substring(0, graphId.length) == graphId && graphList[j].charAt(graphId.length) == ' ') {
+                       if (j+1 < graphList.length) {
+                               var tmp = graphList[j+1];
+                               graphList[j+1] = graphList[i];
+                               graphList[j]   = tmp;
                        }
                        break;
                }
@@ -619,7 +619,7 @@ function GraphListFromCookie(lname) {
        if (document.cookie.length > 0) {
                var cname= 'graphLst'+lname+'=';
                var cookies = document.cookie.split('; ');
-               for (i = 0; i < cookies.length; i++)
+               for (var i = 0; i < cookies.length; i++)
                        if (cookies[i].substring(0, cname.length) == cname)
                                return cookies[i].substring(cname.length).split('/');
        }
@@ -663,7 +663,7 @@ function GraphListRefresh() {
        } else {
                select.removeAttribute('disabled');
                for (i = 0; i < optCnt; i++) {
-                       newOption = document.createElement("option");
+                       var newOption = document.createElement("option");
                        newOption.value = options[i][0];
                        if (newOption.value == oldValue)
                                newOption.setAttribute('selected', 'selected');
@@ -705,7 +705,7 @@ function GraphSave() {
        if (graphList.length > 0) {
                // Save graph list to cookie
                var str = '';
-               for (i = 0; i < graphList.length; i++) {
+               for (var i = 0; i < graphList.length; i++) {
                        var g = graphList[i].indexOf(' ');
                        if (i > 0)
                                str += '/';
@@ -743,7 +743,7 @@ function GraphLoad() {
        // Load graph list from cookie
        var grLst = GraphListFromCookie(cname);
        var oldLength = graphList.length;
-       for (i = 0; i < grLst.length; i++) {
+       for (var i = 0; i < grLst.length; i++) {
                var host        = '';
                var plugin      = '';
                var pinst       = '';
@@ -753,7 +753,7 @@ function GraphLoad() {
                var logarithmic = false;
                var tinyLegend  = false;
                var graph = grLst[i].split('&');
-               for (j = 0; j < graph.length; j++)
+               for (var j = 0; j < graph.length; j++)
                        if (graph[j] == 'logarithmic=1')
                                logarithmic = true;
                        else if (graph[j] == 'tinylegend=1')
index 1f8ab2d..daddf68 100644 (file)
@@ -647,7 +647,8 @@ static void start_read_threads(size_t num) /* {{{ */
     }
 
     char name[THREAD_NAME_MAX];
-    snprintf(name, sizeof(name), "reader#%" PRIu64, (uint64_t)read_threads_num);
+    ssnprintf(name, sizeof(name), "reader#%" PRIu64,
+              (uint64_t)read_threads_num);
     set_thread_name(read_threads[read_threads_num], name);
 
     read_threads_num++;
@@ -836,8 +837,8 @@ static void start_write_threads(size_t num) /* {{{ */
     }
 
     char name[THREAD_NAME_MAX];
-    snprintf(name, sizeof(name), "writer#%" PRIu64,
-             (uint64_t)write_threads_num);
+    ssnprintf(name, sizeof(name), "writer#%" PRIu64,
+              (uint64_t)write_threads_num);
     set_thread_name(write_threads[write_threads_num], name);
 
     write_threads_num++;
index 75bdc12..ff0022e 100644 (file)
@@ -24,6 +24,9 @@
  *   Florian Forster <octo at collectd.org>
  **/
 
+#ifndef UTILS_RANDOM_H
+#define UTILS_RANDOM_H 1
+
 /**
  * Returns a random double value in the range [0..1), i.e. excluding 1.
  *
@@ -46,3 +49,5 @@ uint32_t cdrand_u(void);
  * outside the intended range. This function is thread- and reentrant-safe.
  */
 long cdrand_range(long min, long max);
+
+#endif /* !UTILS_RANDOM_H */
index 515a601..99c3ed0 100644 (file)
@@ -325,8 +325,8 @@ static int strlisttoarray(char *str_list, char ***names, size_t *names_num) {
       continue;
 
     if ((isdupstr((const char **)*names, *names_num, token))) {
-      ERROR(RDT_PLUGIN ": Duplicated process name \'%s\' in group \'%s\'",
-            token, str_list);
+      ERROR(RDT_PLUGIN ": Duplicated process name \'%s\'", token);
+
       return -EINVAL;
     } else {
       if (0 != strarray_add(names, names_num, token)) {
index 806265a..b998cf3 100644 (file)
@@ -638,7 +638,7 @@ static int ir_config(const char *key, const char *value) {
   } else if ((strcasecmp(key, "QDisc") == 0) ||
              (strcasecmp(key, "Class") == 0) ||
              (strcasecmp(key, "Filter") == 0)) {
-    if ((fields_num < 1) || (fields_num > 2)) {
+    if (fields_num > 2) {
       ERROR("netlink plugin: Invalid number of fields for option "
             "`%s'. Got %i, expected 1 or 2.",
             key, fields_num);
index 7cfd310..2d961d4 100644 (file)
@@ -1456,13 +1456,13 @@ int service_name_to_port_number(const char *service_name) {
       service_number = (int)ntohs(sa->sin6_port);
     }
 
-    if ((service_number > 0) && (service_number <= 65535))
+    if (service_number > 0)
       break;
   }
 
   freeaddrinfo(ai_list);
 
-  if ((service_number > 0) && (service_number <= 65535))
+  if (service_number > 0)
     return service_number;
   return -1;
 } /* int service_name_to_port_number */
index 9d878da..6c2c8ae 100644 (file)
@@ -24,6 +24,9 @@
  *   Florian Forster <ff at octo.it>
  **/
 
+#ifndef UTILS_LATENCY_LATENCY_H
+#define UTILS_LATENCY_LATENCY_H 1
+
 #include "collectd.h"
 
 #include "utils_time.h"
@@ -61,3 +64,5 @@ cdtime_t latency_counter_get_percentile(latency_counter_t *lc, double percent);
  */
 double latency_counter_get_rate(const latency_counter_t *lc, cdtime_t lower,
                                 cdtime_t upper, const cdtime_t now);
+
+#endif /* UTILS_LATENCY_LATENCY_H */
index 8b19497..9170398 100644 (file)
@@ -27,6 +27,9 @@
  *   Michał Aleksiński <michalx.aleksinski@intel.com>
  **/
 
+#ifndef UTILS_PROC_PIDS_PROC_PIDS_H
+#define UTILS_PROC_PIDS_PROC_PIDS_H 1
+
 #include <dirent.h>
 #include <sys/types.h>
 
@@ -224,3 +227,5 @@ int proc_pids_update(const char *procfs_path, proc_pids_t *proc_pids[],
  *   0 on success. -1 on error.
  */
 int proc_pids_free(proc_pids_t *proc_pids[], size_t proc_pids_num);
+
+#endif /* UTILS_PROC_PIDS_PROC_PIDS_H */
index 43d3fcf..771c241 100644 (file)
@@ -33,6 +33,9 @@
  *   regular expressions.
  */
 
+#ifndef UTILS_TAIL_MATCH_H
+#define UTILS_TAIL_MATCH_H 1
+
 #include "utils/latency/latency_config.h"
 #include "utils/match/match.h"
 
@@ -133,3 +136,5 @@ int tail_match_add_match_simple(cu_tail_match_t *obj, const char *regex,
  *   Zero on success, nonzero on failure.
  */
 int tail_match_read(cu_tail_match_t *obj);
+
+#endif /* UTILS_TAIL_MATCH_H */
index a3c2451..be93b9d 100644 (file)
@@ -231,23 +231,6 @@ static int za_read(void) {
     return -1;
   }
 
-  // Ignore the first two lines because they contain information about
-  // the rest of the file.
-  // See kstat_seq_show_headers module/spl/spl-kstat.c of the spl kernel
-  // module.
-  if (fgets(buffer, sizeof(buffer), fh) == NULL) {
-    ERROR("zfs_arc plugin: \"%s\" does not contain a single line.",
-          ZOL_ARCSTATS_FILE);
-    fclose(fh);
-    return (-1);
-  }
-  if (fgets(buffer, sizeof(buffer), fh) == NULL) {
-    ERROR("zfs_arc plugin: \"%s\" does not contain at least two lines.",
-          ZOL_ARCSTATS_FILE);
-    fclose(fh);
-    return (-1);
-  }
-
   while (fgets(buffer, sizeof(buffer), fh) != NULL) {
     char *fields[3];
     value_t v;