Merge branch 'collectd-4.4' of octo@verplant.org:/var/lib/git/collectd into collectd-4.4
authorFlorian Forster <octo@leeloo.lan.home.verplant.org>
Tue, 27 May 2008 15:52:36 +0000 (17:52 +0200)
committerFlorian Forster <octo@leeloo.lan.home.verplant.org>
Tue, 27 May 2008 15:52:36 +0000 (17:52 +0200)
build.sh
src/collectd-nagios.c
src/collectd.conf.in
src/email.c
src/liboconfig/oconfig.c
src/ntpd.c
src/utils_cmd_getval.c
src/utils_llist.c
src/utils_threshold.c

index 3efb44f..cede2e4 100755 (executable)
--- a/build.sh
+++ b/build.sh
@@ -1,5 +1,15 @@
 #! /bin/sh
 
+if ! which lex > /dev/null 2>&1; then
+       echo "WARNING: lex not found!" >&2
+       echo "Make sure that you have a flex compatible tool available." >&2
+fi
+
+if ! which yacc > /dev/null 2>&1; then
+       echo "WARNING: yacc not found!" >&2
+       echo "Make sure that you have a GNU bison compatible tool available." >&2
+fi
+
 libtoolize=libtoolize
 
 if which glibtoolize > /dev/null 2>&1; then
index f4dff5b..1bf5b3f 100644 (file)
@@ -201,12 +201,17 @@ static int get_values (int *ret_values_num, double **ret_values,
                fclose (fh_out);
                return (-1);
        }
-       fclose (fh_in); fh_in = NULL; fd = -1;
-       fclose (fh_out); fh_out = NULL;
 
-       values_num = atoi (buffer);
-       if (values_num < 1)
-               return (-1);
+       {
+               char *ptr = strchr (buffer, ' ');
+
+               if (ptr != NULL)
+                       *ptr = '\0';
+
+               values_num = atoi (buffer);
+               if (values_num < 1)
+                       return (-1);
+       }
 
        values = (double *) malloc (values_num * sizeof (double));
        if (values == NULL)
@@ -225,32 +230,33 @@ static int get_values (int *ret_values_num, double **ret_values,
                return (-1);
        }
 
+       i = 0;
+       while (fgets (buffer, sizeof (buffer), fh_in) != NULL)
        {
-               char *ptr = strchr (buffer, ' ') + 1;
                char *key;
                char *value;
 
-               i = 0;
-               while ((key = strtok (ptr, " \t")) != NULL)
-               {
-                       ptr = NULL;
-                       value = strchr (key, '=');
-                       if (value == NULL)
-                               continue;
-                       *value = '\0'; value++;
+               key = buffer;
 
-                       if (ignore_ds (key) != 0)
-                               continue;
+               value = strchr (key, '=');
+               if (value == NULL)
+                       continue;
+               *value = '\0'; value++;
 
-                       values_names[i] = strdup (key);
-                       values[i] = atof (value);
+               if (ignore_ds (key) != 0)
+                       continue;
 
-                       i++;
-                       if (i >= values_num)
-                               break;
-               }
-               values_num = i;
+               values_names[i] = strdup (key);
+               values[i] = atof (value);
+
+               i++;
+               if (i >= values_num)
+                       break;
        }
+       values_num = i;
+
+       fclose (fh_in); fh_in = NULL; fd = -1;
+       fclose (fh_out); fh_out = NULL;
 
        *ret_values_num = values_num;
        *ret_values = values;
index e900ce8..001baae 100644 (file)
@@ -101,6 +101,11 @@ FQDNLookup   true
 #      IgnoreSelected false
 #</Plugin>
 
+#<Plugin df>
+#      Disk "/^[hs]d[a-f][0-9]?$/"
+#      IgnoreSelected false
+#</Plugin>
+
 #<Plugin dns>
 #      Interface "eth0"
 #      IgnoreSource "192.168.0.1"
index 87daed1..ed10e34 100644 (file)
@@ -292,7 +292,7 @@ static void *collect (void *arg)
 
                        len = strlen (line);
                        if (('\n' != line[len - 1]) && ('\r' != line[len - 1])) {
-                               log_warn ("[thread #%5lu] line too long (> %i characters): "
+                               log_warn ("[thread #%5lu] line too long (> %lu characters): "
                                                "'%s' (truncated)", self, sizeof (line) - 1, line);
 
                                while (NULL != fgets (line, sizeof (line), this->socket))
index 8cc3c8a..79b53ae 100644 (file)
@@ -27,7 +27,7 @@
 extern FILE *yyin;
 
 oconfig_item_t *ci_root;
-char           *c_file;
+const char     *c_file;
 
 static void yyset_in  (FILE *fd)
 {
index 90fdfd7..7abc743 100644 (file)
@@ -613,7 +613,7 @@ static int ntpd_receive_response (int *res_items, int *res_size,
                if (pkt_item_len < res_item_size)
                        pkt_padding = res_item_size - pkt_item_len;
                DEBUG ("res_item_size = %i; pkt_padding = %i;",
-                               res_item_size, pkt_padding);
+                               res_item_size, (int) pkt_padding);
 
                /* Extract the sequence number */
                pkt_sequence = INFO_SEQ (res.auth_seq);
@@ -652,7 +652,7 @@ static int ntpd_receive_response (int *res_items, int *res_size,
                 * We start by allocating some more memory.
                 */
                DEBUG ("realloc (%p, %i)", (void *) *res_data,
-                               (items_num + pkt_item_num) * res_item_size);
+                               (int) (items_num + pkt_item_num) * res_item_size);
                items = realloc ((void *) *res_data,
                                (items_num + pkt_item_num) * res_item_size);
                if (items == NULL)
index 01c6899..470d302 100644 (file)
@@ -102,8 +102,8 @@ int handle_getval (FILE *fh, char **fields, int fields_num)
   if (ds->ds_num != values_num)
   {
     ERROR ("ds[%s]->ds_num = %i, "
-       "but uc_get_rate_by_name returned %i values.",
-       ds->type, ds->ds_num, values_num);
+       "but uc_get_rate_by_name returned %u values.",
+       ds->type, ds->ds_num, (unsigned int) values_num);
     print_to_socket (fh, "-1 Error reading value from cache.\n");
     sfree (values);
     sfree (identifier_copy);
index 7fae025..bf5f7e4 100644 (file)
@@ -59,6 +59,9 @@ void llist_destroy (llist_t *l)
        llentry_t *e_this;
        llentry_t *e_next;
 
+       if (l == NULL)
+               return;
+
        for (e_this = l->head; e_this != NULL; e_this = e_next)
        {
                e_next = e_this->next;
@@ -140,6 +143,9 @@ llentry_t *llist_search (llist_t *l, const char *key)
 {
        llentry_t *e;
 
+       if (l == NULL)
+               return (NULL);
+
        for (e = l->head; e != NULL; e = e->next)
                if (strcmp (key, e->key) == 0)
                        break;
@@ -149,10 +155,14 @@ llentry_t *llist_search (llist_t *l, const char *key)
 
 llentry_t *llist_head (llist_t *l)
 {
+       if (l == NULL)
+               return (NULL);
        return (l->head);
 }
 
 llentry_t *llist_tail (llist_t *l)
 {
+       if (l == NULL)
+               return (NULL);
        return (l->tail);
 }
index b4fb855..4da8943 100644 (file)
@@ -645,7 +645,7 @@ static int ut_report_state (const data_set_t *ds,
            "%f. That is within the %s region of %f and %f.",
            ds->ds[ds_index].name, values[ds_index],
            (state == STATE_ERROR) ? "failure" : "warning",
-           min, min);
+           min, max);
       }
       else
       {