__print_funct_t json_print_softnet_stats(struct activity *a, int curr, int tab,
unsigned long long itv)
{
+ int i;
+ struct stats_softnet *ssnc, *ssnp;
+ int sep = FALSE;
+ char cpuno[8];
+
if (!IS_SELECTED(a->options) || (a->nr <= 0))
goto close_json_markup;
json_markup_network(tab, OPEN_JSON_MARKUP);
+ tab++;
+
+ xprintf(tab++, "\"softnet\": [");
+
+ 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...
+ */
- /* FIXME */
+ /* Should current CPU (including CPU "all") be displayed? */
+ if (!(a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))))
+ /* No */
+ continue;
+
+ /* Yes: Display current CPU stats */
+
+ if (sep) {
+ printf(",\n");
+ }
+ sep = TRUE;
+
+ if (!i) {
+ /* This is CPU "all" */
+ strcpy(cpuno, "all");
+ }
+ else {
+ sprintf(cpuno, "%d", i - 1);
+ }
+
+ xprintf0(tab, "{\"cpu\": \"%s\", "
+ "\"total\": %.2f, "
+ "\"dropd\": %.2f, "
+ "\"squeezd\": %.2f, "
+ "\"rx_rps\": %.2f, "
+ "\"flw_lim\": %.2f}",
+ cpuno,
+ S_VALUE(ssnp->processed, ssnc->processed, itv),
+ S_VALUE(ssnp->dropped, ssnc->dropped, itv),
+ S_VALUE(ssnp->time_squeeze, ssnc->time_squeeze, itv),
+ S_VALUE(ssnp->received_rps, ssnc->received_rps, itv),
+ S_VALUE(ssnp->flow_limit, ssnc->flow_limit, itv));
+ }
+
+ printf("\n");
+ xprintf0(--tab, "]");
+
+ tab --;
close_json_markup:
if (CLOSE_MARKUP(a->options)) {