perl plugin: Exported plugin_log() to Perl.
[collectd.git] / src / collectd.c
index e873adc..0986e40 100644 (file)
@@ -23,7 +23,6 @@
 #include "collectd.h"
 #include "common.h"
 
-#include "network.h"
 #include "plugin.h"
 #include "configfile.h"
 
@@ -70,7 +69,7 @@ static int init_global_variables (void)
 
        str = global_option_get ("Interval");
        if (str == NULL)
-               str = COLLECTD_STEP;
+               str = "10";
        interval_g = atoi (str);
        if (interval_g <= 0)
        {
@@ -91,7 +90,9 @@ static int change_basedir (const char *orig_dir)
 
        if (dir == NULL)
        {
-               ERROR ("strdup failed: %s", strerror (errno));
+               char errbuf[1024];
+               ERROR ("strdup failed: %s",
+                               sstrerror (errno, errbuf, sizeof (errbuf)));
                return (-1);
        }
        
@@ -111,21 +112,27 @@ static int change_basedir (const char *orig_dir)
                {
                        if (mkdir (orig_dir, 0755) == -1)
                        {
+                               char errbuf[1024];
                                ERROR ("mkdir (%s): %s", orig_dir,
-                                               strerror (errno));
+                                               sstrerror (errno, errbuf,
+                                                       sizeof (errbuf)));
                                return (-1);
                        }
                        else if (chdir (orig_dir) == -1)
                        {
+                               char errbuf[1024];
                                ERROR ("chdir (%s): %s", orig_dir,
-                                               strerror (errno));
+                                               sstrerror (errno, errbuf,
+                                                       sizeof (errbuf)));
                                return (-1);
                        }
                }
                else
                {
+                       char errbuf[1024];
                        ERROR ("chdir (%s): %s", orig_dir,
-                                       strerror (errno));
+                                       sstrerror (errno, errbuf,
+                                               sizeof (errbuf)));
                        return (-1);
                }
        }
@@ -179,11 +186,6 @@ static void exit_usage (char *name)
                        "  Config-File       "CONFIGFILE"\n"
                        "  PID-File          "PIDFILE"\n"
                        "  Data-Directory    "PKGLOCALSTATEDIR"\n"
-#if COLLECT_DEBUG
-                       "  Log-File          "LOGFILE"\n"
-#endif
-                       "  Step              "COLLECTD_STEP" seconds\n"
-                       "  Heartbeat         "COLLECTD_HEARTBEAT" seconds\n"
                        "\n"PACKAGE" "VERSION", http://collectd.org/\n"
                        "by Florian octo Forster <octo@verplant.org>\n"
                        "for contributions see `AUTHORS'\n");
@@ -227,7 +229,10 @@ static int do_loop (void)
        {
                if (gettimeofday (&tv_next, NULL) < 0)
                {
-                       ERROR ("gettimeofday failed: %s", strerror (errno));
+                       char errbuf[1024];
+                       ERROR ("gettimeofday failed: %s",
+                                       sstrerror (errno, errbuf,
+                                               sizeof (errbuf)));
                        return (-1);
                }
                tv_next.tv_sec += interval_g;
@@ -241,8 +246,10 @@ static int do_loop (void)
 
                if (gettimeofday (&tv_now, NULL) < 0)
                {
+                       char errbuf[1024];
                        ERROR ("gettimeofday failed: %s",
-                                       strerror (errno));
+                                       sstrerror (errno, errbuf,
+                                               sizeof (errbuf)));
                        return (-1);
                }
 
@@ -258,7 +265,10 @@ static int do_loop (void)
                {
                        if (errno != EINTR)
                        {
-                               ERROR ("nanosleep failed: %s", strerror (errno));
+                               char errbuf[1024];
+                               ERROR ("nanosleep failed: %s",
+                                               sstrerror (errno, errbuf,
+                                                       sizeof (errbuf)));
                                return (-1);
                        }
                }
@@ -282,7 +292,9 @@ static int pidfile_create (void)
 
        if ((fh = fopen (file, "w")) == NULL)
        {
-               ERROR ("fopen (%s): %s", file, strerror (errno));
+               char errbuf[1024];
+               ERROR ("fopen (%s): %s", file,
+                               sstrerror (errno, errbuf, sizeof (errbuf)));
                return (1);
        }
 
@@ -396,7 +408,10 @@ int main (int argc, char **argv)
                if ((pid = fork ()) == -1)
                {
                        /* error */
-                       fprintf (stderr, "fork: %s", strerror (errno));
+                       char errbuf[1024];
+                       fprintf (stderr, "fork: %s",
+                                       sstrerror (errno, errbuf,
+                                               sizeof (errbuf)));
                        return (1);
                }
                else if (pid != 0)