collectd.conf(5): Documented the `iptables', `logfile', `processes', `syslog', and...
[collectd.git] / src / load.c
index 3e60a43..b92e54f 100644 (file)
@@ -4,8 +4,7 @@
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
+ * Free Software Foundation; only version 2 of the License is applicable.
  *
  * This program is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -57,7 +56,7 @@ static data_set_t ds =
 };
 
 #if LOAD_HAVE_READ
-static void load_submit (double snum, double mnum, double lnum)
+static void load_submit (gauge_t snum, gauge_t mnum, gauge_t lnum)
 {
        value_t values[3];
        value_list_t vl = VALUE_LIST_INIT;
@@ -67,12 +66,10 @@ static void load_submit (double snum, double mnum, double lnum)
        values[2].gauge = lnum;
 
        vl.values = values;
-       vl.values_len = 3;
+       vl.values_len = STATIC_ARRAY_SIZE (values);
        vl.time = time (NULL);
-       strcpy (vl.host, hostname);
+       strcpy (vl.host, hostname_g);
        strcpy (vl.plugin, "load");
-       strcpy (vl.plugin_instance, "");
-       strcpy (vl.type_instance, "");
 
        plugin_dispatch_values ("load", &vl);
 }
@@ -85,11 +82,15 @@ static int load_read (void)
        if (getloadavg (load, 3) == 3)
                load_submit (load[LOADAVG_1MIN], load[LOADAVG_5MIN], load[LOADAVG_15MIN]);
        else
-               syslog (LOG_WARNING, "load: getloadavg failed: %s", strerror (errno));
+       {
+               char errbuf[1024];
+               WARNING ("load: getloadavg failed: %s",
+                               sstrerror (errno, errbuf, sizeof (errbuf)));
+       }
 /* #endif HAVE_GETLOADAVG */
 
 #elif defined(KERNEL_LINUX)
-       double snum, mnum, lnum;
+       gauge_t snum, mnum, lnum;
        FILE *loadavg;
        char buffer[16];
 
@@ -98,19 +99,27 @@ static int load_read (void)
        
        if ((loadavg = fopen ("/proc/loadavg", "r")) == NULL)
        {
-               syslog (LOG_WARNING, "load: fopen: %s", strerror (errno));
+               char errbuf[1024];
+               WARNING ("load: fopen: %s",
+                               sstrerror (errno, errbuf, sizeof (errbuf)));
                return;
        }
 
        if (fgets (buffer, 16, loadavg) == NULL)
        {
-               syslog (LOG_WARNING, "load: fgets: %s", strerror (errno));
+               char errbuf[1024];
+               WARNING ("load: fgets: %s",
+                               sstrerror (errno, errbuf, sizeof (errbuf)));
                fclose (loadavg);
                return;
        }
 
        if (fclose (loadavg))
-               syslog (LOG_WARNING, "load: fclose: %s", strerror (errno));
+       {
+               char errbuf[1024];
+               WARNING ("load: fclose: %s",
+                               sstrerror (errno, errbuf, sizeof (errbuf)));
+       }
 
        numfields = strsplit (buffer, fields, 8);
 
@@ -125,7 +134,7 @@ static int load_read (void)
 /* #endif KERNEL_LINUX */
 
 #elif defined(HAVE_LIBSTATGRAB)
-       double snum, mnum, lnum;
+       gauge_t snum, mnum, lnum;
        sg_load_stats *ls;
 
        if ((ls = sg_get_load_stats ()) == NULL)