X-Git-Url: https://git.octo.it/?p=collectd.git;a=blobdiff_plain;f=src%2Fipmi.c;h=47ceacaefeb96d7faa50a44eaa9cd3f8c7eaee45;hp=95f32bc441ea3a2c2e3ffd72b179583fb2db9048;hb=633c3966f770e4d46651a2fe219a18d8a9907a9f;hpb=01d7cbf017b973a7f7f0d177d59f4090ce1b2a77 diff --git a/src/ipmi.c b/src/ipmi.c index 95f32bc4..47ceacae 100644 --- a/src/ipmi.c +++ b/src/ipmi.c @@ -1,7 +1,8 @@ /** * collectd - src/ipmi.c - * Copyright (C) 2008 Florian octo Forster - * Copyright (C) 2008 Peter Holik + * Copyright (C) 2008-2009 Florian octo Forster + * Copyright (C) 2008 Peter Holik + * Copyright (C) 2009 Bruno Prémont * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -17,8 +18,9 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * Authors: - * Florian octo Forster + * Florian octo Forster * Peter Holik + * Bruno Prémont **/ #include "collectd.h" @@ -111,9 +113,9 @@ static int sensor_list_remove (ipmi_sensor_t *sensor); static void sensor_read_handler (ipmi_sensor_t *sensor, int err, enum ipmi_value_present_e value_present, - unsigned int raw_value, + unsigned int __attribute__((unused)) raw_value, double value, - ipmi_states_t *states, + ipmi_states_t __attribute__((unused)) *states, void *user_data) { value_t values[1]; @@ -134,7 +136,7 @@ static void sensor_read_handler (ipmi_sensor_t *sensor, if (c_ipmi_nofiy_notpresent) { - notification_t n = { NOTIF_WARNING, time(NULL), "", "", "ipmi", + notification_t n = { NOTIF_WARNING, cdtime (), "", "", "ipmi", "", "", "", NULL }; sstrncpy (n.host, hostname_g, sizeof (n.host)); @@ -148,11 +150,33 @@ static void sensor_read_handler (ipmi_sensor_t *sensor, } } } + else if (IPMI_IS_IPMI_ERR(err) && IPMI_GET_IPMI_ERR(err) == IPMI_NOT_SUPPORTED_IN_PRESENT_STATE_CC) + { + INFO ("ipmi plugin: sensor_read_handler: Sensor %s not ready", + list_item->sensor_name); + } else { - INFO ("ipmi plugin: sensor_read_handler: Removing sensor %s, " - "because it failed with status %#x.", - list_item->sensor_name, err); + if (IPMI_IS_IPMI_ERR(err)) + INFO ("ipmi plugin: sensor_read_handler: Removing sensor %s, " + "because it failed with IPMI error %#x.", + list_item->sensor_name, IPMI_GET_IPMI_ERR(err)); + else if (IPMI_IS_OS_ERR(err)) + INFO ("ipmi plugin: sensor_read_handler: Removing sensor %s, " + "because it failed with OS error %#x.", + list_item->sensor_name, IPMI_GET_OS_ERR(err)); + else if (IPMI_IS_RMCPP_ERR(err)) + INFO ("ipmi plugin: sensor_read_handler: Removing sensor %s, " + "because it failed with RMCPP error %#x.", + list_item->sensor_name, IPMI_GET_RMCPP_ERR(err)); + else if (IPMI_IS_SOL_ERR(err)) + INFO ("ipmi plugin: sensor_read_handler: Removing sensor %s, " + "because it failed with RMCPP error %#x.", + list_item->sensor_name, IPMI_GET_SOL_ERR(err)); + else + INFO ("ipmi plugin: sensor_read_handler: Removing sensor %s, " + "because it failed with error %#x. of class %#x", + list_item->sensor_name, err & 0xff, err & 0xffffff00); sensor_list_remove (sensor); } return; @@ -166,7 +190,7 @@ static void sensor_read_handler (ipmi_sensor_t *sensor, if (c_ipmi_nofiy_notpresent) { - notification_t n = { NOTIF_OKAY, time(NULL), "", "", "ipmi", + notification_t n = { NOTIF_OKAY, cdtime (), "", "", "ipmi", "", "", "", NULL }; sstrncpy (n.host, hostname_g, sizeof (n.host)); @@ -197,7 +221,6 @@ static void sensor_read_handler (ipmi_sensor_t *sensor, vl.values = values; vl.values_len = 1; - vl.time = time (NULL); sstrncpy (vl.host, hostname_g, sizeof (vl.host)); sstrncpy (vl.plugin, "ipmi", sizeof (vl.plugin)); @@ -340,7 +363,7 @@ static int sensor_list_add (ipmi_sensor_t *sensor) if (c_ipmi_nofiy_add && (c_ipmi_init_in_progress == 0)) { - notification_t n = { NOTIF_OKAY, time(NULL), "", "", "ipmi", + notification_t n = { NOTIF_OKAY, cdtime (), "", "", "ipmi", "", "", "", NULL }; sstrncpy (n.host, hostname_g, sizeof (n.host)); @@ -394,7 +417,7 @@ static int sensor_list_remove (ipmi_sensor_t *sensor) if (c_ipmi_nofiy_remove && c_ipmi_active) { - notification_t n = { NOTIF_WARNING, time(NULL), "", "", + notification_t n = { NOTIF_WARNING, cdtime (), "", "", "ipmi", "", "", "", NULL }; sstrncpy (n.host, hostname_g, sizeof (n.host)); @@ -457,9 +480,9 @@ static int sensor_list_remove_all (void) * Entity handlers */ static void entity_sensor_update_handler (enum ipmi_update_e op, - ipmi_entity_t *entity, + ipmi_entity_t __attribute__((unused)) *entity, ipmi_sensor_t *sensor, - void *user_data) + void __attribute__((unused)) *user_data) { /* TODO: Ignore sensors we cannot read */ @@ -478,9 +501,9 @@ static void entity_sensor_update_handler (enum ipmi_update_e op, * Domain handlers */ static void domain_entity_update_handler (enum ipmi_update_e op, - ipmi_domain_t *domain, + ipmi_domain_t __attribute__((unused)) *domain, ipmi_entity_t *entity, - void *user_data) + void __attribute__((unused)) *user_data) { int status; @@ -572,7 +595,7 @@ static int thread_init (os_handler_t **ret_os_handler) return (0); } /* int thread_init */ -static void *thread_main (void *user_data) +static void *thread_main (void __attribute__((unused)) *user_data) { int status; os_handler_t *os_handler = NULL; @@ -609,31 +632,23 @@ static int c_ipmi_config (const char *key, const char *value) else if (strcasecmp ("IgnoreSelected", key) == 0) { int invert = 1; - if ((strcasecmp ("True", value) == 0) - || (strcasecmp ("Yes", value) == 0) - || (strcasecmp ("On", value) == 0)) + if (IS_TRUE (value)) invert = 0; ignorelist_set_invert (ignorelist, invert); } else if (strcasecmp ("NotifySensorAdd", key) == 0) { - if ((strcasecmp ("True", value) == 0) - || (strcasecmp ("Yes", value) == 0) - || (strcasecmp ("On", value) == 0)) + if (IS_TRUE (value)) c_ipmi_nofiy_add = 1; } else if (strcasecmp ("NotifySensorRemove", key) == 0) { - if ((strcasecmp ("True", value) == 0) - || (strcasecmp ("Yes", value) == 0) - || (strcasecmp ("On", value) == 0)) + if (IS_TRUE (value)) c_ipmi_nofiy_remove = 1; } else if (strcasecmp ("NotifySensorNotPresent", key) == 0) { - if ((strcasecmp ("True", value) == 0) - || (strcasecmp ("Yes", value) == 0) - || (strcasecmp ("On", value) == 0)) + if (IS_TRUE (value)) c_ipmi_nofiy_notpresent = 1; } else @@ -649,11 +664,12 @@ static int c_ipmi_init (void) int status; /* Don't send `ADD' notifications during startup (~ 1 minute) */ - c_ipmi_init_in_progress = 1 + (60 / interval_g); + time_t iv = CDTIME_T_TO_TIME_T (plugin_get_interval ()); + c_ipmi_init_in_progress = 1 + (60 / iv); c_ipmi_active = 1; - status = pthread_create (&thread_id, /* attr = */ NULL, thread_main, + status = plugin_thread_create (&thread_id, /* attr = */ NULL, thread_main, /* user data = */ NULL); if (status != 0) {