blob: 5e50a2272a52be877358c4db43c4ad2cc19dff94 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
// SPDX-License-Identifier: GPL-3.0-or-later
#ifndef NETDATA_ACLK_STATS_H
#define NETDATA_ACLK_STATS_H
#include "../../daemon/common.h"
#include "libnetdata/libnetdata.h"
#include "aclk_common.h"
#define ACLK_STATS_THREAD_NAME "ACLK_Stats"
extern netdata_mutex_t aclk_stats_mutex;
#define ACLK_STATS_LOCK netdata_mutex_lock(&aclk_stats_mutex)
#define ACLK_STATS_UNLOCK netdata_mutex_unlock(&aclk_stats_mutex)
extern int aclk_stats_enabled;
struct aclk_stats_thread {
netdata_thread_t *thread;
int query_thread_count;
};
// preserve between samples
struct aclk_metrics {
volatile uint8_t online;
};
//mat = max average total
struct aclk_metric_mat_data {
volatile uint32_t total;
volatile uint32_t count;
volatile uint32_t max;
};
//mat = max average total
struct aclk_metric_mat {
char *name;
char *title;
RRDSET *st;
RRDDIM *rd_avg;
RRDDIM *rd_max;
RRDDIM *rd_total;
long prio;
char *unit;
};
extern struct aclk_mat_metrics {
#ifdef NETDATA_INTERNAL_CHECKS
struct aclk_metric_mat latency;
#endif
struct aclk_metric_mat cloud_q_db_query_time;
struct aclk_metric_mat cloud_q_recvd_to_processed;
} aclk_mat_metrics;
void aclk_metric_mat_update(struct aclk_metric_mat_data *metric, usec_t measurement);
#define ACLK_STATS_CLOUD_REQ_TYPE_CNT 7
// if you change update cloud_req_type_names
int aclk_cloud_req_type_to_idx(const char *name);
// reset to 0 on every sample
extern struct aclk_metrics_per_sample {
/* in the unlikely event of ACLK disconnecting
and reconnecting under 1 sampling rate
we want to make sure we record the disconnection
despite it being then seemingly longer in graph */
volatile uint8_t offline_during_sample;
volatile uint32_t queries_queued;
volatile uint32_t queries_dispatched;
volatile uint32_t write_q_added;
volatile uint32_t write_q_consumed;
volatile uint32_t read_q_added;
volatile uint32_t read_q_consumed;
volatile uint32_t cloud_req_ok;
volatile uint32_t cloud_req_err;
volatile uint16_t cloud_req_v1;
volatile uint16_t cloud_req_v2;
volatile uint16_t cloud_req_by_type[ACLK_STATS_CLOUD_REQ_TYPE_CNT];
#ifdef NETDATA_INTERNAL_CHECKS
struct aclk_metric_mat_data latency;
#endif
struct aclk_metric_mat_data cloud_q_db_query_time;
struct aclk_metric_mat_data cloud_q_recvd_to_processed;
} aclk_metrics_per_sample;
extern uint32_t *aclk_queries_per_thread;
extern struct rusage *rusage_per_thread;
void *aclk_stats_main_thread(void *ptr);
void aclk_stats_thread_cleanup();
void aclk_stats_upd_online(int online);
#endif /* NETDATA_ACLK_STATS_H */
|