Merge branch 'pull/collectd-4.1' into collectd-4.1
authorFlorian Forster <octo@leeloo.lan.home.verplant.org>
Fri, 28 Sep 2007 10:19:19 +0000 (12:19 +0200)
committerFlorian Forster <octo@leeloo.lan.home.verplant.org>
Fri, 28 Sep 2007 10:19:19 +0000 (12:19 +0200)
configure.in
src/perl.c
src/snmp.c

index 51f26c3..54d38d5 100644 (file)
@@ -770,7 +770,7 @@ AC_ARG_WITH(libcurl, [AS_HELP_STRING([--with-libcurl@<:@=PREFIX@:>@], [Path to l
        then
                with_libcurl="yes"
        else
-               if test -x "$withval"
+               if test -f "$withval" && test -x "$withval"
                then
                        with_curl_config="$withval"
                        with_libcurl="yes"
@@ -779,6 +779,7 @@ AC_ARG_WITH(libcurl, [AS_HELP_STRING([--with-libcurl@<:@=PREFIX@:>@], [Path to l
                        with_curl_config="$withval/bin/curl-config"
                        with_libcurl="yes"
                fi; fi
+               with_libcurl="yes"
        fi; fi
 ],
 [
@@ -944,13 +945,14 @@ AC_ARG_WITH(libmysql, [AS_HELP_STRING([--with-libmysql@<:@=PREFIX@:>@], [Path to
        then
                with_libmysql="yes"
        else
-               if test -x "$withval";
+               if test -f "$withval" && test -x "$withval";
                then
                        with_mysql_config="$withval"
                else if test -x "$withval/bin/mysql_config"
                then
                        with_mysql_config="$withval/bin/mysql_config"
                fi; fi
+               with_libmysql="yes"
        fi; fi
 ],
 [
@@ -1298,16 +1300,16 @@ AC_ARG_WITH(libupsclient, [AS_HELP_STRING([--with-libupsclient@<:@=PREFIX@:>@],
        then
                with_libupsclient="no"
        else
-               with_libupsclient="yes"
                if test "x$withval" != "xyes"
                then
-                       if test -x "$withval"
+                       if test -f "$withval" && test -x "$withval";
                        then
                                with_upsclient_config="$withval"
                        else
                                with_upsclient_config="$withval/bin/libupsclient-config"
                        fi
                fi
+               with_libupsclient="yes"
        fi
 ],
 [
@@ -1372,17 +1374,20 @@ AC_ARG_WITH(libxmms, [AS_HELP_STRING([--with-libxmms@<:@=PREFIX@:>@], [Path to l
 [
        if test "x$withval" != "xno" -a "x$withval" != "xyes"
        then
-               if test -x "$withval/bin/xmms-config"
+               if test -f "$withval" && test -x "$withval";
+               then
+                       with_xmms_config="$withval"
+               else if test -x "$withval/bin/xmms-config"
                then
                        with_xmms_config="$withval/bin/xmms-config"
-               fi
-       fi
-       if test "x$withval" = "xno"
+               fi; fi
+               with_libxmms="yes"
+       else if test "x$withval" = "xno"
        then
                with_libxmms="no"
        else
                with_libxmms="yes"
-       fi
+       fi; fi
 ],
 [
        with_libxmms="yes"
index 1ad7248..f2cb7b6 100644 (file)
@@ -333,7 +333,7 @@ static char *get_module_name (char *buf, size_t buf_len, const char *module) {
                status = snprintf (buf, buf_len, "%s::%s", base_name, module);
        if ((status < 0) || (status >= buf_len))
                return (NULL);
-       buf[buf_len] = '\0';
+       buf[buf_len - 1] = '\0';
        return (buf);
 } /* char *get_module_name */
 
index 2c4c930..3c8a4fc 100644 (file)
@@ -609,8 +609,8 @@ static void csnmp_host_close_session (host_definition_t *host)
 
     snmp_sess_error (host->sess_handle, NULL, NULL, &errstr);
 
-    ERROR ("snmp plugin: snmp_sess_close failed: %s",
-       (errstr == NULL) ? "Unknown problem" : errstr);
+    ERROR ("snmp plugin: host %s: snmp_sess_close failed: %s",
+       host->name, (errstr == NULL) ? "Unknown problem" : errstr);
     sfree (errstr);
   }
 
@@ -639,8 +639,8 @@ static void csnmp_host_open_session (host_definition_t *host)
 
     snmp_error (&sess, NULL, NULL, &errstr);
 
-    ERROR ("snmp plugin: snmp_sess_open failed: %s",
-       (errstr == NULL) ? "Unknown problem" : errstr);
+    ERROR ("snmp plugin: host %s: snmp_sess_open failed: %s",
+       host->name, (errstr == NULL) ? "Unknown problem" : errstr);
     sfree (errstr);
   }
 } /* void csnmp_host_open_session */
@@ -654,6 +654,9 @@ static value_t csnmp_value_list_to_value (struct variable_list *vl, int type)
   if ((vl->type == ASN_INTEGER)
       || (vl->type == ASN_UINTEGER)
       || (vl->type == ASN_COUNTER)
+#ifdef ASN_TIMETICKS
+      || (vl->type == ASN_TIMETICKS)
+#endif
       || (vl->type == ASN_GAUGE))
   {
     temp = (uint32_t) *vl->val.integer;
@@ -789,6 +792,12 @@ static int csnmp_read_table (host_definition_t *host, data_definition_t *data)
   DEBUG ("snmp plugin: csnmp_read_table (host = %s, data = %s)",
       host->name, data->name);
 
+  if (host->sess_handle == NULL)
+  {
+    DEBUG ("snmp plugin: csnmp_read_table: host->sess_handle == NULL");
+    return (-1);
+  }
+
   ds = plugin_get_ds (data->type);
   if (!ds)
   {
@@ -849,8 +858,8 @@ static int csnmp_read_table (host_definition_t *host, data_definition_t *data)
       char *errstr = NULL;
 
       snmp_sess_error (host->sess_handle, NULL, NULL, &errstr);
-      ERROR ("snmp plugin: snmp_sess_synch_response failed: %s",
-         (errstr == NULL) ? "Unknown problem" : errstr);
+      ERROR ("snmp plugin: host %s: snmp_sess_synch_response failed: %s",
+         host->name, (errstr == NULL) ? "Unknown problem" : errstr);
       csnmp_host_close_session (host);
 
       status = -1;
@@ -1025,6 +1034,12 @@ static int csnmp_read_value (host_definition_t *host, data_definition_t *data)
   DEBUG ("snmp plugin: csnmp_read_value (host = %s, data = %s)",
       host->name, data->name);
 
+  if (host->sess_handle == NULL)
+  {
+    DEBUG ("snmp plugin: csnmp_read_table: host->sess_handle == NULL");
+    return (-1);
+  }
+
   ds = plugin_get_ds (data->type);
   if (!ds)
   {
@@ -1076,8 +1091,8 @@ static int csnmp_read_value (host_definition_t *host, data_definition_t *data)
     char *errstr = NULL;
 
     snmp_sess_error (host->sess_handle, NULL, NULL, &errstr);
-    ERROR ("snmp plugin: snmp_sess_synch_response failed: %s",
-       (errstr == NULL) ? "Unknown problem" : errstr);
+    ERROR ("snmp plugin: host %s: snmp_sess_synch_response failed: %s",
+       host->name, (errstr == NULL) ? "Unknown problem" : errstr);
     csnmp_host_close_session (host);
     sfree (errstr);
 
@@ -1168,7 +1183,10 @@ static int csnmp_init (void)
   int i;
 
   if (host_head == NULL)
+  {
+    NOTICE ("snmp plugin: No host has been defined.");
     return (-1);
+  }
 
   call_snmp_init_once ();
 
@@ -1203,7 +1221,10 @@ static int csnmp_init (void)
 
   threads = (pthread_t *) malloc (threads_num * sizeof (pthread_t));
   if (threads == NULL)
+  {
+    ERROR ("snmp plugin: malloc failed.");
     return (-1);
+  }
   memset (threads, '\0', threads_num * sizeof (pthread_t));
 
   for (i = 0; i < threads_num; i++)