/**
* collectd - src/ipmi.c
* Copyright (C) 2008 Florian octo Forster
+ * Copyright (C) 2008 Peter Holik
*
* 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
*
* Authors:
* Florian octo Forster <octo at verplant.org>
+ * Peter Holik <peter at holik.at>
**/
#include "collectd.h"
ipmi_sensor_id_t sensor_id;
char sensor_name[DATA_MAX_NAME_LEN];
char sensor_type[DATA_MAX_NAME_LEN];
+ int sensor_not_present;
c_ipmi_sensor_list_t *next;
};
"Sensor",
"IgnoreSelected",
"NotifySensorAdd",
- "NotifySensorRemove"
+ "NotifySensorRemove",
+ "NotifySensorNotPresent"
};
static int config_keys_num = STATIC_ARRAY_SIZE (config_keys);
static int c_ipmi_nofiy_add = 0;
static int c_ipmi_nofiy_remove = 0;
+static int c_ipmi_nofiy_notpresent = 0;
/*
* Misc private functions
if (err != 0)
{
- INFO ("ipmi plugin: sensor_read_handler: Removing sensor %s, "
- "because it failed with status %#x.",
- list_item->sensor_name, err);
- sensor_list_remove (sensor);
+ if ((err & 0xff) == IPMI_NOT_PRESENT_CC)
+ {
+ if (list_item->sensor_not_present == 0)
+ {
+ list_item->sensor_not_present = 1;
+
+ INFO ("ipmi plugin: sensor_read_handler: sensor %s "
+ "not present.", list_item->sensor_name);
+
+ if (c_ipmi_nofiy_notpresent)
+ {
+ notification_t n = { NOTIF_WARNING, time(NULL), "", "", "ipmi",
+ "", "", "", 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 not present", list_item->sensor_name);
+
+ plugin_dispatch_notification (&n);
+ }
+ }
+ }
+ else
+ {
+ INFO ("ipmi plugin: sensor_read_handler: Removing sensor %s, "
+ "because it failed with status %#x.",
+ list_item->sensor_name, err);
+ sensor_list_remove (sensor);
+ }
return;
}
+ else if (list_item->sensor_not_present == 1)
+ {
+ list_item->sensor_not_present = 0;
+
+ INFO ("ipmi plugin: sensor_read_handler: sensor %s present.",
+ list_item->sensor_name);
+
+ if (c_ipmi_nofiy_notpresent)
+ {
+ notification_t n = { NOTIF_OKAY, time(NULL), "", "", "ipmi",
+ "", "", "", 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 present", list_item->sensor_name);
+
+ plugin_dispatch_notification (&n);
+ }
+ }
if (value_present != IPMI_BOTH_VALUES_PRESENT)
{
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);
+ len = DATA_MAX_NAME_LEN - strlen(sensor_name) - 1;
strncat(sensor_name, " ", len--);
strncat(sensor_name, ipmi_entity_get_entity_id_string(ent), len);
char *sensor_name_ptr_id = strstr (sensor_name, "(");
sensor_name_ptr += 2;
- len = DATA_MAX_NAME_LEN - strlen(sensor_name);
+ len = DATA_MAX_NAME_LEN - strlen(sensor_name) - 1;
strncat(sensor_name, " ", len--);
strncat(sensor_name, sensor_name_ptr_id,
MIN(sensor_name_ptr - sensor_name_ptr_id - 1, len));
{
int status;
- printf ("domain_connection_change_handler (domain = %p, err = %i, "
+ DEBUG ("domain_connection_change_handler (domain = %p, err = %i, "
"conn_num = %u, port_num = %u, still_connected = %i, "
"user_data = %p);\n",
(void *) domain, err, conn_num, port_num, still_connected, user_data);
status = thread_init (&os_handler);
if (status != 0)
{
- fprintf (stderr, "ipmi plugin: thread_init failed.\n");
+ ERROR ("ipmi plugin: thread_init failed.\n");
return ((void *) -1);
}
|| (strcasecmp ("On", value) == 0))
c_ipmi_nofiy_remove = 1;
}
+ else if (strcasecmp ("NotifySensorNotPresent", key) == 0)
+ {
+ if ((strcasecmp ("True", value) == 0)
+ || (strcasecmp ("Yes", value) == 0)
+ || (strcasecmp ("On", value) == 0))
+ c_ipmi_nofiy_notpresent = 1;
+ }
else
{
return (-1);