Code

curl stats: Use CamelCase identifiers instead of using underscores.
authorSebastian Harl <sh@tokkee.org>
Mon, 30 May 2016 20:39:53 +0000 (22:39 +0200)
committerSebastian Harl <sh@tokkee.org>
Fri, 10 Jun 2016 19:04:49 +0000 (21:04 +0200)
This is more consistent with the usual collectd style but still close enough
to the names used in cURL.

src/collectd.conf.pod
src/utils_curl_stats.c

index 925262c1e4f5bd46f49ffbd8a9df96b0a89cd8a4..605ba0596a6056ab27ac6efb36c987df6a4c2cf3 100644 (file)
@@ -1464,74 +1464,74 @@ See L<http://curl.haxx.se/libcurl/c/curl_easy_getinfo.html> for more details.
 
 =over 4
 
-=item B<total_time> B<true|false>
+=item B<TotalTime> B<true|false>
 
 Total time of the transfer, including name resolving, TCP connect, etc.
 
-=item B<namelookup_time> B<true|false>
+=item B<NamelookupTime> B<true|false>
 
 Time it took from the start until name resolving was completed.
 
-=item B<connect_time> B<true|false>
+=item B<ConnectTime> B<true|false>
 
 Time it took from the start until the connect to the remote host (or proxy)
 was completed.
 
-=item B<appconnect_time> B<true|false>
+=item B<AppconnectTime> B<true|false>
 
 Time it took from the start until the SSL/SSH connect/handshake to the remote
 host was completed.
 
-=item B<pretransfer_time> B<true|false>
+=item B<PretransferTime> B<true|false>
 
 Time it took from the start until the file transfer is just about to begin.
 
-=item B<starttransfer_time> B<true|false>
+=item B<StarttransferTime> B<true|false>
 
 Time it took from the start until the first byte was received.
 
-=item B<redirect_time> B<true|false>
+=item B<RedirectTime> B<true|false>
 
 Time it took for all redirection steps include name lookup, connect,
 pre-transfer and transfer before final transaction was started.
 
-=item B<redirect_count> B<true|false>
+=item B<RedirectCount> B<true|false>
 
 The total number of redirections that were actually followed.
 
-=item B<size_upload> B<true|false>
+=item B<SizeUpload> B<true|false>
 
 The total amount of bytes that were uploaded.
 
-=item B<size_download> B<true|false>
+=item B<SizeDownload> B<true|false>
 
 The total amount of bytes that were downloaded.
 
-=item B<speed_download> B<true|false>
+=item B<SpeedDownload> B<true|false>
 
 The average download speed that curl measured for the complete download.
 
-=item B<speed_upload> B<true|false>
+=item B<SpeedUpload> B<true|false>
 
 The average upload speed that curl measured for the complete upload.
 
-=item B<header_size> B<true|false>
+=item B<HeaderSize> B<true|false>
 
 The total size of all the headers received.
 
-=item B<request_size> B<true|false>
+=item B<RequestSize> B<true|false>
 
 The total size of the issued requests.
 
-=item B<content_length_download> B<true|false>
+=item B<ContentLengthDownload> B<true|false>
 
 The content-length of the download.
 
-=item B<content_length_upload> B<true|false>
+=item B<ContentLengthUpload> B<true|false>
 
 The specified size of the upload.
 
-=item B<num_connects> B<true|false>
+=item B<NumConnects> B<true|false>
 
 The number of new connections that were created to achieve the transfer.
 
index 6e98bcfd018f0a731eda44dc98799228450a4a2d..5a37083a0aa6e680c26852b4cd6e1307386315f1 100644 (file)
@@ -110,32 +110,33 @@ static int dispatch_size (CURL *curl, CURLINFO info, value_list_t *vl)
 
 static struct {
        const char *name;
+       const char *config_key;
        size_t offset;
 
        int (*dispatcher)(CURL *, CURLINFO, value_list_t *);
        const char *type;
        CURLINFO info;
 } field_specs[] = {
-#define SPEC(name, dispatcher, type, info) \
-       { #name, offsetof (curl_stats_t, name), dispatcher, type, info }
-
-       SPEC (total_time,              dispatch_gauge, "duration", CURLINFO_TOTAL_TIME),
-       SPEC (namelookup_time,         dispatch_gauge, "duration", CURLINFO_NAMELOOKUP_TIME),
-       SPEC (connect_time,            dispatch_gauge, "duration", CURLINFO_CONNECT_TIME),
-       SPEC (pretransfer_time,        dispatch_gauge, "duration", CURLINFO_PRETRANSFER_TIME),
-       SPEC (size_upload,             dispatch_gauge, "bytes",    CURLINFO_SIZE_UPLOAD),
-       SPEC (size_download,           dispatch_gauge, "bytes",    CURLINFO_SIZE_DOWNLOAD),
-       SPEC (speed_download,          dispatch_speed, "bitrate",  CURLINFO_SPEED_DOWNLOAD),
-       SPEC (speed_upload,            dispatch_speed, "bitrate",  CURLINFO_SPEED_UPLOAD),
-       SPEC (header_size,             dispatch_size,  "bytes",    CURLINFO_HEADER_SIZE),
-       SPEC (request_size,            dispatch_size,  "bytes",    CURLINFO_REQUEST_SIZE),
-       SPEC (content_length_download, dispatch_gauge, "bytes",    CURLINFO_CONTENT_LENGTH_DOWNLOAD),
-       SPEC (content_length_upload,   dispatch_gauge, "bytes",    CURLINFO_CONTENT_LENGTH_UPLOAD),
-       SPEC (starttransfer_time,      dispatch_gauge, "duration", CURLINFO_STARTTRANSFER_TIME),
-       SPEC (redirect_time,           dispatch_gauge, "duration", CURLINFO_REDIRECT_TIME),
-       SPEC (redirect_count,          dispatch_size,  "count",    CURLINFO_REDIRECT_COUNT),
-       SPEC (num_connects,            dispatch_size,  "count",    CURLINFO_NUM_CONNECTS),
-       SPEC (appconnect_time,         dispatch_gauge, "duration", CURLINFO_APPCONNECT_TIME),
+#define SPEC(name, config_key, dispatcher, type, info) \
+       { #name, config_key, offsetof (curl_stats_t, name), dispatcher, type, info }
+
+       SPEC (total_time,              "TotalTime",              dispatch_gauge, "duration", CURLINFO_TOTAL_TIME),
+       SPEC (namelookup_time,         "NamelookupTime",         dispatch_gauge, "duration", CURLINFO_NAMELOOKUP_TIME),
+       SPEC (connect_time,            "ConnectTime",            dispatch_gauge, "duration", CURLINFO_CONNECT_TIME),
+       SPEC (pretransfer_time,        "PretransferTime",        dispatch_gauge, "duration", CURLINFO_PRETRANSFER_TIME),
+       SPEC (size_upload,             "SizeUpload",             dispatch_gauge, "bytes",    CURLINFO_SIZE_UPLOAD),
+       SPEC (size_download,           "SizeDownload",           dispatch_gauge, "bytes",    CURLINFO_SIZE_DOWNLOAD),
+       SPEC (speed_download,          "SpeedDownload",          dispatch_speed, "bitrate",  CURLINFO_SPEED_DOWNLOAD),
+       SPEC (speed_upload,            "SpeedUpload",            dispatch_speed, "bitrate",  CURLINFO_SPEED_UPLOAD),
+       SPEC (header_size,             "HeaderSize",             dispatch_size,  "bytes",    CURLINFO_HEADER_SIZE),
+       SPEC (request_size,            "RequestSize",            dispatch_size,  "bytes",    CURLINFO_REQUEST_SIZE),
+       SPEC (content_length_download, "ContentLengthDownload",  dispatch_gauge, "bytes",    CURLINFO_CONTENT_LENGTH_DOWNLOAD),
+       SPEC (content_length_upload,   "ContentLengthUpload",    dispatch_gauge, "bytes",    CURLINFO_CONTENT_LENGTH_UPLOAD),
+       SPEC (starttransfer_time,      "StarttransferTime",      dispatch_gauge, "duration", CURLINFO_STARTTRANSFER_TIME),
+       SPEC (redirect_time,           "RedirectTime",           dispatch_gauge, "duration", CURLINFO_REDIRECT_TIME),
+       SPEC (redirect_count,          "RedirectCount",          dispatch_size,  "count",    CURLINFO_REDIRECT_COUNT),
+       SPEC (num_connects,            "NumConnects",            dispatch_size,  "count",    CURLINFO_NUM_CONNECTS),
+       SPEC (appconnect_time,         "AppconnectTime",         dispatch_gauge, "duration", CURLINFO_APPCONNECT_TIME),
 
 #undef SPEC
 };
@@ -170,9 +171,12 @@ curl_stats_t *curl_stats_from_config (oconfig_item_t *ci)
                oconfig_item_t *c = ci->children + i;
                size_t field;
 
-               for (field = 0; field < STATIC_ARRAY_SIZE (field_specs); ++field)
+               for (field = 0; field < STATIC_ARRAY_SIZE (field_specs); ++field) {
+                       if (! strcasecmp (c->key, field_specs[field].config_key))
+                               break;
                        if (! strcasecmp (c->key, field_specs[field].name))
                                break;
+               }
                if (field >= STATIC_ARRAY_SIZE (field_specs))
                {
                        ERROR ("curl stats: Unknown field name %s", c->key);