X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fnginx.c;h=3850accf05c663cce1a7f799781c4142b9b7bd80;hb=e14e8b7f5c5bf9d0fe5cc632c6383f304d4ac2ad;hp=4e4ce3bbc6115572873668a76507f80ccd82b316;hpb=2cf10557f58144e13793a3d69ae5d4b7c8d6c305;p=collectd.git diff --git a/src/nginx.c b/src/nginx.c index 4e4ce3bb..3850accf 100644 --- a/src/nginx.c +++ b/src/nginx.c @@ -27,9 +27,9 @@ **/ #include "collectd.h" + #include "common.h" #include "plugin.h" -#include "configfile.h" #include @@ -71,7 +71,7 @@ static size_t nginx_curl_callback (void *buf, size_t size, size_t nmemb, len = (sizeof (nginx_buffer) - 1) - nginx_buffer_len; } - if (len <= 0) + if (len == 0) return (len); memcpy (&nginx_buffer[nginx_buffer_len], buf, len); @@ -188,15 +188,14 @@ static int init (void) } else { - curl_easy_setopt (curl, CURLOPT_TIMEOUT_MS, - CDTIME_T_TO_MS(plugin_get_interval())); + curl_easy_setopt (curl, CURLOPT_TIMEOUT_MS, (long) CDTIME_T_TO_MS(plugin_get_interval())); } #endif return (0); } /* void init */ -static void submit (char *type, char *inst, long long value) +static void submit (const char *type, const char *inst, long long value) { value_t values[1]; value_list_t vl = VALUE_LIST_INIT; @@ -211,7 +210,7 @@ static void submit (char *type, char *inst, long long value) return; vl.values = values; - vl.values_len = 1; + vl.values_len = STATIC_ARRAY_SIZE (values); sstrncpy (vl.host, hostname_g, sizeof (vl.host)); sstrncpy (vl.plugin, "nginx", sizeof (vl.plugin)); sstrncpy (vl.plugin_instance, "", sizeof (vl.plugin_instance)); @@ -225,8 +224,6 @@ static void submit (char *type, char *inst, long long value) static int nginx_read (void) { - int i; - char *ptr; char *lines[16]; int lines_num = 0; @@ -264,7 +261,7 @@ static int nginx_read (void) * 16630948 16630948 31070465 * Reading: 6 Writing: 179 Waiting: 106 */ - for (i = 0; i < lines_num; i++) + for (int i = 0; i < lines_num; i++) { fields_num = strsplit (lines[i], fields, (sizeof (fields) / sizeof (fields[0])));