diff options
author | Costa Tsaousis <costa@netdata.cloud> | 2024-01-23 20:20:41 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-23 20:20:41 +0200 |
commit | f466b8aef52c1ea394651f5fe6b4586a5e39e5af (patch) | |
tree | 96130302033cc5df6b2a5683931138c72e4ab88e /collectors | |
parent | 33412db1f50d833e56889ea4762725dfde5d6d8f (diff) |
DYNCFG: dynamically configured alerts (#16779)
* cleanup alerts
* fix references
* fix references
* fix references
* load alerts once and apply them to each node
* simplify health_create_alarm_entry()
* Compile without warnings with compiler flags:
-Wall -Wextra -Wformat=2 -Wshadow -Wno-format-nonliteral -Winit-self
* code re-organization and cleanup
* generate patterns when applying prototypes; give unique dyncfg names to all alerts
* eval expressions keep the source and the parsed_as as STRING pointers
* renamed host to node in dyncfg ids
* renamed host to node in dyncfg ids
* add all cloud roles to the list of parsed X-Netdata-Role header and also default to member access level
* working functionality
* code re-organization: moved health event-loop to a new file, moved health globals to health.c
* rrdcalctemplate is removed; alert_cfg is removed; foreach dimension is removed; RRDCALCs are now instanciated only when they are linked to RRDSETs
* dyncfg alert prototypes initialization for alerts
* health dyncfg split to separate file
* cleanup not-needed code
* normalize matches between parsing and json
* also detect !* for disabled alerts
* dyncfg capability disabled
* Store alert config part1
* Add rrdlabels_common_count
* wip health variables lookup without indexes
* Improve rrdlabels_common_count by reusing rrdlabels_find_label_with_key_unsafe with an additional parameter
* working variables with runtime lookup
* working variables with runtime lookup
* delete rrddimvar and rrdfamily index
* remove rrdsetvar; now all variables are in RRDVARs inside hosts and charts
* added /api/v1/variable that resolves a variable the same way alerts do
* remove rrdcalc from eval
* remove debug code
* remove duplicate assignment
* Fix memory leak
* all alert variables are now handled by alert_variable_lookup() and EVAL is now independent of alerts
* hide all internal structures of EVAL
* Enable -Wformat flag
Signed-off-by: Tasos Katsoulas <tasos@netdata.cloud>
* Adjust binding for calculation, warning, critical
* Remove unused macro
* Update config hash id
* use the right info and summary in alerts log
* use synchronous queries for alerts
* Handle cases when config_hash_id is missing from health_log
* remove deadlock from health worker
* parsing to json payload for health alert prototypes
* cleaner parsing and avoiding memory leaks in case of duplicate members in json
* fix left-over rename of function
* Keep original lookup field to send to the cloud
Cleanup / rename function to store config
Remove unused DEFINEs, functions
* Use ac->lookup
* link jobs to the host when the template is registered; do not accept running a function without a host
* full dyncfg support for health alerts, except action TEST
* working dyncfg additions, updates, removals
* fixed missing source, wrong status updates
* add alerts by type, component, classification, recipient and module at the /api/v2/alerts endpoint
* fix dyncfg unittest
* rename functions
* generalize the json-c parser macros and move them to libnetdata
* report progress when enabling and disabling dyncfg templates
* moved rrdcalc and rrdvar to health
* update alarms
* added schema for alerts; separated alert_action_options from rrdr_options; restructured the json payload for alerts
* enable parsed json alerts; allow sending back accepted but disabled
* added format_version for alerts payload; enables/disables status now is also inheritted by the status of the rules; fixed variable names in json output
* remove the RRDHOST pointer from DYNCFG
* Fix command field submitted to the cloud
* do not send updates to creation requests, for DYNCFG jobs
---------
Signed-off-by: Tasos Katsoulas <tasos@netdata.cloud>
Co-authored-by: Stelios Fragkakis <52996999+stelfrag@users.noreply.github.com>
Co-authored-by: Tasos Katsoulas <tasos@netdata.cloud>
Co-authored-by: ilyam8 <ilya@netdata.cloud>
Diffstat (limited to 'collectors')
20 files changed, 147 insertions, 145 deletions
diff --git a/collectors/apps.plugin/apps_plugin.c b/collectors/apps.plugin/apps_plugin.c index 6caad8cb1b..a74c8fd958 100644 --- a/collectors/apps.plugin/apps_plugin.c +++ b/collectors/apps.plugin/apps_plugin.c @@ -1349,8 +1349,8 @@ void arl_callback_status_nonvoluntary_ctxt_switches(const char *name, uint32_t h pid_incremental_rate(stat, p->status_nonvoluntary_ctxt_switches, str2kernel_uint_t(procfile_lineword(aptr->ff, aptr->line, 1))); } -static void update_proc_state_count(char proc_state) { - switch (proc_state) { +static void update_proc_state_count(char proc_stt) { + switch (proc_stt) { case 'S': proc_state_count[PROC_STATUS_SLEEPING] += 1; break; diff --git a/collectors/cgroups.plugin/cgroup-charts.c b/collectors/cgroups.plugin/cgroup-charts.c index a89e8ac454..1a337cd994 100644 --- a/collectors/cgroups.plugin/cgroup-charts.c +++ b/collectors/cgroups.plugin/cgroup-charts.c @@ -96,7 +96,7 @@ void update_cpu_utilization_limit_chart(struct cgroup *cg, NETDATA_DOUBLE cpu_li cg->prev_cpu_usage = cpu_usage; - rrdsetvar_custom_chart_variable_set(cg->st_cpu, cg->chart_var_cpu_limit, cpu_limit); + rrdvar_chart_variable_set(cg->st_cpu, cg->chart_var_cpu_limit, cpu_limit); rrdset_done(chart); } diff --git a/collectors/cgroups.plugin/cgroup-internals.h b/collectors/cgroups.plugin/cgroup-internals.h index 5fc7ca5e6d..e1c1830b3e 100644 --- a/collectors/cgroups.plugin/cgroup-internals.h +++ b/collectors/cgroups.plugin/cgroup-internals.h @@ -287,16 +287,16 @@ struct cgroup { char *filename_cpu_cfs_quota; unsigned long long cpu_cfs_quota; - const RRDSETVAR_ACQUIRED *chart_var_cpu_limit; + const RRDVAR_ACQUIRED *chart_var_cpu_limit; NETDATA_DOUBLE prev_cpu_usage; char *filename_memory_limit; unsigned long long memory_limit; - const RRDSETVAR_ACQUIRED *chart_var_memory_limit; + const RRDVAR_ACQUIRED *chart_var_memory_limit; char *filename_memoryswap_limit; unsigned long long memoryswap_limit; - const RRDSETVAR_ACQUIRED *chart_var_memoryswap_limit; + const RRDVAR_ACQUIRED *chart_var_memoryswap_limit; const DICTIONARY_ITEM *cgroup_netdev_link; diff --git a/collectors/cgroups.plugin/sys_fs_cgroup.c b/collectors/cgroups.plugin/sys_fs_cgroup.c index 7f686f8f97..4362bf9915 100644 --- a/collectors/cgroups.plugin/sys_fs_cgroup.c +++ b/collectors/cgroups.plugin/sys_fs_cgroup.c @@ -1282,12 +1282,12 @@ cpu_limits2_err: static inline int update_memory_limits(struct cgroup *cg) { char **filename = &cg->filename_memory_limit; - const RRDSETVAR_ACQUIRED **chart_var = &cg->chart_var_memory_limit; + const RRDVAR_ACQUIRED **chart_var = &cg->chart_var_memory_limit; unsigned long long *value = &cg->memory_limit; if(*filename) { if(unlikely(!*chart_var)) { - *chart_var = rrdsetvar_custom_chart_variable_add_and_acquire(cg->st_mem_usage, "memory_limit"); + *chart_var = rrdvar_chart_variable_add_and_acquire(cg->st_mem_usage, "memory_limit"); if(!*chart_var) { collector_error("Cannot create cgroup %s chart variable '%s'. Will not update its limit anymore.", cg->id, "memory_limit"); freez(*filename); @@ -1303,7 +1303,8 @@ static inline int update_memory_limits(struct cgroup *cg) { *filename = NULL; } else { - rrdsetvar_custom_chart_variable_set(cg->st_mem_usage, *chart_var, (NETDATA_DOUBLE)(*value) / (1024.0 * 1024.0)); + rrdvar_chart_variable_set( + cg->st_mem_usage, *chart_var, (NETDATA_DOUBLE)(*value) / (1024.0 * 1024.0)); return 1; } } else { @@ -1318,11 +1319,12 @@ static inline int update_memory_limits(struct cgroup *cg) { char *s = "max\n\0"; if(strcmp(s, buffer) == 0){ *value = UINT64_MAX; - rrdsetvar_custom_chart_variable_set(cg->st_mem_usage, *chart_var, (NETDATA_DOUBLE)(*value) / (1024.0 * 1024.0)); + rrdvar_chart_variable_set( + cg->st_mem_usage, *chart_var, (NETDATA_DOUBLE)(*value) / (1024.0 * 1024.0)); return 1; } *value = str2ull(buffer, NULL); - rrdsetvar_custom_chart_variable_set(cg->st_mem_usage, *chart_var, (NETDATA_DOUBLE)(*value) / (1024.0 * 1024.0)); + rrdvar_chart_variable_set(cg->st_mem_usage, *chart_var, (NETDATA_DOUBLE)(*value) / (1024.0 * 1024.0)); return 1; } } @@ -1400,7 +1402,7 @@ void update_cgroup_charts() { } if(unlikely(!cg->chart_var_cpu_limit)) { - cg->chart_var_cpu_limit = rrdsetvar_custom_chart_variable_add_and_acquire(cg->st_cpu, "cpu_limit"); + cg->chart_var_cpu_limit = rrdvar_chart_variable_add_and_acquire(cg->st_cpu, "cpu_limit"); if(!cg->chart_var_cpu_limit) { collector_error("Cannot create cgroup %s chart variable 'cpu_limit'. Will not update its limit anymore.", cg->id); if(cg->filename_cpuset_cpus) freez(cg->filename_cpuset_cpus); @@ -1430,7 +1432,7 @@ void update_cgroup_charts() { rrdset_is_obsolete___safe_from_collector_thread(cg->st_cpu_limit); cg->st_cpu_limit = NULL; } - rrdsetvar_custom_chart_variable_set(cg->st_cpu, cg->chart_var_cpu_limit, NAN); + rrdvar_chart_variable_set(cg->st_cpu, cg->chart_var_cpu_limit, NAN); } } } diff --git a/collectors/cgroups.plugin/tests/test_doubles.c b/collectors/cgroups.plugin/tests/test_doubles.c index b13d4b19ce..53fefa9c24 100644 --- a/collectors/cgroups.plugin/tests/test_doubles.c +++ b/collectors/cgroups.plugin/tests/test_doubles.c @@ -101,7 +101,7 @@ collected_number rrddim_set_by_pointer(RRDSET *st, RRDDIM *rd, collected_number return 0; } -const RRDSETVAR_ACQUIRED *rrdsetvar_custom_chart_variable_add_and_acquire(RRDSET *st, const char *name) +const RRDVAR_ACQUIRED *rrdvar_chart_variable_add_and_acquire(RRDSET *st, const char *name) { UNUSED(st); UNUSED(name); @@ -109,7 +109,7 @@ const RRDSETVAR_ACQUIRED *rrdsetvar_custom_chart_variable_add_and_acquire(RRDSET return NULL; } -void rrdsetvar_custom_chart_variable_set(RRDSET *st, const RRDSETVAR_ACQUIRED *rsa, NETDATA_DOUBLE value) +void rrdvar_chart_variable_set(RRDSET *st, const RRDVAR_ACQUIRED *rsa, NETDATA_DOUBLE value) { UNUSED(st); UNUSED(rsa); diff --git a/collectors/freeipmi.plugin/freeipmi_plugin.c b/collectors/freeipmi.plugin/freeipmi_plugin.c index 8537c93c73..9cc6a456d4 100644 --- a/collectors/freeipmi.plugin/freeipmi_plugin.c +++ b/collectors/freeipmi.plugin/freeipmi_plugin.c @@ -66,9 +66,8 @@ static void netdata_update_ipmi_sensor_reading( , int sensor_bitmask_type , int sensor_bitmask , char **sensor_bitmask_strings - , struct netdata_ipmi_state *state -); -static void netdata_update_ipmi_sel_events_count(struct netdata_ipmi_state *state, uint32_t events); + , struct netdata_ipmi_state *stt); +static void netdata_update_ipmi_sel_events_count(struct netdata_ipmi_state *stt, uint32_t events); // END NETDATA CODE // ---------------------------------------------------------------------------- @@ -906,7 +905,7 @@ const char *netdata_collect_type_to_string(IPMI_COLLECTION_TYPE type) { return "unknown"; } -static void netdata_sensor_set_value(struct sensor *sn, void *sensor_reading, struct netdata_ipmi_state *state __maybe_unused) { +static void netdata_sensor_set_value(struct sensor *sn, void *sensor_reading, struct netdata_ipmi_state *stt __maybe_unused) { switch(sn->sensor_reading_type) { case IPMI_MONITORING_SENSOR_READING_TYPE_UNSIGNED_INTEGER8_BOOL: sn->sensor_reading.bool_value = *((uint8_t *)sensor_reading); @@ -940,8 +939,7 @@ static void netdata_update_ipmi_sensor_reading( , int sensor_bitmask_type __maybe_unused , int sensor_bitmask __maybe_unused , char **sensor_bitmask_strings __maybe_unused - , struct netdata_ipmi_state *state -) { + , struct netdata_ipmi_state *stt) { if(unlikely(sensor_state == IPMI_MONITORING_STATE_UNKNOWN && sensor_type == IPMI_MONITORING_SENSOR_TYPE_UNKNOWN && sensor_units == IPMI_MONITORING_SENSOR_UNITS_UNKNOWN && @@ -953,38 +951,38 @@ static void netdata_update_ipmi_sensor_reading( if(unlikely(!sensor_name || !*sensor_name)) sensor_name = "UNNAMED"; - state->sensors.collected++; + stt->sensors.collected++; char key[SENSORS_DICT_KEY_SIZE + 1]; snprintfz(key, SENSORS_DICT_KEY_SIZE, "i%d_n%d_t%d_u%d_%s", record_id, sensor_number, sensor_reading_type, sensor_units, sensor_name); // find the sensor record - const DICTIONARY_ITEM *item = dictionary_get_and_acquire_item(state->sensors.dict, key); + const DICTIONARY_ITEM *item = dictionary_get_and_acquire_item(stt->sensors.dict, key); if(likely(item)) { // recurring collection - if(state->debug) + if(stt->debug) fprintf(stderr, "%s: reusing sensor record for sensor '%s', id %d, number %d, type %d, state %d, units %d, reading_type %d\n", program_name, sensor_name, record_id, sensor_number, sensor_type, sensor_state, sensor_units, sensor_reading_type); struct sensor *sn = dictionary_acquired_item_value(item); if(sensor_reading) { - netdata_sensor_set_value(sn, sensor_reading, state); - sn->last_collected_metric_ut = state->sensors.now_ut; + netdata_sensor_set_value(sn, sensor_reading, stt); + sn->last_collected_metric_ut = stt->sensors.now_ut; } sn->sensor_state = sensor_state; - sn->last_collected_state_ut = state->sensors.now_ut; + sn->last_collected_state_ut = stt->sensors.now_ut; - dictionary_acquired_item_release(state->sensors.dict, item); + dictionary_acquired_item_release(stt->sensors.dict, item); return; } - if(state->debug) + if(stt->debug) fprintf(stderr, "Allocating new sensor data record for sensor '%s', id %d, number %d, type %d, state %d, units %d, reading_type %d\n", sensor_name, record_id, sensor_number, sensor_type, sensor_state, sensor_units, sensor_reading_type); @@ -993,12 +991,12 @@ static void netdata_update_ipmi_sensor_reading( bool excluded_state = excluded_status_record_ids_check(record_id); if(excluded_metric) { - if(state->debug) + if(stt->debug) fprintf(stderr, "Sensor '%s' is excluded by excluded_record_ids_check()\n", sensor_name); } if(excluded_state) { - if(state->debug) + if(stt->debug) fprintf(stderr, "Sensor '%s' is excluded for status check, by excluded_status_record_ids_check()\n", sensor_name); } @@ -1023,7 +1021,7 @@ static void netdata_update_ipmi_sensor_reading( t.units = "Celsius"; t.family = "temperatures"; t.chart_type = "line"; - t.priority = state->sensors.priority + 10; + t.priority = stt->sensors.priority + 10; break; case IPMI_MONITORING_SENSOR_UNITS_FAHRENHEIT: @@ -1033,7 +1031,7 @@ static void netdata_update_ipmi_sensor_reading( t.units = "Fahrenheit"; t.family = "temperatures"; t.chart_type = "line"; - t.priority = state->sensors.priority + 20; + t.priority = stt->sensors.priority + 20; break; case IPMI_MONITORING_SENSOR_UNITS_VOLTS: @@ -1043,7 +1041,7 @@ static void netdata_update_ipmi_sensor_reading( t.units = "Volts"; t.family = "voltages"; t.chart_type = "line"; - t.priority = state->sensors.priority + 30; + t.priority = stt->sensors.priority + 30; break; case IPMI_MONITORING_SENSOR_UNITS_AMPS: @@ -1053,7 +1051,7 @@ static void netdata_update_ipmi_sensor_reading( t.units = "Amps"; t.family = "current"; t.chart_type = "line"; - t.priority = state->sensors.priority + 40; + t.priority = stt->sensors.priority + 40; break; case IPMI_MONITORING_SENSOR_UNITS_RPM: @@ -1063,7 +1061,7 @@ static void netdata_update_ipmi_sensor_reading( t.units = "RPM"; t.family = "fans"; t.chart_type = "line"; - t.priority = state->sensors.priority + 50; + t.priority = stt->sensors.priority + 50; break; case IPMI_MONITORING_SENSOR_UNITS_WATTS: @@ -1073,7 +1071,7 @@ static void netdata_update_ipmi_sensor_reading( t.units = "Watts"; t.family = "power"; t.chart_type = "line"; - t.priority = state->sensors.priority + 60; + t.priority = stt->sensors.priority + 60; break; case IPMI_MONITORING_SENSOR_UNITS_PERCENT: @@ -1083,11 +1081,11 @@ static void netdata_update_ipmi_sensor_reading( t.units = "%%"; t.family = "other"; t.chart_type = "line"; - t.priority = state->sensors.priority + 70; + t.priority = stt->sensors.priority + 70; break; default: - t.priority = state->sensors.priority + 80; + t.priority = stt->sensors.priority + 80; t.do_metric = false; break; } @@ -1108,57 +1106,57 @@ static void netdata_update_ipmi_sensor_reading( } if(sensor_reading) { - netdata_sensor_set_value(&t, sensor_reading, state); - t.last_collected_metric_ut = state->sensors.now_ut; + netdata_sensor_set_value(&t, sensor_reading, stt); + t.last_collected_metric_ut = stt->sensors.now_ut; } - t.last_collected_state_ut = state->sensors.now_ut; + t.last_collected_state_ut = stt->sensors.now_ut; - dictionary_set(state->sensors.dict, key, &t, sizeof(t)); + dictionary_set(stt->sensors.dict, key, &t, sizeof(t)); } -static void netdata_update_ipmi_sel_events_count(struct netdata_ipmi_state *state, uint32_t events) { - state->sel.events = events; +static void netdata_update_ipmi_sel_events_count(struct netdata_ipmi_state *stt, uint32_t events) { + stt->sel.events = events; } -int netdata_ipmi_collect_data(struct ipmi_monitoring_ipmi_config *ipmi_config, IPMI_COLLECTION_TYPE type, struct netdata_ipmi_state *state) { +int netdata_ipmi_collect_data(struct ipmi_monitoring_ipmi_config *ipmi_config, IPMI_COLLECTION_TYPE type, struct netdata_ipmi_state *stt) { errno = 0; if(type & IPMI_COLLECT_TYPE_SENSORS) { - state->sensors.collected = 0; - state->sensors.now_ut = now_monotonic_usec(); + stt->sensors.collected = 0; + stt->sensors.now_ut = now_monotonic_usec(); - if (netdata_read_ipmi_sensors(ipmi_config, state) < 0) return -1; + if (netdata_read_ipmi_sensors(ipmi_config, stt) < 0) return -1; } if(type & IPMI_COLLECT_TYPE_SEL) { - state->sel.events = 0; - state->sel.now_ut = now_monotonic_usec(); - if(netdata_get_ipmi_sel_events_count(ipmi_config, state) < 0) return -2; + stt->sel.events = 0; + stt->sel.now_ut = now_monotonic_usec(); + if(netdata_get_ipmi_sel_events_count(ipmi_config, stt) < 0) return -2; } return 0; } -int netdata_ipmi_detect_speed_secs(struct ipmi_monitoring_ipmi_config *ipmi_config, IPMI_COLLECTION_TYPE type, struct netdata_ipmi_state *state) { +int netdata_ipmi_detect_speed_secs(struct ipmi_monitoring_ipmi_config *ipmi_config, IPMI_COLLECTION_TYPE type, struct netdata_ipmi_state *stt) { int i, checks = SPEED_TEST_ITERATIONS, successful = 0; usec_t total = 0; for(i = 0 ; i < checks ; i++) { - if(unlikely(state->debug)) + if(unlikely(stt->debug)) fprintf(stderr, "%s: checking %s data collection speed iteration %d of %d\n", program_name, netdata_collect_type_to_string(type), i + 1, checks); // measure the time a data collection needs usec_t start = now_realtime_usec(); - if(netdata_ipmi_collect_data(ipmi_config, type, state) < 0) + if(netdata_ipmi_collect_data(ipmi_config, type, stt) < 0) continue; usec_t end = now_realtime_usec(); successful++; - if(unlikely(state->debug)) + if(unlikely(stt->debug)) fprintf(stderr, "%s: %s data collection speed was %"PRIu64" usec\n", program_name, netdata_collect_type_to_string(type), end - start); @@ -1298,31 +1296,32 @@ static inline bool is_sensor_updated(usec_t last_collected_ut, usec_t now_ut, us return (now_ut - last_collected_ut < freq * 2) ? true : false; } -static size_t send_ipmi_sensor_metrics_to_netdata(struct netdata_ipmi_state *state) { - if(state->sensors.status != ICS_RUNNING) { - if(unlikely(state->debug)) +static size_t send_ipmi_sensor_metrics_to_netdata(struct netdata_ipmi_state *stt) { + if(stt->sensors.status != ICS_RUNNING) { + if(unlikely(stt->debug)) fprintf(stderr, "%s: %s() sensors state is not RUNNING\n", program_name, __FUNCTION__ ); return 0; } size_t total_sensors_sent = 0; - int update_every = (int)(state->sensors.freq_ut / USEC_PER_SEC); + int update_every_s = (int)(stt->sensors.freq_ut / USEC_PER_SEC); struct sensor *sn; netdata_mutex_lock(&stdout_mutex); // generate the CHART/DIMENSION lines, if we have to - dfe_start_reentrant(state->sensors.dict, sn) { + dfe_start_reentrant(stt->sensors.dict, sn) { if(unlikely(!sn->do_metric && !sn->do_state)) continue; bool did_metric = false, did_state = false; if(likely(sn->do_metric)) { - if(unlikely(!is_sensor_updated(sn->last_collected_metric_ut, state->updates.now_ut, state->sensors.freq_ut))) { - if(unlikely(state->debug)) + if(unlikely(!is_sensor_updated(sn->last_collected_metric_ut, stt->updates.now_ut, stt->sensors.freq_ut))) { + if(unlikely(stt->debug)) fprintf(stderr, "%s: %s() sensor '%s' metric is not UPDATED (last updated %"PRIu64", now %"PRIu64", freq %"PRIu64"\n", - program_name, __FUNCTION__, sn->sensor_name, sn->last_collected_metric_ut, state->updates.now_ut, state->sensors.freq_ut); + program_name, __FUNCTION__, sn->sensor_name, sn->last_collected_metric_ut, + stt->updates.now_ut, stt->sensors.freq_ut); } else { if (unlikely(!sn->metric_chart_sent)) { @@ -1330,7 +1329,8 @@ static size_t send_ipmi_sensor_metrics_to_netdata(struct netdata_ipmi_state *sta printf("CHART '%s_%s' '' '%s' '%s' '%s' '%s' '%s' %d %d '' '%s' '%s'\n", sn->context, sn_dfe.name, sn->title, sn->units, sn->family, sn->context, - sn->chart_type, sn->priority + 1, update_every, program_name, "sensors"); + sn->chart_type, sn->priority + 1, + update_every_s, program_name, "sensors"); printf("CLABEL 'sensor' '%s' 1\n", sn->sensor_name); printf("CLABEL 'type' '%s' 1\n", sn->type); @@ -1344,19 +1344,16 @@ static size_t send_ipmi_sensor_metrics_to_netdata(struct netdata_ipmi_state *sta switch (sn->sensor_reading_type) { case IPMI_MONITORING_SENSOR_READING_TYPE_UNSIGNED_INTEGER32: - printf("SET '%s' = %u\n", sn->dimension, sn->sensor_reading.uint32_value - ); + printf("SET '%s' = %u\n", sn->dimension, sn->sensor_reading.uint32_value); break; case IPMI_MONITORING_SENSOR_READING_TYPE_DOUBLE: printf("SET '%s' = %lld\n", sn->dimension, - (long long int) (sn->sensor_reading.double_value * sn->multiplier) - ); + (long long int) (sn->sensor_reading.double_value * sn->multiplier)); break; case IPMI_MONITORING_SENSOR_READING_TYPE_UNSIGNED_INTEGER8_BOOL: - printf("SET '%s' = %u\n", sn->dimension, sn->sensor_reading.bool_value - ); + printf("SET '%s' = %u\n", sn->dimension, sn->sensor_reading.bool_value); break; default: @@ -1372,17 +1369,18 @@ static size_t send_ipmi_sensor_metrics_to_netdata(struct netdata_ipmi_state *sta } if(likely(sn->do_state)) { - if(unlikely(!is_sensor_updated(sn->last_collected_state_ut, state->updates.now_ut, state->sensors.freq_ut))) { - if (unlikely(state->debug)) + if(unlikely(!is_sensor_updated(sn->last_collected_state_ut, stt->updates.now_ut, stt->sensors.freq_ut))) { + if (unlikely(stt->debug)) fprintf(stderr, "%s: %s() sensor '%s' state is not UPDATED (last updated %"PRIu64", now %"PRIu64", freq %"PRIu64"\n", - program_name, __FUNCTION__, sn->sensor_name, sn->last_collected_state_ut, state->updates.now_ut, state->sensors.freq_ut); + program_name, __FUNCTION__, sn->sensor_name, sn->last_collected_state_ut, + stt->updates.now_ut, stt->sensors.freq_ut); } else { if (unlikely(!sn->state_chart_sent)) { sn->state_chart_sent = true; printf("CHART 'ipmi.sensor_state_%s' '' 'IPMI Sensor State' 'state' 'states' 'ipmi.sensor_state' 'line' %d %d '' '%s' '%s'\n", - sn_dfe.name, sn->priority, update_every, program_name, "sensors"); + sn_dfe.name, sn->priority, update_every_s, program_name, "sensors"); printf("CLABEL 'sensor' '%s' 1\n", sn->sensor_name); printf("CLABEL 'type' '%s' 1\n", sn->type); @@ -1415,17 +1413,17 @@ static size_t send_ipmi_sensor_metrics_to_netdata(struct netdata_ipmi_state *sta return total_sensors_sent; } -static size_t send_ipmi_sel_metrics_to_netdata(struct netdata_ipmi_state *state) { +static size_t send_ipmi_sel_metrics_to_netdata(struct netdata_ipmi_state *stt) { static bool sel_chart_generated = false; netdata_mutex_lock(&stdout_mutex); - if(likely(state->sel.status == ICS_RUNNING)) { + if(likely(stt->sel.status == ICS_RUNNING)) { if(unlikely(!sel_chart_generated)) { sel_chart_generated = true; printf("CHART ipmi.events '' 'IPMI Events' 'events' 'events' ipmi.sel area %d %d '' '%s' '%s'\n" - , state->sel.priority + 2 - , (int)(state->sel.freq_ut / USEC_PER_SEC) + , stt->sel.priority + 2 + , (int)(stt->sel.freq_ut / USEC_PER_SEC) , program_name , "sel" ); @@ -1436,13 +1434,14 @@ static size_t send_ipmi_sel_metrics_to_netdata(struct netdata_ipmi_state *state) "BEGIN ipmi.events\n" "SET events = %zu\n" "END\n" - , state->sel.events + , + stt->sel.events ); } netdata_mutex_unlock(&stdout_mutex); - return state->sel.events; + return stt->sel.events; } // ---------------------------------------------------------------------------- @@ -1618,7 +1617,7 @@ static void freeimi_function_sensors(const char *transaction, char *function __m // ---------------------------------------------------------------------------- // main, command line arguments parsing -static void plugin_exit(int code) { +static NORETURN void plugin_exit(int code) { fflush(stdout); function_plugin_should_exit = true; exit(code); diff --git a/collectors/plugins.d/README.md b/collectors/plugins.d/README.md index a62ed4c5a1..6faf102865 100644 --- a/collectors/plugins.d/README.md +++ b/collectors/plugins.d/README.md @@ -693,7 +693,8 @@ When responding to additions and updates, Netdata uses the following success res - `200`, responding with 200, means the configuration has been accepted and it is running. - `202`, responding with 202, means the configuration has been accepted but it is not yet running. A subsequent `status` action will update it. -- `299`, responding with 299, means the configuration has been accepted but a restart is required to apply it. +- `298`, responding with 298, means the configuration has been accepted but it is disabled for some reason (probably because it matches nothing or the contents are not useful - use the `message` to provide additional information). +- `299`, responding with 299, means the configuration has been accepted but a restart is required to apply it. ## Data collection diff --git a/collectors/plugins.d/pluginsd_ |