// SPDX-License-Identifier: GPL-3.0-or-later
#include "health.h"
unsigned int default_health_enabled = 1;
char *silencers_filename;
// the queue of executed alarm notifications that haven't been waited for yet
static struct {
ALARM_ENTRY *head; // oldest
ALARM_ENTRY *tail; // latest
} alarm_notifications_in_progress = {NULL, NULL};
static inline void enqueue_alarm_notify_in_progress(ALARM_ENTRY *ae)
{
ae->prev_in_progress = NULL;
ae->next_in_progress = NULL;
if (NULL != alarm_notifications_in_progress.tail) {
ae->prev_in_progress = alarm_notifications_in_progress.tail;
alarm_notifications_in_progress.tail->next_in_progress = ae;
}
if (NULL == alarm_notifications_in_progress.head) {
alarm_notifications_in_progress.head = ae;
}
alarm_notifications_in_progress.tail = ae;
}
static inline void unlink_alarm_notify_in_progress(ALARM_ENTRY *ae)
{
struct alarm_entry *prev = ae->prev_in_progress;
struct alarm_entry *next = ae->next_in_progress;
if (NULL != prev) {
prev->next_in_progress = next;
}
if (NULL != next) {
next->prev_in_progress = prev;
}
if (ae == alarm_notifications_in_progress.head) {
alarm_notifications_in_progress.head = next;
}
if (ae == alarm_notifications_in_progress.tail) {
alarm_notifications_in_progress.tail = prev;
}
}
// ----------------------------------------------------------------------------
// health initialization
/**
* User Config directory
*
* Get the config directory for health and return it.
*
* @return a pointer to the user config directory
*/
inline char *health_user_config_dir(void) {
char buffer[FILENAME_MAX + 1];
snprintfz(buffer, FILENAME_MAX, "%s/health.d", netdata_configured_user_config_dir);
return config_get(CONFIG_SECTION_DIRECTORIES, "health config", buffer);
}
/**
* Stock Config Directory
*
* Get the Stock config directory and return it.
*
* @return a pointer to the stock config directory.
*/
inline char *health_stock_config_dir(void) {
char buffer[FILENAME_MAX + 1];
snprintfz(buffer, FILENAME_MAX, "%s/health.d", netdata_configured_stock_config_dir);
return config_get(CONFIG_SECTION_DIRECTORIES, "stock health config", buffer);
}
/**
* Silencers init
*
* Function used to initialize the silencer structure.
*/
static void health_silencers_init(