summaryrefslogtreecommitdiffstats
path: root/libnetdata/worker_utilization/worker_utilization.h
blob: e2f46c5a6f92846e21cde175d7e4c0b4e7688fee (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
#ifndef WORKER_UTILIZATION_H
#define WORKER_UTILIZATION_H 1

#include "../libnetdata.h"

// workers interfaces

#define WORKER_UTILIZATION_MAX_JOB_TYPES 50

typedef enum __attribute__((packed)) {
    WORKER_METRIC_EMPTY = 0,
    WORKER_METRIC_IDLE_BUSY = 1,
    WORKER_METRIC_ABSOLUTE = 2,
    WORKER_METRIC_INCREMENT = 3,
    WORKER_METRIC_INCREMENTAL_TOTAL = 4,
} WORKER_METRIC_TYPE;

void workers_utilization_enable(void);
size_t workers_allocated_memory(void);
void worker_register(const char *name);
void worker_register_job_name(size_t job_id, const char *name);
void worker_register_job_custom_metric(size_t job_id, const char *name, const char *units, WORKER_METRIC_TYPE type);
void worker_unregister(void);

void worker_is_idle(void);
void worker_is_busy(size_t job_id);
void worker_set_metric(size_t job_id, NETDATA_DOUBLE value);

// statistics interface

void workers_foreach(const char *name, void (*callback)(
                                                      void *data
                                                      , pid_t pid
                                                      , const char *thread_tag
                                                      , size_t max_job_id
                                                      , size_t utilization_usec
                                                      , size_t duration_usec
                                                      , size_t jobs_started
                                                      , size_t is_running
                                                      , STRING **job_types_names
                                                      , STRING **job_types_units
                                                      , WORKER_METRIC_TYPE *job_metric_types
                                                      , size_t *job_types_jobs_started
                                                      , usec_t *job_types_busy_time
                                                      , NETDATA_DOUBLE *job_custom_values
                                                      )
                                                      , void *data);

#endif // WORKER_UTILIZATION_H