Merge branch 'sh/plugin_interval'
authorFlorian Forster <octo@collectd.org>
Fri, 16 Nov 2012 06:53:27 +0000 (07:53 +0100)
committerFlorian Forster <octo@collectd.org>
Fri, 16 Nov 2012 06:55:52 +0000 (07:55 +0100)
Conflicts:
src/amqp.c
src/exec.c
src/memcached.c
src/unixsock.c

19 files changed:
1  2 
src/amqp.c
src/collectd.c
src/collectd.conf.pod
src/configfile.c
src/configfile.h
src/disk.c
src/email.c
src/exec.c
src/network.c
src/perl.c
src/pinba.c
src/ping.c
src/plugin.c
src/plugin.h
src/postgresql.c
src/python.c
src/rrdtool.c
src/snmp.c
src/unixsock.c

diff --cc src/amqp.c
@@@ -607,25 -552,21 +609,25 @@@ static void *camqp_subscribe_thread (vo
          status = camqp_connect (conf);
          if (status != 0)
          {
 +            struct timespec ts_interval;
              ERROR ("amqp plugin: camqp_connect failed. "
                      "Will sleep for %.3f seconds.",
-                     CDTIME_T_TO_DOUBLE (interval_g));
-             CDTIME_T_TO_TIMESPEC (interval_g, &ts_interval);
+                     CDTIME_T_TO_DOUBLE (interval));
 -            sleep (interval);
++            CDTIME_T_TO_TIMESPEC (interval, &ts_interval);
 +            nanosleep (&ts_interval, /* remaining = */ NULL);
              continue;
          }
  
          status = amqp_simple_wait_frame (conf->connection, &frame);
          if (status < 0)
          {
 +            struct timespec ts_interval;
              ERROR ("amqp plugin: amqp_simple_wait_frame failed. "
                      "Will sleep for %.3f seconds.",
-                     CDTIME_T_TO_DOUBLE (interval_g));
+                     CDTIME_T_TO_DOUBLE (interval));
              camqp_close_connection (conf);
-             CDTIME_T_TO_TIMESPEC (interval_g, &ts_interval);
 -            sleep (interval);
++            CDTIME_T_TO_TIMESPEC (interval, &ts_interval);
 +            nanosleep (&ts_interval, /* remaining = */ NULL);
              continue;
          }
  
diff --cc src/collectd.c
Simple merge
Simple merge
Simple merge
Simple merge
diff --cc src/disk.c
@@@ -248,16 -235,6 +248,17 @@@ static void disk_submit (const char *pl
        plugin_dispatch_values (&vl);
  } /* void disk_submit */
  
-       double avg_time_incr = CDTIME_T_TO_DOUBLE (interval_g) * avg_time;
 +#if KERNEL_LINUX
 +static counter_t disk_calc_time_incr (counter_t delta_time, counter_t delta_ops)
 +{
++      double interval = CDTIME_T_TO_DOUBLE (plugin_get_interval ());
 +      double avg_time = ((double) delta_time) / ((double) delta_ops);
++      double avg_time_incr = interval * avg_time;
 +
 +      return ((counter_t) (avg_time_incr + .5));
 +}
 +#endif
 +
  #if HAVE_IOKIT_IOKITLIB_H
  static signed long long dict_get_value (CFDictionaryRef dict, const char *key)
  {
diff --cc src/email.c
Simple merge
diff --cc src/exec.c
@@@ -826,8 -814,7 +827,8 @@@ static int exec_read (void) /* {{{ *
  
      pthread_attr_init (&attr);
      pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED);
-     pthread_create (&t, &attr, exec_read_one, (void *) pl);
+     plugin_thread_create (&t, &attr, exec_read_one, (void *) pl);
 +    pthread_attr_destroy (&attr);
    } /* for (pl) */
  
    return (0);
@@@ -870,8 -857,7 +871,8 @@@ static int exec_notification (const not
  
      pthread_attr_init (&attr);
      pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED);
-     pthread_create (&t, &attr, exec_notification_one, (void *) pln);
+     plugin_thread_create (&t, &attr, exec_notification_one, (void *) pln);
 +    pthread_attr_destroy (&attr);
    } /* for (pl) */
  
    return (0);
diff --cc src/network.c
Simple merge
diff --cc src/perl.c
Simple merge
diff --cc src/pinba.c
Simple merge
diff --cc src/ping.c
Simple merge
diff --cc src/plugin.c
Simple merge
diff --cc src/plugin.h
Simple merge
@@@ -345,12 -337,10 +345,13 @@@ static PGresult *c_psql_exec_query_para
                        case C_PSQL_PARAM_INTERVAL:
                                ssnprintf (interval, sizeof (interval), "%.3f",
                                                (db->interval > 0)
-                                               ? CDTIME_T_TO_DOUBLE (db->interval) : interval_g);
+                                               ? CDTIME_T_TO_DOUBLE (db->interval)
+                                               : plugin_get_interval ());
                                params[i] = interval;
                                break;
 +                      case C_PSQL_PARAM_INSTANCE:
 +                              params[i] = db->instance;
 +                              break;
                        default:
                                assert (0);
                }
diff --cc src/python.c
Simple merge
diff --cc src/rrdtool.c
Simple merge
diff --cc src/snmp.c
Simple merge
diff --cc src/unixsock.c
@@@ -363,7 -352,11 +363,8 @@@ static void *us_server_thread (void __a
  
                DEBUG ("Spawning child to handle connection on fd #%i", *remote_fd);
  
-               status = pthread_create (&th, &th_attr, us_handle_client, (void *) remote_fd);
 -              pthread_attr_init (&th_attr);
 -              pthread_attr_setdetachstate (&th_attr, PTHREAD_CREATE_DETACHED);
 -
+               status = plugin_thread_create (&th, &th_attr,
+                               us_handle_client, (void *) remote_fd);
                if (status != 0)
                {
                        char errbuf[1024];