]> granicus.if.org Git - sysstat/commitdiff
Split large functions into smaller ones
authorSebastien GODARD <sysstat@users.noreply.github.com>
Sat, 11 Mar 2023 15:21:55 +0000 (16:21 +0100)
committerSebastien GODARD <sysstat@users.noreply.github.com>
Sat, 11 Mar 2023 15:21:55 +0000 (16:21 +0100)
Signed-off-by: Sebastien GODARD <sysstat@users.noreply.github.com>
json_stats.c
pcp_def_metrics.c
pcp_stats.c
pr_stats.c
raw_stats.c
rndr_stats.c
svg_stats.c
xml_stats.c

index 0ee3eb2f01c0674a464281cdf3da88e2a1903812..5b75bbc5bf82ea997189f16e2b21ec8ea8969141 100644 (file)
@@ -518,6 +518,88 @@ __print_funct_t json_print_io_stats(struct activity *a, int curr, int tab,
                 S_VALUE(sip->dk_drive_dblk, sic->dk_drive_dblk, itv));
 }
 
+/*
+ * **************************************************************************
+ * Display RAM memory utilization in JSON.
+ *
+ * IN:
+ * @smc                Structure with statistics.
+ * @dispall    TRUE if all memory fields should be displayed.
+ ***************************************************************************
+ */
+void json_print_ram_memory_stats(struct stats_memory *smc, int dispall)
+{
+       unsigned long long nousedmem;
+
+       nousedmem = smc->frmkb + smc->bufkb + smc->camkb + smc->slabkb;
+       if (nousedmem > smc->tlmkb) {
+               nousedmem = smc->tlmkb;
+       }
+
+       printf("\"memfree\": %llu, "
+              "\"avail\": %llu, "
+              "\"memused\": %llu, "
+              "\"memused-percent\": %.2f, "
+              "\"buffers\": %llu, "
+              "\"cached\": %llu, "
+              "\"commit\": %llu, "
+              "\"commit-percent\": %.2f, "
+              "\"active\": %llu, "
+              "\"inactive\": %llu, "
+              "\"dirty\": %llu",
+              smc->frmkb,
+              smc->availablekb,
+              smc->tlmkb - nousedmem,
+              smc->tlmkb ? SP_VALUE(nousedmem, smc->tlmkb, smc->tlmkb)
+                         : 0.0,
+              smc->bufkb,
+              smc->camkb,
+              smc->comkb,
+              (smc->tlmkb + smc->tlskb) ? SP_VALUE(0, smc->comkb, smc->tlmkb + smc->tlskb)
+                                        : 0.0,
+              smc->activekb,
+              smc->inactkb,
+              smc->dirtykb);
+
+       if (dispall) {
+               /* Display extended memory stats */
+               printf(", \"anonpg\": %llu, "
+                      "\"slab\": %llu, "
+                      "\"kstack\": %llu, "
+                      "\"pgtbl\": %llu, "
+                      "\"vmused\": %llu",
+                      smc->anonpgkb,
+                      smc->slabkb,
+                      smc->kstackkb,
+                      smc->pgtblkb,
+                      smc->vmusedkb);
+       }
+}
+
+/*
+ * **************************************************************************
+ * Display swap memory utilization in JSON.
+ *
+ * IN:
+ * @smc                Structure with statistics.
+ ***************************************************************************
+ */
+void json_print_swap_memory_stats(struct stats_memory *smc)
+{
+       printf("\"swpfree\": %llu, "
+              "\"swpused\": %llu, "
+              "\"swpused-percent\": %.2f, "
+              "\"swpcad\": %llu, "
+              "\"swpcad-percent\": %.2f",
+              smc->frskb,
+              smc->tlskb - smc->frskb,
+              smc->tlskb ? SP_VALUE(smc->frskb, smc->tlskb, smc->tlskb)
+                         : 0.0,
+              smc->caskb,
+              (smc->tlskb - smc->frskb) ? SP_VALUE(0, smc->caskb, smc->tlskb - smc->frskb)
+                                        : 0.0);
+}
+
 /*
  ***************************************************************************
  * Display memory statistics in JSON.
@@ -539,77 +621,15 @@ __print_funct_t json_print_memory_stats(struct activity *a, int curr, int tab,
        xprintf0(tab, "\"memory\": {");
 
        if (DISPLAY_MEMORY(a->opt_flags)) {
-               unsigned long long nousedmem;
-
                sep = TRUE;
-
-               nousedmem = smc->frmkb + smc->bufkb + smc->camkb + smc->slabkb;
-               if (nousedmem > smc->tlmkb) {
-                       nousedmem = smc->tlmkb;
-               }
-
-               printf("\"memfree\": %llu, "
-                      "\"avail\": %llu, "
-                      "\"memused\": %llu, "
-                      "\"memused-percent\": %.2f, "
-                      "\"buffers\": %llu, "
-                      "\"cached\": %llu, "
-                      "\"commit\": %llu, "
-                      "\"commit-percent\": %.2f, "
-                      "\"active\": %llu, "
-                      "\"inactive\": %llu, "
-                      "\"dirty\": %llu",
-                      smc->frmkb,
-                      smc->availablekb,
-                      smc->tlmkb - nousedmem,
-                      smc->tlmkb ?
-                      SP_VALUE(nousedmem, smc->tlmkb, smc->tlmkb) :
-                      0.0,
-                      smc->bufkb,
-                      smc->camkb,
-                      smc->comkb,
-                      (smc->tlmkb + smc->tlskb) ?
-                      SP_VALUE(0, smc->comkb, smc->tlmkb + smc->tlskb) :
-                      0.0,
-                      smc->activekb,
-                      smc->inactkb,
-                      smc->dirtykb);
-
-               if (DISPLAY_MEM_ALL(a->opt_flags)) {
-                       /* Display extended memory stats */
-                       printf(", \"anonpg\": %llu, "
-                              "\"slab\": %llu, "
-                              "\"kstack\": %llu, "
-                              "\"pgtbl\": %llu, "
-                              "\"vmused\": %llu",
-                              smc->anonpgkb,
-                              smc->slabkb,
-                              smc->kstackkb,
-                              smc->pgtblkb,
-                              smc->vmusedkb);
-               }
+               json_print_ram_memory_stats(smc, DISPLAY_MEM_ALL(a->opt_flags));
        }
 
        if (DISPLAY_SWAP(a->opt_flags)) {
-
                if (sep) {
                        printf(", ");
                }
-
-               printf("\"swpfree\": %llu, "
-                      "\"swpused\": %llu, "
-                      "\"swpused-percent\": %.2f, "
-                      "\"swpcad\": %llu, "
-                      "\"swpcad-percent\": %.2f",
-                      smc->frskb,
-                      smc->tlskb - smc->frskb,
-                      smc->tlskb ?
-                      SP_VALUE(smc->frskb, smc->tlskb, smc->tlskb) :
-                      0.0,
-                      smc->caskb,
-                      (smc->tlskb - smc->frskb) ?
-                      SP_VALUE(0, smc->caskb, smc->tlskb - smc->frskb) :
-                      0.0);
+               json_print_swap_memory_stats(smc);
        }
 
        printf("}");
index 8f89d0b8f25746e033e9a29969f3250d904e6460..712c03dc83894315ea692e286de34a8914f3e3ae 100644 (file)
@@ -71,7 +71,206 @@ void pcp_def_percpu_int_metrics(struct activity *a, int cpu)
 }
 
 /*
+ * **************************************************************************
+ * Define PCP metrics for global CPU statistics.
+ ***************************************************************************
+ */
+void pcp_def_global_cpu_metrics(void)
+{
+#ifdef HAVE_PCP
+       pmiAddMetric("kernel.all.cpu.user",
+                    pmiID(60, 0, 20), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_COUNTER,
+                    pmiUnits(0, 1, 0, 0, PM_TIME_MSEC, 0));
+
+       pmiAddMetric("kernel.all.cpu.nice",
+                    pmiID(60, 0, 21), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_COUNTER,
+                    pmiUnits(0, 1, 0, 0, PM_TIME_MSEC, 0));
+
+       pmiAddMetric("kernel.all.cpu.sys",
+                    pmiID(60, 0, 22), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_COUNTER,
+                    pmiUnits(0, 1, 0, 0, PM_TIME_MSEC, 0));
+
+       pmiAddMetric("kernel.all.cpu.idle",
+                    pmiID(60, 0, 23), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_COUNTER,
+                    pmiUnits(0, 1, 0, 0, PM_TIME_MSEC, 0));
+
+       pmiAddMetric("kernel.all.cpu.iowait",
+                    pmiID(60, 0, 25), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_COUNTER,
+                    pmiUnits(0, 1, 0, 0, PM_TIME_MSEC, 0));
+
+       pmiAddMetric("kernel.all.cpu.steal",
+                    pmiID(60, 0, 55), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_COUNTER,
+                    pmiUnits(0, 1, 0, 0, PM_TIME_MSEC, 0));
+
+       pmiAddMetric("kernel.all.cpu.irq.hard",
+                    pmiID(60, 0, 54), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_COUNTER,
+                    pmiUnits(0, 1, 0, 0, PM_TIME_MSEC, 0));
+
+       pmiAddMetric("kernel.all.cpu.irq.soft",
+                    pmiID(60, 0, 53), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_COUNTER,
+                    pmiUnits(0, 1, 0, 0, PM_TIME_MSEC, 0));
+
+       pmiAddMetric("kernel.all.cpu.irq.total",
+                    pmiID(60, 0, 34), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_COUNTER,
+                    pmiUnits(0, 1, 0, 0, PM_TIME_MSEC, 0));
+
+       pmiAddMetric("kernel.all.cpu.guest",
+                    pmiID(60, 0, 60), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_COUNTER,
+                    pmiUnits(0, 1, 0, 0, PM_TIME_MSEC, 0));
+
+       pmiAddMetric("kernel.all.cpu.guest_nice",
+                    pmiID(60, 0, 81), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_COUNTER,
+                    pmiUnits(0, 1, 0, 0, PM_TIME_MSEC, 0));
+#endif /* HAVE_PCP */
+}
+
+#ifdef HAVE_PCP
+/*
+ * **************************************************************************
+ * Define PCP metrics for per-CPU statistics.
+ *
+ * IN
+ * @indom      Instance domain.
+ ***************************************************************************
+ */
+void pcp_def_percpu_metrics(pmInDom indom)
+{
+       pmiAddMetric("kernel.percpu.cpu.user",
+                    pmiID(60, 0, 0), PM_TYPE_U64, indom, PM_SEM_COUNTER,
+                    pmiUnits(0, 1, 0, 0, PM_TIME_MSEC, 0));
+
+       pmiAddMetric("kernel.percpu.cpu.nice",
+                    pmiID(60, 0, 1), PM_TYPE_U64, indom, PM_SEM_COUNTER,
+                    pmiUnits(0, 1, 0, 0, PM_TIME_MSEC, 0));
+
+       pmiAddMetric("kernel.percpu.cpu.sys",
+                    pmiID(60, 0, 2), PM_TYPE_U64, indom, PM_SEM_COUNTER,
+                    pmiUnits(0, 1, 0, 0, PM_TIME_MSEC, 0));
+
+       pmiAddMetric("kernel.percpu.cpu.idle",
+                    pmiID(60, 0, 3), PM_TYPE_U64, indom, PM_SEM_COUNTER,
+                    pmiUnits(0, 1, 0, 0, PM_TIME_MSEC, 0));
+
+       pmiAddMetric("kernel.percpu.cpu.iowait",
+                    pmiID(60, 0, 30), PM_TYPE_U64, indom, PM_SEM_COUNTER,
+                    pmiUnits(0, 1, 0, 0, PM_TIME_MSEC, 0));
+
+       pmiAddMetric("kernel.percpu.cpu.steal",
+                    pmiID(60, 0, 58), PM_TYPE_U64, indom, PM_SEM_COUNTER,
+                    pmiUnits(0, 1, 0, 0, PM_TIME_MSEC, 0));
+
+       pmiAddMetric("kernel.percpu.cpu.irq.hard",
+                    pmiID(60, 0, 57), PM_TYPE_U64, indom, PM_SEM_COUNTER,
+                    pmiUnits(0, 1, 0, 0, PM_TIME_MSEC, 0));
+
+       pmiAddMetric("kernel.percpu.cpu.irq.soft",
+                    pmiID(60, 0, 56), PM_TYPE_U64, indom, PM_SEM_COUNTER,
+                    pmiUnits(0, 1, 0, 0, PM_TIME_MSEC, 0));
+
+       pmiAddMetric("kernel.percpu.cpu.irq.total",
+                    pmiID(60, 0, 35), PM_TYPE_U64, indom, PM_SEM_COUNTER,
+                    pmiUnits(0, 1, 0, 0, PM_TIME_MSEC, 0));
+
+       pmiAddMetric("kernel.percpu.cpu.guest",
+                    pmiID(60, 0, 61), PM_TYPE_U64, indom, PM_SEM_COUNTER,
+                    pmiUnits(0, 1, 0, 0, PM_TIME_MSEC, 0));
+
+       pmiAddMetric("kernel.percpu.cpu.guest_nice",
+                    pmiID(60, 0, 83), PM_TYPE_U64, indom, PM_SEM_COUNTER,
+                    pmiUnits(0, 1, 0, 0, PM_TIME_MSEC, 0));
+}
+#endif /* HAVE_PCP */
+
+/*
+ * **************************************************************************
+ * Define PCP metrics for global CPU softnet statistics.
  ***************************************************************************
+ */
+void pcp_def_global_softnet_metrics(void)
+{
+#ifdef HAVE_PCP
+       pmiAddMetric("network.softnet.processed",
+                    pmiID(60, 57, 0), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_COUNTER,
+                    pmiUnits(0, 0, 1, 0, 0, PM_COUNT_ONE));
+
+       pmiAddMetric("network.softnet.dropped",
+                    pmiID(60, 57, 1), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_COUNTER,
+                    pmiUnits(0, 0, 1, 0, 0, PM_COUNT_ONE));
+
+       pmiAddMetric("network.softnet.time_squeeze",
+                    pmiID(60, 57, 2), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_COUNTER,
+                    pmiUnits(0, 0, 1, 0, 0, PM_COUNT_ONE));
+
+       pmiAddMetric("network.softnet.received_rps",
+                    pmiID(60, 57, 4), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_COUNTER,
+                    pmiUnits(0, 0, 1, 0, 0, PM_COUNT_ONE));
+
+       pmiAddMetric("network.softnet.flow_limit",
+                    pmiID(60, 57, 5), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_COUNTER,
+                    pmiUnits(0, 0, 1, 0, 0, PM_COUNT_ONE));
+
+       pmiAddMetric("network.softnet.backlog_length",
+                    pmiID(60, 57, 12), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_COUNTER,
+                    pmiUnits(0, 0, 1, 0, 0, PM_COUNT_ONE));
+#endif /* HAVE_PCP */
+}
+
+#ifdef HAVE_PCP
+/*
+ * **************************************************************************
+ * Define PCP metrics for per-CPU softnet statistics.
+ *
+ * IN
+ * @indom      Instance domain.
+ ***************************************************************************
+ */
+void pcp_def_percpu_softnet_metrics(pmInDom indom)
+{
+       pmiAddMetric("network.softnet.percpu.processed",
+                    pmiID(60, 57, 6), PM_TYPE_U64, indom, PM_SEM_COUNTER,
+                    pmiUnits(0, 0, 1, 0, 0, PM_COUNT_ONE));
+
+       pmiAddMetric("network.softnet.percpu.dropped",
+                    pmiID(60, 57, 7), PM_TYPE_U64, indom, PM_SEM_COUNTER,
+                    pmiUnits(0, 0, 1, 0, 0, PM_COUNT_ONE));
+
+       pmiAddMetric("network.softnet.percpu.time_squeeze",
+                    pmiID(60, 57, 8), PM_TYPE_U64, indom, PM_SEM_COUNTER,
+                    pmiUnits(0, 0, 1, 0, 0, PM_COUNT_ONE));
+
+       pmiAddMetric("network.softnet.percpu.received_rps",
+                    pmiID(60, 57, 10), PM_TYPE_U64, indom, PM_SEM_COUNTER,
+                    pmiUnits(0, 0, 1, 0, 0, PM_COUNT_ONE));
+
+       pmiAddMetric("network.softnet.percpu.flow_limit",
+                    pmiID(60, 57, 11), PM_TYPE_U64, indom, PM_SEM_COUNTER,
+                    pmiUnits(0, 0, 1, 0, 0, PM_COUNT_ONE));
+
+       pmiAddMetric("network.softnet.percpu.backlog_length",
+                    pmiID(60, 57, 13), PM_TYPE_U64, indom, PM_SEM_COUNTER,
+                    pmiUnits(0, 0, 1, 0, 0, PM_COUNT_ONE));
+}
+#endif /* HAVE_PCP */
+
+#ifdef HAVE_PCP
+/*
+ * **************************************************************************
+ * Define PCP metrics for CPU frequency statistics.
+ *
+ * IN
+ * @indom      Instance domain.
+ ***************************************************************************
+ */
+void pcp_def_pwr_cpufreq_metrics(pmInDom indom)
+{
+       pmiAddMetric("hinv.cpu.clock",
+                    pmiID(60, 18, 0), PM_TYPE_FLOAT, indom, PM_SEM_DISCRETE,
+                    pmiUnits(0, -1, 0, 0, PM_TIME_USEC, 0));
+}
+#endif /* HAVE_PCP */
+
+/*
+ ***********************************************global****************************
  * Define PCP metrics for CPU related statistics.
  *
  * IN:
@@ -99,76 +298,12 @@ void pcp_def_cpu_metrics(struct activity *a)
                if (!i) {
                        if (a->id == A_CPU) {
                                /* This is CPU "all" */
-                               pmiAddMetric("kernel.all.cpu.user",
-                                            pmiID(60, 0, 20), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_COUNTER,
-                                            pmiUnits(0, 1, 0, 0, PM_TIME_MSEC, 0));
-
-                               pmiAddMetric("kernel.all.cpu.nice",
-                                            pmiID(60, 0, 21), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_COUNTER,
-                                            pmiUnits(0, 1, 0, 0, PM_TIME_MSEC, 0));
-
-                               pmiAddMetric("kernel.all.cpu.sys",
-                                            pmiID(60, 0, 22), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_COUNTER,
-                                            pmiUnits(0, 1, 0, 0, PM_TIME_MSEC, 0));
-
-                               pmiAddMetric("kernel.all.cpu.idle",
-                                            pmiID(60, 0, 23), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_COUNTER,
-                                            pmiUnits(0, 1, 0, 0, PM_TIME_MSEC, 0));
-
-                               pmiAddMetric("kernel.all.cpu.iowait",
-                                            pmiID(60, 0, 25), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_COUNTER,
-                                            pmiUnits(0, 1, 0, 0, PM_TIME_MSEC, 0));
-
-                               pmiAddMetric("kernel.all.cpu.steal",
-                                            pmiID(60, 0, 55), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_COUNTER,
-                                            pmiUnits(0, 1, 0, 0, PM_TIME_MSEC, 0));
-
-                               pmiAddMetric("kernel.all.cpu.irq.hard",
-                                            pmiID(60, 0, 54), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_COUNTER,
-                                            pmiUnits(0, 1, 0, 0, PM_TIME_MSEC, 0));
-
-                               pmiAddMetric("kernel.all.cpu.irq.soft",
-                                            pmiID(60, 0, 53), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_COUNTER,
-                                            pmiUnits(0, 1, 0, 0, PM_TIME_MSEC, 0));
-
-                               pmiAddMetric("kernel.all.cpu.irq.total",
-                                            pmiID(60, 0, 34), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_COUNTER,
-                                            pmiUnits(0, 1, 0, 0, PM_TIME_MSEC, 0));
-
-                               pmiAddMetric("kernel.all.cpu.guest",
-                                            pmiID(60, 0, 60), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_COUNTER,
-                                            pmiUnits(0, 1, 0, 0, PM_TIME_MSEC, 0));
-
-                               pmiAddMetric("kernel.all.cpu.guest_nice",
-                                            pmiID(60, 0, 81), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_COUNTER,
-                                            pmiUnits(0, 1, 0, 0, PM_TIME_MSEC, 0));
+                               pcp_def_global_cpu_metrics();
                        }
 
                        else if (a->id == A_NET_SOFT) {
                                /* Create metrics for A_NET_SOFT */
-                               pmiAddMetric("network.softnet.processed",
-                                            pmiID(60, 57, 0), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_COUNTER,
-                                            pmiUnits(0, 0, 1, 0, 0, PM_COUNT_ONE));
-
-                               pmiAddMetric("network.softnet.dropped",
-                                            pmiID(60, 57, 1), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_COUNTER,
-                                            pmiUnits(0, 0, 1, 0, 0, PM_COUNT_ONE));
-
-                               pmiAddMetric("network.softnet.time_squeeze",
-                                            pmiID(60, 57, 2), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_COUNTER,
-                                            pmiUnits(0, 0, 1, 0, 0, PM_COUNT_ONE));
-
-                               pmiAddMetric("network.softnet.received_rps",
-                                            pmiID(60, 57, 4), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_COUNTER,
-                                            pmiUnits(0, 0, 1, 0, 0, PM_COUNT_ONE));
-
-                               pmiAddMetric("network.softnet.flow_limit",
-                                            pmiID(60, 57, 5), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_COUNTER,
-                                            pmiUnits(0, 0, 1, 0, 0, PM_COUNT_ONE));
-
-                               pmiAddMetric("network.softnet.backlog_length",
-                                            pmiID(60, 57, 12), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_COUNTER,
-                                            pmiUnits(0, 0, 1, 0, 0, PM_COUNT_ONE));
+                               pcp_def_global_softnet_metrics();
                        }
                }
                else {
@@ -192,83 +327,17 @@ void pcp_def_cpu_metrics(struct activity *a)
                        else if (first) {
                                if (a->id == A_CPU) {
                                        /* Create metrics for A_CPU */
-                                       pmiAddMetric("kernel.percpu.cpu.user",
-                                                    pmiID(60, 0, 0), PM_TYPE_U64, indom, PM_SEM_COUNTER,
-                                                    pmiUnits(0, 1, 0, 0, PM_TIME_MSEC, 0));
-
-                                       pmiAddMetric("kernel.percpu.cpu.nice",
-                                                    pmiID(60, 0, 1), PM_TYPE_U64, indom, PM_SEM_COUNTER,
-                                                    pmiUnits(0, 1, 0, 0, PM_TIME_MSEC, 0));
-
-                                       pmiAddMetric("kernel.percpu.cpu.sys",
-                                                    pmiID(60, 0, 2), PM_TYPE_U64, indom, PM_SEM_COUNTER,
-                                                    pmiUnits(0, 1, 0, 0, PM_TIME_MSEC, 0));
-
-                                       pmiAddMetric("kernel.percpu.cpu.idle",
-                                                    pmiID(60, 0, 3), PM_TYPE_U64, indom, PM_SEM_COUNTER,
-                                                    pmiUnits(0, 1, 0, 0, PM_TIME_MSEC, 0));
-
-                                       pmiAddMetric("kernel.percpu.cpu.iowait",
-                                                    pmiID(60, 0, 30), PM_TYPE_U64, indom, PM_SEM_COUNTER,
-                                                    pmiUnits(0, 1, 0, 0, PM_TIME_MSEC, 0));
-
-                                       pmiAddMetric("kernel.percpu.cpu.steal",
-                                                    pmiID(60, 0, 58), PM_TYPE_U64, indom, PM_SEM_COUNTER,
-                                                    pmiUnits(0, 1, 0, 0, PM_TIME_MSEC, 0));
-
-                                       pmiAddMetric("kernel.percpu.cpu.irq.hard",
-                                                    pmiID(60, 0, 57), PM_TYPE_U64, indom, PM_SEM_COUNTER,
-                                                    pmiUnits(0, 1, 0, 0, PM_TIME_MSEC, 0));
-
-                                       pmiAddMetric("kernel.percpu.cpu.irq.soft",
-                                                    pmiID(60, 0, 56), PM_TYPE_U64, indom, PM_SEM_COUNTER,
-                                                    pmiUnits(0, 1, 0, 0, PM_TIME_MSEC, 0));
-
-                                       pmiAddMetric("kernel.percpu.cpu.irq.total",
-                                                    pmiID(60, 0, 35), PM_TYPE_U64, indom, PM_SEM_COUNTER,
-                                                    pmiUnits(0, 1, 0, 0, PM_TIME_MSEC, 0));
-
-                                       pmiAddMetric("kernel.percpu.cpu.guest",
-                                                    pmiID(60, 0, 61), PM_TYPE_U64, indom, PM_SEM_COUNTER,
-                                                    pmiUnits(0, 1, 0, 0, PM_TIME_MSEC, 0));
-
-                                       pmiAddMetric("kernel.percpu.cpu.guest_nice",
-                                                    pmiID(60, 0, 83), PM_TYPE_U64, indom, PM_SEM_COUNTER,
-                                                    pmiUnits(0, 1, 0, 0, PM_TIME_MSEC, 0));
+                                       pcp_def_percpu_metrics(indom);
                                }
 
                                else if (a->id == A_PWR_CPU) {
                                        /* Create metric for A_PWR_CPU */
-                                       pmiAddMetric("hinv.cpu.clock",
-                                                    pmiID(60, 18, 0), PM_TYPE_FLOAT, indom, PM_SEM_DISCRETE,
-                                                    pmiUnits(0, -1, 0, 0, PM_TIME_USEC, 0));
+                                       pcp_def_pwr_cpufreq_metrics(indom);
                                }
 
                                else if (a->id == A_NET_SOFT) {
-                                       /* Create metrics for a_NET_SOFT */
-                                       pmiAddMetric("network.softnet.percpu.processed",
-                                                    pmiID(60, 57, 6), PM_TYPE_U64, indom, PM_SEM_COUNTER,
-                                                    pmiUnits(0, 0, 1, 0, 0, PM_COUNT_ONE));
-
-                                       pmiAddMetric("network.softnet.percpu.dropped",
-                                                    pmiID(60, 57, 7), PM_TYPE_U64, indom, PM_SEM_COUNTER,
-                                                    pmiUnits(0, 0, 1, 0, 0, PM_COUNT_ONE));
-
-                                       pmiAddMetric("network.softnet.percpu.time_squeeze",
-                                                    pmiID(60, 57, 8), PM_TYPE_U64, indom, PM_SEM_COUNTER,
-                                                    pmiUnits(0, 0, 1, 0, 0, PM_COUNT_ONE));
-
-                                       pmiAddMetric("network.softnet.percpu.received_rps",
-                                                    pmiID(60, 57, 10), PM_TYPE_U64, indom, PM_SEM_COUNTER,
-                                                    pmiUnits(0, 0, 1, 0, 0, PM_COUNT_ONE));
-
-                                       pmiAddMetric("network.softnet.percpu.flow_limit",
-                                                    pmiID(60, 57, 11), PM_TYPE_U64, indom, PM_SEM_COUNTER,
-                                                    pmiUnits(0, 0, 1, 0, 0, PM_COUNT_ONE));
-
-                                       pmiAddMetric("network.softnet.percpu.backlog_length",
-                                                    pmiID(60, 57, 13), PM_TYPE_U64, indom, PM_SEM_COUNTER,
-                                                    pmiUnits(0, 0, 1, 0, 0, PM_COUNT_ONE));
+                                       /* Create metrics for A_NET_SOFT */
+                                       pcp_def_percpu_softnet_metrics(indom);
                                }
 
                                first = FALSE;
@@ -446,99 +515,124 @@ void pcp_def_io_metrics(void)
 }
 
 /*
- ***************************************************************************
- * Define PCP metrics for memory statistics.
+ * **************************************************************************
+ * Define PCP metrics for RAM memory utilization.
  *
  * IN:
  * @a          Activity structure with statistics.
  ***************************************************************************
  */
-void pcp_def_memory_metrics(struct activity *a)
+void pcp_def_ram_memory_metrics(struct activity *a)
 {
 #ifdef HAVE_PCP
-       if (DISPLAY_MEMORY(a->opt_flags)) {
+       pmiAddMetric("hinv.physmem",
+                    pmiID(60, 1, 9), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_DISCRETE,
+                    pmiUnits(1, 0, 0, PM_SPACE_MBYTE, 0, 0));
 
-               pmiAddMetric("hinv.physmem",
-                            pmiID(60, 1, 9), PM_TYPE_U32, PM_INDOM_NULL, PM_SEM_DISCRETE,
-                            pmiUnits(1, 0, 0, PM_SPACE_MBYTE, 0, 0));
+       pmiAddMetric("mem.physmem",
+                    pmiID(60, 1, 0), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_DISCRETE,
+                    pmiUnits(1, 0, 0, PM_SPACE_KBYTE, 0, 0));
 
-               pmiAddMetric("mem.physmem",
-                            pmiID(60, 1, 0), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_DISCRETE,
-                            pmiUnits(1, 0, 0, PM_SPACE_KBYTE, 0, 0));
+       pmiAddMetric("mem.util.free",
+                    pmiID(60, 1, 2), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_INSTANT,
+                    pmiUnits(1, 0, 0, PM_SPACE_KBYTE, 0, 0));
 
-               pmiAddMetric("mem.util.free",
-                            pmiID(60, 1, 2), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_INSTANT,
-                            pmiUnits(1, 0, 0, PM_SPACE_KBYTE, 0, 0));
+       pmiAddMetric("mem.util.available",
+                    pmiID(60, 1, 58), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_INSTANT,
+                    pmiUnits(1, 0, 0, PM_SPACE_KBYTE, 0, 0));
 
-               pmiAddMetric("mem.util.available",
-                            pmiID(60, 1, 58), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_INSTANT,
-                            pmiUnits(1, 0, 0, PM_SPACE_KBYTE, 0, 0));
+       pmiAddMetric("mem.util.used",
+                    pmiID(60, 1, 1), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_INSTANT,
+                    pmiUnits(1, 0, 0, PM_SPACE_KBYTE, 0, 0));
 
-               pmiAddMetric("mem.util.used",
-                            pmiID(60, 1, 1), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_INSTANT,
-                            pmiUnits(1, 0, 0, PM_SPACE_KBYTE, 0, 0));
+       pmiAddMetric("mem.util.bufmem",
+                    pmiID(60, 1, 4), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_INSTANT,
+                    pmiUnits(1, 0, 0, PM_SPACE_KBYTE, 0, 0));
 
-               pmiAddMetric("mem.util.bufmem",
-                            pmiID(60, 1, 4), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_INSTANT,
-                            pmiUnits(1, 0, 0, PM_SPACE_KBYTE, 0, 0));
+       pmiAddMetric("mem.util.cached",
+                    pmiID(60, 1, 5), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_INSTANT,
+                    pmiUnits(1, 0, 0, PM_SPACE_KBYTE, 0, 0));
 
-               pmiAddMetric("mem.util.cached",
-                            pmiID(60, 1, 5), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_INSTANT,
-                            pmiUnits(1, 0, 0, PM_SPACE_KBYTE, 0, 0));
+       pmiAddMetric("mem.util.committed_AS",
+                    pmiID(60, 1, 26), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_INSTANT,
+                    pmiUnits(1, 0, 0, PM_SPACE_KBYTE, 0, 0));
 
-               pmiAddMetric("mem.util.committed_AS",
-                            pmiID(60, 1, 26), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_INSTANT,
-                            pmiUnits(1, 0, 0, PM_SPACE_KBYTE, 0, 0));
+       pmiAddMetric("mem.util.active",
+                    pmiID(60, 1, 14), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_INSTANT,
+                    pmiUnits(1, 0, 0, PM_SPACE_KBYTE, 0, 0));
+
+       pmiAddMetric("mem.util.inactive",
+                    pmiID(60, 1, 15), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_INSTANT,
+                    pmiUnits(1, 0, 0, PM_SPACE_KBYTE, 0, 0));
+
+       pmiAddMetric("mem.util.dirty",
+                    pmiID(60, 1, 22), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_INSTANT,
+                    pmiUnits(1, 0, 0, PM_SPACE_KBYTE, 0, 0));
+
+       if (DISPLAY_MEM_ALL(a->opt_flags)) {
 
-               pmiAddMetric("mem.util.active",
-                            pmiID(60, 1, 14), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_INSTANT,
+               pmiAddMetric("mem.util.anonpages",
+                            pmiID(60, 1, 30), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_INSTANT,
                             pmiUnits(1, 0, 0, PM_SPACE_KBYTE, 0, 0));
 
-               pmiAddMetric("mem.util.inactive",
-                            pmiID(60, 1, 15), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_INSTANT,
+               pmiAddMetric("mem.util.slab",
+                            pmiID(60, 1, 25), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_INSTANT,
                             pmiUnits(1, 0, 0, PM_SPACE_KBYTE, 0, 0));
 
-               pmiAddMetric("mem.util.dirty",
-                            pmiID(60, 1, 22), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_INSTANT,
+               pmiAddMetric("mem.util.kernelStack",
+                            pmiID(60, 1, 43), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_INSTANT,
                             pmiUnits(1, 0, 0, PM_SPACE_KBYTE, 0, 0));
 
-               if (DISPLAY_MEM_ALL(a->opt_flags)) {
+               pmiAddMetric("mem.util.pageTables",
+                            pmiID(60, 1, 27), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_INSTANT,
+                            pmiUnits(1, 0, 0, PM_SPACE_KBYTE, 0, 0));
 
-                       pmiAddMetric("mem.util.anonpages",
-                                    pmiID(60, 1, 30), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_INSTANT,
-                                    pmiUnits(1, 0, 0, PM_SPACE_KBYTE, 0, 0));
+               pmiAddMetric("mem.util.vmallocUsed",
+                            pmiID(60, 1, 51), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_INSTANT,
+                            pmiUnits(1, 0, 0, PM_SPACE_KBYTE, 0, 0));
+       }
+#endif /* HAVE_PCP */
+}
 
-                       pmiAddMetric("mem.util.slab",
-                                    pmiID(60, 1, 25), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_INSTANT,
-                                    pmiUnits(1, 0, 0, PM_SPACE_KBYTE, 0, 0));
+/*
+ * **************************************************************************
+ * Define PCP metrics for swap memory utilization.
+ ***************************************************************************
+ */
+void pcp_def_swap_memory_metrics(void)
+{
+#ifdef HAVE_PCP
+       pmiAddMetric("mem.util.swapFree",
+                    pmiID(60, 1, 21), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_INSTANT,
+                    pmiUnits(1, 0, 0, PM_SPACE_KBYTE, 0, 0));
 
-                       pmiAddMetric("mem.util.kernelStack",
-                                    pmiID(60, 1, 43), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_INSTANT,
-                                    pmiUnits(1, 0, 0, PM_SPACE_KBYTE, 0, 0));
+       pmiAddMetric("mem.util.swapTotal",
+                    pmiID(60, 1, 20), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_INSTANT,
+                    pmiUnits(1, 0, 0, PM_SPACE_KBYTE, 0, 0));
 
-                       pmiAddMetric("mem.util.pageTables",
-                                    pmiID(60, 1, 27), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_INSTANT,
-                                    pmiUnits(1, 0, 0, PM_SPACE_KBYTE, 0, 0));
+       pmiAddMetric("mem.util.swapCached",
+                    pmiID(60, 1, 13), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_INSTANT,
+                    pmiUnits(1, 0, 0, PM_SPACE_KBYTE, 0, 0));
+#endif /* HAVE_PCP */
+}
 
-                       pmiAddMetric("mem.util.vmallocUsed",
-                                    pmiID(60, 1, 51), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_INSTANT,
-                                    pmiUnits(1, 0, 0, PM_SPACE_KBYTE, 0, 0));
-               }
+/*
+ ***************************************************************************
+ * Define PCP metrics for memory statistics.
+ *
+ * IN:
+ * @a          Activity structure with statistics.
+ ***************************************************************************
+ */
+void pcp_def_memory_metrics(struct activity *a)
+{
+#ifdef HAVE_PCP
+       if (DISPLAY_MEMORY(a->opt_flags)) {
+               pcp_def_ram_memory_metrics(a);
        }
 
        if (DISPLAY_SWAP(a->opt_flags)) {
-
-               pmiAddMetric("mem.util.swapFree",
-                            pmiID(60, 1, 21), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_INSTANT,
-                            pmiUnits(1, 0, 0, PM_SPACE_KBYTE, 0, 0));
-
-               pmiAddMetric("mem.util.swapTotal",
-                            pmiID(60, 1, 20), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_INSTANT,
-                            pmiUnits(1, 0, 0, PM_SPACE_KBYTE, 0, 0));
-
-               pmiAddMetric("mem.util.swapCached",
-                            pmiID(60, 1, 13), PM_TYPE_U64, PM_INDOM_NULL, PM_SEM_INSTANT,
-                            pmiUnits(1, 0, 0, PM_SPACE_KBYTE, 0, 0));
+               pcp_def_swap_memory_metrics();
        }
 #endif /* HAVE_PCP */
 }
@@ -1864,6 +1958,85 @@ void pcp_def_fchost_metrics(struct activity *a)
 #endif /* HAVE_PCP */
 }
 
+#ifdef HAVE_PCP
+/*
+ * **************************************************************************
+ * Define PCP metrics for pressure-stall CPU statistics.
+ *
+ * IN
+ * @indom      Instance domain.
+ ***************************************************************************
+ */
+void pcp_def_psicpu_metrics(pmInDom indom)
+{
+       pmiAddMetric("kernel.all.pressure.cpu.some.total",
+                    pmiID(60, 83, 1), PM_TYPE_U64, indom, PM_SEM_COUNTER,
+                    pmiUnits(0, 1, 0, 0, PM_TIME_USEC, 0));
+
+       pmiAddMetric("kernel.all.pressure.cpu.some.avg",
+                    pmiID(60, 83, 0), PM_TYPE_FLOAT, PM_INDOM_NULL, PM_SEM_INSTANT,
+                    pmiUnits(0, 0, 0, 0, 0, 0));
+}
+#endif /* HAVE_PCP */
+
+#ifdef HAVE_PCP
+/*
+ * **************************************************************************
+ * Define PCP metrics for pressure-stall I/O statistics.
+ *
+ * IN
+ * @indom      Instance domain.
+ ***************************************************************************
+ */
+void pcp_def_psiio_metrics(pmInDom indom)
+{
+       pmiAddMetric("kernel.all.pressure.io.some.total",
+                    pmiID(60, 85, 1), PM_TYPE_U64, indom, PM_SEM_COUNTER,
+                    pmiUnits(0, 1, 0, 0, PM_TIME_USEC, 0));
+
+       pmiAddMetric("kernel.all.pressure.io.some.avg",
+                    pmiID(60, 85, 0), PM_TYPE_FLOAT, PM_INDOM_NULL, PM_SEM_INSTANT,
+                    pmiUnits(0, 0, 0, 0, 0, 0));
+
+       pmiAddMetric("kernel.all.pressure.io.full.total",
+                    pmiID(60, 85, 3), PM_TYPE_U64, indom, PM_SEM_COUNTER,
+                    pmiUnits(0, 1, 0, 0, PM_TIME_USEC, 0));
+
+       pmiAddMetric("kernel.all.pressure.io.full.avg",
+                    pmiID(60, 85, 2), PM_TYPE_FLOAT, PM_INDOM_NULL, PM_SEM_INSTANT,
+                    pmiUnits(0, 0, 0, 0, 0, 0));
+}
+#endif /* HAVE_PCP */
+
+#ifdef HAVE_PCP
+/*
+ * **************************************************************************
+ * Define PCP metrics for pressure-stall memory statistics.
+ *
+ * IN
+ * @indom      Instance domain.
+ ***************************************************************************
+ */
+void pcp_def_psimem_metrics(pmInDom indom)
+{
+       pmiAddMetric("kernel.all.pressure.memory.some.total",
+                    pmiID(60, 84, 1), PM_TYPE_U64, indom, PM_SEM_COUNTER,
+                    pmiUnits(0, 1, 0, 0, PM_TIME_USEC, 0));
+
+       pmiAddMetric("kernel.all.pressure.memory.some.avg",
+                    pmiID(60, 84, 0), PM_TYPE_FLOAT, PM_INDOM_NULL, PM_SEM_INSTANT,
+                    pmiUnits(0, 0, 0, 0, 0, 0));
+
+       pmiAddMetric("kernel.all.pressure.memory.full.total",
+                    pmiID(60, 84, 3), PM_TYPE_U64, indom, PM_SEM_COUNTER,
+                    pmiUnits(0, 1, 0, 0, PM_TIME_USEC, 0));
+
+       pmiAddMetric("kernel.all.pressure.memory.full.avg",
+                    pmiID(60, 84, 2), PM_TYPE_FLOAT, PM_INDOM_NULL, PM_SEM_INSTANT,
+                    pmiUnits(0, 0, 0, 0, 0, 0));
+}
+#endif /* HAVE_PCP */
+
 /*
  ***************************************************************************
  * Define PCP metrics for pressure-stall statistics.
@@ -1888,49 +2061,15 @@ void pcp_def_psi_metrics(struct activity *a)
 
        if (a->id == A_PSI_CPU) {
                /* Create metrics for A_PSI_CPU */
-               pmiAddMetric("kernel.all.pressure.cpu.some.total",
-                            pmiID(60, 83, 1), PM_TYPE_U64, indom, PM_SEM_COUNTER,
-                            pmiUnits(0, 1, 0, 0, PM_TIME_USEC, 0));
-
-               pmiAddMetric("kernel.all.pressure.cpu.some.avg",
-                            pmiID(60, 83, 0), PM_TYPE_FLOAT, PM_INDOM_NULL, PM_SEM_INSTANT,
-                            pmiUnits(0, 0, 0, 0, 0, 0));
+               pcp_def_psicpu_metrics(indom);
        }
        else if (a->id == A_PSI_IO) {
                /* Create metrics for A_PSI_IO */
-               pmiAddMetric("kernel.all.pressure.io.some.total",
-                            pmiID(60, 85, 1), PM_TYPE_U64, indom, PM_SEM_COUNTER,
-                            pmiUnits(0, 1, 0, 0, PM_TIME_USEC, 0));
-
-               pmiAddMetric("kernel.all.pressure.io.some.avg",
-                            pmiID(60, 85, 0), PM_TYPE_FLOAT, PM_INDOM_NULL, PM_SEM_INSTANT,
-                            pmiUnits(0, 0, 0, 0, 0, 0));
-
-               pmiAddMetric("kernel.all.pressure.io.full.total",
-                            pmiID(60, 85, 3), PM_TYPE_U64, indom, PM_SEM_COUNTER,
-                            pmiUnits(0, 1, 0, 0, PM_TIME_USEC, 0));
-
-               pmiAddMetric("kernel.all.pressure.io.full.avg",
-                            pmiID(60, 85, 2), PM_TYPE_FLOAT, PM_INDOM_NULL, PM_SEM_INSTANT,
-                            pmiUnits(0, 0, 0, 0, 0, 0));
+               pcp_def_psiio_metrics(indom);
        }
        else {
                /* Create metrics for A_PSI_MEM */
-               pmiAddMetric("kernel.all.pressure.memory.some.total",
-                            pmiID(60, 84, 1), PM_TYPE_U64, indom, PM_SEM_COUNTER,
-                            pmiUnits(0, 1, 0, 0, PM_TIME_USEC, 0));
-
-               pmiAddMetric("kernel.all.pressure.memory.some.avg",
-                            pmiID(60, 84, 0), PM_TYPE_FLOAT, PM_INDOM_NULL, PM_SEM_INSTANT,
-                            pmiUnits(0, 0, 0, 0, 0, 0));
-
-               pmiAddMetric("kernel.all.pressure.memory.full.total",
-                            pmiID(60, 84, 3), PM_TYPE_U64, indom, PM_SEM_COUNTER,
-                            pmiUnits(0, 1, 0, 0, PM_TIME_USEC, 0));
-
-               pmiAddMetric("kernel.all.pressure.memory.full.avg",
-                            pmiID(60, 84, 2), PM_TYPE_FLOAT, PM_INDOM_NULL, PM_SEM_INSTANT,
-                            pmiUnits(0, 0, 0, 0, 0, 0));
+               pcp_def_psimem_metrics(indom);
        }
 #endif /* HAVE_PCP */
 }
index 069166a2b735f55f71a3a50450827d1278cde15c..a1217f1bae73107be4edb070a995d54fa054ae96 100644 (file)
@@ -370,85 +370,116 @@ __print_funct_t pcp_print_io_stats(struct activity *a, int curr)
 }
 
 /*
- ***************************************************************************
- * Display memory statistics in PCP format.
+ * **************************************************************************
+ * Display RAM memory utilization in PCP format.
  *
  * IN:
- * @a          Activity structure with statistics.
- * @curr       Index in array for current sample statistics.
+ * @smc                Structure with statistics.
+ * @dispall    TRUE if all memory fields should be displayed.
  ***************************************************************************
  */
-__print_funct_t pcp_print_memory_stats(struct activity *a, int curr)
+void pcp_print_ram_memory_stats(struct stats_memory *smc, int dispall)
 {
 #ifdef HAVE_PCP
        char buf[64];
-       struct stats_memory
-               *smc = (struct stats_memory *) a->buf[curr];
 
-       if (DISPLAY_MEMORY(a->opt_flags)) {
+       snprintf(buf, sizeof(buf), "%lu", (unsigned long) (smc->tlmkb >> 10));
+       pmiPutValue("hinv.physmem", NULL, buf);
 
-               snprintf(buf, sizeof(buf), "%lu", (unsigned long) (smc->tlmkb >> 10));
-               pmiPutValue("hinv.physmem", NULL, buf);
+       snprintf(buf, sizeof(buf), "%llu", smc->tlmkb);
+       pmiPutValue("mem.physmem", NULL, buf);
 
-               snprintf(buf, sizeof(buf), "%llu", smc->tlmkb);
-               pmiPutValue("mem.physmem", NULL, buf);
+       snprintf(buf, sizeof(buf), "%llu", smc->frmkb);
+       pmiPutValue("mem.util.free", NULL, buf);
 
-               snprintf(buf, sizeof(buf), "%llu", smc->frmkb);
-               pmiPutValue("mem.util.free", NULL, buf);
+       snprintf(buf, sizeof(buf), "%llu", smc->availablekb);
+       pmiPutValue("mem.util.available", NULL, buf);
 
-               snprintf(buf, sizeof(buf), "%llu", smc->availablekb);
-               pmiPutValue("mem.util.available", NULL, buf);
+       snprintf(buf, sizeof(buf), "%llu", smc->tlmkb - smc->frmkb);
+       pmiPutValue("mem.util.used", NULL, buf);
 
-               snprintf(buf, sizeof(buf), "%llu", smc->tlmkb - smc->frmkb);
-               pmiPutValue("mem.util.used", NULL, buf);
+       snprintf(buf, sizeof(buf), "%llu", smc->bufkb);
+       pmiPutValue("mem.util.bufmem", NULL, buf);
 
-               snprintf(buf, sizeof(buf), "%llu", smc->bufkb);
-               pmiPutValue("mem.util.bufmem", NULL, buf);
+       snprintf(buf, sizeof(buf), "%llu", smc->camkb);
+       pmiPutValue("mem.util.cached", NULL, buf);
 
-               snprintf(buf, sizeof(buf), "%llu", smc->camkb);
-               pmiPutValue("mem.util.cached", NULL, buf);
+       snprintf(buf, sizeof(buf), "%llu", smc->comkb);
+       pmiPutValue("mem.util.committed_AS", NULL, buf);
 
-               snprintf(buf, sizeof(buf), "%llu", smc->comkb);
-               pmiPutValue("mem.util.committed_AS", NULL, buf);
+       snprintf(buf, sizeof(buf), "%llu", smc->activekb);
+       pmiPutValue("mem.util.active", NULL, buf);
 
-               snprintf(buf, sizeof(buf), "%llu", smc->activekb);
-               pmiPutValue("mem.util.active", NULL, buf);
+       snprintf(buf, sizeof(buf), "%llu", smc->inactkb);
+       pmiPutValue("mem.util.inactive", NULL, buf);
 
-               snprintf(buf, sizeof(buf), "%llu", smc->inactkb);
-               pmiPutValue("mem.util.inactive", NULL, buf);
+       snprintf(buf, sizeof(buf), "%llu", smc->dirtykb);
+       pmiPutValue("mem.util.dirty", NULL, buf);
 
-               snprintf(buf, sizeof(buf), "%llu", smc->dirtykb);
-               pmiPutValue("mem.util.dirty", NULL, buf);
+       if (dispall) {
+               snprintf(buf, sizeof(buf), "%llu", smc->anonpgkb);
+               pmiPutValue("mem.util.anonpages", NULL, buf);
 
-               if (DISPLAY_MEM_ALL(a->opt_flags)) {
+               snprintf(buf, sizeof(buf), "%llu", smc->slabkb);
+               pmiPutValue("mem.util.slab", NULL, buf);
 
-                       snprintf(buf, sizeof(buf), "%llu", smc->anonpgkb);
-                       pmiPutValue("mem.util.anonpages", NULL, buf);
+               snprintf(buf, sizeof(buf), "%llu", smc->kstackkb);
+               pmiPutValue("mem.util.kernelStack", NULL, buf);
 
-                       snprintf(buf, sizeof(buf), "%llu", smc->slabkb);
-                       pmiPutValue("mem.util.slab", NULL, buf);
+               snprintf(buf, sizeof(buf), "%llu", smc->pgtblkb);
+               pmiPutValue("mem.util.pageTables", NULL, buf);
 
-                       snprintf(buf, sizeof(buf), "%llu", smc->kstackkb);
-                       pmiPutValue("mem.util.kernelStack", NULL, buf);
+               snprintf(buf, sizeof(buf), "%llu", smc->vmusedkb);
+               pmiPutValue("mem.util.vmallocUsed", NULL, buf);
+       }
+#endif /* HAVE_PCP */
+}
 
-                       snprintf(buf, sizeof(buf), "%llu", smc->pgtblkb);
-                       pmiPutValue("mem.util.pageTables", NULL, buf);
+/*
+ * **************************************************************************
+ * Display swap memory utilization in PCP format.
+ *
+ * IN:
+ * @smc                Structure with statistics.
+ ***************************************************************************
+ */
+void pcp_print_swap_memory_stats(struct stats_memory *smc)
+{
+#ifdef HAVE_PCP
+       char buf[64];
 
-                       snprintf(buf, sizeof(buf), "%llu", smc->vmusedkb);
-                       pmiPutValue("mem.util.vmallocUsed", NULL, buf);
-               }
-       }
+       snprintf(buf, sizeof(buf), "%llu", smc->frskb);
+       pmiPutValue("mem.util.swapFree", NULL, buf);
 
-       if (DISPLAY_SWAP(a->opt_flags)) {
+       snprintf(buf, sizeof(buf), "%llu", smc->tlskb);
+       pmiPutValue("mem.util.swapTotal", NULL, buf);
+
+       snprintf(buf, sizeof(buf), "%llu", smc->caskb);
+       pmiPutValue("mem.util.swapCached", NULL, buf);
+#endif /* HAVE_PCP */
+}
 
-               snprintf(buf, sizeof(buf), "%llu", smc->frskb);
-               pmiPutValue("mem.util.swapFree", NULL, buf);
+/*
+ ***************************************************************************
+ * Display memory statistics in PCP format.
+ *
+ * IN:
+ * @a          Activity structure with statistics.
+ * @curr       Index in array for current sample statistics.
+ ***************************************************************************
+ */
+__print_funct_t pcp_print_memory_stats(struct activity *a, int curr)
+{
+#ifdef HAVE_PCP
+       struct stats_memory
+               *smc = (struct stats_memory *) a->buf[curr];
 
-               snprintf(buf, sizeof(buf), "%llu", smc->tlskb);
-               pmiPutValue("mem.util.swapTotal", NULL, buf);
+       if (DISPLAY_MEMORY(a->opt_flags)) {
+               pcp_print_ram_memory_stats(smc, DISPLAY_MEM_ALL(a->opt_flags));
+       }
 
-               snprintf(buf, sizeof(buf), "%llu", smc->caskb);
-               pmiPutValue("mem.util.swapCached", NULL, buf);
+       if (DISPLAY_SWAP(a->opt_flags)) {
+               pcp_print_swap_memory_stats(smc);
        }
 #endif /* HAVE_PCP */
 }
index 514c6dbcd88db56817e46d0217fda714ee2ab81f..8197b463db9b6c19377eadfe53cacda3816d0b49 100644 (file)
@@ -539,21 +539,19 @@ __print_funct_t print_io_stats(struct activity *a, int prev, int curr,
 }
 
 /*
- ***************************************************************************
- * Display memory and swap statistics. This function is used to
+ * **************************************************************************
+ * Display RAM memory utilization. This function is used to
  * display instantaneous and average statistics.
  *
  * IN:
- * @a          Activity structure with statistics.
- * @prev       Index in array where stats used as reference are.
- * @curr       Index in array for current sample statistics.
+ * @smc                Structure with statistics.
  * @dispavg    TRUE if displaying average statistics.
+ * @unit       Default values unit.
+ * @dispall    TRUE if all memory fields should be displayed.
  ***************************************************************************
  */
-void stub_print_memory_stats(struct activity *a, int prev, int curr, int dispavg)
+void print_ram_memory_stats(struct stats_memory *smc, int dispavg, int unit, int dispall)
 {
-       struct stats_memory
-               *smc = (struct stats_memory *) a->buf[curr];
        static unsigned long long
                avg_frmkb       = 0,
                avg_bufkb       = 0,
@@ -568,10 +566,193 @@ void stub_print_memory_stats(struct activity *a, int prev, int curr, int dispavg
                avg_pgtblkb     = 0,
                avg_vmusedkb    = 0,
                avg_availablekb = 0;
+       unsigned long long nousedmem;
+
+       if (!dispavg) {
+               /* Display instantaneous values */
+               nousedmem = smc->frmkb + smc->bufkb + smc->camkb + smc->slabkb;
+               if (nousedmem > smc->tlmkb) {
+                       nousedmem = smc->tlmkb;
+               }
+               cprintf_u64(unit, 3, 9,
+                           (unsigned long long) smc->frmkb,
+                           (unsigned long long) smc->availablekb,
+                           (unsigned long long) (smc->tlmkb - nousedmem));
+               cprintf_xpc(DISPLAY_UNIT(flags), XHIGH, 1, 9, 2,
+                           smc->tlmkb ?
+                           SP_VALUE(nousedmem, smc->tlmkb, smc->tlmkb)
+                           : 0.0);
+               cprintf_u64(unit, 3, 9,
+                           (unsigned long long) smc->bufkb,
+                           (unsigned long long) smc->camkb,
+                           (unsigned long long) smc->comkb);
+               cprintf_xpc(DISPLAY_UNIT(flags), XHIGH, 1, 9, 2,
+                           (smc->tlmkb + smc->tlskb) ?
+                           SP_VALUE(0, smc->comkb, smc->tlmkb + smc->tlskb)
+                           : 0.0);
+               cprintf_u64(unit, 3, 9,
+                           (unsigned long long) smc->activekb,
+                           (unsigned long long) smc->inactkb,
+                           (unsigned long long) smc->dirtykb);
+
+               if (dispall) {
+                       /* Display extended memory statistics */
+                       cprintf_u64(unit, 5, 9,
+                                   (unsigned long long) smc->anonpgkb,
+                                   (unsigned long long) smc->slabkb,
+                                   (unsigned long long) smc->kstackkb,
+                                   (unsigned long long) smc->pgtblkb,
+                                   (unsigned long long) smc->vmusedkb);
+               }
+
+               /*
+                * Will be used to compute the average.
+                * We assume that the total amount of memory installed can not vary
+                * during the interval given on the command line.
+                */
+               avg_frmkb       += smc->frmkb;
+               avg_bufkb       += smc->bufkb;
+               avg_camkb       += smc->camkb;
+               avg_comkb       += smc->comkb;
+               avg_activekb    += smc->activekb;
+               avg_inactkb     += smc->inactkb;
+               avg_dirtykb     += smc->dirtykb;
+               avg_anonpgkb    += smc->anonpgkb;
+               avg_slabkb      += smc->slabkb;
+               avg_kstackkb    += smc->kstackkb;
+               avg_pgtblkb     += smc->pgtblkb;
+               avg_vmusedkb    += smc->vmusedkb;
+               avg_availablekb += smc->availablekb;
+       }
+       else {
+               /* Display average values */
+               nousedmem = avg_frmkb + avg_bufkb + avg_camkb + avg_slabkb;
+               cprintf_f(unit, FALSE, 3, 9, 0,
+                         (double) avg_frmkb / avg_count,
+                         (double) avg_availablekb / avg_count,
+                         (double) smc->tlmkb - ((double) nousedmem / avg_count));
+               cprintf_xpc(DISPLAY_UNIT(flags), XHIGH, 1, 9, 2,
+                           smc->tlmkb ?
+                           SP_VALUE((double) (nousedmem / avg_count), smc->tlmkb, smc->tlmkb)
+                           : 0.0);
+               cprintf_f(unit, FALSE, 3, 9, 0,
+                         (double) avg_bufkb / avg_count,
+                         (double) avg_camkb / avg_count,
+                         (double) avg_comkb / avg_count);
+               cprintf_xpc(DISPLAY_UNIT(flags), XHIGH, 1, 9, 2,
+                           (smc->tlmkb + smc->tlskb) ?
+                           SP_VALUE(0.0, (double) (avg_comkb / avg_count), smc->tlmkb + smc->tlskb)
+                           : 0.0);
+               cprintf_f(unit, FALSE, 3, 9, 0,
+                         (double) avg_activekb / avg_count,
+                         (double) avg_inactkb / avg_count,
+                         (double) avg_dirtykb / avg_count);
+
+               if (dispall) {
+                       cprintf_f(unit, FALSE, 5, 9, 0,
+                                 (double) avg_anonpgkb / avg_count,
+                                 (double) avg_slabkb / avg_count,
+                                 (double) avg_kstackkb / avg_count,
+                                 (double) avg_pgtblkb / avg_count,
+                                 (double) avg_vmusedkb / avg_count);
+               }
+
+               /* Reset average counters */
+               avg_frmkb = avg_bufkb = avg_camkb = avg_comkb = 0;
+               avg_activekb = avg_inactkb = avg_dirtykb = 0;
+               avg_anonpgkb = avg_slabkb = avg_kstackkb = 0;
+               avg_pgtblkb = avg_vmusedkb = avg_availablekb = 0;
+       }
+
+       printf("\n");
+}
+
+/*
+ * **************************************************************************
+ * Display swap memory utilization. This function is used to
+ * display instantaneous and average statistics.
+ *
+ * IN:
+ * @smc                Structure with statistics.
+ * @dispavg    TRUE if displaying average statistics.
+ * @unit       Default values unit.
+ ***************************************************************************
+ */
+void print_swap_memory_stats(struct stats_memory *smc, int dispavg, int unit)
+{
        static unsigned long long
                avg_frskb = 0,
                avg_tlskb = 0,
                avg_caskb = 0;
+
+       if (!dispavg) {
+               /* Display instantaneous values */
+               cprintf_u64(unit, 2, 9,
+                           (unsigned long long) smc->frskb,
+                           (unsigned long long) (smc->tlskb - smc->frskb));
+               cprintf_xpc(DISPLAY_UNIT(flags), XHIGH, 1, 9, 2,
+                           smc->tlskb ?
+                           SP_VALUE(smc->frskb, smc->tlskb, smc->tlskb)
+                           : 0.0);
+               cprintf_u64(unit, 1, 9,
+                           (unsigned long long) smc->caskb);
+               cprintf_xpc(DISPLAY_UNIT(flags), FALSE, 1, 9, 2,
+                           (smc->tlskb - smc->frskb) ?
+                           SP_VALUE(0, smc->caskb, smc->tlskb - smc->frskb)
+                           : 0.0);
+
+               /*
+                * Will be used to compute the average.
+                * We assume that the total amount of swap space may vary.
+                */
+               avg_frskb += smc->frskb;
+               avg_tlskb += smc->tlskb;
+               avg_caskb += smc->caskb;
+       }
+       else {
+               /* Display average values */
+               cprintf_f(unit, FALSE, 2, 9, 0,
+                         (double) avg_frskb / avg_count,
+                         ((double) avg_tlskb / avg_count) -
+                         ((double) avg_frskb / avg_count));
+               cprintf_xpc(DISPLAY_UNIT(flags), XHIGH, 1, 9, 2,
+                           avg_tlskb ?
+                           SP_VALUE((double) avg_frskb / avg_count,
+                                    (double) avg_tlskb / avg_count,
+                                    (double) avg_tlskb / avg_count)
+                           : 0.0);
+               cprintf_f(unit, FALSE, 1, 9, 0,
+                         (double) avg_caskb / avg_count);
+               cprintf_xpc(DISPLAY_UNIT(flags), FALSE, 1, 9, 2,
+                           (avg_tlskb != avg_frskb) ?
+                           SP_VALUE(0.0, (double) avg_caskb / avg_count,
+                                    ((double) avg_tlskb / avg_count) -
+                                    ((double) avg_frskb / avg_count))
+                           : 0.0);
+
+               /* Reset average counters */
+               avg_frskb = avg_tlskb = avg_caskb = 0;
+       }
+
+       printf("\n");
+}
+
+/*
+ ***************************************************************************
+ * Display memory and swap utilization. This function is used to
+ * display instantaneous and average statistics.
+ *
+ * IN:
+ * @a          Activity structure with statistics.
+ * @prev       Index in array where stats used as reference are.
+ * @curr       Index in array for current sample statistics.
+ * @dispavg    TRUE if displaying average statistics.
+ ***************************************************************************
+ */
+void stub_print_memory_stats(struct activity *a, int curr, int dispavg)
+{
+       struct stats_memory
+               *smc = (struct stats_memory *) a->buf[curr];
        int unit = NO_UNIT;
 
        if (DISPLAY_UNIT(flags)) {
@@ -580,110 +761,12 @@ void stub_print_memory_stats(struct activity *a, int prev, int curr, int dispavg
        }
 
        if (DISPLAY_MEMORY(a->opt_flags)) {
-               unsigned long long nousedmem;
-
                if (dish) {
                        print_hdr_line(timestamp[!curr], a, FIRST, 0, 9, NULL);
                }
                printf("%-11s", timestamp[curr]);
 
-               if (!dispavg) {
-                       /* Display instantaneous values */
-                       nousedmem = smc->frmkb + smc->bufkb + smc->camkb + smc->slabkb;
-                       if (nousedmem > smc->tlmkb) {
-                               nousedmem = smc->tlmkb;
-                       }
-                       cprintf_u64(unit, 3, 9,
-                                   (unsigned long long) smc->frmkb,
-                                   (unsigned long long) smc->availablekb,
-                                   (unsigned long long) (smc->tlmkb - nousedmem));
-                       cprintf_xpc(DISPLAY_UNIT(flags), XHIGH, 1, 9, 2,
-                                  smc->tlmkb ?
-                                  SP_VALUE(nousedmem, smc->tlmkb, smc->tlmkb)
-                                  : 0.0);
-                       cprintf_u64(unit, 3, 9,
-                                   (unsigned long long) smc->bufkb,
-                                   (unsigned long long) smc->camkb,
-                                   (unsigned long long) smc->comkb);
-                       cprintf_xpc(DISPLAY_UNIT(flags), XHIGH, 1, 9, 2,
-                                  (smc->tlmkb + smc->tlskb) ?
-                                  SP_VALUE(0, smc->comkb, smc->tlmkb + smc->tlskb)
-                                  : 0.0);
-                       cprintf_u64(unit, 3, 9,
-                                   (unsigned long long) smc->activekb,
-                                   (unsigned long long) smc->inactkb,
-                                   (unsigned long long) smc->dirtykb);
-
-                       if (DISPLAY_MEM_ALL(a->opt_flags)) {
-                               /* Display extended memory statistics */
-                               cprintf_u64(unit, 5, 9,
-                                           (unsigned long long) smc->anonpgkb,
-                                           (unsigned long long) smc->slabkb,
-                                           (unsigned long long) smc->kstackkb,
-                                           (unsigned long long) smc->pgtblkb,
-                                           (unsigned long long) smc->vmusedkb);
-                       }
-
-                       /*
-                        * Will be used to compute the average.
-                        * We assume that the total amount of memory installed can not vary
-                        * during the interval given on the command line.
-                        */
-                       avg_frmkb       += smc->frmkb;
-                       avg_bufkb       += smc->bufkb;
-                       avg_camkb       += smc->camkb;
-                       avg_comkb       += smc->comkb;
-                       avg_activekb    += smc->activekb;
-                       avg_inactkb     += smc->inactkb;
-                       avg_dirtykb     += smc->dirtykb;
-                       avg_anonpgkb    += smc->anonpgkb;
-                       avg_slabkb      += smc->slabkb;
-                       avg_kstackkb    += smc->kstackkb;
-                       avg_pgtblkb     += smc->pgtblkb;
-                       avg_vmusedkb    += smc->vmusedkb;
-                       avg_availablekb += smc->availablekb;
-               }
-               else {
-                       /* Display average values */
-                       nousedmem = avg_frmkb + avg_bufkb + avg_camkb + avg_slabkb;
-                       cprintf_f(unit, FALSE, 3, 9, 0,
-                                 (double) avg_frmkb / avg_count,
-                                 (double) avg_availablekb / avg_count,
-                                 (double) smc->tlmkb - ((double) nousedmem / avg_count));
-                       cprintf_xpc(DISPLAY_UNIT(flags), XHIGH, 1, 9, 2,
-                                  smc->tlmkb ?
-                                  SP_VALUE((double) (nousedmem / avg_count), smc->tlmkb, smc->tlmkb)
-                                  : 0.0);
-                       cprintf_f(unit, FALSE, 3, 9, 0,
-                                 (double) avg_bufkb / avg_count,
-                                 (double) avg_camkb / avg_count,
-                                 (double) avg_comkb / avg_count);
-                       cprintf_xpc(DISPLAY_UNIT(flags), XHIGH, 1, 9, 2,
-                                  (smc->tlmkb + smc->tlskb) ?
-                                  SP_VALUE(0.0, (double) (avg_comkb / avg_count), smc->tlmkb + smc->tlskb)
-                                  : 0.0);
-                       cprintf_f(unit, FALSE, 3, 9, 0,
-                                 (double) avg_activekb / avg_count,
-                                 (double) avg_inactkb / avg_count,
-                                 (double) avg_dirtykb / avg_count);
-
-                       if (DISPLAY_MEM_ALL(a->opt_flags)) {
-                               cprintf_f(unit, FALSE, 5, 9, 0,
-                                         (double) avg_anonpgkb / avg_count,
-                                         (double) avg_slabkb / avg_count,
-                                         (double) avg_kstackkb / avg_count,
-                                         (double) avg_pgtblkb / avg_count,
-                                         (double) avg_vmusedkb / avg_count);
-                       }
-
-                       /* Reset average counters */
-                       avg_frmkb = avg_bufkb = avg_camkb = avg_comkb = 0;
-                       avg_activekb = avg_inactkb = avg_dirtykb = 0;
-                       avg_anonpgkb = avg_slabkb = avg_kstackkb = 0;
-                       avg_pgtblkb = avg_vmusedkb = avg_availablekb = 0;
-               }
-
-               printf("\n");
+               print_ram_memory_stats(smc, dispavg, unit, DISPLAY_MEM_ALL(a->opt_flags));
        }
 
        if (DISPLAY_SWAP(a->opt_flags)) {
@@ -692,56 +775,7 @@ void stub_print_memory_stats(struct activity *a, int prev, int curr, int dispavg
                }
                printf("%-11s", timestamp[curr]);
 
-               if (!dispavg) {
-                       /* Display instantaneous values */
-                       cprintf_u64(unit, 2, 9,
-                                   (unsigned long long) smc->frskb,
-                                   (unsigned long long) (smc->tlskb - smc->frskb));
-                       cprintf_xpc(DISPLAY_UNIT(flags), XHIGH, 1, 9, 2,
-                                  smc->tlskb ?
-                                  SP_VALUE(smc->frskb, smc->tlskb, smc->tlskb)
-                                  : 0.0);
-                       cprintf_u64(unit, 1, 9,
-                                   (unsigned long long) smc->caskb);
-                       cprintf_xpc(DISPLAY_UNIT(flags), FALSE, 1, 9, 2,
-                                  (smc->tlskb - smc->frskb) ?
-                                  SP_VALUE(0, smc->caskb, smc->tlskb - smc->frskb)
-                                  : 0.0);
-
-                       /*
-                        * Will be used to compute the average.
-                        * We assume that the total amount of swap space may vary.
-                        */
-                       avg_frskb += smc->frskb;
-                       avg_tlskb += smc->tlskb;
-                       avg_caskb += smc->caskb;
-               }
-               else {
-                       /* Display average values */
-                       cprintf_f(unit, FALSE, 2, 9, 0,
-                                 (double) avg_frskb / avg_count,
-                                 ((double) avg_tlskb / avg_count) -
-                                 ((double) avg_frskb / avg_count));
-                       cprintf_xpc(DISPLAY_UNIT(flags), XHIGH, 1, 9, 2,
-                                  avg_tlskb ?
-                                  SP_VALUE((double) avg_frskb / avg_count,
-                                           (double) avg_tlskb / avg_count,
-                                           (double) avg_tlskb / avg_count)
-                                  : 0.0);
-                       cprintf_f(unit, FALSE, 1, 9, 0,
-                                 (double) avg_caskb / avg_count);
-                       cprintf_xpc(DISPLAY_UNIT(flags), FALSE, 1, 9, 2,
-                                  (avg_tlskb != avg_frskb) ?
-                                  SP_VALUE(0.0, (double) avg_caskb / avg_count,
-                                           ((double) avg_tlskb / avg_count) -
-                                           ((double) avg_frskb / avg_count))
-                                  : 0.0);
-
-                       /* Reset average counters */
-                       avg_frskb = avg_tlskb = avg_caskb = 0;
-               }
-
-               printf("\n");
+               print_swap_memory_stats(smc, dispavg, unit);
        }
 }
 
@@ -759,7 +793,7 @@ void stub_print_memory_stats(struct activity *a, int prev, int curr, int dispavg
 __print_funct_t print_memory_stats(struct activity *a, int prev, int curr,
                                   unsigned long long itv)
 {
-       stub_print_memory_stats(a, prev, curr, FALSE);
+       stub_print_memory_stats(a, curr, FALSE);
 }
 
 /*
@@ -776,7 +810,7 @@ __print_funct_t print_memory_stats(struct activity *a, int prev, int curr,
 __print_funct_t print_avg_memory_stats(struct activity *a, int prev, int curr,
                                       unsigned long long itv)
 {
-       stub_print_memory_stats(a, prev, curr, TRUE);
+       stub_print_memory_stats(a, curr, TRUE);
 }
 
 /*
index 1469ec844b145529af1bda508a6f5c2087564c22..53a7a02e2fd9389babf8770739df762ab758b018 100644 (file)
@@ -391,6 +391,56 @@ __print_funct_t raw_print_io_stats(struct activity *a, char *timestr, int curr)
        printf("\n");
 }
 
+/*
+ * **************************************************************************
+ * Display RAM memory utilization in raw format.
+ *
+ * IN:
+ * @smc                Structure with statistics.
+ * @dispall    TRUE if all memory fields should be displayed.
+ ***************************************************************************
+ */
+void raw_print_ram_memory_stats(struct stats_memory *smc, int dispall)
+{
+       printf(" %s; %llu;", pfield(NULL, 0), smc->availablekb);
+       printf(" kbttlmem; %llu;", smc->tlmkb);
+       pfield(NULL, 0); /* Skip kbmemused */
+       pfield(NULL, 0); /* Skip %memused */
+       printf(" %s; %llu;", pfield(NULL, 0), smc->bufkb);
+       printf(" %s; %llu;", pfield(NULL, 0), smc->camkb);
+       printf(" %s; %llu;", pfield(NULL, 0), smc->comkb);
+       pfield(NULL, 0); /* Skip %commit */
+       printf(" %s; %llu;", pfield(NULL, 0), smc->activekb);
+       printf(" %s; %llu;", pfield(NULL, 0), smc->inactkb);
+       printf(" %s; %llu;", pfield(NULL, 0), smc->dirtykb);
+
+       if (dispall) {
+               printf(" %s; %llu;", pfield(NULL, 0), smc->anonpgkb);
+               printf(" %s; %llu;", pfield(NULL, 0), smc->slabkb);
+               printf(" %s; %llu;", pfield(NULL, 0), smc->kstackkb);
+               printf(" %s; %llu;", pfield(NULL, 0), smc->pgtblkb);
+               printf(" %s; %llu;", pfield(NULL, 0), smc->vmusedkb);
+       }
+       printf("\n");
+}
+
+/*
+ * **************************************************************************
+ * Display swap memory utilization in raw format.
+ *
+ * IN:
+ * @smc                Structure with statistics.
+ ***************************************************************************
+ */
+void raw_print_swap_memory_stats(struct stats_memory *smc)
+{
+       printf(" kbttlswp; %llu;", smc->tlskb);
+       pfield(NULL, 0); /* Skip kbswpused */
+       pfield(NULL, 0); /* Skip %swpused */
+       printf(" %s; %llu;", pfield(NULL, 0), smc->caskb);
+       printf("\n");
+}
+
 /*
  ***************************************************************************
  * Display memory statistics in raw format.
@@ -408,35 +458,12 @@ __print_funct_t raw_print_memory_stats(struct activity *a, char *timestr, int cu
 
        if (DISPLAY_MEMORY(a->opt_flags)) {
                printf("%s; %s; %llu;", timestr, pfield(a->hdr_line, FIRST), smc->frmkb);
-               printf(" %s; %llu;", pfield(NULL, 0), smc->availablekb);
-               printf(" kbttlmem; %llu;", smc->tlmkb);
-               pfield(NULL, 0); /* Skip kbmemused */
-               pfield(NULL, 0); /* Skip %memused */
-               printf(" %s; %llu;", pfield(NULL, 0), smc->bufkb);
-               printf(" %s; %llu;", pfield(NULL, 0), smc->camkb);
-               printf(" %s; %llu;", pfield(NULL, 0), smc->comkb);
-               pfield(NULL, 0); /* Skip %commit */
-               printf(" %s; %llu;", pfield(NULL, 0), smc->activekb);
-               printf(" %s; %llu;", pfield(NULL, 0), smc->inactkb);
-               printf(" %s; %llu;", pfield(NULL, 0), smc->dirtykb);
-
-               if (DISPLAY_MEM_ALL(a->opt_flags)) {
-                       printf(" %s; %llu;", pfield(NULL, 0), smc->anonpgkb);
-                       printf(" %s; %llu;", pfield(NULL, 0), smc->slabkb);
-                       printf(" %s; %llu;", pfield(NULL, 0), smc->kstackkb);
-                       printf(" %s; %llu;", pfield(NULL, 0), smc->pgtblkb);
-                       printf(" %s; %llu;", pfield(NULL, 0), smc->vmusedkb);
-               }
-               printf("\n");
+               raw_print_ram_memory_stats(smc, DISPLAY_MEM_ALL(a->opt_flags));
        }
 
        if (DISPLAY_SWAP(a->opt_flags)) {
                printf("%s; %s; %llu;", timestr, pfield(a->hdr_line, SECOND), smc->frskb);
-               printf(" kbttlswp; %llu;", smc->tlskb);
-               pfield(NULL, 0); /* Skip kbswpused */
-               pfield(NULL, 0); /* Skip %swpused */
-               printf(" %s; %llu;", pfield(NULL, 0), smc->caskb);
-               printf("\n");
+               raw_print_swap_memory_stats(smc);
        }
 }
 
index 3d660c61f357adc29fde4b21bc6d3a80f475c315..6bd8cdd8261c8caa1027d87209783928459723e7 100644 (file)
@@ -792,131 +792,148 @@ __print_funct_t render_io_stats(struct activity *a, int isdb, char *pre,
 }
 
 /*
- ***************************************************************************
- * Display memory and swap statistics in selected format.
+ * **************************************************************************
+ * Display RAM memory utilization in selected format.
  *
  * IN:
- * @a          Activity structure with statistics.
+ * @smc                Structure with statistics.
  * @isdb       Flag, true if db printing, false if ppc printing.
- * @pre                Prefix string for output entries
- * @curr       Index in array for current sample statistics.
- * @itv                Interval of time in 1/100th of a second.
+ * @pre                Prefix string for output entries.
+ * @dispall    TRUE if all memory fields should be displayed.
+ * @pt_newlin  Rendering flag for last displayed field.
  ***************************************************************************
  */
-__print_funct_t render_memory_stats(struct activity *a, int isdb, char *pre,
-                                   int curr, unsigned long long itv)
+void render_ram_memory_stats(struct stats_memory *smc, int isdb, char *pre,
+                            int dispall, int pt_newlin)
 {
-       struct stats_memory
-               *smc = (struct stats_memory *) a->buf[curr];
-       int pt_newlin
-               = PT_NOFLAG + (DISPLAY_HORIZONTALLY(flags) ? 0 : PT_NEWLIN);
+       unsigned long long nousedmem;
+       int ptn;
 
-       if (DISPLAY_MEMORY(a->opt_flags)) {
-               unsigned long long nousedmem;
-               int ptn;
+       nousedmem = smc->frmkb + smc->bufkb + smc->camkb + smc->slabkb;
+       if (nousedmem > smc->tlmkb) {
+               nousedmem = smc->tlmkb;
+       }
 
-               nousedmem = smc->frmkb + smc->bufkb + smc->camkb + smc->slabkb;
-               if (nousedmem > smc->tlmkb) {
-                       nousedmem = smc->tlmkb;
-               }
+       render(isdb, pre, PT_USEINT,
+              "-\tkbmemfree", NULL, NULL, smc->frmkb, DNOVAL, NULL);
 
-               render(isdb, pre, PT_USEINT,
-                      "-\tkbmemfree", NULL, NULL,
-                      smc->frmkb, DNOVAL, NULL);
+       render(isdb, pre, PT_USEINT,
+              "-\tkbavail", NULL, NULL, smc->availablekb, DNOVAL, NULL);
 
-               render(isdb, pre, PT_USEINT,
-                      "-\tkbavail", NULL, NULL,
-                      smc->availablekb, DNOVAL, NULL);
+       render(isdb, pre, PT_USEINT,
+              "-\tkbmemused", NULL, NULL, smc->tlmkb - nousedmem, DNOVAL, NULL);
 
-               render(isdb, pre, PT_USEINT,
-                      "-\tkbmemused", NULL, NULL,
-                      smc->tlmkb - nousedmem, DNOVAL, NULL);
+       render(isdb, pre, PT_NOFLAG,
+              "-\t%memused", NULL, NULL, NOVAL,
+              smc->tlmkb ? SP_VALUE(nousedmem, smc->tlmkb, smc->tlmkb)
+                         : 0.0,
+              NULL);
 
-               render(isdb, pre, PT_NOFLAG,
-                      "-\t%memused", NULL, NULL, NOVAL,
-                      smc->tlmkb ?
-                      SP_VALUE(nousedmem, smc->tlmkb, smc->tlmkb) :
-                      0.0, NULL);
+       render(isdb, pre, PT_USEINT,
+              "-\tkbbuffers", NULL, NULL, smc->bufkb, DNOVAL, NULL);
 
-               render(isdb, pre, PT_USEINT,
-                      "-\tkbbuffers", NULL, NULL,
-                      smc->bufkb, DNOVAL, NULL);
+       render(isdb, pre, PT_USEINT,
+              "-\tkbcached", NULL, NULL, smc->camkb, DNOVAL, NULL);
 
-               render(isdb, pre, PT_USEINT,
-                      "-\tkbcached", NULL, NULL,
-                      smc->camkb, DNOVAL, NULL);
+       render(isdb, pre, PT_USEINT,
+              "-\tkbcommit", NULL, NULL, smc->comkb, DNOVAL, NULL);
 
-               render(isdb, pre, PT_USEINT,
-                      "-\tkbcommit", NULL, NULL,
-                      smc->comkb, DNOVAL, NULL);
+       render(isdb, pre, PT_NOFLAG,
+              "-\t%commit", NULL, NULL, NOVAL,
+              (smc->tlmkb + smc->tlskb) ? SP_VALUE(0, smc->comkb, smc->tlmkb + smc->tlskb)
+                                        : 0.0,
+              NULL);
 
-               render(isdb, pre, PT_NOFLAG,
-                      "-\t%commit", NULL, NULL, NOVAL,
-                      (smc->tlmkb + smc->tlskb) ?
-                      SP_VALUE(0, smc->comkb, smc->tlmkb + smc->tlskb) :
-                      0.0, NULL);
+       render(isdb, pre, PT_USEINT,
+              "-\tkbactive", NULL, NULL, smc->activekb, DNOVAL, NULL);
 
-               render(isdb, pre, PT_USEINT,
-                      "-\tkbactive", NULL, NULL,
-                      smc->activekb, DNOVAL, NULL);
+       render(isdb, pre, PT_USEINT,
+              "-\tkbinact", NULL, NULL, smc->inactkb, DNOVAL, NULL);
 
+       ptn = dispall ? 0 : pt_newlin;
+       render(isdb, pre, PT_USEINT | ptn,
+              "-\tkbdirty", NULL, NULL, smc->dirtykb, DNOVAL, NULL);
+
+       if (dispall) {
                render(isdb, pre, PT_USEINT,
-                      "-\tkbinact", NULL, NULL,
-                      smc->inactkb, DNOVAL, NULL);
+                      "-\tkbanonpg", NULL, NULL, smc->anonpgkb, DNOVAL, NULL);
 
-               ptn = DISPLAY_MEM_ALL(a->opt_flags) ? 0 : pt_newlin;
-               render(isdb, pre, PT_USEINT | ptn,
-                      "-\tkbdirty", NULL, NULL,
-                      smc->dirtykb, DNOVAL, NULL);
+               render(isdb, pre, PT_USEINT,
+                      "-\tkbslab", NULL, NULL, smc->slabkb, DNOVAL, NULL);
 
-               if (DISPLAY_MEM_ALL(a->opt_flags)) {
-                       render(isdb, pre, PT_USEINT,
-                              "-\tkbanonpg", NULL, NULL,
-                              smc->anonpgkb, DNOVAL, NULL);
+               render(isdb, pre, PT_USEINT,
+                      "-\tkbkstack", NULL, NULL, smc->kstackkb, DNOVAL, NULL);
 
-                       render(isdb, pre, PT_USEINT,
-                              "-\tkbslab", NULL, NULL,
-                              smc->slabkb, DNOVAL, NULL);
+               render(isdb, pre, PT_USEINT,
+                      "-\tkbpgtbl", NULL, NULL, smc->pgtblkb, DNOVAL, NULL);
 
-                       render(isdb, pre, PT_USEINT,
-                              "-\tkbkstack", NULL, NULL,
-                              smc->kstackkb, DNOVAL, NULL);
+               render(isdb, pre, PT_USEINT | pt_newlin,
+                      "-\tkbvmused", NULL, NULL, smc->vmusedkb, DNOVAL, NULL);
+       }
+}
 
-                       render(isdb, pre, PT_USEINT,
-                              "-\tkbpgtbl", NULL, NULL,
-                              smc->pgtblkb, DNOVAL, NULL);
+/*
+ * **************************************************************************
+ * Display swap memory utilization in selected format.
+ *
+ * IN:
+ * @smc                Structure with statistics.
+ * @isdb       Flag, true if db printing, false if ppc printing.
+ * @pre                Prefix string for output entries.
+ * @pt_newlin  Rendering flag for last displayed field.
+ ***************************************************************************
+ */
+void render_swap_memory_stats(struct stats_memory *smc, int isdb, char *pre,
+                             int pt_newlin)
+{
+       render(isdb, pre, PT_USEINT,
+              "-\tkbswpfree", NULL, NULL, smc->frskb, DNOVAL, NULL);
 
-                       render(isdb, pre, PT_USEINT | pt_newlin,
-                              "-\tkbvmused", NULL, NULL,
-                              smc->vmusedkb, DNOVAL, NULL);
-               }
-       }
+       render(isdb, pre, PT_USEINT,
+              "-\tkbswpused", NULL, NULL, smc->tlskb - smc->frskb, DNOVAL, NULL);
 
-       if (DISPLAY_SWAP(a->opt_flags)) {
+       render(isdb, pre, PT_NOFLAG,
+              "-\t%swpused", NULL, NULL, NOVAL,
+              smc->tlskb ? SP_VALUE(smc->frskb, smc->tlskb, smc->tlskb)
+                         : 0.0,
+              NULL);
 
-               render(isdb, pre, PT_USEINT,
-                      "-\tkbswpfree", NULL, NULL,
-                      smc->frskb, DNOVAL, NULL);
+       render(isdb, pre, PT_USEINT,
+              "-\tkbswpcad", NULL, NULL, smc->caskb, DNOVAL, NULL);
 
-               render(isdb, pre, PT_USEINT,
-                      "-\tkbswpused", NULL, NULL,
-                      smc->tlskb - smc->frskb, DNOVAL, NULL);
+       render(isdb, pre, pt_newlin,
+              "-\t%swpcad", NULL, NULL, NOVAL,
+              (smc->tlskb - smc->frskb) ? SP_VALUE(0, smc->caskb, smc->tlskb - smc->frskb)
+                                        : 0.0,
+              NULL);
+}
 
-               render(isdb, pre, PT_NOFLAG,
-                      "-\t%swpused", NULL, NULL, NOVAL,
-                      smc->tlskb ?
-                      SP_VALUE(smc->frskb, smc->tlskb, smc->tlskb) :
-                      0.0, NULL);
+/*
+ ***************************************************************************
+ * Display memory and swap statistics in selected format.
+ *
+ * IN:
+ * @a          Activity structure with statistics.
+ * @isdb       Flag, true if db printing, false if ppc printing.
+ * @pre                Prefix string for output entries
+ * @curr       Index in array for current sample statistics.
+ * @itv                Interval of time in 1/100th of a second.
+ ***************************************************************************
+ */
+__print_funct_t render_memory_stats(struct activity *a, int isdb, char *pre,
+                                   int curr, unsigned long long itv)
+{
+       struct stats_memory
+               *smc = (struct stats_memory *) a->buf[curr];
+       int pt_newlin
+               = PT_NOFLAG + (DISPLAY_HORIZONTALLY(flags) ? 0 : PT_NEWLIN);
 
-               render(isdb, pre, PT_USEINT,
-                      "-\tkbswpcad", NULL, NULL,
-                      smc->caskb, DNOVAL, NULL);
+       if (DISPLAY_MEMORY(a->opt_flags)) {
+               render_ram_memory_stats(smc, isdb, pre, DISPLAY_MEM_ALL(a->opt_flags), pt_newlin);
+       }
 
-               render(isdb, pre, pt_newlin,
-                      "-\t%swpcad", NULL, NULL, NOVAL,
-                      (smc->tlskb - smc->frskb) ?
-                      SP_VALUE(0, smc->caskb, smc->tlskb - smc->frskb) :
-                      0.0, NULL);
+       if (DISPLAY_SWAP(a->opt_flags)) {
+               render_swap_memory_stats(smc, isdb, pre, pt_newlin);
        }
 }
 
index 8be204e2ebeb103aafb569cc29d872c3bcdc4bbe..3c4f861c4a7c4a1f453789fae5a361d2ad32efb1 100644 (file)
@@ -1743,54 +1743,49 @@ __print_funct_t svg_print_io_stats(struct activity *a, int curr, int action, str
 }
 
 /*
- ***************************************************************************
- * Display memory statistics in SVG.
+ * **************************************************************************
+ * Display RAM memory utilization in SVG.
  *
  * IN:
  * @a          Activity structure with statistics.
- * @curr       Index in array for current sample statistics.
+ * @smc                Structure with statistics.
  * @action     Action expected from current function.
+ * @dispall    TRUE if all memory fields should be displayed.
  * @svg_p      SVG specific parameters: Current graph number (.@graph_no),
  *             flag indicating that a restart record has been previously
  *             found (.@restart) and time used for the X axis origin
  *             (@ust_time_ref).
- * @itv                Interval of time in 1/100th of a second (only with F_MAIN action).
  * @record_hdr Pointer on record header of current stats sample.
+ * @xid                Current SVG graph number.
+ *
+ * OUT:
+ * @xid                Next SVG graph number.
  ***************************************************************************
  */
-__print_funct_t svg_print_memory_stats(struct activity *a, int curr, int action, struct svg_parm *svg_p,
-                                      unsigned long long itv, struct record_header *record_hdr)
+void svg_print_ram_memory_stats(struct activity *a, struct stats_memory *smc, int action, int dispall,
+                               struct svg_parm *svg_p, struct record_header *record_hdr, int *xid)
 {
-       struct stats_memory
-               *smc = (struct stats_memory *) a->buf[curr];
-       int group1[] = {3, 1, 3, 1, 3, 5};
-       int g_type1[] = {SVG_LINE_GRAPH, SVG_BAR_GRAPH, SVG_LINE_GRAPH,
-                        SVG_BAR_GRAPH, SVG_LINE_GRAPH, SVG_LINE_GRAPH};
-       int group2[] = {3, 1, 1};
-       int g_type2[] = {SVG_LINE_GRAPH, SVG_BAR_GRAPH, SVG_BAR_GRAPH};
-       char *title1[] = {"Memory utilization (1)", "Memory utilization (2)",
-                         "Memory utilization (3)", "Memory utilization (4)",
-                         "Memory utilization (5)", "Memory utilization (6)"};
-       char *title2[] = {"Swap utilization (1)", "Swap utilization (2)",
-                         "Swap utilization (3)"};
-       char *g_title1[] = {"MBmemfree", "MBavail", "MBmemused", "%memused", "MBbuffers",
-                           "MBcached", "MBcommit", "%commit", "MBactive", "MBinact",
-                           "MBdirty", "MBanonpg", "MBslab", "MBkstack", "MBpgtbl",
-                           "MBvmused"};
-       char *g_title2[] = {"MBswpfree", "MBswpused", "MBswpcad", "%swpused",
-                           "%swpcad"};
-       int g_fields[] = {0, 4, 5, 21, 16, 22, 18, 6, 8, 9, 10, 11, 12, 13, 14, 15, 1};
+       int group[] = {3, 1, 3, 1, 3, 5};
+       int g_type[] = {SVG_LINE_GRAPH, SVG_BAR_GRAPH, SVG_LINE_GRAPH,
+                       SVG_BAR_GRAPH, SVG_LINE_GRAPH, SVG_LINE_GRAPH};
+       char *title[] = {"Memory utilization (1)", "Memory utilization (2)",
+                        "Memory utilization (3)", "Memory utilization (4)",
+                        "Memory utilization (5)", "Memory utilization (6)"};
+       char *g_title[] = {"MBmemfree", "MBavail", "MBmemused", "%memused", "MBbuffers",
+                          "MBcached", "MBcommit", "%commit", "MBactive", "MBinact",
+                          "MBdirty", "MBanonpg", "MBslab", "MBkstack", "MBpgtbl",
+                          "MBvmused"};
+       int g_fields[] = {0, 4, 5, -1, -1, -1, -1, 6, 8, 9, 10, 11, 12, 13, 14, 15, 1};
        static double *spmin, *spmax;
        static char **out;
        static int *outsize;
-       static int xid = 0;
 
        if (action & F_BEGIN) {
                /*
                 * Allocate arrays that will contain the graphs data
                 * and the min/max values.
                 */
-               out = allocate_graph_lines(23, &outsize, &spmin, &spmax);
+               out = allocate_graph_lines(16, &outsize, &spmin, &spmax);
        }
 
        if (action & F_MAIN) {
@@ -1798,8 +1793,8 @@ __print_funct_t svg_print_memory_stats(struct activity *a, int curr, int action,
                double tval;
 
                /* Check for min/max values */
-               save_extrema(a->gtypes_nr, (void *) a->buf[curr], NULL,
-                            itv, spmin, spmax, g_fields);
+               save_extrema(a->gtypes_nr, (void *) smc, NULL, 0, spmin, spmax, g_fields);
+
                /* Compute %memused min/max values */
                nousedmem = smc->frmkb + smc->bufkb + smc->camkb + smc->slabkb;
                if (nousedmem > smc->tlmkb) {
@@ -1821,24 +1816,6 @@ __print_funct_t svg_print_memory_stats(struct activity *a, int curr, int action,
                if (tval < *(spmin + 7)) {
                        *(spmin + 7) = tval;
                }
-               /* Compute %swpused min/max values */
-               tval = smc->tlskb ?
-                      SP_VALUE(smc->frskb, smc->tlskb, smc->tlskb) : 0.0;
-               if (tval > *(spmax + 19)) {
-                       *(spmax + 19) = tval;
-               }
-               if (tval < *(spmin + 19)) {
-                       *(spmin + 19) = tval;
-               }
-               /* Compute %swpcad min/max values */
-               tval = (smc->tlskb - smc->frskb) ?
-                      SP_VALUE(0, smc->caskb, smc->tlskb - smc->frskb) : 0.0;
-               if (tval > *(spmax + 20)) {
-                       *(spmax + 20) = tval;
-               }
-               if (tval < *(spmin + 20)) {
-                       *(spmin + 20) = tval;
-               }
                /* Compute memused min/max values in MB */
                tval = ((double) (smc->tlmkb - nousedmem)) / 1024;
                if (tval > *(spmax + 2)) {
@@ -1847,14 +1824,6 @@ __print_funct_t svg_print_memory_stats(struct activity *a, int curr, int action,
                if (tval < *(spmin + 2)) {
                        *(spmin + 2) = tval;
                }
-               /* Compute swpused min/max values in MB */
-               tval = ((double) (smc->tlskb - smc->frskb)) / 1024;
-               if (tval > *(spmax + 17)) {
-                       *(spmax + 17) = tval;
-               }
-               if (tval < *(spmin + 17)) {
-                       *(spmin + 17) = tval;
-               }
 
                /* MBmemfree */
                lnappend(record_hdr->ust_time - svg_p->ust_time_ref,
@@ -1875,19 +1844,7 @@ __print_funct_t svg_print_memory_stats(struct activity *a, int curr, int action,
                /* MBcached */
                lnappend(record_hdr->ust_time - svg_p->ust_time_ref,
                         ((double) smc->camkb) / 1024,
-                         out + 5, outsize + 5, svg_p->restart);
-               /* MBswpfree */
-               lnappend(record_hdr->ust_time - svg_p->ust_time_ref,
-                        ((double) smc->frskb) / 1024,
-                        out + 16, outsize + 16, svg_p->restart);
-               /* MBswpused */
-               lnappend(record_hdr->ust_time - svg_p->ust_time_ref,
-                        ((double) (smc->tlskb - smc->frskb)) / 1024,
-                        out + 17, outsize + 17, svg_p->restart);
-               /* MBswpcad */
-               lnappend(record_hdr->ust_time - svg_p->ust_time_ref,
-                        ((double) smc->caskb) / 1024,
-                        out + 18, outsize + 18, svg_p->restart);
+                        out + 5, outsize + 5, svg_p->restart);
                /* MBcommit */
                lnappend(record_hdr->ust_time - svg_p->ust_time_ref,
                         ((double) smc->comkb) / 1024,
@@ -1927,58 +1884,190 @@ __print_funct_t svg_print_memory_stats(struct activity *a, int curr, int action,
                /* %memused */
                brappend(record_hdr->ust_time - svg_p->ust_time_ref,
                         0.0,
-                        smc->tlmkb ?
-                        SP_VALUE(nousedmem, smc->tlmkb, smc->tlmkb) : 0.0,
-                        out + 3, outsize + 3, svg_p->dt);
+                        smc->tlmkb ? SP_VALUE(nousedmem, smc->tlmkb, smc->tlmkb)
+                                   : 0.0,
+                       out + 3, outsize + 3, svg_p->dt);
                /* %commit */
                brappend(record_hdr->ust_time - svg_p->ust_time_ref,
                         0.0,
-                        (smc->tlmkb + smc->tlskb) ?
-                        SP_VALUE(0, smc->comkb, smc->tlmkb + smc->tlskb) : 0.0,
+                        (smc->tlmkb + smc->tlskb) ? SP_VALUE(0, smc->comkb, smc->tlmkb + smc->tlskb)
+                                                  : 0.0,
                         out + 7, outsize + 7, svg_p->dt);
+       }
+
+       if (action & F_END) {
+               int i;
+
+               /* Conversion kB -> MB */
+               for (i = 0; i < 17; i++) {
+                       if (g_fields[i] >= 0) {
+                               *(spmin + g_fields[i]) /= 1024;
+                               *(spmax + g_fields[i]) /= 1024;
+                       }
+               }
+
+               if (draw_activity_graphs(dispall ? 6 : 5,
+                                        g_type, title, g_title, NULL, group,
+                                        spmin, spmax, out, outsize, svg_p, record_hdr,
+                                        FALSE, a, *xid)) {
+                       (*xid)++;
+               }
+
+               /* Free remaining structures */
+               free_graphs(out, outsize, spmin, spmax);
+       }
+}
+
+/*
+ * **************************************************************************
+ * Display swap memory utilization in SVG.
+ *
+ * IN:
+ * @a          Activity structure with statistics.
+ * @smc                Structure with statistics.
+ * @action     Action expected from current function.
+ * @svg_p      SVG specific parameters: Current graph number (.@graph_no),
+ *             flag indicating that a restart record has been previously
+ *             found (.@restart) and time used for the X axis origin
+ *             (@ust_time_ref).
+ * @record_hdr Pointer on record header of current stats sample.
+ * @xid                SVG graph number.
+ ***************************************************************************
+ */
+__print_funct_t svg_print_swap_memory_stats(struct activity *a, struct stats_memory *smc,
+                                           int action, struct svg_parm *svg_p,
+                                           struct record_header *record_hdr, int xid)
+{
+       int group[] = {3, 1, 1};
+       int g_type[] = {SVG_LINE_GRAPH, SVG_BAR_GRAPH, SVG_BAR_GRAPH};
+       char *title[] = {"Swap utilization (1)", "Swap utilization (2)",
+                         "Swap utilization (3)"};
+       char *g_title[] = {"MBswpfree", "MBswpused", "MBswpcad", "%swpused",
+                           "%swpcad"};
+       int g_fields[] = {-1, -1, -1, 5, 0, 6, 2,
+                         -1, -1, -1, -1, -1, -1, -1, -1, -1, -1};
+       static double *spmin, *spmax;
+       static char **out;
+       static int *outsize;
+
+       if (action & F_BEGIN) {
+               /*
+                * Allocate arrays that will contain the graphs data
+                * and the min/max values.
+                */
+               out = allocate_graph_lines(7, &outsize, &spmin, &spmax);
+       }
+
+       if (action & F_MAIN) {
+               double tval;
+
+               /* Check for min/max values */
+               save_extrema(a->gtypes_nr, (void *) smc, NULL, 0, spmin, spmax, g_fields);
+
+               /* Compute %swpused min/max values */
+               tval = smc->tlskb ?
+               SP_VALUE(smc->frskb, smc->tlskb, smc->tlskb) : 0.0;
+               if (tval > *(spmax + 3)) {
+                       *(spmax + 3) = tval;
+               }
+               if (tval < *(spmin + 3)) {
+                       *(spmin + 3) = tval;
+               }
+               /* Compute %swpcad min/max values */
+               tval = (smc->tlskb - smc->frskb) ?
+               SP_VALUE(0, smc->caskb, smc->tlskb - smc->frskb) : 0.0;
+               if (tval > *(spmax + 4)) {
+                       *(spmax + 4) = tval;
+               }
+               if (tval < *(spmin + 4)) {
+                       *(spmin + 4) = tval;
+               }
+               /* Compute swpused min/max values in MB */
+               tval = ((double) (smc->tlskb - smc->frskb)) / 1024;
+               if (tval > *(spmax + 1)) {
+                       *(spmax + 1) = tval;
+               }
+               if (tval < *(spmin + 1)) {
+                       *(spmin + 1) = tval;
+               }
+
+               /* MBswpfree */
+               lnappend(record_hdr->ust_time - svg_p->ust_time_ref,
+                        ((double) smc->frskb) / 1024,
+                        out, outsize, svg_p->restart);
+               /* MBswpused */
+               lnappend(record_hdr->ust_time - svg_p->ust_time_ref,
+                        ((double) (smc->tlskb - smc->frskb)) / 1024,
+                        out + 1, outsize + 1, svg_p->restart);
+               /* MBswpcad */
+               lnappend(record_hdr->ust_time - svg_p->ust_time_ref,
+                        ((double) smc->caskb) / 1024,
+                        out + 2, outsize + 2, svg_p->restart);
                /* %swpused */
                brappend(record_hdr->ust_time - svg_p->ust_time_ref,
                         0.0,
-                        smc->tlskb ?
-                        SP_VALUE(smc->frskb, smc->tlskb, smc->tlskb) : 0.0,
-                        out + 19, outsize + 19, svg_p->dt);
+                        smc->tlskb ? SP_VALUE(smc->frskb, smc->tlskb, smc->tlskb)
+                                   : 0.0,
+                        out + 3, outsize + 3, svg_p->dt);
                /* %swpcad */
                brappend(record_hdr->ust_time - svg_p->ust_time_ref,
                         0.0,
-                        (smc->tlskb - smc->frskb) ?
-                        SP_VALUE(0, smc->caskb, smc->tlskb - smc->frskb) : 0.0,
-                        out + 20, outsize + 20, svg_p->dt);
+                        (smc->tlskb - smc->frskb) ? SP_VALUE(0, smc->caskb, smc->tlskb - smc->frskb)
+                                                  : 0.0,
+                        out + 4, outsize + 4, svg_p->dt);
        }
 
        if (action & F_END) {
                int i;
 
                /* Conversion kB -> MB */
-               for (i = 0; i < 17; i++) {
+               for (i = 3; i < 7; i++) {
                        *(spmin + g_fields[i]) /= 1024;
                        *(spmax + g_fields[i]) /= 1024;
                }
 
-               if (DISPLAY_MEMORY(a->opt_flags)) {
-                       if (draw_activity_graphs(DISPLAY_MEM_ALL(a->opt_flags) ? 6 : 5,
-                                                g_type1, title1, g_title1, NULL, group1,
-                                                spmin, spmax, out, outsize, svg_p, record_hdr,
-                                                FALSE, a, xid)) {
-                               xid++;
-                       }
-               }
-
-               if (DISPLAY_SWAP(a->opt_flags)) {
-                       draw_activity_graphs(3, g_type2, title2, g_title2, NULL, group2,
-                                            spmin + 16, spmax + 16, out + 16, outsize + 16,
-                                            svg_p, record_hdr, FALSE, a, xid);
-               }
+               draw_activity_graphs(3, g_type, title, g_title, NULL, group,
+                                    spmin, spmax, out, outsize,
+                                    svg_p, record_hdr, FALSE, a, xid);
 
                /* Free remaining structures */
                free_graphs(out, outsize, spmin, spmax);
        }
 }
 
+/*
+ * **************************************************************************
+ * Display memory statistics in SVG.
+ *
+ * IN:
+ * @a          Activity structure with statistics.
+ * @curr       Index in array for current sample statistics.
+ * @action     Action expected from current function.
+ * @svg_p      SVG specific parameters: Current graph number (.@graph_no),
+ *             flag indicating that a restart record has been previously
+ *             found (.@restart) and time used for the X axis origin
+ *             (@ust_time_ref).
+ * @itv                Interval of time in 1/100th of a second (only with F_MAIN action).
+ * @record_hdr Pointer on record header of current stats sample.
+ ***************************************************************************
+ */
+__print_funct_t svg_print_memory_stats(struct activity *a, int curr, int action, struct svg_parm *svg_p,
+                                      unsigned long long itv, struct record_header *record_hdr)
+{
+       struct stats_memory
+               *smc = (struct stats_memory *) a->buf[curr];
+       static int xid = 0;
+
+       if (DISPLAY_MEMORY(a->opt_flags)) {
+               svg_print_ram_memory_stats(a, smc, action, DISPLAY_MEM_ALL(a->opt_flags),
+                                          svg_p, record_hdr, &xid);
+       }
+
+       if (DISPLAY_SWAP(a->opt_flags)) {
+               svg_print_swap_memory_stats(a, smc, action, svg_p, record_hdr, xid);
+       }
+}
+
 /*
  ***************************************************************************
  * Display kernel tables statistics in SVG.
index 4793fd2ed8386e683779fa29d0529087cebd2aa1..28228c0e256948cd0fa37e508a12a5de7567e214 100644 (file)
@@ -498,107 +498,114 @@ __print_funct_t xml_print_io_stats(struct activity *a, int curr, int tab,
 }
 
 /*
- ***************************************************************************
- * Display memory statistics in XML.
+ * **************************************************************************
+ * Display RAM memory utilization in XML.
  *
  * IN:
- * @a          Activity structure with statistics.
- * @curr       Index in array for current sample statistics.
+ * @smc                Structure with statistics.
+ * @dispall    TRUE if all memory fields should be displayed.
  * @tab                Indentation in XML output.
- * @itv                Interval of time in 1/100th of a second.
  ***************************************************************************
  */
-__print_funct_t xml_print_memory_stats(struct activity *a, int curr, int tab,
-                                      unsigned long long itv)
+void xml_print_ram_memory_stats(struct stats_memory *smc, int dispall, int *tab)
 {
-       struct stats_memory
-               *smc = (struct stats_memory *) a->buf[curr];
+       unsigned long long nousedmem;
 
-       xprintf(tab, "<memory unit=\"kB\">");
+       nousedmem = smc->frmkb + smc->bufkb + smc->camkb + smc->slabkb;
+       if (nousedmem > smc->tlmkb) {
+               nousedmem = smc->tlmkb;
+       }
 
-       if (DISPLAY_MEMORY(a->opt_flags)) {
-               unsigned long long nousedmem;
+       xprintf(++(*tab), "<memfree>%llu</memfree>", smc->frmkb);
 
-               nousedmem = smc->frmkb + smc->bufkb + smc->camkb + smc->slabkb;
-               if (nousedmem > smc->tlmkb) {
-                       nousedmem = smc->tlmkb;
-               }
+       xprintf(*tab, "<avail>%llu</avail>", smc->availablekb);
 
-               xprintf(++tab, "<memfree>%llu</memfree>",
-                       smc->frmkb);
+       xprintf(*tab, "<memused>%llu</memused>", smc->tlmkb - nousedmem);
 
-               xprintf(tab, "<avail>%llu</avail>",
-                       smc->availablekb);
+       xprintf(*tab, "<memused-percent>%.2f</memused-percent>",
+               smc->tlmkb ? SP_VALUE(nousedmem, smc->tlmkb, smc->tlmkb)
+                          : 0.0);
 
-               xprintf(tab, "<memused>%llu</memused>",
-                       smc->tlmkb - nousedmem);
+       xprintf(*tab, "<buffers>%llu</buffers>", smc->bufkb);
 
-               xprintf(tab, "<memused-percent>%.2f</memused-percent>",
-                       smc->tlmkb ?
-                       SP_VALUE(nousedmem, smc->tlmkb, smc->tlmkb) :
-                       0.0);
+       xprintf(*tab, "<cached>%llu</cached>", smc->camkb);
 
-               xprintf(tab, "<buffers>%llu</buffers>",
-                       smc->bufkb);
+       xprintf(*tab, "<commit>%llu</commit>", smc->comkb);
 
-               xprintf(tab, "<cached>%llu</cached>",
-                       smc->camkb);
+       xprintf(*tab, "<commit-percent>%.2f</commit-percent>",
+               (smc->tlmkb + smc->tlskb) ? SP_VALUE(0, smc->comkb, smc->tlmkb + smc->tlskb)
+                                         : 0.0);
 
-               xprintf(tab, "<commit>%llu</commit>",
-                       smc->comkb);
+       xprintf(*tab, "<active>%llu</active>", smc->activekb);
 
-               xprintf(tab, "<commit-percent>%.2f</commit-percent>",
-                       (smc->tlmkb + smc->tlskb) ?
-                       SP_VALUE(0, smc->comkb, smc->tlmkb + smc->tlskb) :
-                       0.0);
+       xprintf(*tab, "<inactive>%llu</inactive>", smc->inactkb);
 
-               xprintf(tab, "<active>%llu</active>",
-                       smc->activekb);
+       xprintf((*tab)--, "<dirty>%llu</dirty>", smc->dirtykb);
 
-               xprintf(tab, "<inactive>%llu</inactive>",
-                       smc->inactkb);
+       if (dispall) {
+               xprintf(++(*tab), "<anonpg>%llu</anonpg>", smc->anonpgkb);
 
-               xprintf(tab--, "<dirty>%llu</dirty>",
-                       smc->dirtykb);
+               xprintf(*tab, "<slab>%llu</slab>", smc->slabkb);
 
-               if (DISPLAY_MEM_ALL(a->opt_flags)) {
-                       xprintf(++tab, "<anonpg>%llu</anonpg>",
-                               smc->anonpgkb);
+               xprintf(*tab, "<kstack>%llu</kstack>", smc->kstackkb);
 
-                       xprintf(tab, "<slab>%llu</slab>",
-                               smc->slabkb);
+               xprintf(*tab, "<pgtbl>%llu</pgtbl>", smc->pgtblkb);
 
-                       xprintf(tab, "<kstack>%llu</kstack>",
-                               smc->kstackkb);
+               xprintf((*tab)--, "<vmused>%llu</vmused>", smc->vmusedkb);
+       }
+}
 
-                       xprintf(tab, "<pgtbl>%llu</pgtbl>",
-                               smc->pgtblkb);
+/*
+ * **************************************************************************
+ * Display swap memory utilization in XML.
+ *
+ * IN:
+ * @smc                Structure with statistics.
+ * @tab                Indentation in XML output.
+ ***************************************************************************
+ */
+void xml_print_swap_memory_stats(struct stats_memory *smc, int *tab)
+{
+       xprintf(++(*tab), "<swpfree>%llu</swpfree>", smc->frskb);
 
-                       xprintf(tab--, "<vmused>%llu</vmused>",
-                               smc->vmusedkb);
-               }
-       }
+       xprintf(*tab, "<swpused>%llu</swpused>", smc->tlskb - smc->frskb);
 
-       if (DISPLAY_SWAP(a->opt_flags)) {
+       xprintf(*tab, "<swpused-percent>%.2f</swpused-percent>",
+               smc->tlskb ? SP_VALUE(smc->frskb, smc->tlskb, smc->tlskb)
+                          : 0.0);
+
+       xprintf(*tab, "<swpcad>%llu</swpcad>", smc->caskb);
 
-               xprintf(++tab, "<swpfree>%llu</swpfree>",
-                       smc->frskb);
+       xprintf((*tab)--, "<swpcad-percent>%.2f</swpcad-percent>",
+               (smc->tlskb - smc->frskb) ? SP_VALUE(0, smc->caskb, smc->tlskb - smc->frskb)
+                                         : 0.0);
+}
 
-               xprintf(tab, "<swpused>%llu</swpused>",
-                       smc->tlskb - smc->frskb);
+/*
+ ***************************************************************************
+ * Display memory statistics in XML.
+ *
+ * IN:
+ * @a          Activity structure with statistics.
+ * @curr       Index in array for current sample statistics.
+ * @tab                Indentation in XML output.
+ * @itv                Interval of time in 1/100th of a second.
+ ***************************************************************************
+ */
+__print_funct_t xml_print_memory_stats(struct activity *a, int curr, int tab,
+                                      unsigned long long itv)
+{
+       struct stats_memory
+               *smc = (struct stats_memory *) a->buf[curr];
 
-               xprintf(tab, "<swpused-percent>%.2f</swpused-percent>",
-                       smc->tlskb ?
-                       SP_VALUE(smc->frskb, smc->tlskb, smc->tlskb) :
-                       0.0);
+       xprintf(tab, "<memory unit=\"kB\">");
 
-               xprintf(tab, "<swpcad>%llu</swpcad>",
-                       smc->caskb);
+       if (DISPLAY_MEMORY(a->opt_flags)) {
+               xml_print_ram_memory_stats(smc, DISPLAY_MEM_ALL(a->opt_flags), &tab);
+       }
 
-               xprintf(tab--, "<swpcad-percent>%.2f</swpcad-percent>",
-                       (smc->tlskb - smc->frskb) ?
-                       SP_VALUE(0, smc->caskb, smc->tlskb - smc->frskb) :
-                       0.0);
+       if (DISPLAY_SWAP(a->opt_flags)) {
+               xml_print_swap_memory_stats(smc, &tab);
        }
 
        xprintf(tab, "</memory>");