67 #ifndef REPORTED_MSU_STAT_TYPES
68 #define REPORTED_MSU_STAT_TYPES \
69 {MSU_QUEUE_LEN, "QUEUE_LEN"}, \
70 {MSU_ITEMS_PROCESSED, "ITEMS_PROCESSED"}, \
71 {MSU_MEM_ALLOC, "MEMORY_ALLOCATED"}, \
72 {MSU_NUM_STATES, "NUM_STATES"}, \
73 {MSU_EXEC_TIME, "EXEC_TIME"}, \
74 {MSU_IDLE_TIME, "IDLE_TIME"}, \
75 {MSU_ERROR_CNT, "ERROR_COUNT"}, \
76 {MSU_UCPUTIME, "MSU_USER_TIME"}, \
77 {MSU_SCPUTIME, "MSU_KERNEL_TIME"}, \
78 {MSU_MINFLT, "MSU_MINOR_FAULTS"}, \
79 {MSU_MAJFLT, "MSU_MAJOR_FAULTS"}, \
80 {MSU_VCSW, "MSU_VOL_CTX_SW"}, \
81 {MSU_IVCSW, "MSU_INVOL_CTX_SW"}
84 #ifndef REPORTED_THREAD_STAT_TYPES
85 #define REPORTED_THREAD_STAT_TYPES \
86 {THREAD_UCPUTIME, "USER_TIME"}, \
87 {THREAD_SCPUTIME, "KERNAL_TIME"}, \
88 {THREAD_MAXRSS, "MAX_RSS"}, \
89 {THREAD_MINFLT, "MINOR_FAULTS"}, \
90 {THREAD_MAJFLT, "MAJOR_FAULTS"}, \
91 {THREAD_VCSW, "VOL_CTX_SW"}, \
92 {THREAD_IVCSW, "INVOL_CTX_SW"}
95 #ifndef REPORTED_STAT_TYPES
96 #define REPORTED_STAT_TYPES \
97 REPORTED_MSU_STAT_TYPES, \
98 REPORTED_THREAD_STAT_TYPES
109 #define N_REPORTED_STAT_TYPES sizeof(reported_stat_types) / sizeof(*reported_stat_types)
114 #define N_REPORTED_MSU_STAT_TYPES \
115 sizeof(reported_msu_stat_types) / sizeof(*reported_msu_stat_types)
120 #define N_REPORTED_THREAD_STAT_TYPES \
121 sizeof(reported_thread_stat_types) / sizeof(*reported_thread_stat_types)
126 #define MAX_STAT_ITEM_ID 4192
129 #define STAT_SAMPLE_SIZE 5
132 #define STAT_SAMPLE_PERIOD_MS 500
163 void *buffer,
size_t buff_len);
int max_stats
The allocated size of the stat_sample::stats structure.
Macro for declaring functions or variables as unused to avoid compiler warnings.
struct timed_stat * stats
The statistics in question.
A single stat sample for a single item.
int deserialize_stat_samples(void *buffer, size_t buff_len, struct stat_sample *samples, int n_samples)
Deserializes from the provided buffer into the samples structure.
static struct stat_type_label reported_msu_stat_types[]
stat_id
The identifiers with which stats can be logged.
int is_thread_stat(enum stat_id id)
static struct stat_type_label reported_stat_types[]
Static structure so the reported stat types can be referenced as an array.
int is_msu_stat(enum stat_id id)
#define REPORTED_STAT_TYPES
int n_stats
The size of the sample (number of stats, not number of items)
enum stat_id stat_id
The ID of the statistic being sampled.
ssize_t serialize_stat_samples(struct stat_sample *samples, int n_samples, void *buffer, size_t buff_len)
Serializes from the provided samples into the buffer
size_t serialized_stat_sample_size(struct stat_sample *sample, int n_samples)
Determines the size needed to hold the serialized version of sample.
unsigned int item_id
The ID for the item being sampled.
Header for a single stat sample for a single item.
#define REPORTED_THREAD_STAT_TYPES
Declares the identifiers with which stats can be logged.
static struct stat_type_label reported_thread_stat_types[]
struct stat_sample * init_stat_samples(int max_stats, int n_samples)
Initilizes n sets of samples of statistics, each of which contains max_stats points.
void free_stat_samples(struct stat_sample *samples, int n_samples)
Frees a set of stat samples.
Holds a single timestamped value.
Structure to hold both the stat ID and the string describing it.
struct stat_sample_hdr hdr
#define REPORTED_MSU_STAT_TYPES