Add a chart with netdata uptime (#10997)
Co-authored-by: Ilya Mashchenko <ilya@netdata.cloud>
Vladimir Kobal committed
Apr 20, 2021 at 15:20 UTC
0a6a14e323ee3b7a2dc17b2ca5b0cce4a8b2eb5e
1 file changed
+34
daemon/global_statistics.c
+34
@@ -181,6 +181,11 @@ void global_statistics_charts(void) {
181
static collected_number compression_ratio = -1,
182
average_response_time = -1;
183
184
+ static time_t netdata_start_time = 0;
185
+ if (!netdata_start_time)
186
+ netdata_start_time = now_boottime_sec();
187
+ time_t netdata_uptime = now_boottime_sec() - netdata_start_time;
188
+
189
struct global_statistics gs;
190
struct rusage me;
191
@@ -223,6 +228,35 @@ void global_statistics_charts(void) {
228
229
// ----------------------------------------------------------------
230
231
+ {
232
+ static RRDSET *st_uptime = NULL;
233
+ static RRDDIM *rd_uptime = NULL;
234
+
235
+ if (unlikely(!st_uptime)) {
236
+ st_uptime = rrdset_create_localhost(
237
+ "netdata",
238
+ "uptime",
239
+ NULL,
240
+ "netdata",
241
+ NULL,
242
+ "Netdata uptime",
243
+ "seconds",
244
+ "netdata",
245
+ "stats",
246
+ 130100,
247
+ localhost->rrd_update_every,
248
+ RRDSET_TYPE_LINE);
249
+
250
+ rd_uptime = rrddim_add(st_uptime, "uptime", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
251
+ } else
252
+ rrdset_next(st_uptime);
253
+
254
+ rrddim_set_by_pointer(st_uptime, rd_uptime, netdata_uptime);
255
+ rrdset_done(st_uptime);
256
+ }
257
+
258
+ // ----------------------------------------------------------------
259
+
260
{
261
static RRDSET *st_clients = NULL;
262
static RRDDIM *rd_clients = NULL;