projects
/
collectd.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
3bde786
)
src/utils_cache.c: Minor cleanups.
author
Florian Forster
<octo@noris.net>
Wed, 29 Sep 2010 15:59:48 +0000
(17:59 +0200)
committer
Florian Forster
<octo@noris.net>
Wed, 29 Sep 2010 15:59:48 +0000
(17:59 +0200)
src/utils_cache.c
patch
|
blob
|
history
diff --git
a/src/utils_cache.c
b/src/utils_cache.c
index
b7eacf3
..
0e9bdbe
100644
(file)
--- a/
src/utils_cache.c
+++ b/
src/utils_cache.c
@@
-206,37
+206,40
@@
static int uc_send_notification (const char *name)
/* if the associated threshold has a missing message, then use custom
* message. FIXME: we do a threshold_search here and in uc_check_timeout
* (calling ut_check_interesting, but we really need to do this once */
/* if the associated threshold has a missing message, then use custom
* message. FIXME: we do a threshold_search here and in uc_check_timeout
* (calling ut_check_interesting, but we really need to do this once */
- if ( !ut_search_threshold(&vl, &th) &&
-
(th.missing_message != NULL)
)
+ status = ut_search_threshold (&vl, &th);
+
while ((status == 0) && (th.missing_message != NULL)
)
{
char msg[NOTIF_MAX_MSG_LEN];
char temp[NOTIF_MAX_MSG_LEN];
{
char msg[NOTIF_MAX_MSG_LEN];
char temp[NOTIF_MAX_MSG_LEN];
+ char missing_str[32] = "";
sstrncpy (msg, th.missing_message, sizeof (msg));
sstrncpy (msg, th.missing_message, sizeof (msg));
- (void) ut_build_message (msg, NOTIF_MAX_MSG_LEN, th.missing_message,
- &ds, 0, &vl, ce->values_gauge,
+ status = ut_build_message (msg, sizeof (msg),
+ /* format = */ th.missing_message,
+ &ds, /* ds index = */ 0,
+ &vl, ce->values_gauge,
&n, &th);
&n, &th);
+ if (status != 0)
+ break;
-#define REPLACE_FIELD(t,v) \
- if (subst_string (temp, sizeof (temp), msg, t, v) != NULL) \
- sstrncpy (msg, temp, sizeof (msg));
-
- char itoa_temp[NOTIF_MAX_MSG_LEN];
-#define ITOA(string,i) \
- memset(string,0x00,sizeof(string)); \
- snprintf(string, sizeof(string), "%i", i);
+ (void) ssnprintf (missing_str, sizeof (missing_str), "%li",
+ (long) (n.time - ce->last_update));
- ITOA(itoa_temp, (int)(n.time - ce->last_update))
- REPLACE_FIELD("%{missing}", itoa_temp)
+ if (subst_string (temp, sizeof (temp), msg,
+ "%{missing}", missing_str) != NULL)
+ sstrncpy (msg, temp, sizeof (msg));
- (void) ssnprintf (n.message, sizeof (n.message),
-
"%s", msg)
;
+ sstrncpy (n.message, msg, sizeof (n.message));
+
break
;
}
}
- else
+
+ /* "ut_search_threshold" returned an error, there is no "missing_message" or
+ * "ut_build_message" failed. Use the generic default. */
+ if ((status != 0) || (th.missing_message == NULL))
{
ssnprintf (n.message, sizeof (n.message),
{
ssnprintf (n.message, sizeof (n.message),
- "
%s has not been updated for %
i seconds.", name,
- (
int
) (n.time - ce->last_update));
+ "
\"%s\" has not been updated for %l
i seconds.", name,
+ (
long
) (n.time - ce->last_update));
}
pthread_mutex_unlock (&cache_lock);
}
pthread_mutex_unlock (&cache_lock);