Merge pull request #814 from mfournier/upstart-systemd-examples
authorPierre-Yves Ritschard <pyr@spootnik.org>
Wed, 19 Nov 2014 16:02:11 +0000 (17:02 +0100)
committerPierre-Yves Ritschard <pyr@spootnik.org>
Wed, 19 Nov 2014 16:02:11 +0000 (17:02 +0100)
upstart and systemd doc & examples

src/cpu.c
src/snmp.c

index cf0eb6f..d1978f9 100644 (file)
--- a/src/cpu.c
+++ b/src/cpu.c
@@ -472,20 +472,34 @@ static void cpu_reset (void) /* {{{ */
 /* Legacy behavior: Dispatches the raw derive values without any aggregation. */
 static void cpu_commit_without_aggregation (void) /* {{{ */
 {
-       size_t cpu_num;
+       int state;
 
-       for (cpu_num = 0; cpu_num < global_cpu_num; cpu_num++)
+       for (state = 0; state < CPU_STATE_ACTIVE; state++)
        {
-               int state;
-
-               for (state = 0; state < CPU_STATE_ACTIVE; state++)
-               {
-                       cpu_state_t *s = get_cpu_state (cpu_num, state);
+               size_t cpu_num;
+               if (report_by_cpu) {
+                       for (cpu_num = 0; cpu_num < global_cpu_num; cpu_num++)
+                       {
+                               cpu_state_t *s = get_cpu_state (cpu_num, state);
 
-                       if (!s->has_value)
-                               continue;
+                               if (!s->has_value)
+                                       continue;
 
-                       submit_derive ((int) cpu_num, (int) state, s->conv.last_value.derive);
+                               submit_derive ((int) cpu_num, (int) state, s->conv.last_value.derive);
+                       }
+               } else {
+                       derive_t derive_total = 0;
+                       for (cpu_num = 0; cpu_num < global_cpu_num; cpu_num++)
+                               {
+                                       cpu_state_t *s = get_cpu_state (cpu_num, state);
+
+                                       if (!s->has_value)
+                                               continue;
+
+                                       derive_total += s->conv.last_value.derive;
+                       
+                               }
+                       submit_derive (-1, (int) state, derive_total);
                }
        }
 } /* }}} void cpu_commit_without_aggregation */
@@ -498,7 +512,7 @@ static void cpu_commit (void) /* {{{ */
        };
        size_t cpu_num;
 
-       if (report_by_cpu && report_by_state && !report_percent)
+       if (report_by_state && !report_percent)
        {
                cpu_commit_without_aggregation ();
                return;
index 7d6e0a1..6466503 100644 (file)
@@ -1618,8 +1618,9 @@ static int csnmp_read_table (host_definition_t *host, data_definition_t *data)
     snmp_free_pdu (res);
   res = NULL;
 
-  if (req != NULL)
-    snmp_free_pdu (req);
+  /*
+   * memory is handled by snmp_synch_response
+   */
   req = NULL;
 
   if (status == 0)