]> granicus.if.org Git - sysstat/commitdiff
sar: Add softnet statistics (part 4): ppc and CSV output formats
authorSebastien GODARD <sysstat@users.noreply.github.com>
Fri, 28 Oct 2016 16:27:00 +0000 (18:27 +0200)
committerSebastien GODARD <sysstat@users.noreply.github.com>
Fri, 28 Oct 2016 16:27:00 +0000 (18:27 +0200)
This patch adds ppc and database (CSV) output formats for softnet
statistics. These formats are displayed using sadf's options -p and -d.

Signed-off-by: Sebastien GODARD <sysstat@users.noreply.github.com>
rndr_stats.c

index 501b31ab1dc19299714d02d0eb0e24e354c790af..d756083b1a41404db99a1ad9fb0dd78d18b77455 100644 (file)
@@ -3000,5 +3000,108 @@ __print_funct_t render_fchost_stats(struct activity *a, int isdb, char *pre,
 __print_funct_t render_softnet_stats(struct activity *a, int isdb, char *pre,
                                     int curr, unsigned long long itv)
 {
-       /* FIXME */
+       int i;
+       struct stats_softnet
+               *ssnc = (struct stats_softnet *) a->buf[curr],
+               *ssnp = (struct stats_softnet *) a->buf[!curr];
+       int pt_newlin
+               = (DISPLAY_HORIZONTALLY(flags) ? PT_NOFLAG : PT_NEWLIN);
+
+       for (i = 0; (i < a->nr) && (i < a->bitmap->b_size + 1); i++) {
+
+               /*
+                * The size of a->buf[...] CPU structure may be different from the default
+                * sizeof(struct stats_pwr_cpufreq) value if data have been read from a file!
+                * That's why we don't use a syntax like:
+                * ssnc = (struct stats_softnet *) a->buf[...] + i;
+                 */
+                ssnc = (struct stats_softnet *) ((char *) a->buf[curr] + i * a->msize);
+                ssnp = (struct stats_softnet *) ((char *) a->buf[!curr] + i * a->msize);
+
+               /*
+                * Note: a->nr is in [1, NR_CPUS + 1].
+                * Bitmap size is provided for (NR_CPUS + 1) CPUs.
+                * Anyway, NR_CPUS may vary between the version of sysstat
+                * used by sadc to create a file, and the version of sysstat
+                * used by sar to read it...
+                */
+
+               /* Should current CPU (including CPU "all") be displayed? */
+               if (a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))) {
+
+                       if (!i) {
+                               /* This is CPU "all" */
+                               render(isdb, pre, PT_NOFLAG,
+                                      "all\ttotal/s",
+                                      "-1", NULL,
+                                      NOVAL,
+                                      S_VALUE(ssnp->processed, ssnc->processed, itv),
+                                      NULL);
+
+                               render(isdb, pre, PT_NOFLAG,
+                                      "all\tdropd/s",
+                                      NULL, NULL,
+                                      NOVAL,
+                                      S_VALUE(ssnp->dropped, ssnc->dropped, itv),
+                                      NULL);
+
+                               render(isdb, pre, PT_NOFLAG,
+                                      "all\tsqueezd/s",
+                                      NULL, NULL,
+                                      NOVAL,
+                                      S_VALUE(ssnp->time_squeeze, ssnc->time_squeeze, itv),
+                                      NULL);
+
+                               render(isdb, pre, PT_NOFLAG,
+                                      "all\trx_rps/s",
+                                      NULL, NULL,
+                                      NOVAL,
+                                      S_VALUE(ssnp->received_rps, ssnc->received_rps, itv),
+                                      NULL);
+
+                               render(isdb, pre, pt_newlin,
+                                      "all\tflw_lim/s",
+                                      NULL, NULL,
+                                      NOVAL,
+                                      S_VALUE(ssnp->flow_limit, ssnc->flow_limit, itv),
+                                      NULL);
+                       }
+                       else {
+                               render(isdb, pre, PT_NOFLAG,
+                                      "cpu%d\ttotal/s",
+                                      "%d", cons(iv, i - 1, NOVAL),
+                                      NOVAL,
+                                      S_VALUE(ssnp->processed, ssnc->processed, itv),
+                                      NULL);
+
+                               render(isdb, pre, PT_NOFLAG,
+                                      "cpu%d\tdropd/s",
+                                      NULL, cons(iv, i - 1, NOVAL),
+                                      NOVAL,
+                                      S_VALUE(ssnp->dropped, ssnc->dropped, itv),
+                                      NULL);
+
+                               render(isdb, pre, PT_NOFLAG,
+                                      "cpu%d\tsqueezd/s",
+                                      NULL, cons(iv, i - 1, NOVAL),
+                                      NOVAL,
+                                      S_VALUE(ssnp->time_squeeze, ssnc->time_squeeze, itv),
+                                      NULL);
+
+                               render(isdb, pre, PT_NOFLAG,
+                                      "cpu%d\trx_rps/s",
+                                      NULL, cons(iv, i - 1, NOVAL),
+                                      NOVAL,
+                                      S_VALUE(ssnp->received_rps, ssnc->received_rps, itv),
+                                      NULL);
+
+                               render(isdb, pre, pt_newlin,
+                                      "cpu%d\tflw_lim/s",
+                                      NULL, cons(iv, i - 1, NOVAL),
+                                      NOVAL,
+                                      S_VALUE(ssnp->flow_limit, ssnc->flow_limit, itv),
+                                      NULL);
+                       }
+               }
+       }
 }