summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: de235d8)
raw | patch | inline | side by side (parent: de235d8)
author | Peter Holik <peter@holik.at> | |
Tue, 19 Aug 2008 08:50:48 +0000 (10:50 +0200) | ||
committer | Florian Forster <octo@huhu.verplant.org> | |
Tue, 19 Aug 2008 08:50:48 +0000 (10:50 +0200) |
It's enabled using the two new configuration options:
* NotifySensorAdd
A notification is produced when a sensor is removed. During the first
minute, i. e. while the plugin is scanning for sensors, this is disabled.
* NotifySensorRemove
If a sensor got removed a notification is produced.
Signed-off-by: Florian Forster <octo@huhu.verplant.org>
* NotifySensorAdd
A notification is produced when a sensor is removed. During the first
minute, i. e. while the plugin is scanning for sensors, this is disabled.
* NotifySensorRemove
If a sensor got removed a notification is produced.
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 7ae54a01825da420369a6ff9f6326d1e9d20197a..da1b0cdb635ff8aad084964f73d71e3e2df44345 100644 (file)
--- a/src/ipmi.c
+++ b/src/ipmi.c
static pthread_mutex_t sensor_list_lock = PTHREAD_MUTEX_INITIALIZER;
static c_ipmi_sensor_list_t *sensor_list = NULL;
+static int c_ipmi_init_in_progress = 0;
static int c_ipmi_active = 0;
static pthread_t thread_id = (pthread_t) 0;
static const char *config_keys[] =
{
"Sensor",
- "IgnoreSelected"
+ "IgnoreSelected",
+ "NotifySensorAdd",
+ "NotifySensorRemove"
};
static int config_keys_num = STATIC_ARRAY_SIZE (config_keys);
static ignorelist_t *ignorelist = NULL;
+static int c_ipmi_nofiy_add = 0;
+static int c_ipmi_nofiy_remove = 0;
+
/*
* Misc private functions
*/
pthread_mutex_unlock (&sensor_list_lock);
+ if (c_ipmi_nofiy_add && (c_ipmi_init_in_progress == 0))
+ {
+ 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 added", list_item->sensor_name);
+
+ plugin_dispatch_notification (&n);
+ }
+
return (0);
} /* int sensor_list_add */
pthread_mutex_unlock (&sensor_list_lock);
+ if (c_ipmi_nofiy_remove && c_ipmi_active)
+ {
+ 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 removed", list_item->sensor_name);
+
+ plugin_dispatch_notification (&n);
+ }
+
free (list_item);
return (0);
} /* int sensor_list_remove */
{
int invert = 1;
if ((strcasecmp ("True", value) == 0)
- || (strcasecmp ("Yes", value) == 0)
- || (strcasecmp ("On", value) == 0))
+ || (strcasecmp ("Yes", value) == 0)
+ || (strcasecmp ("On", value) == 0))
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))
+ c_ipmi_nofiy_add = 1;
+ }
+ else if (strcasecmp ("NotifySensorRemove", key) == 0)
+ {
+ if ((strcasecmp ("True", value) == 0)
+ || (strcasecmp ("Yes", value) == 0)
+ || (strcasecmp ("On", value) == 0))
+ c_ipmi_nofiy_remove = 1;
+ }
else
{
return (-1);
{
int status;
+ /* Don't send `ADD' notifications during startup (~ 1 minute) */
+ c_ipmi_init_in_progress = 1 + (60 / interval_g);
+
c_ipmi_active = 1;
status = pthread_create (&thread_id, /* attr = */ NULL, thread_main,
}
sensor_list_read_all ();
-
+
+ if (c_ipmi_init_in_progress > 0)
+ c_ipmi_init_in_progress--;
+ else
+ c_ipmi_init_in_progress = 0;
+
return (0);
} /* int c_ipmi_read */