summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 31604b1)
raw | patch | inline | side by side (parent: 31604b1)
author | Peter Holik <peter@holik.at> | |
Tue, 19 Aug 2008 08:46:44 +0000 (10:46 +0200) | ||
committer | Florian Forster <octo@huhu.verplant.org> | |
Tue, 19 Aug 2008 08:46:44 +0000 (10:46 +0200) |
Signed-off-by: Florian Forster <octo@huhu.verplant.org>
src/ipmi.c | patch | blob | history |
diff --git a/src/ipmi.c b/src/ipmi.c
index b9cfa1960b1a6b2c045ca03318769b42036c9e7c..7ae54a01825da420369a6ff9f6326d1e9d20197a 100644 (file)
--- a/src/ipmi.c
+++ b/src/ipmi.c
struct c_ipmi_sensor_list_s
{
ipmi_sensor_id_t sensor_id;
+ char sensor_name[DATA_MAX_NAME_LEN];
+ char sensor_type[DATA_MAX_NAME_LEN];
c_ipmi_sensor_list_t *next;
};
value_t values[1];
value_list_t vl = VALUE_LIST_INIT;
- char sensor_name[IPMI_SENSOR_NAME_LEN];
- char *sensor_name_ptr;
- int sensor_type;
- const char *type;
-
- memset (sensor_name, 0, sizeof (sensor_name));
- ipmi_sensor_get_name (sensor, sensor_name, sizeof (sensor_name));
- sensor_name[sizeof (sensor_name) - 1] = 0;
-
- sensor_name_ptr = strstr (sensor_name, ").");
- if (sensor_name_ptr == NULL)
- sensor_name_ptr = sensor_name;
- else
- sensor_name_ptr += 2;
+ c_ipmi_sensor_list_t *list_item = (c_ipmi_sensor_list_t *)user_data;
if (err != 0)
{
INFO ("ipmi plugin: sensor_read_handler: Removing sensor %s, "
"because it failed with status %#x.",
- sensor_name_ptr, err);
+ list_item->sensor_name, err);
sensor_list_remove (sensor);
return;
}
INFO ("ipmi plugin: sensor_read_handler: Removing sensor %s, "
"because it provides %s. If you need this sensor, "
"please file a bug report.",
- sensor_name_ptr,
+ list_item->sensor_name,
(value_present == IPMI_RAW_VALUE_PRESENT)
? "only the raw value"
: "no value");
return;
}
- /* Both `ignorelist' and `plugin_instance' may be NULL. */
- if (ignorelist_match (ignorelist, sensor_name_ptr) != 0)
+ values[0].gauge = value;
+
+ 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));
+ sstrncpy (vl.type, list_item->sensor_type, sizeof (vl.type));
+ sstrncpy (vl.type_instance, list_item->sensor_name, sizeof (vl.type_instance));
+
+ plugin_dispatch_values (&vl);
+} /* void sensor_read_handler */
+
+static int sensor_list_add (ipmi_sensor_t *sensor)
+{
+ ipmi_sensor_id_t sensor_id;
+ c_ipmi_sensor_list_t *list_item;
+ c_ipmi_sensor_list_t *list_prev;
+
+ char sensor_name[DATA_MAX_NAME_LEN];
+ char *sensor_name_ptr;
+ int sensor_type, len;
+ const char *type;
+ ipmi_entity_t *ent = ipmi_sensor_get_entity(sensor);
+
+ sensor_id = ipmi_sensor_convert_to_id (sensor);
+
+ memset (sensor_name, 0, sizeof (sensor_name));
+ ipmi_sensor_get_name (sensor, sensor_name, sizeof (sensor_name));
+ sensor_name[sizeof (sensor_name) - 1] = 0;
+
+ len = DATA_MAX_NAME_LEN - strlen(sensor_name);
+ strncat(sensor_name, " ", len--);
+ strncat(sensor_name, ipmi_entity_get_entity_id_string(ent), len);
+
+ sensor_name_ptr = strstr (sensor_name, ").");
+ if (sensor_name_ptr == NULL)
+ sensor_name_ptr = sensor_name;
+ else
{
- sensor_list_remove (sensor);
- return;
+ char *sensor_name_ptr_id = strstr (sensor_name, "(");
+
+ sensor_name_ptr += 2;
+ len = DATA_MAX_NAME_LEN - strlen(sensor_name);
+ strncat(sensor_name, " ", len--);
+ strncat(sensor_name, sensor_name_ptr_id,
+ MIN(sensor_name_ptr - sensor_name_ptr_id - 1, len));
}
+ /* Both `ignorelist' and `plugin_instance' may be NULL. */
+ if (ignorelist_match (ignorelist, sensor_name_ptr) != 0)
+ return (0);
+
/* FIXME: Use rate unit or base unit to scale the value */
sensor_type = ipmi_sensor_get_sensor_type (sensor);
default:
{
const char *sensor_type_str;
-
+
sensor_type_str = ipmi_sensor_get_sensor_type_string (sensor);
- INFO ("ipmi plugin: sensor_read_handler: Removing sensor %s, "
+ INFO ("ipmi plugin: sensor_list_add: Ignore sensor %s, "
"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);
- sensor_list_remove (sensor);
- return;
+ return (-1);
}
} /* switch (sensor_type) */
- values[0].gauge = value;
-
- 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));
- sstrncpy (vl.type, type, sizeof (vl.type));
- sstrncpy (vl.type_instance, sensor_name_ptr, sizeof (vl.type_instance));
-
- plugin_dispatch_values (&vl);
-} /* void sensor_read_handler */
-
-static int sensor_list_add (ipmi_sensor_t *sensor)
-{
- ipmi_sensor_id_t sensor_id;
- c_ipmi_sensor_list_t *list_item;
- c_ipmi_sensor_list_t *list_prev;
-
- sensor_id = ipmi_sensor_convert_to_id (sensor);
-
pthread_mutex_lock (&sensor_list_lock);
list_prev = NULL;
else
sensor_list = list_item;
+ sstrncpy (list_item->sensor_name, sensor_name_ptr,
+ sizeof (list_item->sensor_name));
+ sstrncpy (list_item->sensor_type, type, sizeof (list_item->sensor_type));
+
pthread_mutex_unlock (&sensor_list_lock);
return (0);
list_item = list_item->next)
{
ipmi_sensor_id_get_reading (list_item->sensor_id,
- sensor_read_handler, /* user data = */ NULL);
+ sensor_read_handler, /* user data = */ list_item);
} /* for (list_item) */
pthread_mutex_unlock (&sensor_list_lock);