allow for 'ReportByCpu false' and 'ValuesPercentage false'
authorFabien Wernli <cpan@faxm0dem.org>
Wed, 12 Nov 2014 10:21:43 +0000 (11:21 +0100)
committerFabien Wernli <cpan@faxm0dem.org>
Wed, 12 Nov 2014 10:21:43 +0000 (11:21 +0100)
this will allow for aggregating total cpu values while keeping derives
(ticks)

Change-Id: Ic22a1b52a5897c18398fa25095a0f3ebcc403ee1

src/cpu.c

index cf0eb6f..91dfade 100644 (file)
--- a/src/cpu.c
+++ b/src/cpu.c
@@ -472,13 +472,13 @@ 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++)
+               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);
 
@@ -487,6 +487,20 @@ static void cpu_commit_without_aggregation (void) /* {{{ */
 
                        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;