| 1 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 2 | |
| 3 | #define PULSE_INTERNALS 1 |
| 4 | #include "pulse-heartbeat.h" |
| 5 | |
| 6 | void pulse_heartbeat_do(bool extended) { |
| 7 | if(!extended) return; |
| 8 | |
| 9 | static RRDSET *st_heartbeat = NULL; |
| 10 | static RRDDIM *rd_heartbeat_min = NULL; |
| 11 | static RRDDIM *rd_heartbeat_max = NULL; |
| 12 | static RRDDIM *rd_heartbeat_avg = NULL; |
| 13 | |
| 14 | if (unlikely(!st_heartbeat)) { |
| 15 | st_heartbeat = rrdset_create_localhost( |
| 16 | "netdata" |
| 17 | , "heartbeat" |
| 18 | , NULL |
| 19 | , "heartbeat" |
| 20 | , NULL |
| 21 | , "System clock jitter" |
| 22 | , "microseconds" |
| 23 | , "netdata" |
| 24 | , "pulse" |
| 25 | , 900000 |
| 26 | , localhost->rrd_update_every |
| 27 | , RRDSET_TYPE_AREA); |
| 28 | |
| 29 | rd_heartbeat_min = rrddim_add(st_heartbeat, "min", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE); |
| 30 | rd_heartbeat_max = rrddim_add(st_heartbeat, "max", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE); |
| 31 | rd_heartbeat_avg = rrddim_add(st_heartbeat, "average", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE); |
| 32 | } |
| 33 | |
| 34 | usec_t min, max, average; |
| 35 | size_t count; |
| 36 | |
| 37 | heartbeat_statistics(&min, &max, &average, &count); |
| 38 | |
| 39 | rrddim_set_by_pointer(st_heartbeat, rd_heartbeat_min, (collected_number)min); |
| 40 | rrddim_set_by_pointer(st_heartbeat, rd_heartbeat_max, (collected_number)max); |
| 41 | rrddim_set_by_pointer(st_heartbeat, rd_heartbeat_avg, (collected_number)average); |
| 42 | |
| 43 | rrdset_done(st_heartbeat); |
| 44 | } |