2 * json_stats.c: Funtions used by sadf to display statistics in JSON format.
3 * (C) 1999-2021 by Sebastien GODARD (sysstat <at> orange.fr)
5 ***************************************************************************
6 * This program is free software; you can redistribute it and/or modify it *
7 * under the terms of the GNU General Public License as published by the *
8 * Free Software Foundation; either version 2 of the License, or (at your *
9 * option) any later version. *
11 * This program is distributed in the hope that it will be useful, but *
12 * WITHOUT ANY WARRANTY; without the implied warranty of MERCHANTABILITY *
13 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License *
16 * You should have received a copy of the GNU General Public License along *
17 * with this program; if not, write to the Free Software Foundation, Inc., *
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA *
19 ***************************************************************************
28 #include "json_stats.h"
33 #define _(string) gettext(string)
35 #define _(string) (string)
38 extern uint64_t flags;
41 ***************************************************************************
42 * Open or close "network" markup.
45 * @tab Number of tabulations.
46 * @action Open or close action.
47 ***************************************************************************
49 void json_markup_network(int tab, int action)
51 static int markup_state = CLOSE_JSON_MARKUP;
53 if (action == markup_state)
55 markup_state = action;
57 if (action == OPEN_JSON_MARKUP) {
59 xprintf(tab, "\"network\": {");
69 ***************************************************************************
70 * Open or close "power-management" markup.
73 * @tab Number of tabulations.
74 * @action Open or close action.
75 ***************************************************************************
77 void json_markup_power_management(int tab, int action)
79 static int markup_state = CLOSE_JSON_MARKUP;
81 if (action == markup_state)
83 markup_state = action;
85 if (action == OPEN_JSON_MARKUP) {
87 xprintf(tab, "\"power-management\": {");
97 ***************************************************************************
98 * Open or close "psi" markup.
101 * @tab Number of tabulations.
102 * @action Open or close action.
103 ***************************************************************************
105 void json_markup_psi(int tab, int action)
107 static int markup_state = CLOSE_JSON_MARKUP;
109 if (action == markup_state)
111 markup_state = action;
113 if (action == OPEN_JSON_MARKUP) {
115 xprintf(tab, "\"psi\": {");
125 ***************************************************************************
126 * Display CPU statistics in JSON.
129 * @a Activity structure with statistics.
130 * @curr Index in array for current sample statistics.
131 * @tab Indentation in output.
132 * @itv Interval of time in 1/100th of a second (independent of the
133 * number of processors). Unused here.
134 ***************************************************************************
136 __print_funct_t json_print_cpu_stats(struct activity *a, int curr, int tab,
137 unsigned long long itv)
141 unsigned long long deltot_jiffies = 1;
142 struct stats_cpu *scc, *scp;
143 unsigned char offline_cpu_bitmap[BITMAP_SIZE(NR_CPUS)] = {0};
146 xprintf(tab++, "\"cpu-load\": [");
148 /* @nr[curr] cannot normally be greater than @nr_ini */
149 if (a->nr[curr] > a->nr_ini) {
150 a->nr_ini = a->nr[curr];
154 * Compute CPU "all" as sum of all individual CPU (on SMP machines)
155 * and look for offline CPU.
158 deltot_jiffies = get_global_cpu_statistics(a, !curr, curr,
159 flags, offline_cpu_bitmap);
162 for (i = 0; (i < a->nr_ini) && (i < a->bitmap->b_size + 1); i++) {
164 /* Should current CPU (including CPU "all") be displayed? */
165 if (!(a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))) ||
166 offline_cpu_bitmap[i >> 3] & (1 << (i & 0x07)))
167 /* Don't display CPU */
170 scc = (struct stats_cpu *) ((char *) a->buf[curr] + i * a->msize);
171 scp = (struct stats_cpu *) ((char *) a->buf[!curr] + i * a->msize);
179 /* This is CPU "all" */
180 strcpy(cpuno, "all");
182 if (a->nr_ini == 1) {
184 * This is a UP machine. In this case
185 * interval has still not been calculated.
187 deltot_jiffies = get_per_cpu_interval(scc, scp);
189 if (!deltot_jiffies) {
190 /* CPU "all" cannot be tickless */
195 sprintf(cpuno, "%d", i - 1);
198 * Recalculate interval for current proc.
199 * If result is 0 then current CPU is a tickless one.
201 deltot_jiffies = get_per_cpu_interval(scc, scp);
203 if (!deltot_jiffies) {
204 /* Current CPU is tickless */
205 if (DISPLAY_CPU_DEF(a->opt_flags)) {
206 xprintf0(tab, "{\"cpu\": \"%d\", "
213 i - 1, 0.0, 0.0, 0.0, 0.0, 0.0, 100.0);
215 else if (DISPLAY_CPU_ALL(a->opt_flags)) {
216 xprintf0(tab, "{\"cpu\": \"%d\", "
227 i - 1, 0.0, 0.0, 0.0, 0.0,
228 0.0, 0.0, 0.0, 0.0, 0.0, 100.0);
234 if (DISPLAY_CPU_DEF(a->opt_flags)) {
235 xprintf0(tab, "{\"cpu\": \"%s\", "
243 ll_sp_value(scp->cpu_user, scc->cpu_user, deltot_jiffies),
244 ll_sp_value(scp->cpu_nice, scc->cpu_nice, deltot_jiffies),
245 ll_sp_value(scp->cpu_sys + scp->cpu_hardirq + scp->cpu_softirq,
246 scc->cpu_sys + scc->cpu_hardirq + scc->cpu_softirq,
248 ll_sp_value(scp->cpu_iowait, scc->cpu_iowait, deltot_jiffies),
249 ll_sp_value(scp->cpu_steal, scc->cpu_steal, deltot_jiffies),
250 scc->cpu_idle < scp->cpu_idle ?
252 ll_sp_value(scp->cpu_idle, scc->cpu_idle, deltot_jiffies));
254 else if (DISPLAY_CPU_ALL(a->opt_flags)) {
255 xprintf0(tab, "{\"cpu\": \"%s\", "
267 (scc->cpu_user - scc->cpu_guest) < (scp->cpu_user - scp->cpu_guest) ?
269 ll_sp_value(scp->cpu_user - scp->cpu_guest,
270 scc->cpu_user - scc->cpu_guest, deltot_jiffies),
271 (scc->cpu_nice - scc->cpu_guest_nice) < (scp->cpu_nice - scp->cpu_guest_nice) ?
273 ll_sp_value(scp->cpu_nice - scp->cpu_guest_nice,
274 scc->cpu_nice - scc->cpu_guest_nice, deltot_jiffies),
275 ll_sp_value(scp->cpu_sys, scc->cpu_sys, deltot_jiffies),
276 ll_sp_value(scp->cpu_iowait, scc->cpu_iowait, deltot_jiffies),
277 ll_sp_value(scp->cpu_steal, scc->cpu_steal, deltot_jiffies),
278 ll_sp_value(scp->cpu_hardirq, scc->cpu_hardirq, deltot_jiffies),
279 ll_sp_value(scp->cpu_softirq, scc->cpu_softirq, deltot_jiffies),
280 ll_sp_value(scp->cpu_guest, scc->cpu_guest, deltot_jiffies),
281 ll_sp_value(scp->cpu_guest_nice, scc->cpu_guest_nice, deltot_jiffies),
282 scc->cpu_idle < scp->cpu_idle ?
284 ll_sp_value(scp->cpu_idle, scc->cpu_idle, deltot_jiffies));
289 xprintf0(--tab, "]");
293 ***************************************************************************
294 * Display task creation and context switch statistics in JSON.
297 * @a Activity structure with statistics.
298 * @curr Index in array for current sample statistics.
299 * @tab Indentation in output.
300 * @itv Interval of time in 1/100th of a second.
301 ***************************************************************************
303 __print_funct_t json_print_pcsw_stats(struct activity *a, int curr, int tab,
304 unsigned long long itv)
307 *spc = (struct stats_pcsw *) a->buf[curr],
308 *spp = (struct stats_pcsw *) a->buf[!curr];
310 /* proc/s and cswch/s */
311 xprintf0(tab, "\"process-and-context-switch\": {"
314 S_VALUE(spp->processes, spc->processes, itv),
315 S_VALUE(spp->context_switch, spc->context_switch, itv));
319 ***************************************************************************
320 * Display interrupts statistics in JSON.
323 * @a Activity structure with statistics.
324 * @curr Index in array for current sample statistics.
325 * @tab Indentation in output.
326 * @itv Interval of time in 1/100th of a second.
327 ***************************************************************************
329 __print_funct_t json_print_irq_stats(struct activity *a, int curr, int tab,
330 unsigned long long itv)
333 struct stats_irq *sic, *sip;
337 xprintf(tab++, "\"interrupts\": [");
339 for (i = 0; (i < a->nr[curr]) && (i < a->bitmap->b_size + 1); i++) {
341 sic = (struct stats_irq *) ((char *) a->buf[curr] + i * a->msize);
342 sip = (struct stats_irq *) ((char *) a->buf[!curr] + i * a->msize);
344 /* Should current interrupt (including int "sum") be displayed? */
345 if (a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))) {
347 /* Yes: Display it */
355 /* This is interrupt "sum" */
356 strcpy(irqno, "sum");
359 sprintf(irqno, "%d", i - 1);
362 xprintf0(tab, "{\"intr\": \"%s\", "
365 S_VALUE(sip->irq_nr, sic->irq_nr, itv));
370 xprintf0(--tab, "]");
374 ***************************************************************************
375 * Display swapping statistics in JSON.
378 * @a Activity structure with statistics.
379 * @curr Index in array for current sample statistics.
380 * @tab Indentation in output.
381 * @itv Interval of time in 1/100th of a second.
382 ***************************************************************************
384 __print_funct_t json_print_swap_stats(struct activity *a, int curr, int tab,
385 unsigned long long itv)
388 *ssc = (struct stats_swap *) a->buf[curr],
389 *ssp = (struct stats_swap *) a->buf[!curr];
391 xprintf0(tab, "\"swap-pages\": {"
393 "\"pswpout\": %.2f}",
394 S_VALUE(ssp->pswpin, ssc->pswpin, itv),
395 S_VALUE(ssp->pswpout, ssc->pswpout, itv));
399 ***************************************************************************
400 * Display paging statistics in JSON.
403 * @a Activity structure with statistics.
404 * @curr Index in array for current sample statistics.
405 * @tab Indentation in output.
406 * @itv Interval of time in 1/100th of a second.
407 ***************************************************************************
409 __print_funct_t json_print_paging_stats(struct activity *a, int curr, int tab,
410 unsigned long long itv)
413 *spc = (struct stats_paging *) a->buf[curr],
414 *spp = (struct stats_paging *) a->buf[!curr];
416 xprintf0(tab, "\"paging\": {"
418 "\"pgpgout\": %.2f, "
422 "\"pgscank\": %.2f, "
423 "\"pgscand\": %.2f, "
424 "\"pgsteal\": %.2f, "
425 "\"vmeff-percent\": %.2f}",
426 S_VALUE(spp->pgpgin, spc->pgpgin, itv),
427 S_VALUE(spp->pgpgout, spc->pgpgout, itv),
428 S_VALUE(spp->pgfault, spc->pgfault, itv),
429 S_VALUE(spp->pgmajfault, spc->pgmajfault, itv),
430 S_VALUE(spp->pgfree, spc->pgfree, itv),
431 S_VALUE(spp->pgscan_kswapd, spc->pgscan_kswapd, itv),
432 S_VALUE(spp->pgscan_direct, spc->pgscan_direct, itv),
433 S_VALUE(spp->pgsteal, spc->pgsteal, itv),
434 (spc->pgscan_kswapd + spc->pgscan_direct -
435 spp->pgscan_kswapd - spp->pgscan_direct) ?
436 SP_VALUE(spp->pgsteal, spc->pgsteal,
437 spc->pgscan_kswapd + spc->pgscan_direct -
438 spp->pgscan_kswapd - spp->pgscan_direct) : 0.0);
442 ***************************************************************************
443 * Display I/O and transfer rate statistics in JSON.
446 * @a Activity structure with statistics.
447 * @curr Index in array for current sample statistics.
448 * @tab Indentation in output.
449 * @itv Interval of time in 1/100th of a second.
450 ***************************************************************************
452 __print_funct_t json_print_io_stats(struct activity *a, int curr, int tab,
453 unsigned long long itv)
456 *sic = (struct stats_io *) a->buf[curr],
457 *sip = (struct stats_io *) a->buf[!curr];
459 xprintf0(tab, "\"io\": {"
471 * If we get negative values, this is probably because
472 * one or more devices/filesystems have been unmounted.
473 * We display 0.0 in this case though we should rather tell
474 * the user that the value cannot be calculated here.
476 sic->dk_drive < sip->dk_drive ? 0.0 :
477 S_VALUE(sip->dk_drive, sic->dk_drive, itv),
478 sic->dk_drive_rio < sip->dk_drive_rio ? 0.0 :
479 S_VALUE(sip->dk_drive_rio, sic->dk_drive_rio, itv),
480 sic->dk_drive_rblk < sip->dk_drive_rblk ? 0.0 :
481 S_VALUE(sip->dk_drive_rblk, sic->dk_drive_rblk, itv),
482 sic->dk_drive_wio < sip->dk_drive_wio ? 0.0 :
483 S_VALUE(sip->dk_drive_wio, sic->dk_drive_wio, itv),
484 sic->dk_drive_wblk < sip->dk_drive_wblk ? 0.0 :
485 S_VALUE(sip->dk_drive_wblk, sic->dk_drive_wblk, itv),
486 sic->dk_drive_dio < sip->dk_drive_dio ? 0.0 :
487 S_VALUE(sip->dk_drive_dio, sic->dk_drive_dio, itv),
488 sic->dk_drive_dblk < sip->dk_drive_dblk ? 0.0 :
489 S_VALUE(sip->dk_drive_dblk, sic->dk_drive_dblk, itv));
493 ***************************************************************************
494 * Display memory statistics in JSON.
497 * @a Activity structure with statistics.
498 * @curr Index in array for current sample statistics.
499 * @tab Indentation in output.
500 * @itv Interval of time in 1/100th of a second.
501 ***************************************************************************
503 __print_funct_t json_print_memory_stats(struct activity *a, int curr, int tab,
504 unsigned long long itv)
507 *smc = (struct stats_memory *) a->buf[curr];
509 unsigned long long nousedmem;
511 xprintf0(tab, "\"memory\": {");
513 if (DISPLAY_MEMORY(a->opt_flags)) {
517 nousedmem = smc->frmkb + smc->bufkb + smc->camkb + smc->slabkb;
518 if (nousedmem > smc->tlmkb) {
519 nousedmem = smc->tlmkb;
522 printf("\"memfree\": %llu, "
524 "\"memused\": %llu, "
525 "\"memused-percent\": %.2f, "
526 "\"buffers\": %llu, "
529 "\"commit-percent\": %.2f, "
531 "\"inactive\": %llu, "
535 smc->tlmkb - nousedmem,
537 SP_VALUE(nousedmem, smc->tlmkb, smc->tlmkb) :
542 (smc->tlmkb + smc->tlskb) ?
543 SP_VALUE(0, smc->comkb, smc->tlmkb + smc->tlskb) :
549 if (DISPLAY_MEM_ALL(a->opt_flags)) {
550 /* Display extended memory stats */
551 printf(", \"anonpg\": %llu, "
564 if (DISPLAY_SWAP(a->opt_flags)) {
571 printf("\"swpfree\": %llu, "
572 "\"swpused\": %llu, "
573 "\"swpused-percent\": %.2f, "
575 "\"swpcad-percent\": %.2f",
577 smc->tlskb - smc->frskb,
579 SP_VALUE(smc->frskb, smc->tlskb, smc->tlskb) :
582 (smc->tlskb - smc->frskb) ?
583 SP_VALUE(0, smc->caskb, smc->tlskb - smc->frskb) :
591 ***************************************************************************
592 * Display kernel tables statistics in JSON.
595 * @a Activity structure with statistics.
596 * @curr Index in array for current sample statistics.
597 * @tab Indentation in output.
598 * @itv Interval of time in 1/100th of a second.
599 ***************************************************************************
601 __print_funct_t json_print_ktables_stats(struct activity *a, int curr, int tab,
602 unsigned long long itv)
605 *skc = (struct stats_ktables *) a->buf[curr];
607 xprintf0(tab, "\"kernel\": {"
608 "\"dentunusd\": %llu, "
609 "\"file-nr\": %llu, "
610 "\"inode-nr\": %llu, "
619 ***************************************************************************
620 * Display queue and load statistics in JSON.
623 * @a Activity structure with statistics.
624 * @curr Index in array for current sample statistics.
625 * @tab Indentation in output.
626 * @itv Interval of time in 1/100th of a second.
627 ***************************************************************************
629 __print_funct_t json_print_queue_stats(struct activity *a, int curr, int tab,
630 unsigned long long itv)
633 *sqc = (struct stats_queue *) a->buf[curr];
635 xprintf0(tab, "\"queue\": {"
636 "\"runq-sz\": %llu, "
637 "\"plist-sz\": %llu, "
638 "\"ldavg-1\": %.2f, "
639 "\"ldavg-5\": %.2f, "
640 "\"ldavg-15\": %.2f, "
641 "\"blocked\": %llu}",
644 (double) sqc->load_avg_1 / 100,
645 (double) sqc->load_avg_5 / 100,
646 (double) sqc->load_avg_15 / 100,
651 ***************************************************************************
652 * Display serial lines statistics in JSON.
655 * @a Activity structure with statistics.
656 * @curr Index in array for current sample statistics.
657 * @tab Indentation in output.
658 * @itv Interval of time in 1/100th of a second.
659 ***************************************************************************
661 __print_funct_t json_print_serial_stats(struct activity *a, int curr, int tab,
662 unsigned long long itv)
665 struct stats_serial *ssc, *ssp;
668 xprintf(tab++, "\"serial\": [");
670 for (i = 0; i < a->nr[curr]; i++) {
674 if (a->nr[!curr] > 0) {
675 ssc = (struct stats_serial *) ((char *) a->buf[curr] + i * a->msize);
677 /* Look for corresponding serial line in previous iteration */
680 if (j >= a->nr[!curr]) {
681 j = a->nr[!curr] - 1;
687 ssp = (struct stats_serial *) ((char *) a->buf[!curr] + j * a->msize);
688 if (ssc->line == ssp->line) {
692 if (++j >= a->nr[!curr]) {
707 xprintf0(tab, "{\"line\": %d, "
710 "\"framerr\": %.2f, "
711 "\"prtyerr\": %.2f, "
715 S_VALUE(ssp->rx, ssc->rx, itv),
716 S_VALUE(ssp->tx, ssc->tx, itv),
717 S_VALUE(ssp->frame, ssc->frame, itv),
718 S_VALUE(ssp->parity, ssc->parity, itv),
719 S_VALUE(ssp->brk, ssc->brk, itv),
720 S_VALUE(ssp->overrun, ssc->overrun, itv));
724 xprintf0(--tab, "]");
728 ***************************************************************************
729 * Display disks statistics in JSON.
732 * @a Activity structure with statistics.
733 * @curr Index in array for current sample statistics.
734 * @tab Indentation in output.
735 * @itv Interval of time in 1/100th of a second.
736 ***************************************************************************
738 __print_funct_t json_print_disk_stats(struct activity *a, int curr, int tab,
739 unsigned long long itv)
742 struct stats_disk *sdc, *sdp, sdpzero;
743 struct ext_disk_stats xds;
747 memset(&sdpzero, 0, STATS_DISK_SIZE);
749 xprintf(tab++, "\"disk\": [");
751 for (i = 0; i < a->nr[curr]; i++) {
753 sdc = (struct stats_disk *) ((char *) a->buf[curr] + i * a->msize);
755 j = check_disk_reg(a, curr, !curr, i);
757 /* This is a newly registered interface. Previous stats are zero */
761 sdp = (struct stats_disk *) ((char *) a->buf[!curr] + j * a->msize);
764 /* Get device name */
765 dev_name = get_device_name(sdc->major, sdc->minor, sdc->wwn, sdc->part_nr,
766 DISPLAY_PRETTY(flags), DISPLAY_PERSIST_NAME_S(flags),
767 USE_STABLE_ID(flags), NULL);
769 if (a->item_list != NULL) {
770 /* A list of devices has been entered on the command line */
771 if (!search_list_item(a->item_list, dev_name))
772 /* Device not found */
776 /* Compute extended statistics values */
777 compute_ext_disk_stats(sdc, sdp, itv, &xds);
784 xprintf0(tab, "{\"disk-device\": \"%s\", "
792 "\"avgrq-sz\": %.2f, "
793 "\"areq-sz\": %.2f, "
794 "\"avgqu-sz\": %.2f, "
797 "\"util-percent\": %.2f}",
798 /* Confusion possible here between index and minor numbers */
800 S_VALUE(sdp->nr_ios, sdc->nr_ios, itv),
801 S_VALUE(sdp->rd_sect, sdc->rd_sect, itv), /* Unit = sectors (for backward compatibility) */
802 S_VALUE(sdp->wr_sect, sdc->wr_sect, itv),
803 S_VALUE(sdp->dc_sect, sdc->dc_sect, itv),
804 S_VALUE(sdp->rd_sect, sdc->rd_sect, itv) / 2,
805 S_VALUE(sdp->wr_sect, sdc->wr_sect, itv) / 2,
806 S_VALUE(sdp->dc_sect, sdc->dc_sect, itv) / 2,
807 /* See iostat for explanations */
808 xds.arqsz, /* Unit = sectors (for backward compatibility) */
810 S_VALUE(sdp->rq_ticks, sdc->rq_ticks, itv) / 1000.0, /* For backward compatibility */
811 S_VALUE(sdp->rq_ticks, sdc->rq_ticks, itv) / 1000.0,
817 xprintf0(--tab, "]");
821 ***************************************************************************
822 * Display network interfaces statistics in JSON.
825 * @a Activity structure with statistics.
826 * @curr Index in array for current sample statistics.
827 * @tab Indentation in output.
828 * @itv Interval of time in 1/100th of a second.
829 ***************************************************************************
831 __print_funct_t json_print_net_dev_stats(struct activity *a, int curr, int tab,
832 unsigned long long itv)
835 struct stats_net_dev *sndc, *sndp, sndzero;
837 double rxkb, txkb, ifutil;
839 memset(&sndzero, 0, STATS_NET_DEV_SIZE);
841 if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
842 goto close_json_markup;
844 json_markup_network(tab, OPEN_JSON_MARKUP);
847 xprintf(tab++, "\"net-dev\": [");
849 for (i = 0; i < a->nr[curr]; i++) {
851 sndc = (struct stats_net_dev *) ((char *) a->buf[curr] + i * a->msize);
853 if (a->item_list != NULL) {
854 /* A list of devices has been entered on the command line */
855 if (!search_list_item(a->item_list, sndc->interface))
856 /* Device not found */
860 j = check_net_dev_reg(a, curr, !curr, i);
862 /* This is a newly registered interface. Previous stats are zero */
866 sndp = (struct stats_net_dev *) ((char *) a->buf[!curr] + j * a->msize);
874 rxkb = S_VALUE(sndp->rx_bytes, sndc->rx_bytes, itv);
875 txkb = S_VALUE(sndp->tx_bytes, sndc->tx_bytes, itv);
876 ifutil = compute_ifutil(sndc, rxkb, txkb);
878 xprintf0(tab, "{\"iface\": \"%s\", "
886 "\"ifutil-percent\": %.2f}",
888 S_VALUE(sndp->rx_packets, sndc->rx_packets, itv),
889 S_VALUE(sndp->tx_packets, sndc->tx_packets, itv),
892 S_VALUE(sndp->rx_compressed, sndc->rx_compressed, itv),
893 S_VALUE(sndp->tx_compressed, sndc->tx_compressed, itv),
894 S_VALUE(sndp->multicast, sndc->multicast, itv),
899 xprintf0(--tab, "]");
904 if (CLOSE_MARKUP(a->options)) {
905 json_markup_network(tab, CLOSE_JSON_MARKUP);
910 ***************************************************************************
911 * Display network interfaces errors statistics in JSON.
914 * @a Activity structure with statistics.
915 * @curr Index in array for current sample statistics.
916 * @tab Indentation in output.
917 * @itv Interval of time in 1/100th of a second.
918 ***************************************************************************
920 __print_funct_t json_print_net_edev_stats(struct activity *a, int curr, int tab,
921 unsigned long long itv)
924 struct stats_net_edev *snedc, *snedp, snedzero;
927 if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
928 goto close_json_markup;
930 memset(&snedzero, 0, STATS_NET_EDEV_SIZE);
932 json_markup_network(tab, OPEN_JSON_MARKUP);
935 xprintf(tab++, "\"net-edev\": [");
937 for (i = 0; i < a->nr[curr]; i++) {
939 snedc = (struct stats_net_edev *) ((char *) a->buf[curr] + i * a->msize);
941 if (a->item_list != NULL) {
942 /* A list of devices has been entered on the command line */
943 if (!search_list_item(a->item_list, snedc->interface))
944 /* Device not found */
948 j = check_net_edev_reg(a, curr, !curr, i);
950 /* This is a newly registered interface. Previous stats are zero */
954 snedp = (struct stats_net_edev *) ((char *) a->buf[!curr] + j * a->msize);
962 xprintf0(tab, "{\"iface\": \"%s\", "
973 S_VALUE(snedp->rx_errors, snedc->rx_errors, itv),
974 S_VALUE(snedp->tx_errors, snedc->tx_errors, itv),
975 S_VALUE(snedp->collisions, snedc->collisions, itv),
976 S_VALUE(snedp->rx_dropped, snedc->rx_dropped, itv),
977 S_VALUE(snedp->tx_dropped, snedc->tx_dropped, itv),
978 S_VALUE(snedp->tx_carrier_errors, snedc->tx_carrier_errors, itv),
979 S_VALUE(snedp->rx_frame_errors, snedc->rx_frame_errors, itv),
980 S_VALUE(snedp->rx_fifo_errors, snedc->rx_fifo_errors, itv),
981 S_VALUE(snedp->tx_fifo_errors, snedc->tx_fifo_errors, itv));
985 xprintf0(--tab, "]");
990 if (CLOSE_MARKUP(a->options)) {
991 json_markup_network(tab, CLOSE_JSON_MARKUP);
996 ***************************************************************************
997 * Display NFS client statistics in JSON.
1000 * @a Activity structure with statistics.
1001 * @curr Index in array for current sample statistics.
1002 * @tab Indentation in output.
1003 * @itv Interval of time in 1/100th of a second.
1004 ***************************************************************************
1006 __print_funct_t json_print_net_nfs_stats(struct activity *a, int curr, int tab,
1007 unsigned long long itv)
1009 struct stats_net_nfs
1010 *snnc = (struct stats_net_nfs *) a->buf[curr],
1011 *snnp = (struct stats_net_nfs *) a->buf[!curr];
1013 if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
1014 goto close_json_markup;
1016 json_markup_network(tab, OPEN_JSON_MARKUP);
1019 xprintf0(tab, "\"net-nfs\": {"
1021 "\"retrans\": %.2f, "
1024 "\"access\": %.2f, "
1025 "\"getatt\": %.2f}",
1026 S_VALUE(snnp->nfs_rpccnt, snnc->nfs_rpccnt, itv),
1027 S_VALUE(snnp->nfs_rpcretrans, snnc->nfs_rpcretrans, itv),
1028 S_VALUE(snnp->nfs_readcnt, snnc->nfs_readcnt, itv),
1029 S_VALUE(snnp->nfs_writecnt, snnc->nfs_writecnt, itv),
1030 S_VALUE(snnp->nfs_accesscnt, snnc->nfs_accesscnt, itv),
1031 S_VALUE(snnp->nfs_getattcnt, snnc->nfs_getattcnt, itv));
1035 if (CLOSE_MARKUP(a->options)) {
1036 json_markup_network(tab, CLOSE_JSON_MARKUP);
1041 ***************************************************************************
1042 * Display NFS server statistics in JSON.
1045 * @a Activity structure with statistics.
1046 * @curr Index in array for current sample statistics.
1047 * @tab Indentation in output.
1048 * @itv Interval of time in 1/100th of a second.
1049 ***************************************************************************
1051 __print_funct_t json_print_net_nfsd_stats(struct activity *a, int curr, int tab,
1052 unsigned long long itv)
1054 struct stats_net_nfsd
1055 *snndc = (struct stats_net_nfsd *) a->buf[curr],
1056 *snndp = (struct stats_net_nfsd *) a->buf[!curr];
1058 if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
1059 goto close_json_markup;
1061 json_markup_network(tab, OPEN_JSON_MARKUP);
1064 xprintf0(tab, "\"net-nfsd\": {"
1066 "\"badcall\": %.2f, "
1067 "\"packet\": %.2f, "
1073 "\"swrite\": %.2f, "
1074 "\"saccess\": %.2f, "
1075 "\"sgetatt\": %.2f}",
1076 S_VALUE(snndp->nfsd_rpccnt, snndc->nfsd_rpccnt, itv),
1077 S_VALUE(snndp->nfsd_rpcbad, snndc->nfsd_rpcbad, itv),
1078 S_VALUE(snndp->nfsd_netcnt, snndc->nfsd_netcnt, itv),
1079 S_VALUE(snndp->nfsd_netudpcnt, snndc->nfsd_netudpcnt, itv),
1080 S_VALUE(snndp->nfsd_nettcpcnt, snndc->nfsd_nettcpcnt, itv),
1081 S_VALUE(snndp->nfsd_rchits, snndc->nfsd_rchits, itv),
1082 S_VALUE(snndp->nfsd_rcmisses, snndc->nfsd_rcmisses, itv),
1083 S_VALUE(snndp->nfsd_readcnt, snndc->nfsd_readcnt, itv),
1084 S_VALUE(snndp->nfsd_writecnt, snndc->nfsd_writecnt, itv),
1085 S_VALUE(snndp->nfsd_accesscnt, snndc->nfsd_accesscnt, itv),
1086 S_VALUE(snndp->nfsd_getattcnt, snndc->nfsd_getattcnt, itv));
1090 if (CLOSE_MARKUP(a->options)) {
1091 json_markup_network(tab, CLOSE_JSON_MARKUP);
1096 ***************************************************************************
1097 * Display network socket statistics in JSON.
1100 * @a Activity structure with statistics.
1101 * @curr Index in array for current sample statistics.
1102 * @tab Indentation in output.
1103 * @itv Interval of time in 1/100th of a second.
1104 ***************************************************************************
1106 __print_funct_t json_print_net_sock_stats(struct activity *a, int curr, int tab,
1107 unsigned long long itv)
1109 struct stats_net_sock
1110 *snsc = (struct stats_net_sock *) a->buf[curr];
1112 if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
1113 goto close_json_markup;
1115 json_markup_network(tab, OPEN_JSON_MARKUP);
1118 xprintf0(tab, "\"net-sock\": {"
1134 if (CLOSE_MARKUP(a->options)) {
1135 json_markup_network(tab, CLOSE_JSON_MARKUP);
1140 ***************************************************************************
1141 * Display IP network statistics in JSON.
1144 * @a Activity structure with statistics.
1145 * @curr Index in array for current sample statistics.
1146 * @tab Indentation in output.
1147 * @itv Interval of time in 1/100th of a second.
1148 ***************************************************************************
1150 __print_funct_t json_print_net_ip_stats(struct activity *a, int curr, int tab,
1151 unsigned long long itv)
1154 *snic = (struct stats_net_ip *) a->buf[curr],
1155 *snip = (struct stats_net_ip *) a->buf[!curr];
1157 if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
1158 goto close_json_markup;
1160 json_markup_network(tab, OPEN_JSON_MARKUP);
1163 xprintf0(tab, "\"net-ip\": {"
1165 "\"fwddgm\": %.2f, "
1170 "\"fragok\": %.2f, "
1171 "\"fragcrt\": %.2f}",
1172 S_VALUE(snip->InReceives, snic->InReceives, itv),
1173 S_VALUE(snip->ForwDatagrams, snic->ForwDatagrams, itv),
1174 S_VALUE(snip->InDelivers, snic->InDelivers, itv),
1175 S_VALUE(snip->OutRequests, snic->OutRequests, itv),
1176 S_VALUE(snip->ReasmReqds, snic->ReasmReqds, itv),
1177 S_VALUE(snip->ReasmOKs, snic->ReasmOKs, itv),
1178 S_VALUE(snip->FragOKs, snic->FragOKs, itv),
1179 S_VALUE(snip->FragCreates, snic->FragCreates, itv));
1183 if (CLOSE_MARKUP(a->options)) {
1184 json_markup_network(tab, CLOSE_JSON_MARKUP);
1189 ***************************************************************************
1190 * Display IP network errors statistics in JSON.
1193 * @a Activity structure with statistics.
1194 * @curr Index in array for current sample statistics.
1195 * @tab Indentation in output.
1196 * @itv Interval of time in 1/100th of a second.
1197 ***************************************************************************
1199 __print_funct_t json_print_net_eip_stats(struct activity *a, int curr, int tab,
1200 unsigned long long itv)
1202 struct stats_net_eip
1203 *sneic = (struct stats_net_eip *) a->buf[curr],
1204 *sneip = (struct stats_net_eip *) a->buf[!curr];
1206 if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
1207 goto close_json_markup;
1209 json_markup_network(tab, OPEN_JSON_MARKUP);
1212 xprintf0(tab, "\"net-eip\": {"
1213 "\"ihdrerr\": %.2f, "
1214 "\"iadrerr\": %.2f, "
1215 "\"iukwnpr\": %.2f, "
1221 S_VALUE(sneip->InHdrErrors, sneic->InHdrErrors, itv),
1222 S_VALUE(sneip->InAddrErrors, sneic->InAddrErrors, itv),
1223 S_VALUE(sneip->InUnknownProtos, sneic->InUnknownProtos, itv),
1224 S_VALUE(sneip->InDiscards, sneic->InDiscards, itv),
1225 S_VALUE(sneip->OutDiscards, sneic->OutDiscards, itv),
1226 S_VALUE(sneip->OutNoRoutes, sneic->OutNoRoutes, itv),
1227 S_VALUE(sneip->ReasmFails, sneic->ReasmFails, itv),
1228 S_VALUE(sneip->FragFails, sneic->FragFails, itv));
1232 if (CLOSE_MARKUP(a->options)) {
1233 json_markup_network(tab, CLOSE_JSON_MARKUP);
1238 ***************************************************************************
1239 * Display ICMP network statistics in JSON.
1242 * @a Activity structure with statistics.
1243 * @curr Index in array for current sample statistics.
1244 * @tab Indentation in output.
1245 * @itv Interval of time in 1/100th of a second.
1246 ***************************************************************************
1248 __print_funct_t json_print_net_icmp_stats(struct activity *a, int curr, int tab,
1249 unsigned long long itv)
1251 struct stats_net_icmp
1252 *snic = (struct stats_net_icmp *) a->buf[curr],
1253 *snip = (struct stats_net_icmp *) a->buf[!curr];
1255 if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
1256 goto close_json_markup;
1258 json_markup_network(tab, OPEN_JSON_MARKUP);
1261 xprintf0(tab, "\"net-icmp\": {"
1272 "\"iadrmk\": %.2f, "
1273 "\"iadrmkr\": %.2f, "
1274 "\"oadrmk\": %.2f, "
1275 "\"oadrmkr\": %.2f}",
1276 S_VALUE(snip->InMsgs, snic->InMsgs, itv),
1277 S_VALUE(snip->OutMsgs, snic->OutMsgs, itv),
1278 S_VALUE(snip->InEchos, snic->InEchos, itv),
1279 S_VALUE(snip->InEchoReps, snic->InEchoReps, itv),
1280 S_VALUE(snip->OutEchos, snic->OutEchos, itv),
1281 S_VALUE(snip->OutEchoReps, snic->OutEchoReps, itv),
1282 S_VALUE(snip->InTimestamps, snic->InTimestamps, itv),
1283 S_VALUE(snip->InTimestampReps, snic->InTimestampReps, itv),
1284 S_VALUE(snip->OutTimestamps, snic->OutTimestamps, itv),
1285 S_VALUE(snip->OutTimestampReps, snic->OutTimestampReps, itv),
1286 S_VALUE(snip->InAddrMasks, snic->InAddrMasks, itv),
1287 S_VALUE(snip->InAddrMaskReps, snic->InAddrMaskReps, itv),
1288 S_VALUE(snip->OutAddrMasks, snic->OutAddrMasks, itv),
1289 S_VALUE(snip->OutAddrMaskReps, snic->OutAddrMaskReps, itv));
1293 if (CLOSE_MARKUP(a->options)) {
1294 json_markup_network(tab, CLOSE_JSON_MARKUP);
1299 ***************************************************************************
1300 * Display ICMP errors message statistics in JSON.
1303 * @a Activity structure with statistics.
1304 * @curr Index in array for current sample statistics.
1305 * @tab Indentation in output.
1306 * @itv Interval of time in 1/100th of a second.
1307 ***************************************************************************
1309 __print_funct_t json_print_net_eicmp_stats(struct activity *a, int curr, int tab,
1310 unsigned long long itv)
1312 struct stats_net_eicmp
1313 *sneic = (struct stats_net_eicmp *) a->buf[curr],
1314 *sneip = (struct stats_net_eicmp *) a->buf[!curr];
1316 if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
1317 goto close_json_markup;
1319 json_markup_network(tab, OPEN_JSON_MARKUP);
1322 xprintf0(tab, "\"net-eicmp\": {"
1325 "\"idstunr\": %.2f, "
1326 "\"odstunr\": %.2f, "
1329 "\"iparmpb\": %.2f, "
1330 "\"oparmpb\": %.2f, "
1333 "\"iredir\": %.2f, "
1334 "\"oredir\": %.2f}",
1335 S_VALUE(sneip->InErrors, sneic->InErrors, itv),
1336 S_VALUE(sneip->OutErrors, sneic->OutErrors, itv),
1337 S_VALUE(sneip->InDestUnreachs, sneic->InDestUnreachs, itv),
1338 S_VALUE(sneip->OutDestUnreachs, sneic->OutDestUnreachs, itv),
1339 S_VALUE(sneip->InTimeExcds, sneic->InTimeExcds, itv),
1340 S_VALUE(sneip->OutTimeExcds, sneic->OutTimeExcds, itv),
1341 S_VALUE(sneip->InParmProbs, sneic->InParmProbs, itv),
1342 S_VALUE(sneip->OutParmProbs, sneic->OutParmProbs, itv),
1343 S_VALUE(sneip->InSrcQuenchs, sneic->InSrcQuenchs, itv),
1344 S_VALUE(sneip->OutSrcQuenchs, sneic->OutSrcQuenchs, itv),
1345 S_VALUE(sneip->InRedirects, sneic->InRedirects, itv),
1346 S_VALUE(sneip->OutRedirects, sneic->OutRedirects, itv));
1350 if (CLOSE_MARKUP(a->options)) {
1351 json_markup_network(tab, CLOSE_JSON_MARKUP);
1356 ***************************************************************************
1357 * Display TCP network statistics in JSON.
1360 * @a Activity structure with statistics.
1361 * @curr Index in array for current sample statistics.
1362 * @tab Indentation in output.
1363 * @itv Interval of time in 1/100th of a second.
1364 ***************************************************************************
1366 __print_funct_t json_print_net_tcp_stats(struct activity *a, int curr, int tab,
1367 unsigned long long itv)
1369 struct stats_net_tcp
1370 *sntc = (struct stats_net_tcp *) a->buf[curr],
1371 *sntp = (struct stats_net_tcp *) a->buf[!curr];
1373 if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
1374 goto close_json_markup;
1376 json_markup_network(tab, OPEN_JSON_MARKUP);
1379 xprintf0(tab, "\"net-tcp\": {"
1380 "\"active\": %.2f, "
1381 "\"passive\": %.2f, "
1384 S_VALUE(sntp->ActiveOpens, sntc->ActiveOpens, itv),
1385 S_VALUE(sntp->PassiveOpens, sntc->PassiveOpens, itv),
1386 S_VALUE(sntp->InSegs, sntc->InSegs, itv),
1387 S_VALUE(sntp->OutSegs, sntc->OutSegs, itv));
1391 if (CLOSE_MARKUP(a->options)) {
1392 json_markup_network(tab, CLOSE_JSON_MARKUP);
1397 ***************************************************************************
1398 * Display TCP network errors statistics in JSON.
1401 * @a Activity structure with statistics.
1402 * @curr Index in array for current sample statistics.
1403 * @tab Indentation in XML output.
1404 * @itv Interval of time in 1/100th of a second.
1405 ***************************************************************************
1407 __print_funct_t json_print_net_etcp_stats(struct activity *a, int curr, int tab,
1408 unsigned long long itv)
1410 struct stats_net_etcp
1411 *snetc = (struct stats_net_etcp *) a->buf[curr],
1412 *snetp = (struct stats_net_etcp *) a->buf[!curr];
1414 if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
1415 goto close_json_markup;
1417 json_markup_network(tab, OPEN_JSON_MARKUP);
1420 xprintf0(tab, "\"net-etcp\": {"
1421 "\"atmptf\": %.2f, "
1422 "\"estres\": %.2f, "
1423 "\"retrans\": %.2f, "
1424 "\"isegerr\": %.2f, "
1426 S_VALUE(snetp->AttemptFails, snetc->AttemptFails, itv),
1427 S_VALUE(snetp->EstabResets, snetc->EstabResets, itv),
1428 S_VALUE(snetp->RetransSegs, snetc->RetransSegs, itv),
1429 S_VALUE(snetp->InErrs, snetc->InErrs, itv),
1430 S_VALUE(snetp->OutRsts, snetc->OutRsts, itv));
1434 if (CLOSE_MARKUP(a->options)) {
1435 json_markup_network(tab, CLOSE_JSON_MARKUP);
1440 ***************************************************************************
1441 * Display UDP network statistics in JSON.
1444 * @a Activity structure with statistics.
1445 * @curr Index in array for current sample statistics.
1446 * @tab Indentation in output.
1447 * @itv Interval of time in 1/100th of a second.
1448 ***************************************************************************
1450 __print_funct_t json_print_net_udp_stats(struct activity *a, int curr, int tab,
1451 unsigned long long itv)
1453 struct stats_net_udp
1454 *snuc = (struct stats_net_udp *) a->buf[curr],
1455 *snup = (struct stats_net_udp *) a->buf[!curr];
1457 if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
1458 goto close_json_markup;
1460 json_markup_network(tab, OPEN_JSON_MARKUP);
1463 xprintf0(tab, "\"net-udp\": {"
1466 "\"noport\": %.2f, "
1467 "\"idgmerr\": %.2f}",
1468 S_VALUE(snup->InDatagrams, snuc->InDatagrams, itv),
1469 S_VALUE(snup->OutDatagrams, snuc->OutDatagrams, itv),
1470 S_VALUE(snup->NoPorts, snuc->NoPorts, itv),
1471 S_VALUE(snup->InErrors, snuc->InErrors, itv));
1475 if (CLOSE_MARKUP(a->options)) {
1476 json_markup_network(tab, CLOSE_JSON_MARKUP);
1481 ***************************************************************************
1482 * Display IPv6 network socket statistics in JSON.
1485 * @a Activity structure with statistics.
1486 * @curr Index in array for current sample statistics.
1487 * @tab Indentation in output.
1488 * @itv Interval of time in 1/100th of a second.
1489 ***************************************************************************
1491 __print_funct_t json_print_net_sock6_stats(struct activity *a, int curr, int tab,
1492 unsigned long long itv)
1494 struct stats_net_sock6
1495 *snsc = (struct stats_net_sock6 *) a->buf[curr];
1497 if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
1498 goto close_json_markup;
1500 json_markup_network(tab, OPEN_JSON_MARKUP);
1503 xprintf0(tab, "\"net-sock6\": {"
1507 "\"ip6-frag\": %u}",
1515 if (CLOSE_MARKUP(a->options)) {
1516 json_markup_network(tab, CLOSE_JSON_MARKUP);
1521 ***************************************************************************
1522 * Display IPv6 network statistics in JSON.
1525 * @a Activity structure with statistics.
1526 * @curr Index in array for current sample statistics.
1527 * @tab Indentation in output.
1528 * @itv Interval of time in 1/100th of a second.
1529 ***************************************************************************
1531 __print_funct_t json_print_net_ip6_stats(struct activity *a, int curr, int tab,
1532 unsigned long long itv)
1534 struct stats_net_ip6
1535 *snic = (struct stats_net_ip6 *) a->buf[curr],
1536 *snip = (struct stats_net_ip6 *) a->buf[!curr];
1538 if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
1539 goto close_json_markup;
1541 json_markup_network(tab, OPEN_JSON_MARKUP);
1544 xprintf0(tab, "\"net-ip6\": {"
1546 "\"fwddgm6\": %.2f, "
1549 "\"asmrq6\": %.2f, "
1550 "\"asmok6\": %.2f, "
1551 "\"imcpck6\": %.2f, "
1552 "\"omcpck6\": %.2f, "
1553 "\"fragok6\": %.2f, "
1554 "\"fragcr6\": %.2f}",
1555 S_VALUE(snip->InReceives6, snic->InReceives6, itv),
1556 S_VALUE(snip->OutForwDatagrams6, snic->OutForwDatagrams6, itv),
1557 S_VALUE(snip->InDelivers6, snic->InDelivers6, itv),
1558 S_VALUE(snip->OutRequests6, snic->OutRequests6, itv),
1559 S_VALUE(snip->ReasmReqds6, snic->ReasmReqds6, itv),
1560 S_VALUE(snip->ReasmOKs6, snic->ReasmOKs6, itv),
1561 S_VALUE(snip->InMcastPkts6, snic->InMcastPkts6, itv),
1562 S_VALUE(snip->OutMcastPkts6, snic->OutMcastPkts6, itv),
1563 S_VALUE(snip->FragOKs6, snic->FragOKs6, itv),
1564 S_VALUE(snip->FragCreates6, snic->FragCreates6, itv));
1568 if (CLOSE_MARKUP(a->options)) {
1569 json_markup_network(tab, CLOSE_JSON_MARKUP);
1574 ***************************************************************************
1575 * Display IPv6 network errors statistics in JSON.
1578 * @a Activity structure with statistics.
1579 * @curr Index in array for current sample statistics.
1580 * @tab Indentation in output.
1581 * @itv Interval of time in 1/100th of a second.
1582 ***************************************************************************
1584 __print_funct_t json_print_net_eip6_stats(struct activity *a, int curr, int tab,
1585 unsigned long long itv)
1587 struct stats_net_eip6
1588 *sneic = (struct stats_net_eip6 *) a->buf[curr],
1589 *sneip = (struct stats_net_eip6 *) a->buf[!curr];
1591 if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
1592 goto close_json_markup;
1594 json_markup_network(tab, OPEN_JSON_MARKUP);
1597 xprintf0(tab, "\"net-eip6\": {"
1598 "\"ihdrer6\": %.2f, "
1599 "\"iadrer6\": %.2f, "
1600 "\"iukwnp6\": %.2f, "
1601 "\"i2big6\": %.2f, "
1602 "\"idisc6\": %.2f, "
1603 "\"odisc6\": %.2f, "
1604 "\"inort6\": %.2f, "
1605 "\"onort6\": %.2f, "
1607 "\"fragf6\": %.2f, "
1608 "\"itrpck6\": %.2f}",
1609 S_VALUE(sneip->InHdrErrors6, sneic->InHdrErrors6, itv),
1610 S_VALUE(sneip->InAddrErrors6, sneic->InAddrErrors6, itv),
1611 S_VALUE(sneip->InUnknownProtos6, sneic->InUnknownProtos6, itv),
1612 S_VALUE(sneip->InTooBigErrors6, sneic->InTooBigErrors6, itv),
1613 S_VALUE(sneip->InDiscards6, sneic->InDiscards6, itv),
1614 S_VALUE(sneip->OutDiscards6, sneic->OutDiscards6, itv),
1615 S_VALUE(sneip->InNoRoutes6, sneic->InNoRoutes6, itv),
1616 S_VALUE(sneip->OutNoRoutes6, sneic->OutNoRoutes6, itv),
1617 S_VALUE(sneip->ReasmFails6, sneic->ReasmFails6, itv),
1618 S_VALUE(sneip->FragFails6, sneic->FragFails6, itv),
1619 S_VALUE(sneip->InTruncatedPkts6, sneic->InTruncatedPkts6, itv));
1623 if (CLOSE_MARKUP(a->options)) {
1624 json_markup_network(tab, CLOSE_JSON_MARKUP);
1629 ***************************************************************************
1630 * Display ICMPv6 network statistics in JSON.
1633 * @a Activity structure with statistics.
1634 * @curr Index in array for current sample statistics.
1635 * @tab Indentation in output.
1636 * @itv Interval of time in 1/100th of a second.
1637 ***************************************************************************
1639 __print_funct_t json_print_net_icmp6_stats(struct activity *a, int curr, int tab,
1640 unsigned long long itv)
1642 struct stats_net_icmp6
1643 *snic = (struct stats_net_icmp6 *) a->buf[curr],
1644 *snip = (struct stats_net_icmp6 *) a->buf[!curr];
1646 if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
1647 goto close_json_markup;
1649 json_markup_network(tab, OPEN_JSON_MARKUP);
1652 xprintf0(tab, "\"net-icmp6\": {"
1656 "\"iechr6\": %.2f, "
1657 "\"oechr6\": %.2f, "
1658 "\"igmbq6\": %.2f, "
1659 "\"igmbr6\": %.2f, "
1660 "\"ogmbr6\": %.2f, "
1661 "\"igmbrd6\": %.2f, "
1662 "\"ogmbrd6\": %.2f, "
1663 "\"irtsol6\": %.2f, "
1664 "\"ortsol6\": %.2f, "
1665 "\"irtad6\": %.2f, "
1666 "\"inbsol6\": %.2f, "
1667 "\"onbsol6\": %.2f, "
1668 "\"inbad6\": %.2f, "
1669 "\"onbad6\": %.2f}",
1670 S_VALUE(snip->InMsgs6, snic->InMsgs6, itv),
1671 S_VALUE(snip->OutMsgs6, snic->OutMsgs6, itv),
1672 S_VALUE(snip->InEchos6, snic->InEchos6, itv),
1673 S_VALUE(snip->InEchoReplies6, snic->InEchoReplies6, itv),
1674 S_VALUE(snip->OutEchoReplies6, snic->OutEchoReplies6, itv),
1675 S_VALUE(snip->InGroupMembQueries6, snic->InGroupMembQueries6, itv),
1676 S_VALUE(snip->InGroupMembResponses6, snic->InGroupMembResponses6, itv),
1677 S_VALUE(snip->OutGroupMembResponses6, snic->OutGroupMembResponses6, itv),
1678 S_VALUE(snip->InGroupMembReductions6, snic->InGroupMembReductions6, itv),
1679 S_VALUE(snip->OutGroupMembReductions6, snic->OutGroupMembReductions6, itv),
1680 S_VALUE(snip->InRouterSolicits6, snic->InRouterSolicits6, itv),
1681 S_VALUE(snip->OutRouterSolicits6, snic->OutRouterSolicits6, itv),
1682 S_VALUE(snip->InRouterAdvertisements6, snic->InRouterAdvertisements6, itv),
1683 S_VALUE(snip->InNeighborSolicits6, snic->InNeighborSolicits6, itv),
1684 S_VALUE(snip->OutNeighborSolicits6, snic->OutNeighborSolicits6, itv),
1685 S_VALUE(snip->InNeighborAdvertisements6, snic->InNeighborAdvertisements6, itv),
1686 S_VALUE(snip->OutNeighborAdvertisements6, snic->OutNeighborAdvertisements6, itv));
1690 if (CLOSE_MARKUP(a->options)) {
1691 json_markup_network(tab, CLOSE_JSON_MARKUP);
1696 ***************************************************************************
1697 * Display ICMPv6 error messages statistics in JSON.
1700 * @a Activity structure with statistics.
1701 * @curr Index in array for current sample statistics.
1702 * @tab Indentation in output.
1703 * @itv Interval of time in 1/100th of a second.
1704 ***************************************************************************
1706 __print_funct_t json_print_net_eicmp6_stats(struct activity *a, int curr, int tab,
1707 unsigned long long itv)
1709 struct stats_net_eicmp6
1710 *sneic = (struct stats_net_eicmp6 *) a->buf[curr],
1711 *sneip = (struct stats_net_eicmp6 *) a->buf[!curr];
1713 if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
1714 goto close_json_markup;
1716 json_markup_network(tab, OPEN_JSON_MARKUP);
1719 xprintf0(tab, "\"net-eicmp6\": {"
1721 "\"idtunr6\": %.2f, "
1722 "\"odtunr6\": %.2f, "
1723 "\"itmex6\": %.2f, "
1724 "\"otmex6\": %.2f, "
1725 "\"iprmpb6\": %.2f, "
1726 "\"oprmpb6\": %.2f, "
1727 "\"iredir6\": %.2f, "
1728 "\"oredir6\": %.2f, "
1729 "\"ipck2b6\": %.2f, "
1730 "\"opck2b6\": %.2f}",
1731 S_VALUE(sneip->InErrors6, sneic->InErrors6, itv),
1732 S_VALUE(sneip->InDestUnreachs6, sneic->InDestUnreachs6, itv),
1733 S_VALUE(sneip->OutDestUnreachs6, sneic->OutDestUnreachs6, itv),
1734 S_VALUE(sneip->InTimeExcds6, sneic->InTimeExcds6, itv),
1735 S_VALUE(sneip->OutTimeExcds6, sneic->OutTimeExcds6, itv),
1736 S_VALUE(sneip->InParmProblems6, sneic->InParmProblems6, itv),
1737 S_VALUE(sneip->OutParmProblems6, sneic->OutParmProblems6, itv),
1738 S_VALUE(sneip->InRedirects6, sneic->InRedirects6, itv),
1739 S_VALUE(sneip->OutRedirects6, sneic->OutRedirects6, itv),
1740 S_VALUE(sneip->InPktTooBigs6, sneic->InPktTooBigs6, itv),
1741 S_VALUE(sneip->OutPktTooBigs6, sneic->OutPktTooBigs6, itv));
1745 if (CLOSE_MARKUP(a->options)) {
1746 json_markup_network(tab, CLOSE_JSON_MARKUP);
1751 ***************************************************************************
1752 * Display UDPv6 network statistics in JSON.
1755 * @a Activity structure with statistics.
1756 * @curr Index in array for current sample statistics.
1757 * @tab Indentation in output.
1758 * @itv Interval of time in 1/100th of a second.
1759 ***************************************************************************
1761 __print_funct_t json_print_net_udp6_stats(struct activity *a, int curr, int tab,
1762 unsigned long long itv)
1764 struct stats_net_udp6
1765 *snuc = (struct stats_net_udp6 *) a->buf[curr],
1766 *snup = (struct stats_net_udp6 *) a->buf[!curr];
1768 if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
1769 goto close_json_markup;
1771 json_markup_network(tab, OPEN_JSON_MARKUP);
1774 xprintf0(tab, "\"net-udp6\": {"
1777 "\"noport6\": %.2f, "
1778 "\"idgmer6\": %.2f}",
1779 S_VALUE(snup->InDatagrams6, snuc->InDatagrams6, itv),
1780 S_VALUE(snup->OutDatagrams6, snuc->OutDatagrams6, itv),
1781 S_VALUE(snup->NoPorts6, snuc->NoPorts6, itv),
1782 S_VALUE(snup->InErrors6, snuc->InErrors6, itv));
1786 if (CLOSE_MARKUP(a->options)) {
1787 json_markup_network(tab, CLOSE_JSON_MARKUP);
1792 ***************************************************************************
1793 * Display CPU frequency statistics in JSON.
1796 * @a Activity structure with statistics.
1797 * @curr Index in array for current sample statistics.
1798 * @tab Indentation in output.
1799 * @itv Interval of time in 1/100th of a second.
1800 ***************************************************************************
1802 __print_funct_t json_print_pwr_cpufreq_stats(struct activity *a, int curr, int tab,
1803 unsigned long long itv)
1806 struct stats_pwr_cpufreq *spc;
1810 if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
1811 goto close_json_markup;
1813 json_markup_power_management(tab, OPEN_JSON_MARKUP);
1816 xprintf(tab++, "\"cpu-frequency\": [");
1818 for (i = 0; (i < a->nr[curr]) && (i < a->bitmap->b_size + 1); i++) {
1820 spc = (struct stats_pwr_cpufreq *) ((char *) a->buf[curr] + i * a->msize);
1822 /* Should current CPU (including CPU "all") be displayed? */
1823 if (!(a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))))
1828 /* This is CPU "all" */
1829 strcpy(cpuno, "all");
1832 sprintf(cpuno, "%d", i - 1);
1840 xprintf0(tab, "{\"number\": \"%s\", "
1841 "\"frequency\": %.2f}",
1843 ((double) spc->cpufreq) / 100);
1847 xprintf0(--tab, "]");
1851 if (CLOSE_MARKUP(a->options)) {
1852 json_markup_power_management(tab, CLOSE_JSON_MARKUP);
1857 ***************************************************************************
1858 * Display fan statistics in JSON.
1861 * @a Activity structure with statistics.
1862 * @curr Index in array for current sample statistics.
1863 * @tab Indentation in output.
1864 * @itv Interval of time in 1/100th of a second.
1865 ***************************************************************************
1867 __print_funct_t json_print_pwr_fan_stats(struct activity *a, int curr, int tab,
1868 unsigned long long itv)
1871 struct stats_pwr_fan *spc;
1874 if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
1875 goto close_json_markup;
1877 json_markup_power_management(tab, OPEN_JSON_MARKUP);
1880 xprintf(tab++, "\"fan-speed\": [");
1882 for (i = 0; i < a->nr[curr]; i++) {
1883 spc = (struct stats_pwr_fan *) ((char *) a->buf[curr] + i * a->msize);
1890 xprintf0(tab, "{\"number\": %d, "
1893 "\"device\": \"%s\"}",
1895 (unsigned long long) spc->rpm,
1896 (unsigned long long) (spc->rpm - spc->rpm_min),
1901 xprintf0(--tab, "]");
1905 if (CLOSE_MARKUP(a->options)) {
1906 json_markup_power_management(tab, CLOSE_JSON_MARKUP);
1911 ***************************************************************************
1912 * Display temperature statistics in JSON.
1915 * @a Activity structure with statistics.
1916 * @curr Index in array for current sample statistics.
1917 * @tab Indentation in output.
1918 * @itv Interval of time in 1/100th of a second.
1919 ***************************************************************************
1921 __print_funct_t json_print_pwr_temp_stats(struct activity *a, int curr, int tab,
1922 unsigned long long itv)
1925 struct stats_pwr_temp *spc;
1928 if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
1929 goto close_json_markup;
1931 json_markup_power_management(tab, OPEN_JSON_MARKUP);
1934 xprintf(tab++, "\"temperature\": [");
1936 for (i = 0; i < a->nr[curr]; i++) {
1937 spc = (struct stats_pwr_temp *) ((char *) a->buf[curr] + i * a->msize);
1944 xprintf0(tab, "{\"number\": %d, "
1946 "\"percent-temp\": %.2f, "
1947 "\"device\": \"%s\"}",
1950 (spc->temp_max - spc->temp_min) ?
1951 (spc->temp - spc->temp_min) / (spc->temp_max - spc->temp_min) * 100 :
1957 xprintf0(--tab, "]");
1961 if (CLOSE_MARKUP(a->options)) {
1962 json_markup_power_management(tab, CLOSE_JSON_MARKUP);
1967 ***************************************************************************
1968 * Display voltage inputs statistics in JSON.
1971 * @a Activity structure with statistics.
1972 * @curr Index in array for current sample statistics.
1973 * @tab Indentation in output.
1974 * @itv Interval of time in 1/100th of a second.
1975 ***************************************************************************
1977 __print_funct_t json_print_pwr_in_stats(struct activity *a, int curr, int tab,
1978 unsigned long long itv)
1981 struct stats_pwr_in *spc;
1984 if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
1985 goto close_json_markup;
1987 json_markup_power_management(tab, OPEN_JSON_MARKUP);
1990 xprintf(tab++, "\"voltage-input\": [");
1992 for (i = 0; i < a->nr[curr]; i++) {
1993 spc = (struct stats_pwr_in *) ((char *) a->buf[curr] + i * a->msize);
2000 xprintf0(tab, "{\"number\": %d, "
2002 "\"percent-in\": %.2f, "
2003 "\"device\": \"%s\"}",
2006 (spc->in_max - spc->in_min) ?
2007 (spc->in - spc->in_min) / (spc->in_max - spc->in_min) * 100 :
2013 xprintf0(--tab, "]");
2017 if (CLOSE_MARKUP(a->options)) {
2018 json_markup_power_management(tab, CLOSE_JSON_MARKUP);
2023 ***************************************************************************
2024 * Display huge pages statistics in JSON.
2027 * @a Activity structure with statistics.
2028 * @curr Index in array for current sample statistics.
2029 * @tab Indentation in output.
2030 * @itv Interval of time in 1/100th of a second.
2031 ***************************************************************************
2033 __print_funct_t json_print_huge_stats(struct activity *a, int curr, int tab,
2034 unsigned long long itv)
2037 *smc = (struct stats_huge *) a->buf[curr];
2039 xprintf0(tab, "\"hugepages\": {"
2040 "\"hugfree\": %llu, "
2041 "\"hugused\": %llu, "
2042 "\"hugused-percent\": %.2f, "
2043 "\"hugrsvd\": %llu, "
2044 "\"hugsurp\": %llu}",
2046 smc->tlhkb - smc->frhkb,
2048 SP_VALUE(smc->frhkb, smc->tlhkb, smc->tlhkb) : 0.0,
2054 ***************************************************************************
2055 * Display weighted CPU frequency statistics in JSON.
2058 * @a Activity structure with statistics.
2059 * @curr Index in array for current sample statistics.
2060 * @tab Indentation in output.
2061 * @itv Interval of time in 1/100th of a second.
2062 ***************************************************************************
2064 __print_funct_t json_print_pwr_wghfreq_stats(struct activity *a, int curr, int tab,
2065 unsigned long long itv)
2068 struct stats_pwr_wghfreq *spc, *spp, *spc_k, *spp_k;
2069 unsigned long long tis, tisfreq;
2073 if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
2074 goto close_json_markup;
2076 json_markup_power_management(tab, OPEN_JSON_MARKUP);
2079 xprintf(tab++, "\"cpu-weighted-frequency\": [");
2081 for (i = 0; (i < a->nr[curr]) && (i < a->bitmap->b_size + 1); i++) {
2083 spc = (struct stats_pwr_wghfreq *) ((char *) a->buf[curr] + i * a->msize * a->nr2);
2084 spp = (struct stats_pwr_wghfreq *) ((char *) a->buf[!curr] + i * a->msize * a->nr2);
2086 /* Should current CPU (including CPU "all") be displayed? */
2087 if (!(a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))))
2094 for (k = 0; k < a->nr2; k++) {
2096 spc_k = (struct stats_pwr_wghfreq *) ((char *) spc + k * a->msize);
2099 spp_k = (struct stats_pwr_wghfreq *) ((char *) spp + k * a->msize);
2101 tisfreq += (spc_k->freq / 1000) *
2102 (spc_k->time_in_state - spp_k->time_in_state);
2103 tis += (spc_k->time_in_state - spp_k->time_in_state);
2107 /* This is CPU "all" */
2108 strcpy(cpuno, "all");
2111 sprintf(cpuno, "%d", i - 1);
2119 xprintf0(tab, "{\"number\": \"%s\", "
2120 "\"weighted-frequency\": %.2f}",
2122 tis ? ((double) tisfreq) / tis : 0.0);
2126 xprintf0(--tab, "]");
2130 if (CLOSE_MARKUP(a->options)) {
2131 json_markup_power_management(tab, CLOSE_JSON_MARKUP);
2136 ***************************************************************************
2137 * Display USB devices statistics in JSON.
2140 * @a Activity structure with statistics.
2141 * @curr Index in array for current sample statistics.
2142 * @tab Indentation in output.
2143 * @itv Interval of time in 1/100th of a second.
2144 ***************************************************************************
2146 __print_funct_t json_print_pwr_usb_stats(struct activity *a, int curr, int tab,
2147 unsigned long long itv)
2150 struct stats_pwr_usb *suc;
2153 if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
2154 goto close_json_markup;
2156 json_markup_power_management(tab, OPEN_JSON_MARKUP);
2159 xprintf(tab++, "\"usb-devices\": [");
2161 for (i = 0; i < a->nr[curr]; i++) {
2162 suc = (struct stats_pwr_usb *) ((char *) a->buf[curr] + i * a->msize);
2169 xprintf0(tab, "{\"bus_number\": %d, "
2170 "\"idvendor\": \"%x\", "
2171 "\"idprod\": \"%x\", "
2172 "\"maxpower\": %u, "
2173 "\"manufact\": \"%s\", "
2174 "\"product\": \"%s\"}",
2178 suc->bmaxpower << 1,
2184 xprintf0(--tab, "]");
2188 if (CLOSE_MARKUP(a->options)) {
2189 json_markup_power_management(tab, CLOSE_JSON_MARKUP);
2194 ***************************************************************************
2195 * Display filesystems statistics in JSON.
2198 * @a Activity structure with statistics.
2199 * @curr Index in array for current sample statistics.
2200 * @tab Indentation in output.
2201 * @itv Interval of time in 1/100th of a second.
2202 ***************************************************************************
2204 __print_funct_t json_print_filesystem_stats(struct activity *a, int curr, int tab,
2205 unsigned long long itv)
2208 struct stats_filesystem *sfc;
2212 xprintf(tab++, "\"filesystems\": [");
2214 for (i = 0; i < a->nr[curr]; i++) {
2215 sfc = (struct stats_filesystem *) ((char *) a->buf[curr] + i * a->msize);
2217 /* Get name to display (persistent or standard fs name, or mount point) */
2218 dev_name = get_fs_name_to_display(a, flags, sfc);
2220 if (a->item_list != NULL) {
2221 /* A list of devices has been entered on the command line */
2222 if (!search_list_item(a->item_list, dev_name))
2223 /* Device not found */
2232 xprintf0(tab, "{\"%s\": \"%s\", "
2233 "\"MBfsfree\": %.0f, "
2234 "\"MBfsused\": %.0f, "
2235 "\"%%fsused\": %.2f, "
2236 "\"%%ufsused\": %.2f, "
2239 "\"%%Iused\": %.2f}",
2240 DISPLAY_MOUNT(a->opt_flags) ? "mountpoint" : "filesystem",
2242 (double) sfc->f_bfree / 1024 / 1024,
2243 (double) (sfc->f_blocks - sfc->f_bfree) / 1024 / 1024,
2244 sfc->f_blocks ? SP_VALUE(sfc->f_bfree, sfc->f_blocks, sfc->f_blocks)
2246 sfc->f_blocks ? SP_VALUE(sfc->f_bavail, sfc->f_blocks, sfc->f_blocks)
2249 sfc->f_files - sfc->f_ffree,
2250 sfc->f_files ? SP_VALUE(sfc->f_ffree, sfc->f_files, sfc->f_files)
2255 xprintf0(--tab, "]");
2259 ***************************************************************************
2260 * Display Fibre Channel HBA statistics in JSON.
2263 * @a Activity structure with statistics.
2264 * @curr Index in array for current sample statistics.
2265 * @tab Indentation in output.
2266 * @itv Interval of time in 1/100th of a second.
2267 ***************************************************************************
2269 __print_funct_t json_print_fchost_stats(struct activity *a, int curr, int tab,
2270 unsigned long long itv)
2272 int i, j, j0, found;
2273 struct stats_fchost *sfcc, *sfcp, sfczero;
2276 if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
2277 goto close_json_markup;
2279 memset(&sfczero, 0, sizeof(struct stats_fchost));
2281 json_markup_network(tab, OPEN_JSON_MARKUP);
2284 xprintf(tab++, "\"fchosts\": [");
2286 for (i = 0; i < a->nr[curr]; i++) {
2289 sfcc = (struct stats_fchost *) ((char *) a->buf[curr] + i * a->msize);
2291 if (a->nr[!curr] > 0) {
2292 /* Look for corresponding structure in previous iteration */
2295 if (j >= a->nr[!curr]) {
2296 j = a->nr[!curr] - 1;
2302 sfcp = (struct stats_fchost *) ((char *) a->buf[!curr] + j * a->msize);
2303 if (!strcmp(sfcc->fchost_name, sfcp->fchost_name)) {
2307 if (++j >= a->nr[!curr]) {
2315 /* This is a newly registered host */
2324 xprintf0(tab, "{\"fchost\": \"%s\", "
2325 "\"fch_rxf\": %.2f, "
2326 "\"fch_txf\": %.2f, "
2327 "\"fch_rxw\": %.2f, "
2328 "\"fch_txw\": %.2f}",
2330 S_VALUE(sfcp->f_rxframes, sfcc->f_rxframes, itv),
2331 S_VALUE(sfcp->f_txframes, sfcc->f_txframes, itv),
2332 S_VALUE(sfcp->f_rxwords, sfcc->f_rxwords, itv),
2333 S_VALUE(sfcp->f_txwords, sfcc->f_txwords, itv));
2337 xprintf0(--tab, "]");
2342 if (CLOSE_MARKUP(a->options)) {
2343 json_markup_network(tab, CLOSE_JSON_MARKUP);
2348 ***************************************************************************
2349 * Display softnet statistics in JSON.
2352 * @a Activity structure with statistics.
2353 * @curr Index in array for current sample statistics.
2354 * @tab Indentation in output.
2355 * @itv Interval of time in 1/100th of a second.
2356 ***************************************************************************
2358 __print_funct_t json_print_softnet_stats(struct activity *a, int curr, int tab,
2359 unsigned long long itv)
2362 struct stats_softnet *ssnc, *ssnp;
2365 unsigned char offline_cpu_bitmap[BITMAP_SIZE(NR_CPUS)] = {0};
2367 if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
2368 goto close_json_markup;
2370 json_markup_network(tab, OPEN_JSON_MARKUP);
2373 xprintf(tab++, "\"softnet\": [");
2375 /* @nr[curr] cannot normally be greater than @nr_ini */
2376 if (a->nr[curr] > a->nr_ini) {
2377 a->nr_ini = a->nr[curr];
2380 /* Compute statistics for CPU "all" */
2381 get_global_soft_statistics(a, !curr, curr, flags, offline_cpu_bitmap);
2383 for (i = 0; (i < a->nr_ini) && (i < a->bitmap->b_size + 1); i++) {
2386 * Should current CPU (including CPU "all") be displayed?
2387 * Note: a->nr is in [1, NR_CPUS + 1].
2388 * Bitmap size is provided for (NR_CPUS + 1) CPUs.
2389 * Anyway, NR_CPUS may vary between the version of sysstat
2390 * used by sadc to create a file, and the version of sysstat
2391 * used by sar to read it...
2393 if (!(a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))) ||
2394 offline_cpu_bitmap[i >> 3] & (1 << (i & 0x07)))
2399 * The size of a->buf[...] CPU structure may be different from the default
2400 * sizeof(struct stats_pwr_cpufreq) value if data have been read from a file!
2401 * That's why we don't use a syntax like:
2402 * ssnc = (struct stats_softnet *) a->buf[...] + i;
2404 ssnc = (struct stats_softnet *) ((char *) a->buf[curr] + i * a->msize);
2405 ssnp = (struct stats_softnet *) ((char *) a->buf[!curr] + i * a->msize);
2413 /* This is CPU "all" */
2414 strcpy(cpuno, "all");
2417 sprintf(cpuno, "%d", i - 1);
2420 xprintf0(tab, "{\"cpu\": \"%s\", "
2423 "\"squeezd\": %.2f, "
2424 "\"rx_rps\": %.2f, "
2425 "\"flw_lim\": %.2f}",
2427 S_VALUE(ssnp->processed, ssnc->processed, itv),
2428 S_VALUE(ssnp->dropped, ssnc->dropped, itv),
2429 S_VALUE(ssnp->time_squeeze, ssnc->time_squeeze, itv),
2430 S_VALUE(ssnp->received_rps, ssnc->received_rps, itv),
2431 S_VALUE(ssnp->flow_limit, ssnc->flow_limit, itv));
2435 xprintf0(--tab, "]");
2440 if (CLOSE_MARKUP(a->options)) {
2441 json_markup_network(tab, CLOSE_JSON_MARKUP);
2446 ***************************************************************************
2447 * Display pressure-stall CPU statistics in JSON.
2450 * @a Activity structure with statistics.
2451 * @curr Index in array for current sample statistics.
2452 * @tab Indentation in output.
2453 * @itv Interval of time in 1/100th of a second.
2454 ***************************************************************************
2456 __print_funct_t json_print_psicpu_stats(struct activity *a, int curr, int tab,
2457 unsigned long long itv)
2459 struct stats_psi_cpu
2460 *psic = (struct stats_psi_cpu *) a->buf[curr],
2461 *psip = (struct stats_psi_cpu *) a->buf[!curr];
2463 if (!IS_SELECTED(a->options))
2464 goto close_json_markup;
2466 json_markup_psi(tab, OPEN_JSON_MARKUP);
2469 xprintf0(tab, "\"psi-cpu\": {"
2470 "\"some_avg10\": %.2f, "
2471 "\"some_avg60\": %.2f, "
2472 "\"some_avg300\": %.2f, "
2473 "\"some_avg\": %.2f}",
2474 (double) psic->some_acpu_10 / 100,
2475 (double) psic->some_acpu_60 / 100,
2476 (double) psic->some_acpu_300 / 100,
2477 ((double) psic->some_cpu_total - psip->some_cpu_total) / (100 * itv));
2481 if (CLOSE_MARKUP(a->options)) {
2482 json_markup_psi(tab, CLOSE_JSON_MARKUP);
2487 ***************************************************************************
2488 * Display pressure-stall I/O statistics in JSON.
2491 * @a Activity structure with statistics.
2492 * @curr Index in array for current sample statistics.
2493 * @tab Indentation in output.
2494 * @itv Interval of time in 1/100th of a second.
2495 ***************************************************************************
2497 __print_funct_t json_print_psiio_stats(struct activity *a, int curr, int tab,
2498 unsigned long long itv)
2501 *psic = (struct stats_psi_io *) a->buf[curr],
2502 *psip = (struct stats_psi_io *) a->buf[!curr];
2504 if (!IS_SELECTED(a->options))
2505 goto close_json_markup;
2507 json_markup_psi(tab, OPEN_JSON_MARKUP);
2510 xprintf0(tab, "\"psi-io\": {"
2511 "\"some_avg10\": %.2f, "
2512 "\"some_avg60\": %.2f, "
2513 "\"some_avg300\": %.2f, "
2514 "\"some_avg\": %.2f, "
2515 "\"full_avg10\": %.2f, "
2516 "\"full_avg60\": %.2f, "
2517 "\"full_avg300\": %.2f, "
2518 "\"full_avg\": %.2f}",
2519 (double) psic->some_aio_10 / 100,
2520 (double) psic->some_aio_60 / 100,
2521 (double) psic->some_aio_300 / 100,
2522 ((double) psic->some_io_total - psip->some_io_total) / (100 * itv),
2523 (double) psic->full_aio_10 / 100,
2524 (double) psic->full_aio_60 / 100,
2525 (double) psic->full_aio_300 / 100,
2526 ((double) psic->full_io_total - psip->full_io_total) / (100 * itv));
2530 if (CLOSE_MARKUP(a->options)) {
2531 json_markup_psi(tab, CLOSE_JSON_MARKUP);
2536 ***************************************************************************
2537 * Display pressure-stall memory statistics in JSON.
2540 * @a Activity structure with statistics.
2541 * @curr Index in array for current sample statistics.
2542 * @tab Indentation in output.
2543 * @itv Interval of time in 1/100th of a second.
2544 ***************************************************************************
2546 __print_funct_t json_print_psimem_stats(struct activity *a, int curr, int tab,
2547 unsigned long long itv)
2549 struct stats_psi_mem
2550 *psic = (struct stats_psi_mem *) a->buf[curr],
2551 *psip = (struct stats_psi_mem *) a->buf[!curr];
2553 if (!IS_SELECTED(a->options))
2554 goto close_json_markup;
2556 json_markup_psi(tab, OPEN_JSON_MARKUP);
2559 xprintf0(tab, "\"psi-mem\": {"
2560 "\"some_avg10\": %.2f, "
2561 "\"some_avg60\": %.2f, "
2562 "\"some_avg300\": %.2f, "
2563 "\"some_avg\": %.2f, "
2564 "\"full_avg10\": %.2f, "
2565 "\"full_avg60\": %.2f, "
2566 "\"full_avg300\": %.2f, "
2567 "\"full_avg\": %.2f}",
2568 (double) psic->some_amem_10 / 100,
2569 (double) psic->some_amem_60 / 100,
2570 (double) psic->some_amem_300 / 100,
2571 ((double) psic->some_mem_total - psip->some_mem_total) / (100 * itv),
2572 (double) psic->full_amem_10 / 100,
2573 (double) psic->full_amem_60 / 100,
2574 (double) psic->full_amem_300 / 100,
2575 ((double) psic->full_mem_total - psip->full_mem_total) / (100 * itv));
2579 if (CLOSE_MARKUP(a->options)) {
2580 json_markup_psi(tab, CLOSE_JSON_MARKUP);