Merge branch 'collectd-4.5'
authorFlorian Forster <octo@leeloo.lan.home.verplant.org>
Sat, 24 Jan 2009 10:04:31 +0000 (11:04 +0100)
committerFlorian Forster <octo@leeloo.lan.home.verplant.org>
Sat, 24 Jan 2009 10:04:31 +0000 (11:04 +0100)
contrib/cussh.pl
src/ascent.c
src/tcpconns.c
src/utils_cache.c

index 2ec6308..ee4c893 100755 (executable)
@@ -62,6 +62,7 @@ use Collectd::Unixsock();
                GETVAL  => \&getval,
                FLUSH   => \&flush,
                LISTVAL => \&listval,
+               PUTNOTIF => \&putnotif,
        };
 
        if (! $sock) {
@@ -163,6 +164,7 @@ Available commands:
   GETVAL
   FLUSH
   LISTVAL
+  PUTNOTIF
 
 See the embedded Perldoc documentation for details. To do that, run:
   perldoc $0
@@ -290,6 +292,29 @@ sub listval {
        return 1;
 }
 
+=item B<PUTNOTIF> [[B<severity>=I<$severity>] [B<message>=I<$message>] [ ...]]
+
+=cut
+
+sub putnotif {
+       my $sock = shift || return;
+       my $line = shift || return;
+
+       my (%values) = ();
+       foreach my $i (split m/ /, $line) {
+               my($key,$val) = split m/=/, $i, 2;
+               if ($key && $val) {
+                       $values{$key} = $val;
+               }
+               else {
+                       $values{'message'} .= ' '.$key;
+               }
+       }
+       $values{'time'} ||= time();
+       my(@tmp) = %values;
+       return $sock->putnotif(%values);
+}
+
 =back
 
 These commands follow the exact same syntax as described in
index 2ad641d..6285176 100644 (file)
@@ -277,10 +277,12 @@ static int ascent_xml_submit_gauge (xmlDoc *doc, xmlNode *node, /* {{{ */
     value = strtod (str_ptr, &end_ptr);
     if (str_ptr == end_ptr)
     {
+      xmlFree(str_ptr);
       ERROR ("ascent plugin: ascent_xml_submit_gauge: strtod failed.");
       return (-1);
     }
   }
+  xmlFree(str_ptr);
 
   return (ascent_submit_gauge (plugin_instance, type, type_instance, value));
 } /* }}} int ascent_xml_submit_gauge */
@@ -306,10 +308,12 @@ static int ascent_xml_read_int (xmlDoc *doc, xmlNode *node, /* {{{ */
     value = strtol (str_ptr, &end_ptr, 0);
     if (str_ptr == end_ptr)
     {
+      xmlFree(str_ptr);
       ERROR ("ascent plugin: ascent_xml_read_int: strtol failed.");
       return (-1);
     }
   }
+  xmlFree(str_ptr);
 
   *ret_value = value;
   return (0);
index d39a6c3..aa1fa38 100644 (file)
@@ -585,7 +585,8 @@ static int conn_read (void)
        && ((inp->inp_vflag & INP_IPV6) == 0))
       continue;
 
-    conn_handle_ports (inp->inp_lport, inp->inp_fport, tp->t_state);
+    conn_handle_ports (ntohs (inp->inp_lport), ntohs (inp->inp_fport),
+       tp->t_state);
   } /* for (in_ptr) */
 
   in_orig = NULL;
index 241aa72..824b7c8 100644 (file)
@@ -186,6 +186,7 @@ static int uc_insert (const data_set_t *ds, const value_list_t *vl,
   ce = cache_alloc (ds->ds_num);
   if (ce == NULL)
   {
+    sfree (key_copy);
     ERROR ("uc_insert: cache_alloc (%i) failed.", ds->ds_num);
     return (-1);
   }
@@ -261,6 +262,7 @@ int uc_check_timeout (void)
       {
        ERROR ("uc_purge: realloc failed.");
        c_avl_iterator_destroy (iter);
+       pthread_mutex_unlock (&cache_lock);
        return (-1);
       }