[collectd] [PATCH] email plugin: Ignore size if it less than or equal to zero.

Sebastian Harl sh<span style="display: none;">.trailing-username</span>(a)<span style="display: none;">leading-domain.</span>tokkee.org
Sun Dec 24 14:22:49 CET 2006


Some daemons (e.g. postgrey) don't provide any size information.

Signed-off-by: Sebastian Harl <sh.trailing-username(a)leading-domain.tokkee.org>
---
 src/collectd.pod |    2 ++
 src/email.c      |    8 +++++---
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/collectd.pod b/src/collectd.pod
index bf76055..8ee77ea 100644
--- a/src/collectd.pod
+++ b/src/collectd.pod
@@ -202,6 +202,8 @@ E-Mail type (e.g. "ham", "spam", "virus"
 
   e:<type>:<size>
 
+If C<size> is less than or equal to zero, C<size> is ignored.
+
 Spam score:
 
   s:<value>
diff --git a/src/email.c b/src/email.c
index 64b82e4..509eb23 100644
--- a/src/email.c
+++ b/src/email.c
@@ -486,9 +486,11 @@ static void *collect (void *arg)
 				type_list_incr (&count, type, 1);
 				pthread_mutex_unlock (&count_mutex);
 
-				pthread_mutex_lock (&size_mutex);
-				type_list_incr (&size, type, bytes);
-				pthread_mutex_unlock (&size_mutex);
+				if (bytes > 0) {
+					pthread_mutex_lock (&size_mutex);
+					type_list_incr (&size, type, bytes);
+					pthread_mutex_unlock (&size_mutex);
+				}
 			}
 			else if ('s' == line[0]) { /* s:<value> */
 				pthread_mutex_lock (&score_mutex);
-- 
1.4.3.2

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://mailman.verplant.org/pipermail/collectd/attachments/20061224/851ff855/attachment.pgp


More information about the collectd mailing list