From: Matthias Runge Date: Wed, 21 Aug 2019 09:15:57 +0000 (+0200) Subject: Merge pull request #3241 from ffontaine/master X-Git-Url: https://git.octo.it/?p=collectd.git;a=commitdiff_plain;h=b7818712d46e9fbac7bd9dfe93dca936c101d680;hp=bfb85f1840f3672518979dd4b52f012fc08b4f88 Merge pull request #3241 from ffontaine/master configure.ac: fix activation of snmp_agent --- diff --git a/bindings/perl/lib/Collectd/Plugins/OpenVZ.pm b/bindings/perl/lib/Collectd/Plugins/OpenVZ.pm index 4c7c3fe4..66359da1 100644 --- a/bindings/perl/lib/Collectd/Plugins/OpenVZ.pm +++ b/bindings/perl/lib/Collectd/Plugins/OpenVZ.pm @@ -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 { diff --git a/contrib/collectd_network.py b/contrib/collectd_network.py index 809f19de..cb328f2b 100644 --- a/contrib/collectd_network.py +++ b/contrib/collectd_network.py @@ -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 diff --git a/contrib/collection3/share/navigate.js b/contrib/collection3/share/navigate.js index 3bfe56ed..0cf15132 100644 --- a/contrib/collection3/share/navigate.js +++ b/contrib/collection3/share/navigate.js @@ -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) { diff --git a/contrib/php-collection/browser.js b/contrib/php-collection/browser.js index 4ddc424d..09673da8 100644 --- a/contrib/php-collection/browser.js +++ b/contrib/php-collection/browser.js @@ -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' : '')+'×pan='+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') diff --git a/src/daemon/plugin.c b/src/daemon/plugin.c index 1f8ab2db..daddf684 100644 --- a/src/daemon/plugin.c +++ b/src/daemon/plugin.c @@ -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++; diff --git a/src/daemon/utils_random.h b/src/daemon/utils_random.h index 75bdc12e..ff0022eb 100644 --- a/src/daemon/utils_random.h +++ b/src/daemon/utils_random.h @@ -24,6 +24,9 @@ * Florian Forster **/ +#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 */ diff --git a/src/intel_rdt.c b/src/intel_rdt.c index 515a601e..99c3ed0d 100644 --- a/src/intel_rdt.c +++ b/src/intel_rdt.c @@ -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)) { diff --git a/src/netlink.c b/src/netlink.c index 806265a2..b998cf31 100644 --- a/src/netlink.c +++ b/src/netlink.c @@ -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); diff --git a/src/utils/common/common.c b/src/utils/common/common.c index 7cfd3109..2d961d43 100644 --- a/src/utils/common/common.c +++ b/src/utils/common/common.c @@ -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 */ diff --git a/src/utils/latency/latency.h b/src/utils/latency/latency.h index 9d878dab..6c2c8aee 100644 --- a/src/utils/latency/latency.h +++ b/src/utils/latency/latency.h @@ -24,6 +24,9 @@ * Florian Forster **/ +#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 */ diff --git a/src/utils/proc_pids/proc_pids.h b/src/utils/proc_pids/proc_pids.h index 8b19497c..9170398f 100644 --- a/src/utils/proc_pids/proc_pids.h +++ b/src/utils/proc_pids/proc_pids.h @@ -27,6 +27,9 @@ * Michał Aleksiński **/ +#ifndef UTILS_PROC_PIDS_PROC_PIDS_H +#define UTILS_PROC_PIDS_PROC_PIDS_H 1 + #include #include @@ -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 */ diff --git a/src/utils_tail_match.h b/src/utils_tail_match.h index 43d3fcfa..771c2410 100644 --- a/src/utils_tail_match.h +++ b/src/utils_tail_match.h @@ -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 */ diff --git a/src/zfs_arc.c b/src/zfs_arc.c index a3c24516..be93b9db 100644 --- a/src/zfs_arc.c +++ b/src/zfs_arc.c @@ -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;