projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'collectd-5.5' into collectd-5.6
[collectd.git]
/
src
/
ipmi.c
diff --git
a/src/ipmi.c
b/src/ipmi.c
index
262c439
..
ad62299
100644
(file)
--- a/
src/ipmi.c
+++ b/
src/ipmi.c
@@
-18,18
+18,17
@@
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* Authors:
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* Authors:
- * Florian octo Forster <octo at
verplant
.org>
+ * Florian octo Forster <octo at
collectd
.org>
* Peter Holik <peter at holik.at>
* Bruno Prémont <bonbons at linux-vserver.org>
**/
#include "collectd.h"
* Peter Holik <peter at holik.at>
* Bruno Prémont <bonbons at linux-vserver.org>
**/
#include "collectd.h"
+
#include "common.h"
#include "plugin.h"
#include "utils_ignorelist.h"
#include "common.h"
#include "plugin.h"
#include "utils_ignorelist.h"
-#include <pthread.h>
-
#include <OpenIPMI/ipmiif.h>
#include <OpenIPMI/ipmi_err.h>
#include <OpenIPMI/ipmi_posix.h>
#include <OpenIPMI/ipmiif.h>
#include <OpenIPMI/ipmi_err.h>
#include <OpenIPMI/ipmi_posix.h>
@@
-82,9
+81,7
@@
static int c_ipmi_nofiy_notpresent = 0;
*/
static void c_ipmi_error (const char *func, int status)
{
*/
static void c_ipmi_error (const char *func, int status)
{
- char errbuf[4096];
-
- memset (errbuf, 0, sizeof (errbuf));
+ char errbuf[4096] = { 0 };
if (IPMI_IS_OS_ERR (status))
{
if (IPMI_IS_OS_ERR (status))
{
@@
-136,7
+133,7
@@
static void sensor_read_handler (ipmi_sensor_t *sensor,
if (c_ipmi_nofiy_notpresent)
{
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));
"", "", "", NULL };
sstrncpy (n.host, hostname_g, sizeof (n.host));
@@
-190,7
+187,7
@@
static void sensor_read_handler (ipmi_sensor_t *sensor,
if (c_ipmi_nofiy_notpresent)
{
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));
"", "", "", NULL };
sstrncpy (n.host, hostname_g, sizeof (n.host));
@@
-236,7
+233,7
@@
static int sensor_list_add (ipmi_sensor_t *sensor)
c_ipmi_sensor_list_t *list_item;
c_ipmi_sensor_list_t *list_prev;
c_ipmi_sensor_list_t *list_item;
c_ipmi_sensor_list_t *list_prev;
- char buffer[DATA_MAX_NAME_LEN];
+ char buffer[DATA_MAX_NAME_LEN]
= { 0 }
;
const char *entity_id_string;
char sensor_name[DATA_MAX_NAME_LEN];
char *sensor_name_ptr;
const char *entity_id_string;
char sensor_name[DATA_MAX_NAME_LEN];
char *sensor_name_ptr;
@@
-246,7
+243,6
@@
static int sensor_list_add (ipmi_sensor_t *sensor)
sensor_id = ipmi_sensor_convert_to_id (sensor);
sensor_id = ipmi_sensor_convert_to_id (sensor);
- memset (buffer, 0, sizeof (buffer));
ipmi_sensor_get_name (sensor, buffer, sizeof (buffer));
buffer[sizeof (buffer) - 1] = 0;
ipmi_sensor_get_name (sensor, buffer, sizeof (buffer));
buffer[sizeof (buffer) - 1] = 0;
@@
-279,7
+275,7
@@
static int sensor_list_add (ipmi_sensor_t *sensor)
{
/* `sensor_id_ptr' now points to "(123)". */
ssnprintf (sensor_name, sizeof (sensor_name),
{
/* `sensor_id_ptr' now points to "(123)". */
ssnprintf (sensor_name, sizeof (sensor_name),
- "%s %s", sensor_name_ptr, sensor_id_ptr);
+ "%s %s", sensor_name_ptr, sensor_id_ptr);
}
/* else: don't touch sensor_name. */
}
}
/* else: don't touch sensor_name. */
}
@@
-363,7
+359,7
@@
static int sensor_list_add (ipmi_sensor_t *sensor)
if (c_ipmi_nofiy_add && (c_ipmi_init_in_progress == 0))
{
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));
"", "", "", NULL };
sstrncpy (n.host, hostname_g, sizeof (n.host));
@@
-417,7
+413,7
@@
static int sensor_list_remove (ipmi_sensor_t *sensor)
if (c_ipmi_nofiy_remove && c_ipmi_active)
{
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));
"ipmi", "", "", "", NULL };
sstrncpy (n.host, hostname_g, sizeof (n.host));
@@
-436,11
+432,9
@@
static int sensor_list_remove (ipmi_sensor_t *sensor)
static int sensor_list_read_all (void)
{
static int sensor_list_read_all (void)
{
- c_ipmi_sensor_list_t *list_item;
-
pthread_mutex_lock (&sensor_list_lock);
pthread_mutex_lock (&sensor_list_lock);
- for (list_item = sensor_list;
+ for (
c_ipmi_sensor_list_t *
list_item = sensor_list;
list_item != NULL;
list_item = list_item->next)
{
list_item != NULL;
list_item = list_item->next)
{
@@
-552,7
+546,6
@@
static void domain_connection_change_handler (ipmi_domain_t *domain,
static int thread_init (os_handler_t **ret_os_handler)
{
os_handler_t *os_handler;
static int thread_init (os_handler_t **ret_os_handler)
{
os_handler_t *os_handler;
- ipmi_open_option_t open_option[1];
ipmi_con_t *smi_connection = NULL;
ipmi_domain_id_t domain_id;
int status;
ipmi_con_t *smi_connection = NULL;
ipmi_domain_id_t domain_id;
int status;
@@
-576,9
+569,12
@@
static int thread_init (os_handler_t **ret_os_handler)
return (-1);
}
return (-1);
}
- memset (open_option, 0, sizeof (open_option));
- open_option[0].option = IPMI_OPEN_OPTION_ALL;
- open_option[0].ival = 1;
+ ipmi_open_option_t open_option[1] = {
+ [0] = {
+ .option = IPMI_OPEN_OPTION_ALL,
+ { .ival = 1 }
+ }
+ };
status = ipmi_open_domain ("mydomain", &smi_connection, /* num_con = */ 1,
domain_connection_change_handler, /* user data = */ NULL,
status = ipmi_open_domain ("mydomain", &smi_connection, /* num_con = */ 1,
domain_connection_change_handler, /* user data = */ NULL,
@@
-664,11
+660,12
@@
static int c_ipmi_init (void)
int status;
/* Don't send `ADD' notifications during startup (~ 1 minute) */
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;
c_ipmi_active = 1;
- status = pthread_create (&thread_id, /* attr = */ NULL, thread_main,
+ status = p
lugin_
thread_create (&thread_id, /* attr = */ NULL, thread_main,
/* user data = */ NULL);
if (status != 0)
{
/* user data = */ NULL);
if (status != 0)
{