summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: a1b19a6)
raw | patch | inline | side by side (parent: a1b19a6)
author | Mytnyk, VolodymyrX <volodymyrx.mytnyk@intel.com> | |
Mon, 28 Nov 2016 16:57:49 +0000 (16:57 +0000) | ||
committer | Mytnyk, Volodymyr <volodymyrx.mytnyk@intel.com> | |
Wed, 11 Oct 2017 16:18:18 +0000 (17:18 +0100) |
- Add support of new analog sensors:
System Airflow, PS1 Input Power, MTT CPU1, MTT CPU2
- Extend list of sensors to support "memory" sensor type.
- Map sensors with a 'percent' flag to 'percent' type
and add sensor type as a prefix to type_instance in
this case. The type_instance of non % sensors will
remain the same (just sensor name).
Signed-off-by: Mytnyk, Volodymyr <volodymyrx.mytnyk@intel.com>
System Airflow, PS1 Input Power, MTT CPU1, MTT CPU2
- Extend list of sensors to support "memory" sensor type.
- Map sensors with a 'percent' flag to 'percent' type
and add sensor type as a prefix to type_instance in
this case. The type_instance of non % sensors will
remain the same (just sensor name).
Signed-off-by: Mytnyk, Volodymyr <volodymyrx.mytnyk@intel.com>
src/ipmi.c | patch | blob | history |
diff --git a/src/ipmi.c b/src/ipmi.c
index a206521a615465629a303dd578bd1383c6cad2d7..22aff82cdfac4f3262b4b752e49b2843f2961f8d 100644 (file)
--- a/src/ipmi.c
+++ b/src/ipmi.c
ipmi_sensor_id_t sensor_id;
char sensor_name[DATA_MAX_NAME_LEN];
char sensor_type[DATA_MAX_NAME_LEN];
+ char type_instance[DATA_MAX_NAME_LEN];
int sensor_not_present;
c_ipmi_sensor_list_t *next;
c_ipmi_instance_t *instance;
unsigned int use;
};
+struct c_ipmi_db_type_map_s {
+ enum ipmi_unit_type_e type;
+ const char *type_name;
+};
+typedef struct c_ipmi_db_type_map_s c_ipmi_db_type_map_t;
+
/*
* Module global variables
*/
if (st->notify_notpresent) {
notification_t n = c_ipmi_notification_init(st, NOTIF_WARNING);
- sstrncpy(n.type_instance, list_item->sensor_name,
+ sstrncpy(n.type_instance, list_item->type_instance,
sizeof(n.type_instance));
sstrncpy(n.type, list_item->sensor_type, sizeof(n.type));
snprintf(n.message, sizeof(n.message), "sensor %s not present",
if (st->notify_notpresent) {
notification_t n = c_ipmi_notification_init(st, NOTIF_OKAY);
- sstrncpy(n.type_instance, list_item->sensor_name,
+ sstrncpy(n.type_instance, list_item->type_instance,
sizeof(n.type_instance));
sstrncpy(n.type, list_item->sensor_type, sizeof(n.type));
snprintf(n.message, sizeof(n.message), "sensor %s present",
sstrncpy(vl.host, st->host, 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));
+ sstrncpy(vl.type_instance, list_item->type_instance,
+ sizeof(vl.type_instance));
plugin_dispatch_values(&vl);
} /* void sensor_read_handler */
@@ -338,6 +346,24 @@ static void sensor_get_name(ipmi_sensor_t *sensor, char *buffer, int buf_len) {
sstrncpy(buffer, sensor_name, buf_len);
}
+static const char *sensor_unit_to_type(ipmi_sensor_t *sensor) {
+ static const c_ipmi_db_type_map_t ipmi_db_type_map[] = {
+ {IPMI_UNIT_TYPE_WATTS, "power"}, {IPMI_UNIT_TYPE_CFM, "flow"}};
+
+ /* check the modifier and rate of the sensor value */
+ if ((ipmi_sensor_get_modifier_unit_use(sensor) != IPMI_MODIFIER_UNIT_NONE) ||
+ (ipmi_sensor_get_rate_unit(sensor) != IPMI_RATE_UNIT_NONE))
+ return NULL;
+
+ /* find the db type by using sensor base unit type */
+ enum ipmi_unit_type_e ipmi_type = ipmi_sensor_get_base_unit(sensor);
+ for (int i = 0; i < STATIC_ARRAY_SIZE(ipmi_db_type_map); i++)
+ if (ipmi_db_type_map[i].type == ipmi_type)
+ return ipmi_db_type_map[i].type_name;
+
+ return NULL;
+} /* const char* sensor_unit_to_type */
+
static int sensor_list_add(c_ipmi_instance_t *st, ipmi_sensor_t *sensor) {
ipmi_sensor_id_t sensor_id;
c_ipmi_sensor_list_t *list_item;
*
* ipmi_sensor_id_get_reading() supports only 'Threshold' sensors.
* See lib/sensor.c:4842, stand_ipmi_sensor_get_reading() for details.
- */
+ */
if (!ipmi_sensor_get_is_readable(sensor)) {
INFO("ipmi plugin: sensor_list_add: Ignore sensor `%s` of `%s`, "
- "because it don't readable! Its type: (%#x, %s). ",
+ "because it isn't readable! Its type: (%#x, %s). ",
sensor_name_ptr, st->name, sensor_type,
ipmi_sensor_get_sensor_type_string(sensor));
return -1;
type = "fanspeed";
break;
+ case IPMI_SENSOR_TYPE_MEMORY:
+ type = "memory";
+ break;
+
default: {
+ /* try to get collectd DB type based on sensor base unit type */
+ if ((type = sensor_unit_to_type(sensor)) != NULL)
+ break;
+
INFO("ipmi plugin: sensor_list_add: Ignore sensor `%s` of `%s`, "
"because I don't know how to handle its type (%#x, %s). "
"If you need this sensor, please file a bug report.",
else
st->sensor_list = list_item;
+ /* if sensor provides the percentage value, use "percent" collectd type
+ and add the `percent` to the type instance of the reported value */
+ if (ipmi_sensor_get_percentage(sensor)) {
+ snprintf(list_item->type_instance, sizeof(list_item->type_instance),
+ "percent-%s", sensor_name_ptr);
+ type = "percent";
+ } else {
+ /* use type instance as a name of the sensor */
+ sstrncpy(list_item->type_instance, sensor_name_ptr,
+ sizeof(list_item->type_instance));
+ }
+
sstrncpy(list_item->sensor_name, sensor_name_ptr,
sizeof(list_item->sensor_name));
sstrncpy(list_item->sensor_type, type, sizeof(list_item->sensor_type));
if (st->notify_add && (st->init_in_progress == 0)) {
notification_t n = c_ipmi_notification_init(st, NOTIF_OKAY);
- sstrncpy(n.type_instance, list_item->sensor_name, sizeof(n.type_instance));
+ sstrncpy(n.type_instance, list_item->type_instance,
+ sizeof(n.type_instance));
sstrncpy(n.type, list_item->sensor_type, sizeof(n.type));
snprintf(n.message, sizeof(n.message), "sensor %s added",
list_item->sensor_name);
if (st->notify_remove && st->active) {
notification_t n = c_ipmi_notification_init(st, NOTIF_WARNING);
- sstrncpy(n.type_instance, list_item->sensor_name, sizeof(n.type_instance));
+ sstrncpy(n.type_instance, list_item->type_instance,
+ sizeof(n.type_instance));
sstrncpy(n.type, list_item->sensor_type, sizeof(n.type));
snprintf(n.message, sizeof(n.message), "sensor %s removed",
list_item->sensor_name);