}
if (errbuf[0] == 0) {
- ssnprintf(errbuf, sizeof(errbuf), "Unknown error %#x", status);
+ snprintf(errbuf, sizeof(errbuf), "Unknown error %#x", status);
}
errbuf[sizeof(errbuf) - 1] = 0;
sstrncpy(n.type_instance, list_item->sensor_name,
sizeof(n.type_instance));
sstrncpy(n.type, list_item->sensor_type, sizeof(n.type));
- ssnprintf(n.message, sizeof(n.message), "sensor %s not present",
- list_item->sensor_name);
+ snprintf(n.message, sizeof(n.message), "sensor %s not present",
+ list_item->sensor_name);
plugin_dispatch_notification(&n);
}
sstrncpy(n.type_instance, list_item->sensor_name,
sizeof(n.type_instance));
sstrncpy(n.type, list_item->sensor_type, sizeof(n.type));
- ssnprintf(n.message, sizeof(n.message), "sensor %s present",
- list_item->sensor_name);
+ snprintf(n.message, sizeof(n.message), "sensor %s present",
+ list_item->sensor_name);
plugin_dispatch_notification(&n);
}
temp[sizeof(temp) - 1] = 0;
if (entity_id_string != NULL && strlen(temp))
- ssnprintf(sensor_name, sizeof(sensor_name), "%s %s", temp,
- entity_id_string);
+ snprintf(sensor_name, sizeof(sensor_name), "%s %s", temp, entity_id_string);
else if (entity_id_string != NULL)
sstrncpy(sensor_name, entity_id_string, sizeof(sensor_name));
else
sensor_id_ptr = strstr(temp, "(");
if (sensor_id_ptr != NULL) {
/* `sensor_id_ptr' now points to "(123)". */
- ssnprintf(sensor_name, sizeof(sensor_name), "%s %s", sensor_name_ptr,
- sensor_id_ptr);
+ snprintf(sensor_name, sizeof(sensor_name), "%s %s", sensor_name_ptr,
+ sensor_id_ptr);
}
/* else: don't touch sensor_name. */
}
/* Both `ignorelist' and `plugin_instance' may be NULL. */
if (ignorelist_match(ignorelist, sensor_name_ptr) != 0)
- return (0);
+ return 0;
/* FIXME: Use rate unit or base unit to scale the value */
"because I don't know how to handle its type (%#x, %s). "
"If you need this sensor, please file a bug report.",
sensor_name_ptr, sensor_type, sensor_type_str);
- return (-1);
+ return -1;
}
} /* switch (sensor_type) */
if (list_item != NULL) {
pthread_mutex_unlock(&sensor_list_lock);
- return (0);
+ return 0;
}
list_item = (c_ipmi_sensor_list_t *)calloc(1, sizeof(c_ipmi_sensor_list_t));
if (list_item == NULL) {
pthread_mutex_unlock(&sensor_list_lock);
- return (-1);
+ return -1;
}
list_item->sensor_id = ipmi_sensor_convert_to_id(sensor);
sstrncpy(n.host, hostname_g, sizeof(n.host));
sstrncpy(n.type_instance, list_item->sensor_name, sizeof(n.type_instance));
sstrncpy(n.type, list_item->sensor_type, sizeof(n.type));
- ssnprintf(n.message, sizeof(n.message), "sensor %s added",
- list_item->sensor_name);
+ snprintf(n.message, sizeof(n.message), "sensor %s added",
+ list_item->sensor_name);
plugin_dispatch_notification(&n);
}
- return (0);
+ return 0;
} /* int sensor_list_add */
static int sensor_list_remove(ipmi_sensor_t *sensor) {
if (list_item == NULL) {
pthread_mutex_unlock(&sensor_list_lock);
- return (-1);
+ return -1;
}
if (list_prev == NULL)
sstrncpy(n.host, hostname_g, sizeof(n.host));
sstrncpy(n.type_instance, list_item->sensor_name, sizeof(n.type_instance));
sstrncpy(n.type, list_item->sensor_type, sizeof(n.type));
- ssnprintf(n.message, sizeof(n.message), "sensor %s removed",
- list_item->sensor_name);
+ snprintf(n.message, sizeof(n.message), "sensor %s removed",
+ list_item->sensor_name);
plugin_dispatch_notification(&n);
}
free(list_item);
- return (0);
+ return 0;
} /* int sensor_list_remove */
static int sensor_list_read_all(void) {
pthread_mutex_unlock(&sensor_list_lock);
- return (0);
+ return 0;
} /* int sensor_list_read_all */
static int sensor_list_remove_all(void) {
list_item = list_next;
} /* while (list_item) */
- return (0);
+ return 0;
} /* int sensor_list_remove_all */
static int sensor_convert_threshold_severity(enum ipmi_thresh_e severity) {
- int _severity = NOTIF_OKAY;
-
switch (severity) {
case IPMI_LOWER_NON_CRITICAL:
case IPMI_UPPER_NON_CRITICAL:
- _severity = NOTIF_OKAY;
- break;
+ return NOTIF_OKAY;
case IPMI_LOWER_CRITICAL:
case IPMI_UPPER_CRITICAL:
- _severity = NOTIF_WARNING;
- break;
+ return NOTIF_WARNING;
case IPMI_LOWER_NON_RECOVERABLE:
case IPMI_UPPER_NON_RECOVERABLE:
- _severity = NOTIF_FAILURE;
- break;
+ return NOTIF_FAILURE;
default:
- break;
+ return NOTIF_OKAY;
} /* switch (severity) */
-
- return (_severity);
} /* int sensor_convert_threshold_severity */
static void add_event_common_data(notification_t *n, ipmi_sensor_t *sensor,
* event in all your event handlers. A NULL may also be passed to an event
* handler if the callback was not due to an event. */
if (event == NULL)
- return (IPMI_EVENT_NOT_HANDLED);
+ return IPMI_EVENT_NOT_HANDLED;
/* offset is a table index and it's represented as enum of strings that are
organized in the way - high and low for each threshold severity level */
ipmi_get_reading_name(event_type, sensor_type, offset);
sensor_get_name(sensor, n.type_instance, sizeof(n.type_instance));
if (value_present != IPMI_NO_VALUES_PRESENT)
- ssnprintf(n.message, sizeof(n.message),
- "sensor %s received event: %s, value is %f", n.type_instance,
- event_state, value);
+ snprintf(n.message, sizeof(n.message),
+ "sensor %s received event: %s, value is %f", n.type_instance,
+ event_state, value);
else
- ssnprintf(n.message, sizeof(n.message),
- "sensor %s received event: %s, value not provided",
- n.type_instance, event_state);
+ snprintf(n.message, sizeof(n.message),
+ "sensor %s received event: %s, value not provided",
+ n.type_instance, event_state);
DEBUG("Threshold event received for sensor %s", n.type_instance);
switch (value_present) {
case IPMI_BOTH_VALUES_PRESENT:
plugin_notification_meta_add_double(&n, "val", value);
- /* both values present, so fall-through to add raw value too */
+ /* both values present, so fall-through to add raw value too */
case IPMI_RAW_VALUE_PRESENT: {
char buf[DATA_MAX_NAME_LEN] = {0};
snprintf(buf, sizeof(buf), "0x%2.2x", raw_value);
/* Delete handled ipmi event from the list */
if (c_ipmi_sel_clear_event) {
ipmi_event_delete(event, NULL, NULL);
- return (IPMI_EVENT_HANDLED);
+ return IPMI_EVENT_HANDLED;
}
- return (IPMI_EVENT_NOT_HANDLED);
+ return IPMI_EVENT_NOT_HANDLED;
} /* int sensor_threshold_event_handler */
static int sensor_discrete_event_handler(ipmi_sensor_t *sensor,
* event in all your event handlers. A NULL may also be passed to an event
* handler if the callback was not due to an event. */
if (event == NULL)
- return (IPMI_EVENT_NOT_HANDLED);
+ return IPMI_EVENT_NOT_HANDLED;
notification_t n = {NOTIF_OKAY, cdtime(), "", "", "ipmi", "", "", "", NULL};
unsigned int event_type = ipmi_sensor_get_event_reading_type(sensor);
const char *event_state =
ipmi_get_reading_name(event_type, sensor_type, offset);
sensor_get_name(sensor, n.type_instance, sizeof(n.type_instance));
- ssnprintf(n.message, sizeof(n.message), "sensor %s received event: %s",
- n.type_instance, event_state);
+ snprintf(n.message, sizeof(n.message), "sensor %s received event: %s",
+ n.type_instance, event_state);
DEBUG("Discrete event received for sensor %s", n.type_instance);
/* Delete handled ipmi event from the list */
if (c_ipmi_sel_clear_event) {
ipmi_event_delete(event, NULL, NULL);
- return (IPMI_EVENT_HANDLED);
+ return IPMI_EVENT_HANDLED;
}
- return (IPMI_EVENT_NOT_HANDLED);
+ return IPMI_EVENT_NOT_HANDLED;
} /* int sensor_discrete_event_handler */
/*
}
} /* void domain_entity_update_handler */
-static void smi_event_handler(ipmi_con_t __attribute__((unused)) *ipmi,
- const ipmi_addr_t __attribute__((unused)) *addr,
+static void smi_event_handler(ipmi_con_t __attribute__((unused)) * ipmi,
+ const ipmi_addr_t __attribute__((unused)) * addr,
unsigned int __attribute__((unused)) addr_len,
ipmi_event_t *event, void *cb_data) {
unsigned int type = ipmi_event_get_type(event);
os_handler = ipmi_posix_thread_setup_os_handler(SIGIO);
if (os_handler == NULL) {
ERROR("ipmi plugin: ipmi_posix_thread_setup_os_handler failed.");
- return (-1);
+ return -1;
}
ipmi_init(os_handler);
/* user data = */ NULL, &smi_connection);
if (status != 0) {
c_ipmi_error("ipmi_smi_setup_con", status);
- return (-1);
+ return -1;
}
- ipmi_open_option_t open_option[1] = {
- [0] = {.option = IPMI_OPEN_OPTION_ALL, {.ival = 1}}};
+ ipmi_open_option_t open_option[1] = {[0] = {.option = IPMI_OPEN_OPTION_ALL,
+ {.ival = 1}}};
status = ipmi_open_domain(
"mydomain", &smi_connection, /* num_con = */ 1,
sizeof(open_option) / sizeof(open_option[0]), &domain_id);
if (status != 0) {
c_ipmi_error("ipmi_open_domain", status);
- return (-1);
+ return -1;
}
*ret_os_handler = os_handler;
- return (0);
+ return 0;
} /* int thread_init */
static void *thread_main(void __attribute__((unused)) * user_data) {
status = thread_init(&os_handler);
if (status != 0) {
ERROR("ipmi plugin: thread_init failed.\n");
- return ((void *)-1);
+ return (void *)-1;
}
while (c_ipmi_active != 0) {
ipmi_posix_thread_free_os_handler(os_handler);
- return ((void *)0);
+ return (void *)0;
} /* void *thread_main */
static int c_ipmi_config(const char *key, const char *value) {
if (ignorelist == NULL)
ignorelist = ignorelist_create(/* invert = */ 1);
if (ignorelist == NULL)
- return (1);
+ return 1;
if (strcasecmp("Sensor", key) == 0) {
ignorelist_add(ignorelist, value);
} else if (strcasecmp("SELClearEvent", key) == 0) {
c_ipmi_sel_clear_event = IS_TRUE(value);
} else {
- return (-1);
+ return -1;
}
- return (0);
+ return 0;
} /* int c_ipmi_config */
static int c_ipmi_init(void) {
c_ipmi_active = 0;
thread_id = (pthread_t)0;
ERROR("ipmi plugin: pthread_create failed.");
- return (-1);
+ return -1;
}
- return (0);
+ return 0;
} /* int c_ipmi_init */
static int c_ipmi_read(void) {
if ((c_ipmi_active == 0) || (thread_id == (pthread_t)0)) {
INFO("ipmi plugin: c_ipmi_read: I'm not active, returning false.");
- return (-1);
+ return -1;
}
sensor_list_read_all();
else
c_ipmi_init_in_progress = 0;
- return (0);
+ return 0;
} /* int c_ipmi_read */
static int c_ipmi_shutdown(void) {
sensor_list_remove_all();
- return (0);
+ return 0;
} /* int c_ipmi_shutdown */
void module_register(void) {