- char logfile[PATH_MAX]; /* mcelog logfile */
- pthread_t tid; /* poll thread id */
- llist_t *dimms_list; /* DIMMs list */
- /* lock for dimms cache */
- _Bool persist;
- pthread_mutex_t dimms_lock;
+ char logfile[PATH_MAX]; /* mcelog logfile */
+ pthread_t tid; /* poll thread id */
+ llist_t *dimms_list; /* DIMMs list */
+ pthread_mutex_t dimms_lock; /* lock for dimms cache */
+ bool persist;
typedef struct mcelog_memory_rec_s {
int corrected_err_total; /* x total*/
int corrected_err_timed; /* x in 24h*/
typedef struct mcelog_memory_rec_s {
int corrected_err_total; /* x total*/
int corrected_err_timed; /* x in 24h*/
- char uncorrected_err_timed_period[DATA_MAX_NAME_LEN];
- char location[DATA_MAX_NAME_LEN]; /* SOCKET x CHANNEL x DIMM x*/
- char dimm_name[DATA_MAX_NAME_LEN]; /* DMI_NAME "DIMM_F1" */
+ char uncorrected_err_timed_period[DATA_MAX_NAME_LEN / 2];
+ char location[DATA_MAX_NAME_LEN / 2]; /* SOCKET x CHANNEL x DIMM x*/
+ char dimm_name[DATA_MAX_NAME_LEN / 2]; /* DMI_NAME "DIMM_F1" */
static int socket_receive(socket_adapter_t *self, FILE **p_file);
static mcelog_config_t g_mcelog_config = {
static int socket_receive(socket_adapter_t *self, FILE **p_file);
static mcelog_config_t g_mcelog_config = {
- ssnprintf(dimm_name, sizeof(dimm_name), "%s_%s", rec->location,
- rec->dimm_name);
+ snprintf(dimm_name, sizeof(dimm_name), "%s_%s", rec->location,
+ rec->dimm_name);
} else
sstrncpy(dimm_name, rec->location, sizeof(dimm_name));
llentry_t *dimm_le = llist_search(g_mcelog_config.dimms_list, dimm_name);
} else
sstrncpy(dimm_name, rec->location, sizeof(dimm_name));
llentry_t *dimm_le = llist_search(g_mcelog_config.dimms_list, dimm_name);
- if (dimm_le == NULL) {
- mcelog_memory_rec_t *dimm_mr = calloc(1, sizeof(*dimm_mr));
- if (dimm_mr == NULL) {
- ERROR(MCELOG_PLUGIN ": Error allocating dimm memory item");
- return NULL;
- }
- char *p_name = strdup(dimm_name);
- if (p_name == NULL) {
- ERROR(MCELOG_PLUGIN ": strdup: error");
- free(dimm_mr);
- return NULL;
- }
+ if (dimm_le != NULL)
+ return dimm_le;
- /* add new dimm */
- dimm_le = llentry_create(p_name, dimm_mr);
- if (dimm_le == NULL) {
- ERROR(MCELOG_PLUGIN ": llentry_create(): error");
- free(dimm_mr);
- free(p_name);
- return NULL;
- }
- pthread_mutex_lock(&g_mcelog_config.dimms_lock);
- llist_append(g_mcelog_config.dimms_list, dimm_le);
- pthread_mutex_unlock(&g_mcelog_config.dimms_lock);
+ /* allocate new linked list entry */
+ mcelog_memory_rec_t *dimm_mr = calloc(1, sizeof(*dimm_mr));
+ if (dimm_mr == NULL) {
+ ERROR(MCELOG_PLUGIN ": Error allocating dimm memory item");
+ return NULL;
+ }
+ char *p_name = strdup(dimm_name);
+ if (p_name == NULL) {
+ ERROR(MCELOG_PLUGIN ": strdup: error");
+ free(dimm_mr);
+ return NULL;
+ /* add new dimm */
+ dimm_le = llentry_create(p_name, dimm_mr);
+ if (dimm_le == NULL) {
+ ERROR(MCELOG_PLUGIN ": llentry_create(): error");
+ free(dimm_mr);
+ free(p_name);
+ return NULL;
+ }
+ pthread_mutex_lock(&g_mcelog_config.dimms_lock);
+ llist_append(g_mcelog_config.dimms_list, dimm_le);
+ pthread_mutex_unlock(&g_mcelog_config.dimms_lock);
+
ERROR(MCELOG_PLUGIN ": Invalid configuration option: \"%s\", Logfile "
"option is already configured.",
child->key);
ERROR(MCELOG_PLUGIN ": Invalid configuration option: \"%s\", Logfile "
"option is already configured.",
child->key);
if (strcasecmp("McelogClientSocket", mem_child->key) == 0) {
if (cf_util_get_string_buffer(
mem_child, socket_adapter.unix_sock.sun_path,
sizeof(socket_adapter.unix_sock.sun_path)) < 0) {
ERROR(MCELOG_PLUGIN ": Invalid configuration option: \"%s\".",
mem_child->key);
if (strcasecmp("McelogClientSocket", mem_child->key) == 0) {
if (cf_util_get_string_buffer(
mem_child, socket_adapter.unix_sock.sun_path,
sizeof(socket_adapter.unix_sock.sun_path)) < 0) {
ERROR(MCELOG_PLUGIN ": Invalid configuration option: \"%s\".",
mem_child->key);
}
} else if (strcasecmp("PersistentNotification", mem_child->key) == 0) {
if (cf_util_get_boolean(mem_child, &g_mcelog_config.persist) < 0) {
ERROR(MCELOG_PLUGIN ": Invalid configuration option: \"%s\".",
mem_child->key);
}
} else if (strcasecmp("PersistentNotification", mem_child->key) == 0) {
if (cf_util_get_boolean(mem_child, &g_mcelog_config.persist) < 0) {
ERROR(MCELOG_PLUGIN ": Invalid configuration option: \"%s\".",
mem_child->key);
}
static int socket_close(socket_adapter_t *self) {
int ret = 0;
pthread_rwlock_rdlock(&self->lock);
if (fcntl(self->sock_fd, F_GETFL) != -1) {
}
static int socket_close(socket_adapter_t *self) {
int ret = 0;
pthread_rwlock_rdlock(&self->lock);
if (fcntl(self->sock_fd, F_GETFL) != -1) {
- ERROR(MCELOG_PLUGIN ": Socket shutdown failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR(MCELOG_PLUGIN ": Socket shutdown failed: %s", STRERRNO);
- ERROR(MCELOG_PLUGIN ": Socket close failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR(MCELOG_PLUGIN ": Socket close failed: %s", STRERRNO);
int ret = -1;
cdtime_t interval = plugin_get_interval();
struct timeval socket_timeout = CDTIME_T_TO_TIMEVAL(interval);
int ret = -1;
cdtime_t interval = plugin_get_interval();
struct timeval socket_timeout = CDTIME_T_TO_TIMEVAL(interval);
- ERROR(MCELOG_PLUGIN ": Could not create a socket. %s",
- sstrerror(errno, errbuff, sizeof(errbuff)));
+ ERROR(MCELOG_PLUGIN ": Could not create a socket. %s", STRERRNO);
pthread_rwlock_rdlock(&self->lock);
if (connect(self->sock_fd, (struct sockaddr *)&(self->unix_sock),
sizeof(self->unix_sock)) < 0) {
pthread_rwlock_rdlock(&self->lock);
if (connect(self->sock_fd, (struct sockaddr *)&(self->unix_sock),
sizeof(self->unix_sock)) < 0) {
- ERROR(MCELOG_PLUGIN ": Failed to connect to mcelog server. %s",
- sstrerror(errno, errbuff, sizeof(errbuff)));
+ ERROR(MCELOG_PLUGIN ": Failed to connect to mcelog server. %s", STRERRNO);
llentry_t *dimm = mcelog_dimm(mr, g_mcelog_config.dimms_list);
if (dimm == NULL) {
ERROR(MCELOG_PLUGIN
": Error adding/getting dimm memory item to/from cache");
llentry_t *dimm = mcelog_dimm(mr, g_mcelog_config.dimms_list);
if (dimm == NULL) {
ERROR(MCELOG_PLUGIN
": Error adding/getting dimm memory item to/from cache");
if (!dispatch_corrected_notifs && !dispatch_uncorrected_notifs) {
DEBUG("%s: No new notifications to dispatch", MCELOG_PLUGIN);
if (!dispatch_corrected_notifs && !dispatch_uncorrected_notifs) {
DEBUG("%s: No new notifications to dispatch", MCELOG_PLUGIN);
sstrncpy(n.host, hostname_g, sizeof(n.host));
if (mr->dimm_name[0] != '\0')
sstrncpy(n.host, hostname_g, sizeof(n.host));
if (mr->dimm_name[0] != '\0')
- ssnprintf(n.plugin_instance, sizeof(n.plugin_instance), "%s_%s",
- mr->location, mr->dimm_name);
+ snprintf(n.plugin_instance, sizeof(n.plugin_instance), "%s_%s",
+ mr->location, mr->dimm_name);
mr->corrected_err_total);
plugin_notification_meta_add_signed_int(&n, MCELOG_CORRECTED_ERR_TIMED,
mr->corrected_err_timed);
mr->corrected_err_total);
plugin_notification_meta_add_signed_int(&n, MCELOG_CORRECTED_ERR_TIMED,
mr->corrected_err_timed);
sstrncpy(n.type_instance, MCELOG_CORRECTED_ERR_TYPE_INS,
sizeof(n.type_instance));
plugin_dispatch_notification(&n);
sstrncpy(n.type_instance, MCELOG_CORRECTED_ERR_TYPE_INS,
sizeof(n.type_instance));
plugin_dispatch_notification(&n);
mr->uncorrected_err_total);
plugin_notification_meta_add_signed_int(&n, MCELOG_UNCORRECTED_ERR_TIMED,
mr->uncorrected_err_timed);
mr->uncorrected_err_total);
plugin_notification_meta_add_signed_int(&n, MCELOG_UNCORRECTED_ERR_TIMED,
mr->uncorrected_err_timed);
sstrncpy(n.type_instance, MCELOG_UNCORRECTED_ERR_TYPE_INS,
sizeof(n.type_instance));
n.severity = NOTIF_FAILURE;
sstrncpy(n.type_instance, MCELOG_UNCORRECTED_ERR_TYPE_INS,
sizeof(n.type_instance));
n.severity = NOTIF_FAILURE;
mcelog_update_dimm_stats(dimm, mr);
if (mr->dimm_name[0] != '\0')
mcelog_update_dimm_stats(dimm, mr);
if (mr->dimm_name[0] != '\0')
- ssnprintf(vl.plugin_instance, sizeof(vl.plugin_instance), "%s_%s",
- mr->location, mr->dimm_name);
+ snprintf(vl.plugin_instance, sizeof(vl.plugin_instance), "%s_%s",
+ mr->location, mr->dimm_name);
else
sstrncpy(vl.plugin_instance, mr->location, sizeof(vl.plugin_instance));
plugin_dispatch_values(&vl);
else
sstrncpy(vl.plugin_instance, mr->location, sizeof(vl.plugin_instance));
plugin_dispatch_values(&vl);
- ssnprintf(vl.type_instance, sizeof(vl.type_instance),
- "corrected_memory_errors_in_%s", mr->corrected_err_timed_period);
+ snprintf(vl.type_instance, sizeof(vl.type_instance),
+ "corrected_memory_errors_in_%s", mr->corrected_err_timed_period);
- ssnprintf(vl.type_instance, sizeof(vl.type_instance),
- "uncorrected_memory_errors_in_%s",
- mr->uncorrected_err_timed_period);
+ snprintf(vl.type_instance, sizeof(vl.type_instance),
+ "uncorrected_memory_errors_in_%s", mr->uncorrected_err_timed_period);
if ((res = poll(&poll_fd, 1, MCELOG_POLL_TIMEOUT)) <= 0) {
if (res != 0 && errno != EINTR) {
if ((res = poll(&poll_fd, 1, MCELOG_POLL_TIMEOUT)) <= 0) {
if (res != 0 && errno != EINTR) {
- char errbuf[MCELOG_BUFF_SIZE];
- ERROR("mcelog: poll failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("mcelog: poll failed: %s", STRERRNO);
mcelog_thread_running = 1;
FILE **pp_file = calloc(1, sizeof(*pp_file));
if (pp_file == NULL) {
mcelog_thread_running = 1;
FILE **pp_file = calloc(1, sizeof(*pp_file));
if (pp_file == NULL) {
- ERROR("mcelog: memory allocation failed: %s",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("mcelog: memory allocation failed: %s", STRERRNO);
int err = pthread_mutex_init(&g_mcelog_config.dimms_lock, NULL);
if (err < 0) {
ERROR(MCELOG_PLUGIN ": plugin: failed to initialize cache lock");
int err = pthread_mutex_init(&g_mcelog_config.dimms_lock, NULL);
if (err < 0) {
ERROR(MCELOG_PLUGIN ": plugin: failed to initialize cache lock");
if (plugin_thread_create(&g_mcelog_config.tid, NULL, poll_worker, NULL,
NULL) != 0) {
ERROR(MCELOG_PLUGIN ": Error creating poll thread.");
if (plugin_thread_create(&g_mcelog_config.tid, NULL, poll_worker, NULL,
NULL) != 0) {
ERROR(MCELOG_PLUGIN ": Error creating poll thread.");