Add request specific statistics to all CURL-based plugins.
[collectd.git] / src / utils_curl_stats.h
1 /**
2  * collectd - src/utils_curl_stats.h
3  * Copyright (C) 2015       Sebastian 'tokkee' Harl
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation
8  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9  * and/or sell copies of the Software, and to permit persons to whom the
10  * Software is furnished to do so, subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included in
13  * all copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21  * DEALINGS IN THE SOFTWARE.
22  *
23  * Authors:
24  *   Sebastian Harl <sh@tokkee.org>
25  **/
26
27 #ifndef UTILS_CURL_STATS_H
28 #define UTILS_CURL_STATS_H 1
29
30 #include "configfile.h"
31 #include "plugin.h"
32
33 #include <curl/curl.h>
34
35 struct curl_stats_s;
36 typedef struct curl_stats_s curl_stats_t;
37
38 /*
39  * curl_stats_from_config allocates and constructs a CURL statistics object
40  * from the specified configuration which is expected to be a single block of
41  * boolean options named after CURL information fields. The boolean value
42  * indicates whether to collect the respective information.
43  *
44  * See http://curl.haxx.se/libcurl/c/curl_easy_getinfo.html
45  */
46 __attribute__((nonnull(1)))
47 curl_stats_t *curl_stats_from_config (oconfig_item_t *ci);
48
49 void curl_stats_destroy (curl_stats_t *s);
50
51 /*
52  * curl_stats_dispatch dispatches performance values from the the specified
53  * CURL session to the daemon.
54  */
55 int curl_stats_dispatch (curl_stats_t *s, CURL *curl,
56                 const char *hostname, const char *plugin, const char *plugin_instance,
57                 const char *instance_prefix);
58
59 #endif /* UTILS_CURL_STATS_H */