projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Many plugins and files: Convert "interval_g" and "vl->interval" to cdtime_t.
[collectd.git]
/
src
/
plugin.c
diff --git
a/src/plugin.c
b/src/plugin.c
index
3682fa5
..
2e25758
100644
(file)
--- a/
src/plugin.c
+++ b/
src/plugin.c
@@
-336,7
+336,7
@@
static void *plugin_read_thread (void __attribute__((unused)) *args)
while (read_loop != 0)
{
read_func_t *rf;
while (read_loop != 0)
{
read_func_t *rf;
-
struct timeval
now;
+
cdtime_t
now;
int status;
int rf_type;
int rc;
int status;
int rf_type;
int rc;
@@
-347,10
+347,9
@@
static void *plugin_read_thread (void __attribute__((unused)) *args)
{
struct timespec abstime;
{
struct timespec abstime;
-
gettimeofday (&now, /* timezone = */ NULL
);
+
now = cdtime (
);
- abstime.tv_sec = now.tv_sec + interval_g;
- abstime.tv_nsec = 1000 * now.tv_usec;
+ CDTIME_T_TO_TIMESPEC (now + interval_g, &abstime);
pthread_mutex_lock (&read_lock);
pthread_cond_timedwait (&read_cond, &read_lock,
pthread_mutex_lock (&read_lock);
pthread_cond_timedwait (&read_cond, &read_lock,
@@
-361,15
+360,13
@@
static void *plugin_read_thread (void __attribute__((unused)) *args)
if ((rf->rf_interval.tv_sec == 0) && (rf->rf_interval.tv_nsec == 0))
{
if ((rf->rf_interval.tv_sec == 0) && (rf->rf_interval.tv_nsec == 0))
{
-
gettimeofday (&now, /* timezone = */ NULL
);
+
now = cdtime (
);
- rf->rf_interval.tv_sec = interval_g;
- rf->rf_interval.tv_nsec = 0;
+ CDTIME_T_TO_TIMESPEC (interval_g, &rf->rf_interval);
rf->rf_effective_interval = rf->rf_interval;
rf->rf_effective_interval = rf->rf_interval;
- rf->rf_next_read.tv_sec = now.tv_sec;
- rf->rf_next_read.tv_nsec = 1000 * now.tv_usec;
+ CDTIME_T_TO_TIMESPEC (now, &rf->rf_next_read);
}
/* sleep until this entry is due,
}
/* sleep until this entry is due,
@@
-380,12
+377,15
@@
static void *plugin_read_thread (void __attribute__((unused)) *args)
* we need to re-evaluate the condition every time
* pthread_cond_timedwait returns. */
rc = 0;
* we need to re-evaluate the condition every time
* pthread_cond_timedwait returns. */
rc = 0;
- while (!timeout_reached(rf->rf_next_read) && rc == 0) {
+ while ((read_loop != 0)
+ && !timeout_reached(rf->rf_next_read)
+ && rc == 0)
+ {
rc = pthread_cond_timedwait (&read_cond, &read_lock,
&rf->rf_next_read);
}
rc = pthread_cond_timedwait (&read_cond, &read_lock,
&rf->rf_next_read);
}
- /* Must hold `rea
l
_lock' when accessing `rf->rf_type'. */
+ /* Must hold `rea
d
_lock' when accessing `rf->rf_type'. */
rf_type = rf->rf_type;
pthread_mutex_unlock (&read_lock);
rf_type = rf->rf_type;
pthread_mutex_unlock (&read_lock);
@@
-456,7
+456,7
@@
static void *plugin_read_thread (void __attribute__((unused)) *args)
}
/* update the ``next read due'' field */
}
/* update the ``next read due'' field */
-
gettimeofday (&now, /* timezone = */ NULL
);
+
now = cdtime (
);
DEBUG ("plugin_read_thread: Effective interval of the "
"%s plugin is %i.%09i.",
DEBUG ("plugin_read_thread: Effective interval of the "
"%s plugin is %i.%09i.",
@@
-473,15
+473,12
@@
static void *plugin_read_thread (void __attribute__((unused)) *args)
NORMALIZE_TIMESPEC (rf->rf_next_read);
/* Check, if `rf_next_read' is in the past. */
NORMALIZE_TIMESPEC (rf->rf_next_read);
/* Check, if `rf_next_read' is in the past. */
- if ((rf->rf_next_read.tv_sec < now.tv_sec)
- || ((rf->rf_next_read.tv_sec == now.tv_sec)
- && (rf->rf_next_read.tv_nsec < (1000 * now.tv_usec))))
+ if (TIMESPEC_TO_CDTIME_T (&rf->rf_next_read) < now)
{
/* `rf_next_read' is in the past. Insert `now'
* so this value doesn't trail off into the
* past too much. */
{
/* `rf_next_read' is in the past. Insert `now'
* so this value doesn't trail off into the
* past too much. */
- rf->rf_next_read.tv_sec = now.tv_sec;
- rf->rf_next_read.tv_nsec = 1000 * now.tv_usec;
+ CDTIME_T_TO_TIMESPEC (now, &rf->rf_next_read);
}
DEBUG ("plugin_read_thread: Next read of the %s plugin at %i.%09i.",
}
DEBUG ("plugin_read_thread: Next read of the %s plugin at %i.%09i.",
@@
-1248,7
+1245,7
@@
int plugin_write (const char *plugin, /* {{{ */
return (status);
} /* }}} int plugin_write */
return (status);
} /* }}} int plugin_write */
-int plugin_flush (const char *plugin,
in
t timeout, const char *identifier)
+int plugin_flush (const char *plugin,
cdtime_
t timeout, const char *identifier)
{
llentry_t *le;
{
llentry_t *le;
@@
-1371,21
+1368,27
@@
int plugin_dispatch_values (value_list_t *vl)
if (c_avl_get (data_sets, vl->type, (void *) &ds) != 0)
{
if (c_avl_get (data_sets, vl->type, (void *) &ds) != 0)
{
- INFO ("plugin_dispatch_values: Dataset not found: %s", vl->type);
+ char ident[6 * DATA_MAX_NAME_LEN];
+
+ FORMAT_VL (ident, sizeof (ident), vl);
+ INFO ("plugin_dispatch_values: Dataset not found: %s "
+ "(from \"%s\"), check your types.db!",
+ vl->type, ident);
return (-1);
}
if (vl->time == 0)
return (-1);
}
if (vl->time == 0)
- vl->time =
time (NULL
);
+ vl->time =
cdtime (
);
if (vl->interval <= 0)
vl->interval = interval_g;
if (vl->interval <= 0)
vl->interval = interval_g;
- DEBUG ("plugin_dispatch_values: time = %
u; interval = %i
; "
+ DEBUG ("plugin_dispatch_values: time = %
.3f; interval = %.3f
; "
"host = %s; "
"plugin = %s; plugin_instance = %s; "
"type = %s; type_instance = %s;",
"host = %s; "
"plugin = %s; plugin_instance = %s; "
"type = %s; type_instance = %s;",
- (unsigned int) vl->time, vl->interval,
+ CDTIME_T_TO_DOUBLE (vl->time),
+ CDTIME_T_TO_DOUBLE (vl->interval),
vl->host,
vl->plugin, vl->plugin_instance,
vl->type, vl->type_instance);
vl->host,
vl->plugin, vl->plugin_instance,
vl->type, vl->type_instance);
@@
-1510,9
+1513,9
@@
int plugin_dispatch_notification (const notification_t *notif)
/* Possible TODO: Add flap detection here */
DEBUG ("plugin_dispatch_notification: severity = %i; message = %s; "
/* Possible TODO: Add flap detection here */
DEBUG ("plugin_dispatch_notification: severity = %i; message = %s; "
- "time = %
u
; host = %s;",
+ "time = %
.3f
; host = %s;",
notif->severity, notif->message,
notif->severity, notif->message,
-
(unsigned int) notif->time
, notif->host);
+
CDTIME_T_TO_DOUBLE (notif->time)
, notif->host);
/* Nobody cares for notifications */
if (list_notification == NULL)
/* Nobody cares for notifications */
if (list_notification == NULL)
@@
-1646,7
+1649,7
@@
static int plugin_notification_meta_add (notification_t *n,
}
case NM_TYPE_BOOLEAN:
{
}
case NM_TYPE_BOOLEAN:
{
- meta->nm_value.nm_boolean = *((
b
ool *) value);
+ meta->nm_value.nm_boolean = *((
_B
ool *) value);
break;
}
default:
break;
}
default:
@@
-1700,7
+1703,7
@@
int plugin_notification_meta_add_double (notification_t *n,
int plugin_notification_meta_add_boolean (notification_t *n,
const char *name,
int plugin_notification_meta_add_boolean (notification_t *n,
const char *name,
-
b
ool value)
+
_B
ool value)
{
return (plugin_notification_meta_add (n, name, NM_TYPE_BOOLEAN, &value));
}
{
return (plugin_notification_meta_add (n, name, NM_TYPE_BOOLEAN, &value));
}