2 * json_stats.c: Functions 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 *stc_cpu_irq, *stp_cpu_irq, *stc_cpuall_irq;
334 unsigned char masked_cpu_bitmap[BITMAP_SIZE(NR_CPUS)] = {0};
337 xprintf(tab++, "\"interrupts\": [");
339 /* @nr[curr] cannot normally be greater than @nr_ini */
340 if (a->nr[curr] > a->nr_ini) {
341 a->nr_ini = a->nr[curr];
344 /* Identify offline and unselected CPU, and keep persistent statistics values */
345 get_global_int_statistics(a, !curr, curr, flags, masked_cpu_bitmap);
347 for (i = 0; i < a->nr2; i++) {
349 stc_cpuall_irq = (struct stats_irq *) ((char *) a->buf[curr] + i * a->msize);
351 if (a->item_list != NULL) {
352 /* A list of devices has been entered on the command line */
353 if (!search_list_item(a->item_list, stc_cpuall_irq->irq_name))
354 /* Device not found */
361 xprintf0(tab, "{\"intr\": \"%s\"", stc_cpuall_irq->irq_name);
364 for (c = 0; (c < a->nr[curr]) && (c < a->bitmap->b_size + 1); c++) {
366 stc_cpu_irq = (struct stats_irq *) ((char *) a->buf[curr] + c * a->msize * a->nr2
368 stp_cpu_irq = (struct stats_irq *) ((char *) a->buf[!curr] + c * a->msize * a->nr2
371 /* Should current CPU (including CPU "all") be displayed? */
372 if (masked_cpu_bitmap[c >> 3] & (1 << (c & 0x07)))
376 /* Yes: Display it */
378 printf(", \"all\": %.2f",
379 S_VALUE(stp_cpu_irq->irq_nr, stc_cpu_irq->irq_nr, itv));
382 printf(", \"CPU%d\": %.2f", c - 1,
383 S_VALUE(stp_cpu_irq->irq_nr, stc_cpu_irq->irq_nr, itv));
390 xprintf0(--tab, "]");
394 ***************************************************************************
395 * Display swapping statistics in JSON.
398 * @a Activity structure with statistics.
399 * @curr Index in array for current sample statistics.
400 * @tab Indentation in output.
401 * @itv Interval of time in 1/100th of a second.
402 ***************************************************************************
404 __print_funct_t json_print_swap_stats(struct activity *a, int curr, int tab,
405 unsigned long long itv)
408 *ssc = (struct stats_swap *) a->buf[curr],
409 *ssp = (struct stats_swap *) a->buf[!curr];
411 xprintf0(tab, "\"swap-pages\": {"
413 "\"pswpout\": %.2f}",
414 S_VALUE(ssp->pswpin, ssc->pswpin, itv),
415 S_VALUE(ssp->pswpout, ssc->pswpout, itv));
419 ***************************************************************************
420 * Display paging statistics in JSON.
423 * @a Activity structure with statistics.
424 * @curr Index in array for current sample statistics.
425 * @tab Indentation in output.
426 * @itv Interval of time in 1/100th of a second.
427 ***************************************************************************
429 __print_funct_t json_print_paging_stats(struct activity *a, int curr, int tab,
430 unsigned long long itv)
433 *spc = (struct stats_paging *) a->buf[curr],
434 *spp = (struct stats_paging *) a->buf[!curr];
436 xprintf0(tab, "\"paging\": {"
438 "\"pgpgout\": %.2f, "
442 "\"pgscank\": %.2f, "
443 "\"pgscand\": %.2f, "
444 "\"pgsteal\": %.2f, "
445 "\"vmeff-percent\": %.2f}",
446 S_VALUE(spp->pgpgin, spc->pgpgin, itv),
447 S_VALUE(spp->pgpgout, spc->pgpgout, itv),
448 S_VALUE(spp->pgfault, spc->pgfault, itv),
449 S_VALUE(spp->pgmajfault, spc->pgmajfault, itv),
450 S_VALUE(spp->pgfree, spc->pgfree, itv),
451 S_VALUE(spp->pgscan_kswapd, spc->pgscan_kswapd, itv),
452 S_VALUE(spp->pgscan_direct, spc->pgscan_direct, itv),
453 S_VALUE(spp->pgsteal, spc->pgsteal, itv),
454 (spc->pgscan_kswapd + spc->pgscan_direct -
455 spp->pgscan_kswapd - spp->pgscan_direct) ?
456 SP_VALUE(spp->pgsteal, spc->pgsteal,
457 spc->pgscan_kswapd + spc->pgscan_direct -
458 spp->pgscan_kswapd - spp->pgscan_direct) : 0.0);
462 ***************************************************************************
463 * Display I/O and transfer rate statistics in JSON.
466 * @a Activity structure with statistics.
467 * @curr Index in array for current sample statistics.
468 * @tab Indentation in output.
469 * @itv Interval of time in 1/100th of a second.
470 ***************************************************************************
472 __print_funct_t json_print_io_stats(struct activity *a, int curr, int tab,
473 unsigned long long itv)
476 *sic = (struct stats_io *) a->buf[curr],
477 *sip = (struct stats_io *) a->buf[!curr];
479 xprintf0(tab, "\"io\": {"
491 * If we get negative values, this is probably because
492 * one or more devices/filesystems have been unmounted.
493 * We display 0.0 in this case though we should rather tell
494 * the user that the value cannot be calculated here.
496 sic->dk_drive < sip->dk_drive ? 0.0 :
497 S_VALUE(sip->dk_drive, sic->dk_drive, itv),
498 sic->dk_drive_rio < sip->dk_drive_rio ? 0.0 :
499 S_VALUE(sip->dk_drive_rio, sic->dk_drive_rio, itv),
500 sic->dk_drive_rblk < sip->dk_drive_rblk ? 0.0 :
501 S_VALUE(sip->dk_drive_rblk, sic->dk_drive_rblk, itv),
502 sic->dk_drive_wio < sip->dk_drive_wio ? 0.0 :
503 S_VALUE(sip->dk_drive_wio, sic->dk_drive_wio, itv),
504 sic->dk_drive_wblk < sip->dk_drive_wblk ? 0.0 :
505 S_VALUE(sip->dk_drive_wblk, sic->dk_drive_wblk, itv),
506 sic->dk_drive_dio < sip->dk_drive_dio ? 0.0 :
507 S_VALUE(sip->dk_drive_dio, sic->dk_drive_dio, itv),
508 sic->dk_drive_dblk < sip->dk_drive_dblk ? 0.0 :
509 S_VALUE(sip->dk_drive_dblk, sic->dk_drive_dblk, itv));
513 ***************************************************************************
514 * Display memory statistics in JSON.
517 * @a Activity structure with statistics.
518 * @curr Index in array for current sample statistics.
519 * @tab Indentation in output.
520 * @itv Interval of time in 1/100th of a second.
521 ***************************************************************************
523 __print_funct_t json_print_memory_stats(struct activity *a, int curr, int tab,
524 unsigned long long itv)
527 *smc = (struct stats_memory *) a->buf[curr];
529 unsigned long long nousedmem;
531 xprintf0(tab, "\"memory\": {");
533 if (DISPLAY_MEMORY(a->opt_flags)) {
537 nousedmem = smc->frmkb + smc->bufkb + smc->camkb + smc->slabkb;
538 if (nousedmem > smc->tlmkb) {
539 nousedmem = smc->tlmkb;
542 printf("\"memfree\": %llu, "
544 "\"memused\": %llu, "
545 "\"memused-percent\": %.2f, "
546 "\"buffers\": %llu, "
549 "\"commit-percent\": %.2f, "
551 "\"inactive\": %llu, "
555 smc->tlmkb - nousedmem,
557 SP_VALUE(nousedmem, smc->tlmkb, smc->tlmkb) :
562 (smc->tlmkb + smc->tlskb) ?
563 SP_VALUE(0, smc->comkb, smc->tlmkb + smc->tlskb) :
569 if (DISPLAY_MEM_ALL(a->opt_flags)) {
570 /* Display extended memory stats */
571 printf(", \"anonpg\": %llu, "
584 if (DISPLAY_SWAP(a->opt_flags)) {
591 printf("\"swpfree\": %llu, "
592 "\"swpused\": %llu, "
593 "\"swpused-percent\": %.2f, "
595 "\"swpcad-percent\": %.2f",
597 smc->tlskb - smc->frskb,
599 SP_VALUE(smc->frskb, smc->tlskb, smc->tlskb) :
602 (smc->tlskb - smc->frskb) ?
603 SP_VALUE(0, smc->caskb, smc->tlskb - smc->frskb) :
611 ***************************************************************************
612 * Display kernel tables statistics in JSON.
615 * @a Activity structure with statistics.
616 * @curr Index in array for current sample statistics.
617 * @tab Indentation in output.
618 * @itv Interval of time in 1/100th of a second.
619 ***************************************************************************
621 __print_funct_t json_print_ktables_stats(struct activity *a, int curr, int tab,
622 unsigned long long itv)
625 *skc = (struct stats_ktables *) a->buf[curr];
627 xprintf0(tab, "\"kernel\": {"
628 "\"dentunusd\": %llu, "
629 "\"file-nr\": %llu, "
630 "\"inode-nr\": %llu, "
639 ***************************************************************************
640 * Display queue and load statistics in JSON.
643 * @a Activity structure with statistics.
644 * @curr Index in array for current sample statistics.
645 * @tab Indentation in output.
646 * @itv Interval of time in 1/100th of a second.
647 ***************************************************************************
649 __print_funct_t json_print_queue_stats(struct activity *a, int curr, int tab,
650 unsigned long long itv)
653 *sqc = (struct stats_queue *) a->buf[curr];
655 xprintf0(tab, "\"queue\": {"
656 "\"runq-sz\": %llu, "
657 "\"plist-sz\": %llu, "
658 "\"ldavg-1\": %.2f, "
659 "\"ldavg-5\": %.2f, "
660 "\"ldavg-15\": %.2f, "
661 "\"blocked\": %llu}",
664 (double) sqc->load_avg_1 / 100,
665 (double) sqc->load_avg_5 / 100,
666 (double) sqc->load_avg_15 / 100,
671 ***************************************************************************
672 * Display serial lines statistics in JSON.
675 * @a Activity structure with statistics.
676 * @curr Index in array for current sample statistics.
677 * @tab Indentation in output.
678 * @itv Interval of time in 1/100th of a second.
679 ***************************************************************************
681 __print_funct_t json_print_serial_stats(struct activity *a, int curr, int tab,
682 unsigned long long itv)
685 struct stats_serial *ssc, *ssp;
688 xprintf(tab++, "\"serial\": [");
690 for (i = 0; i < a->nr[curr]; i++) {
694 if (a->nr[!curr] > 0) {
695 ssc = (struct stats_serial *) ((char *) a->buf[curr] + i * a->msize);
697 /* Look for corresponding serial line in previous iteration */
700 if (j >= a->nr[!curr]) {
701 j = a->nr[!curr] - 1;
707 ssp = (struct stats_serial *) ((char *) a->buf[!curr] + j * a->msize);
708 if (ssc->line == ssp->line) {
712 if (++j >= a->nr[!curr]) {
727 xprintf0(tab, "{\"line\": %d, "
730 "\"framerr\": %.2f, "
731 "\"prtyerr\": %.2f, "
735 S_VALUE(ssp->rx, ssc->rx, itv),
736 S_VALUE(ssp->tx, ssc->tx, itv),
737 S_VALUE(ssp->frame, ssc->frame, itv),
738 S_VALUE(ssp->parity, ssc->parity, itv),
739 S_VALUE(ssp->brk, ssc->brk, itv),
740 S_VALUE(ssp->overrun, ssc->overrun, itv));
744 xprintf0(--tab, "]");
748 ***************************************************************************
749 * Display disks statistics in JSON.
752 * @a Activity structure with statistics.
753 * @curr Index in array for current sample statistics.
754 * @tab Indentation in output.
755 * @itv Interval of time in 1/100th of a second.
756 ***************************************************************************
758 __print_funct_t json_print_disk_stats(struct activity *a, int curr, int tab,
759 unsigned long long itv)
762 struct stats_disk *sdc, *sdp, sdpzero;
763 struct ext_disk_stats xds;
767 memset(&sdpzero, 0, STATS_DISK_SIZE);
769 xprintf(tab++, "\"disk\": [");
771 for (i = 0; i < a->nr[curr]; i++) {
773 sdc = (struct stats_disk *) ((char *) a->buf[curr] + i * a->msize);
775 j = check_disk_reg(a, curr, !curr, i);
777 /* This is a newly registered interface. Previous stats are zero */
781 sdp = (struct stats_disk *) ((char *) a->buf[!curr] + j * a->msize);
784 /* Get device name */
785 dev_name = get_device_name(sdc->major, sdc->minor, sdc->wwn, sdc->part_nr,
786 DISPLAY_PRETTY(flags), DISPLAY_PERSIST_NAME_S(flags),
787 USE_STABLE_ID(flags), NULL);
789 if (a->item_list != NULL) {
790 /* A list of devices has been entered on the command line */
791 if (!search_list_item(a->item_list, dev_name))
792 /* Device not found */
796 /* Compute extended statistics values */
797 compute_ext_disk_stats(sdc, sdp, itv, &xds);
804 xprintf0(tab, "{\"disk-device\": \"%s\", "
812 "\"avgrq-sz\": %.2f, "
813 "\"areq-sz\": %.2f, "
814 "\"avgqu-sz\": %.2f, "
817 "\"util-percent\": %.2f}",
818 /* Confusion possible here between index and minor numbers */
820 S_VALUE(sdp->nr_ios, sdc->nr_ios, itv),
821 S_VALUE(sdp->rd_sect, sdc->rd_sect, itv), /* Unit = sectors (for backward compatibility) */
822 S_VALUE(sdp->wr_sect, sdc->wr_sect, itv),
823 S_VALUE(sdp->dc_sect, sdc->dc_sect, itv),
824 S_VALUE(sdp->rd_sect, sdc->rd_sect, itv) / 2,
825 S_VALUE(sdp->wr_sect, sdc->wr_sect, itv) / 2,
826 S_VALUE(sdp->dc_sect, sdc->dc_sect, itv) / 2,
827 /* See iostat for explanations */
828 xds.arqsz, /* Unit = sectors (for backward compatibility) */
830 S_VALUE(sdp->rq_ticks, sdc->rq_ticks, itv) / 1000.0, /* For backward compatibility */
831 S_VALUE(sdp->rq_ticks, sdc->rq_ticks, itv) / 1000.0,
837 xprintf0(--tab, "]");
841 ***************************************************************************
842 * Display network interfaces statistics in JSON.
845 * @a Activity structure with statistics.
846 * @curr Index in array for current sample statistics.
847 * @tab Indentation in output.
848 * @itv Interval of time in 1/100th of a second.
849 ***************************************************************************
851 __print_funct_t json_print_net_dev_stats(struct activity *a, int curr, int tab,
852 unsigned long long itv)
855 struct stats_net_dev *sndc, *sndp, sndzero;
857 double rxkb, txkb, ifutil;
859 memset(&sndzero, 0, STATS_NET_DEV_SIZE);
861 if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
862 goto close_json_markup;
864 json_markup_network(tab, OPEN_JSON_MARKUP);
867 xprintf(tab++, "\"net-dev\": [");
869 for (i = 0; i < a->nr[curr]; i++) {
871 sndc = (struct stats_net_dev *) ((char *) a->buf[curr] + i * a->msize);
873 if (a->item_list != NULL) {
874 /* A list of devices has been entered on the command line */
875 if (!search_list_item(a->item_list, sndc->interface))
876 /* Device not found */
880 j = check_net_dev_reg(a, curr, !curr, i);
882 /* This is a newly registered interface. Previous stats are zero */
886 sndp = (struct stats_net_dev *) ((char *) a->buf[!curr] + j * a->msize);
894 rxkb = S_VALUE(sndp->rx_bytes, sndc->rx_bytes, itv);
895 txkb = S_VALUE(sndp->tx_bytes, sndc->tx_bytes, itv);
896 ifutil = compute_ifutil(sndc, rxkb, txkb);
898 xprintf0(tab, "{\"iface\": \"%s\", "
906 "\"ifutil-percent\": %.2f}",
908 S_VALUE(sndp->rx_packets, sndc->rx_packets, itv),
909 S_VALUE(sndp->tx_packets, sndc->tx_packets, itv),
912 S_VALUE(sndp->rx_compressed, sndc->rx_compressed, itv),
913 S_VALUE(sndp->tx_compressed, sndc->tx_compressed, itv),
914 S_VALUE(sndp->multicast, sndc->multicast, itv),
919 xprintf0(--tab, "]");
924 if (CLOSE_MARKUP(a->options)) {
925 json_markup_network(tab, CLOSE_JSON_MARKUP);
930 ***************************************************************************
931 * Display network interfaces errors statistics in JSON.
934 * @a Activity structure with statistics.
935 * @curr Index in array for current sample statistics.
936 * @tab Indentation in output.
937 * @itv Interval of time in 1/100th of a second.
938 ***************************************************************************
940 __print_funct_t json_print_net_edev_stats(struct activity *a, int curr, int tab,
941 unsigned long long itv)
944 struct stats_net_edev *snedc, *snedp, snedzero;
947 if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
948 goto close_json_markup;
950 memset(&snedzero, 0, STATS_NET_EDEV_SIZE);
952 json_markup_network(tab, OPEN_JSON_MARKUP);
955 xprintf(tab++, "\"net-edev\": [");
957 for (i = 0; i < a->nr[curr]; i++) {
959 snedc = (struct stats_net_edev *) ((char *) a->buf[curr] + i * a->msize);
961 if (a->item_list != NULL) {
962 /* A list of devices has been entered on the command line */
963 if (!search_list_item(a->item_list, snedc->interface))
964 /* Device not found */
968 j = check_net_edev_reg(a, curr, !curr, i);
970 /* This is a newly registered interface. Previous stats are zero */
974 snedp = (struct stats_net_edev *) ((char *) a->buf[!curr] + j * a->msize);
982 xprintf0(tab, "{\"iface\": \"%s\", "
993 S_VALUE(snedp->rx_errors, snedc->rx_errors, itv),
994 S_VALUE(snedp->tx_errors, snedc->tx_errors, itv),
995 S_VALUE(snedp->collisions, snedc->collisions, itv),
996 S_VALUE(snedp->rx_dropped, snedc->rx_dropped, itv),
997 S_VALUE(snedp->tx_dropped, snedc->tx_dropped, itv),
998 S_VALUE(snedp->tx_carrier_errors, snedc->tx_carrier_errors, itv),
999 S_VALUE(snedp->rx_frame_errors, snedc->rx_frame_errors, itv),
1000 S_VALUE(snedp->rx_fifo_errors, snedc->rx_fifo_errors, itv),
1001 S_VALUE(snedp->tx_fifo_errors, snedc->tx_fifo_errors, itv));
1005 xprintf0(--tab, "]");
1010 if (CLOSE_MARKUP(a->options)) {
1011 json_markup_network(tab, CLOSE_JSON_MARKUP);
1016 ***************************************************************************
1017 * Display NFS client statistics in JSON.
1020 * @a Activity structure with statistics.
1021 * @curr Index in array for current sample statistics.
1022 * @tab Indentation in output.
1023 * @itv Interval of time in 1/100th of a second.
1024 ***************************************************************************
1026 __print_funct_t json_print_net_nfs_stats(struct activity *a, int curr, int tab,
1027 unsigned long long itv)
1029 struct stats_net_nfs
1030 *snnc = (struct stats_net_nfs *) a->buf[curr],
1031 *snnp = (struct stats_net_nfs *) a->buf[!curr];
1033 if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
1034 goto close_json_markup;
1036 json_markup_network(tab, OPEN_JSON_MARKUP);
1039 xprintf0(tab, "\"net-nfs\": {"
1041 "\"retrans\": %.2f, "
1044 "\"access\": %.2f, "
1045 "\"getatt\": %.2f}",
1046 S_VALUE(snnp->nfs_rpccnt, snnc->nfs_rpccnt, itv),
1047 S_VALUE(snnp->nfs_rpcretrans, snnc->nfs_rpcretrans, itv),
1048 S_VALUE(snnp->nfs_readcnt, snnc->nfs_readcnt, itv),
1049 S_VALUE(snnp->nfs_writecnt, snnc->nfs_writecnt, itv),
1050 S_VALUE(snnp->nfs_accesscnt, snnc->nfs_accesscnt, itv),
1051 S_VALUE(snnp->nfs_getattcnt, snnc->nfs_getattcnt, itv));
1055 if (CLOSE_MARKUP(a->options)) {
1056 json_markup_network(tab, CLOSE_JSON_MARKUP);
1061 ***************************************************************************
1062 * Display NFS server statistics in JSON.
1065 * @a Activity structure with statistics.
1066 * @curr Index in array for current sample statistics.
1067 * @tab Indentation in output.
1068 * @itv Interval of time in 1/100th of a second.
1069 ***************************************************************************
1071 __print_funct_t json_print_net_nfsd_stats(struct activity *a, int curr, int tab,
1072 unsigned long long itv)
1074 struct stats_net_nfsd
1075 *snndc = (struct stats_net_nfsd *) a->buf[curr],
1076 *snndp = (struct stats_net_nfsd *) a->buf[!curr];
1078 if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
1079 goto close_json_markup;
1081 json_markup_network(tab, OPEN_JSON_MARKUP);
1084 xprintf0(tab, "\"net-nfsd\": {"
1086 "\"badcall\": %.2f, "
1087 "\"packet\": %.2f, "
1093 "\"swrite\": %.2f, "
1094 "\"saccess\": %.2f, "
1095 "\"sgetatt\": %.2f}",
1096 S_VALUE(snndp->nfsd_rpccnt, snndc->nfsd_rpccnt, itv),
1097 S_VALUE(snndp->nfsd_rpcbad, snndc->nfsd_rpcbad, itv),
1098 S_VALUE(snndp->nfsd_netcnt, snndc->nfsd_netcnt, itv),
1099 S_VALUE(snndp->nfsd_netudpcnt, snndc->nfsd_netudpcnt, itv),
1100 S_VALUE(snndp->nfsd_nettcpcnt, snndc->nfsd_nettcpcnt, itv),
1101 S_VALUE(snndp->nfsd_rchits, snndc->nfsd_rchits, itv),
1102 S_VALUE(snndp->nfsd_rcmisses, snndc->nfsd_rcmisses, itv),
1103 S_VALUE(snndp->nfsd_readcnt, snndc->nfsd_readcnt, itv),
1104 S_VALUE(snndp->nfsd_writecnt, snndc->nfsd_writecnt, itv),
1105 S_VALUE(snndp->nfsd_accesscnt, snndc->nfsd_accesscnt, itv),
1106 S_VALUE(snndp->nfsd_getattcnt, snndc->nfsd_getattcnt, itv));
1110 if (CLOSE_MARKUP(a->options)) {
1111 json_markup_network(tab, CLOSE_JSON_MARKUP);
1116 ***************************************************************************
1117 * Display network socket statistics in JSON.
1120 * @a Activity structure with statistics.
1121 * @curr Index in array for current sample statistics.
1122 * @tab Indentation in output.
1123 * @itv Interval of time in 1/100th of a second.
1124 ***************************************************************************
1126 __print_funct_t json_print_net_sock_stats(struct activity *a, int curr, int tab,
1127 unsigned long long itv)
1129 struct stats_net_sock
1130 *snsc = (struct stats_net_sock *) a->buf[curr];
1132 if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
1133 goto close_json_markup;
1135 json_markup_network(tab, OPEN_JSON_MARKUP);
1138 xprintf0(tab, "\"net-sock\": {"
1154 if (CLOSE_MARKUP(a->options)) {
1155 json_markup_network(tab, CLOSE_JSON_MARKUP);
1160 ***************************************************************************
1161 * Display IP network statistics in JSON.
1164 * @a Activity structure with statistics.
1165 * @curr Index in array for current sample statistics.
1166 * @tab Indentation in output.
1167 * @itv Interval of time in 1/100th of a second.
1168 ***************************************************************************
1170 __print_funct_t json_print_net_ip_stats(struct activity *a, int curr, int tab,
1171 unsigned long long itv)
1174 *snic = (struct stats_net_ip *) a->buf[curr],
1175 *snip = (struct stats_net_ip *) a->buf[!curr];
1177 if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
1178 goto close_json_markup;
1180 json_markup_network(tab, OPEN_JSON_MARKUP);
1183 xprintf0(tab, "\"net-ip\": {"
1185 "\"fwddgm\": %.2f, "
1190 "\"fragok\": %.2f, "
1191 "\"fragcrt\": %.2f}",
1192 S_VALUE(snip->InReceives, snic->InReceives, itv),
1193 S_VALUE(snip->ForwDatagrams, snic->ForwDatagrams, itv),
1194 S_VALUE(snip->InDelivers, snic->InDelivers, itv),
1195 S_VALUE(snip->OutRequests, snic->OutRequests, itv),
1196 S_VALUE(snip->ReasmReqds, snic->ReasmReqds, itv),
1197 S_VALUE(snip->ReasmOKs, snic->ReasmOKs, itv),
1198 S_VALUE(snip->FragOKs, snic->FragOKs, itv),
1199 S_VALUE(snip->FragCreates, snic->FragCreates, itv));
1203 if (CLOSE_MARKUP(a->options)) {
1204 json_markup_network(tab, CLOSE_JSON_MARKUP);
1209 ***************************************************************************
1210 * Display IP network errors statistics in JSON.
1213 * @a Activity structure with statistics.
1214 * @curr Index in array for current sample statistics.
1215 * @tab Indentation in output.
1216 * @itv Interval of time in 1/100th of a second.
1217 ***************************************************************************
1219 __print_funct_t json_print_net_eip_stats(struct activity *a, int curr, int tab,
1220 unsigned long long itv)
1222 struct stats_net_eip
1223 *sneic = (struct stats_net_eip *) a->buf[curr],
1224 *sneip = (struct stats_net_eip *) a->buf[!curr];
1226 if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
1227 goto close_json_markup;
1229 json_markup_network(tab, OPEN_JSON_MARKUP);
1232 xprintf0(tab, "\"net-eip\": {"
1233 "\"ihdrerr\": %.2f, "
1234 "\"iadrerr\": %.2f, "
1235 "\"iukwnpr\": %.2f, "
1241 S_VALUE(sneip->InHdrErrors, sneic->InHdrErrors, itv),
1242 S_VALUE(sneip->InAddrErrors, sneic->InAddrErrors, itv),
1243 S_VALUE(sneip->InUnknownProtos, sneic->InUnknownProtos, itv),
1244 S_VALUE(sneip->InDiscards, sneic->InDiscards, itv),
1245 S_VALUE(sneip->OutDiscards, sneic->OutDiscards, itv),
1246 S_VALUE(sneip->OutNoRoutes, sneic->OutNoRoutes, itv),
1247 S_VALUE(sneip->ReasmFails, sneic->ReasmFails, itv),
1248 S_VALUE(sneip->FragFails, sneic->FragFails, itv));
1252 if (CLOSE_MARKUP(a->options)) {
1253 json_markup_network(tab, CLOSE_JSON_MARKUP);
1258 ***************************************************************************
1259 * Display ICMP network statistics in JSON.
1262 * @a Activity structure with statistics.
1263 * @curr Index in array for current sample statistics.
1264 * @tab Indentation in output.
1265 * @itv Interval of time in 1/100th of a second.
1266 ***************************************************************************
1268 __print_funct_t json_print_net_icmp_stats(struct activity *a, int curr, int tab,
1269 unsigned long long itv)
1271 struct stats_net_icmp
1272 *snic = (struct stats_net_icmp *) a->buf[curr],
1273 *snip = (struct stats_net_icmp *) a->buf[!curr];
1275 if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
1276 goto close_json_markup;
1278 json_markup_network(tab, OPEN_JSON_MARKUP);
1281 xprintf0(tab, "\"net-icmp\": {"
1292 "\"iadrmk\": %.2f, "
1293 "\"iadrmkr\": %.2f, "
1294 "\"oadrmk\": %.2f, "
1295 "\"oadrmkr\": %.2f}",
1296 S_VALUE(snip->InMsgs, snic->InMsgs, itv),
1297 S_VALUE(snip->OutMsgs, snic->OutMsgs, itv),
1298 S_VALUE(snip->InEchos, snic->InEchos, itv),
1299 S_VALUE(snip->InEchoReps, snic->InEchoReps, itv),
1300 S_VALUE(snip->OutEchos, snic->OutEchos, itv),
1301 S_VALUE(snip->OutEchoReps, snic->OutEchoReps, itv),
1302 S_VALUE(snip->InTimestamps, snic->InTimestamps, itv),
1303 S_VALUE(snip->InTimestampReps, snic->InTimestampReps, itv),
1304 S_VALUE(snip->OutTimestamps, snic->OutTimestamps, itv),
1305 S_VALUE(snip->OutTimestampReps, snic->OutTimestampReps, itv),
1306 S_VALUE(snip->InAddrMasks, snic->InAddrMasks, itv),
1307 S_VALUE(snip->InAddrMaskReps, snic->InAddrMaskReps, itv),
1308 S_VALUE(snip->OutAddrMasks, snic->OutAddrMasks, itv),
1309 S_VALUE(snip->OutAddrMaskReps, snic->OutAddrMaskReps, itv));
1313 if (CLOSE_MARKUP(a->options)) {
1314 json_markup_network(tab, CLOSE_JSON_MARKUP);
1319 ***************************************************************************
1320 * Display ICMP errors message statistics in JSON.
1323 * @a Activity structure with statistics.
1324 * @curr Index in array for current sample statistics.
1325 * @tab Indentation in output.
1326 * @itv Interval of time in 1/100th of a second.
1327 ***************************************************************************
1329 __print_funct_t json_print_net_eicmp_stats(struct activity *a, int curr, int tab,
1330 unsigned long long itv)
1332 struct stats_net_eicmp
1333 *sneic = (struct stats_net_eicmp *) a->buf[curr],
1334 *sneip = (struct stats_net_eicmp *) a->buf[!curr];
1336 if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
1337 goto close_json_markup;
1339 json_markup_network(tab, OPEN_JSON_MARKUP);
1342 xprintf0(tab, "\"net-eicmp\": {"
1345 "\"idstunr\": %.2f, "
1346 "\"odstunr\": %.2f, "
1349 "\"iparmpb\": %.2f, "
1350 "\"oparmpb\": %.2f, "
1353 "\"iredir\": %.2f, "
1354 "\"oredir\": %.2f}",
1355 S_VALUE(sneip->InErrors, sneic->InErrors, itv),
1356 S_VALUE(sneip->OutErrors, sneic->OutErrors, itv),
1357 S_VALUE(sneip->InDestUnreachs, sneic->InDestUnreachs, itv),
1358 S_VALUE(sneip->OutDestUnreachs, sneic->OutDestUnreachs, itv),
1359 S_VALUE(sneip->InTimeExcds, sneic->InTimeExcds, itv),
1360 S_VALUE(sneip->OutTimeExcds, sneic->OutTimeExcds, itv),
1361 S_VALUE(sneip->InParmProbs, sneic->InParmProbs, itv),
1362 S_VALUE(sneip->OutParmProbs, sneic->OutParmProbs, itv),
1363 S_VALUE(sneip->InSrcQuenchs, sneic->InSrcQuenchs, itv),
1364 S_VALUE(sneip->OutSrcQuenchs, sneic->OutSrcQuenchs, itv),
1365 S_VALUE(sneip->InRedirects, sneic->InRedirects, itv),
1366 S_VALUE(sneip->OutRedirects, sneic->OutRedirects, itv));
1370 if (CLOSE_MARKUP(a->options)) {
1371 json_markup_network(tab, CLOSE_JSON_MARKUP);
1376 ***************************************************************************
1377 * Display TCP network statistics in JSON.
1380 * @a Activity structure with statistics.
1381 * @curr Index in array for current sample statistics.
1382 * @tab Indentation in output.
1383 * @itv Interval of time in 1/100th of a second.
1384 ***************************************************************************
1386 __print_funct_t json_print_net_tcp_stats(struct activity *a, int curr, int tab,
1387 unsigned long long itv)
1389 struct stats_net_tcp
1390 *sntc = (struct stats_net_tcp *) a->buf[curr],
1391 *sntp = (struct stats_net_tcp *) a->buf[!curr];
1393 if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
1394 goto close_json_markup;
1396 json_markup_network(tab, OPEN_JSON_MARKUP);
1399 xprintf0(tab, "\"net-tcp\": {"
1400 "\"active\": %.2f, "
1401 "\"passive\": %.2f, "
1404 S_VALUE(sntp->ActiveOpens, sntc->ActiveOpens, itv),
1405 S_VALUE(sntp->PassiveOpens, sntc->PassiveOpens, itv),
1406 S_VALUE(sntp->InSegs, sntc->InSegs, itv),
1407 S_VALUE(sntp->OutSegs, sntc->OutSegs, itv));
1411 if (CLOSE_MARKUP(a->options)) {
1412 json_markup_network(tab, CLOSE_JSON_MARKUP);
1417 ***************************************************************************
1418 * Display TCP network errors statistics in JSON.
1421 * @a Activity structure with statistics.
1422 * @curr Index in array for current sample statistics.
1423 * @tab Indentation in XML output.
1424 * @itv Interval of time in 1/100th of a second.
1425 ***************************************************************************
1427 __print_funct_t json_print_net_etcp_stats(struct activity *a, int curr, int tab,
1428 unsigned long long itv)
1430 struct stats_net_etcp
1431 *snetc = (struct stats_net_etcp *) a->buf[curr],
1432 *snetp = (struct stats_net_etcp *) a->buf[!curr];
1434 if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
1435 goto close_json_markup;
1437 json_markup_network(tab, OPEN_JSON_MARKUP);
1440 xprintf0(tab, "\"net-etcp\": {"
1441 "\"atmptf\": %.2f, "
1442 "\"estres\": %.2f, "
1443 "\"retrans\": %.2f, "
1444 "\"isegerr\": %.2f, "
1446 S_VALUE(snetp->AttemptFails, snetc->AttemptFails, itv),
1447 S_VALUE(snetp->EstabResets, snetc->EstabResets, itv),
1448 S_VALUE(snetp->RetransSegs, snetc->RetransSegs, itv),
1449 S_VALUE(snetp->InErrs, snetc->InErrs, itv),
1450 S_VALUE(snetp->OutRsts, snetc->OutRsts, itv));
1454 if (CLOSE_MARKUP(a->options)) {
1455 json_markup_network(tab, CLOSE_JSON_MARKUP);
1460 ***************************************************************************
1461 * Display UDP network statistics in JSON.
1464 * @a Activity structure with statistics.
1465 * @curr Index in array for current sample statistics.
1466 * @tab Indentation in output.
1467 * @itv Interval of time in 1/100th of a second.
1468 ***************************************************************************
1470 __print_funct_t json_print_net_udp_stats(struct activity *a, int curr, int tab,
1471 unsigned long long itv)
1473 struct stats_net_udp
1474 *snuc = (struct stats_net_udp *) a->buf[curr],
1475 *snup = (struct stats_net_udp *) a->buf[!curr];
1477 if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
1478 goto close_json_markup;
1480 json_markup_network(tab, OPEN_JSON_MARKUP);
1483 xprintf0(tab, "\"net-udp\": {"
1486 "\"noport\": %.2f, "
1487 "\"idgmerr\": %.2f}",
1488 S_VALUE(snup->InDatagrams, snuc->InDatagrams, itv),
1489 S_VALUE(snup->OutDatagrams, snuc->OutDatagrams, itv),
1490 S_VALUE(snup->NoPorts, snuc->NoPorts, itv),
1491 S_VALUE(snup->InErrors, snuc->InErrors, itv));
1495 if (CLOSE_MARKUP(a->options)) {
1496 json_markup_network(tab, CLOSE_JSON_MARKUP);
1501 ***************************************************************************
1502 * Display IPv6 network socket statistics in JSON.
1505 * @a Activity structure with statistics.
1506 * @curr Index in array for current sample statistics.
1507 * @tab Indentation in output.
1508 * @itv Interval of time in 1/100th of a second.
1509 ***************************************************************************
1511 __print_funct_t json_print_net_sock6_stats(struct activity *a, int curr, int tab,
1512 unsigned long long itv)
1514 struct stats_net_sock6
1515 *snsc = (struct stats_net_sock6 *) a->buf[curr];
1517 if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
1518 goto close_json_markup;
1520 json_markup_network(tab, OPEN_JSON_MARKUP);
1523 xprintf0(tab, "\"net-sock6\": {"
1527 "\"ip6-frag\": %u}",
1535 if (CLOSE_MARKUP(a->options)) {
1536 json_markup_network(tab, CLOSE_JSON_MARKUP);
1541 ***************************************************************************
1542 * Display IPv6 network statistics in JSON.
1545 * @a Activity structure with statistics.
1546 * @curr Index in array for current sample statistics.
1547 * @tab Indentation in output.
1548 * @itv Interval of time in 1/100th of a second.
1549 ***************************************************************************
1551 __print_funct_t json_print_net_ip6_stats(struct activity *a, int curr, int tab,
1552 unsigned long long itv)
1554 struct stats_net_ip6
1555 *snic = (struct stats_net_ip6 *) a->buf[curr],
1556 *snip = (struct stats_net_ip6 *) a->buf[!curr];
1558 if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
1559 goto close_json_markup;
1561 json_markup_network(tab, OPEN_JSON_MARKUP);
1564 xprintf0(tab, "\"net-ip6\": {"
1566 "\"fwddgm6\": %.2f, "
1569 "\"asmrq6\": %.2f, "
1570 "\"asmok6\": %.2f, "
1571 "\"imcpck6\": %.2f, "
1572 "\"omcpck6\": %.2f, "
1573 "\"fragok6\": %.2f, "
1574 "\"fragcr6\": %.2f}",
1575 S_VALUE(snip->InReceives6, snic->InReceives6, itv),
1576 S_VALUE(snip->OutForwDatagrams6, snic->OutForwDatagrams6, itv),
1577 S_VALUE(snip->InDelivers6, snic->InDelivers6, itv),
1578 S_VALUE(snip->OutRequests6, snic->OutRequests6, itv),
1579 S_VALUE(snip->ReasmReqds6, snic->ReasmReqds6, itv),
1580 S_VALUE(snip->ReasmOKs6, snic->ReasmOKs6, itv),
1581 S_VALUE(snip->InMcastPkts6, snic->InMcastPkts6, itv),
1582 S_VALUE(snip->OutMcastPkts6, snic->OutMcastPkts6, itv),
1583 S_VALUE(snip->FragOKs6, snic->FragOKs6, itv),
1584 S_VALUE(snip->FragCreates6, snic->FragCreates6, itv));
1588 if (CLOSE_MARKUP(a->options)) {
1589 json_markup_network(tab, CLOSE_JSON_MARKUP);
1594 ***************************************************************************
1595 * Display IPv6 network errors statistics in JSON.
1598 * @a Activity structure with statistics.
1599 * @curr Index in array for current sample statistics.
1600 * @tab Indentation in output.
1601 * @itv Interval of time in 1/100th of a second.
1602 ***************************************************************************
1604 __print_funct_t json_print_net_eip6_stats(struct activity *a, int curr, int tab,
1605 unsigned long long itv)
1607 struct stats_net_eip6
1608 *sneic = (struct stats_net_eip6 *) a->buf[curr],
1609 *sneip = (struct stats_net_eip6 *) a->buf[!curr];
1611 if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
1612 goto close_json_markup;
1614 json_markup_network(tab, OPEN_JSON_MARKUP);
1617 xprintf0(tab, "\"net-eip6\": {"
1618 "\"ihdrer6\": %.2f, "
1619 "\"iadrer6\": %.2f, "
1620 "\"iukwnp6\": %.2f, "
1621 "\"i2big6\": %.2f, "
1622 "\"idisc6\": %.2f, "
1623 "\"odisc6\": %.2f, "
1624 "\"inort6\": %.2f, "
1625 "\"onort6\": %.2f, "
1627 "\"fragf6\": %.2f, "
1628 "\"itrpck6\": %.2f}",
1629 S_VALUE(sneip->InHdrErrors6, sneic->InHdrErrors6, itv),
1630 S_VALUE(sneip->InAddrErrors6, sneic->InAddrErrors6, itv),
1631 S_VALUE(sneip->InUnknownProtos6, sneic->InUnknownProtos6, itv),
1632 S_VALUE(sneip->InTooBigErrors6, sneic->InTooBigErrors6, itv),
1633 S_VALUE(sneip->InDiscards6, sneic->InDiscards6, itv),
1634 S_VALUE(sneip->OutDiscards6, sneic->OutDiscards6, itv),
1635 S_VALUE(sneip->InNoRoutes6, sneic->InNoRoutes6, itv),
1636 S_VALUE(sneip->OutNoRoutes6, sneic->OutNoRoutes6, itv),
1637 S_VALUE(sneip->ReasmFails6, sneic->ReasmFails6, itv),
1638 S_VALUE(sneip->FragFails6, sneic->FragFails6, itv),
1639 S_VALUE(sneip->InTruncatedPkts6, sneic->InTruncatedPkts6, itv));
1643 if (CLOSE_MARKUP(a->options)) {
1644 json_markup_network(tab, CLOSE_JSON_MARKUP);
1649 ***************************************************************************
1650 * Display ICMPv6 network statistics in JSON.
1653 * @a Activity structure with statistics.
1654 * @curr Index in array for current sample statistics.
1655 * @tab Indentation in output.
1656 * @itv Interval of time in 1/100th of a second.
1657 ***************************************************************************
1659 __print_funct_t json_print_net_icmp6_stats(struct activity *a, int curr, int tab,
1660 unsigned long long itv)
1662 struct stats_net_icmp6
1663 *snic = (struct stats_net_icmp6 *) a->buf[curr],
1664 *snip = (struct stats_net_icmp6 *) a->buf[!curr];
1666 if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
1667 goto close_json_markup;
1669 json_markup_network(tab, OPEN_JSON_MARKUP);
1672 xprintf0(tab, "\"net-icmp6\": {"
1676 "\"iechr6\": %.2f, "
1677 "\"oechr6\": %.2f, "
1678 "\"igmbq6\": %.2f, "
1679 "\"igmbr6\": %.2f, "
1680 "\"ogmbr6\": %.2f, "
1681 "\"igmbrd6\": %.2f, "
1682 "\"ogmbrd6\": %.2f, "
1683 "\"irtsol6\": %.2f, "
1684 "\"ortsol6\": %.2f, "
1685 "\"irtad6\": %.2f, "
1686 "\"inbsol6\": %.2f, "
1687 "\"onbsol6\": %.2f, "
1688 "\"inbad6\": %.2f, "
1689 "\"onbad6\": %.2f}",
1690 S_VALUE(snip->InMsgs6, snic->InMsgs6, itv),
1691 S_VALUE(snip->OutMsgs6, snic->OutMsgs6, itv),
1692 S_VALUE(snip->InEchos6, snic->InEchos6, itv),
1693 S_VALUE(snip->InEchoReplies6, snic->InEchoReplies6, itv),
1694 S_VALUE(snip->OutEchoReplies6, snic->OutEchoReplies6, itv),
1695 S_VALUE(snip->InGroupMembQueries6, snic->InGroupMembQueries6, itv),
1696 S_VALUE(snip->InGroupMembResponses6, snic->InGroupMembResponses6, itv),
1697 S_VALUE(snip->OutGroupMembResponses6, snic->OutGroupMembResponses6, itv),
1698 S_VALUE(snip->InGroupMembReductions6, snic->InGroupMembReductions6, itv),
1699 S_VALUE(snip->OutGroupMembReductions6, snic->OutGroupMembReductions6, itv),
1700 S_VALUE(snip->InRouterSolicits6, snic->InRouterSolicits6, itv),
1701 S_VALUE(snip->OutRouterSolicits6, snic->OutRouterSolicits6, itv),
1702 S_VALUE(snip->InRouterAdvertisements6, snic->InRouterAdvertisements6, itv),
1703 S_VALUE(snip->InNeighborSolicits6, snic->InNeighborSolicits6, itv),
1704 S_VALUE(snip->OutNeighborSolicits6, snic->OutNeighborSolicits6, itv),
1705 S_VALUE(snip->InNeighborAdvertisements6, snic->InNeighborAdvertisements6, itv),
1706 S_VALUE(snip->OutNeighborAdvertisements6, snic->OutNeighborAdvertisements6, itv));
1710 if (CLOSE_MARKUP(a->options)) {
1711 json_markup_network(tab, CLOSE_JSON_MARKUP);
1716 ***************************************************************************
1717 * Display ICMPv6 error messages statistics in JSON.
1720 * @a Activity structure with statistics.
1721 * @curr Index in array for current sample statistics.
1722 * @tab Indentation in output.
1723 * @itv Interval of time in 1/100th of a second.
1724 ***************************************************************************
1726 __print_funct_t json_print_net_eicmp6_stats(struct activity *a, int curr, int tab,
1727 unsigned long long itv)
1729 struct stats_net_eicmp6
1730 *sneic = (struct stats_net_eicmp6 *) a->buf[curr],
1731 *sneip = (struct stats_net_eicmp6 *) a->buf[!curr];
1733 if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
1734 goto close_json_markup;
1736 json_markup_network(tab, OPEN_JSON_MARKUP);
1739 xprintf0(tab, "\"net-eicmp6\": {"
1741 "\"idtunr6\": %.2f, "
1742 "\"odtunr6\": %.2f, "
1743 "\"itmex6\": %.2f, "
1744 "\"otmex6\": %.2f, "
1745 "\"iprmpb6\": %.2f, "
1746 "\"oprmpb6\": %.2f, "
1747 "\"iredir6\": %.2f, "
1748 "\"oredir6\": %.2f, "
1749 "\"ipck2b6\": %.2f, "
1750 "\"opck2b6\": %.2f}",
1751 S_VALUE(sneip->InErrors6, sneic->InErrors6, itv),
1752 S_VALUE(sneip->InDestUnreachs6, sneic->InDestUnreachs6, itv),
1753 S_VALUE(sneip->OutDestUnreachs6, sneic->OutDestUnreachs6, itv),
1754 S_VALUE(sneip->InTimeExcds6, sneic->InTimeExcds6, itv),
1755 S_VALUE(sneip->OutTimeExcds6, sneic->OutTimeExcds6, itv),
1756 S_VALUE(sneip->InParmProblems6, sneic->InParmProblems6, itv),
1757 S_VALUE(sneip->OutParmProblems6, sneic->OutParmProblems6, itv),
1758 S_VALUE(sneip->InRedirects6, sneic->InRedirects6, itv),
1759 S_VALUE(sneip->OutRedirects6, sneic->OutRedirects6, itv),
1760 S_VALUE(sneip->InPktTooBigs6, sneic->InPktTooBigs6, itv),
1761 S_VALUE(sneip->OutPktTooBigs6, sneic->OutPktTooBigs6, itv));
1765 if (CLOSE_MARKUP(a->options)) {
1766 json_markup_network(tab, CLOSE_JSON_MARKUP);
1771 ***************************************************************************
1772 * Display UDPv6 network statistics in JSON.
1775 * @a Activity structure with statistics.
1776 * @curr Index in array for current sample statistics.
1777 * @tab Indentation in output.
1778 * @itv Interval of time in 1/100th of a second.
1779 ***************************************************************************
1781 __print_funct_t json_print_net_udp6_stats(struct activity *a, int curr, int tab,
1782 unsigned long long itv)
1784 struct stats_net_udp6
1785 *snuc = (struct stats_net_udp6 *) a->buf[curr],
1786 *snup = (struct stats_net_udp6 *) a->buf[!curr];
1788 if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
1789 goto close_json_markup;
1791 json_markup_network(tab, OPEN_JSON_MARKUP);
1794 xprintf0(tab, "\"net-udp6\": {"
1797 "\"noport6\": %.2f, "
1798 "\"idgmer6\": %.2f}",
1799 S_VALUE(snup->InDatagrams6, snuc->InDatagrams6, itv),
1800 S_VALUE(snup->OutDatagrams6, snuc->OutDatagrams6, itv),
1801 S_VALUE(snup->NoPorts6, snuc->NoPorts6, itv),
1802 S_VALUE(snup->InErrors6, snuc->InErrors6, itv));
1806 if (CLOSE_MARKUP(a->options)) {
1807 json_markup_network(tab, CLOSE_JSON_MARKUP);
1812 ***************************************************************************
1813 * Display CPU frequency statistics in JSON.
1816 * @a Activity structure with statistics.
1817 * @curr Index in array for current sample statistics.
1818 * @tab Indentation in output.
1819 * @itv Interval of time in 1/100th of a second.
1820 ***************************************************************************
1822 __print_funct_t json_print_pwr_cpufreq_stats(struct activity *a, int curr, int tab,
1823 unsigned long long itv)
1826 struct stats_pwr_cpufreq *spc;
1830 if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
1831 goto close_json_markup;
1833 json_markup_power_management(tab, OPEN_JSON_MARKUP);
1836 xprintf(tab++, "\"cpu-frequency\": [");
1838 for (i = 0; (i < a->nr[curr]) && (i < a->bitmap->b_size + 1); i++) {
1840 spc = (struct stats_pwr_cpufreq *) ((char *) a->buf[curr] + i * a->msize);
1842 /* Should current CPU (including CPU "all") be displayed? */
1843 if (!(a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))))
1848 /* This is CPU "all" */
1849 strcpy(cpuno, "all");
1852 sprintf(cpuno, "%d", i - 1);
1860 xprintf0(tab, "{\"number\": \"%s\", "
1861 "\"frequency\": %.2f}",
1863 ((double) spc->cpufreq) / 100);
1867 xprintf0(--tab, "]");
1871 if (CLOSE_MARKUP(a->options)) {
1872 json_markup_power_management(tab, CLOSE_JSON_MARKUP);
1877 ***************************************************************************
1878 * Display fan statistics in JSON.
1881 * @a Activity structure with statistics.
1882 * @curr Index in array for current sample statistics.
1883 * @tab Indentation in output.
1884 * @itv Interval of time in 1/100th of a second.
1885 ***************************************************************************
1887 __print_funct_t json_print_pwr_fan_stats(struct activity *a, int curr, int tab,
1888 unsigned long long itv)
1891 struct stats_pwr_fan *spc;
1894 if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
1895 goto close_json_markup;
1897 json_markup_power_management(tab, OPEN_JSON_MARKUP);
1900 xprintf(tab++, "\"fan-speed\": [");
1902 for (i = 0; i < a->nr[curr]; i++) {
1903 spc = (struct stats_pwr_fan *) ((char *) a->buf[curr] + i * a->msize);
1910 xprintf0(tab, "{\"number\": %d, "
1913 "\"device\": \"%s\"}",
1915 (unsigned long long) spc->rpm,
1916 (unsigned long long) (spc->rpm - spc->rpm_min),
1921 xprintf0(--tab, "]");
1925 if (CLOSE_MARKUP(a->options)) {
1926 json_markup_power_management(tab, CLOSE_JSON_MARKUP);
1931 ***************************************************************************
1932 * Display temperature statistics in JSON.
1935 * @a Activity structure with statistics.
1936 * @curr Index in array for current sample statistics.
1937 * @tab Indentation in output.
1938 * @itv Interval of time in 1/100th of a second.
1939 ***************************************************************************
1941 __print_funct_t json_print_pwr_temp_stats(struct activity *a, int curr, int tab,
1942 unsigned long long itv)
1945 struct stats_pwr_temp *spc;
1948 if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
1949 goto close_json_markup;
1951 json_markup_power_management(tab, OPEN_JSON_MARKUP);
1954 xprintf(tab++, "\"temperature\": [");
1956 for (i = 0; i < a->nr[curr]; i++) {
1957 spc = (struct stats_pwr_temp *) ((char *) a->buf[curr] + i * a->msize);
1964 xprintf0(tab, "{\"number\": %d, "
1966 "\"percent-temp\": %.2f, "
1967 "\"device\": \"%s\"}",
1970 (spc->temp_max - spc->temp_min) ?
1971 (spc->temp - spc->temp_min) / (spc->temp_max - spc->temp_min) * 100 :
1977 xprintf0(--tab, "]");
1981 if (CLOSE_MARKUP(a->options)) {
1982 json_markup_power_management(tab, CLOSE_JSON_MARKUP);
1987 ***************************************************************************
1988 * Display voltage inputs statistics in JSON.
1991 * @a Activity structure with statistics.
1992 * @curr Index in array for current sample statistics.
1993 * @tab Indentation in output.
1994 * @itv Interval of time in 1/100th of a second.
1995 ***************************************************************************
1997 __print_funct_t json_print_pwr_in_stats(struct activity *a, int curr, int tab,
1998 unsigned long long itv)
2001 struct stats_pwr_in *spc;
2004 if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
2005 goto close_json_markup;
2007 json_markup_power_management(tab, OPEN_JSON_MARKUP);
2010 xprintf(tab++, "\"voltage-input\": [");
2012 for (i = 0; i < a->nr[curr]; i++) {
2013 spc = (struct stats_pwr_in *) ((char *) a->buf[curr] + i * a->msize);
2020 xprintf0(tab, "{\"number\": %d, "
2022 "\"percent-in\": %.2f, "
2023 "\"device\": \"%s\"}",
2026 (spc->in_max - spc->in_min) ?
2027 (spc->in - spc->in_min) / (spc->in_max - spc->in_min) * 100 :
2033 xprintf0(--tab, "]");
2037 if (CLOSE_MARKUP(a->options)) {
2038 json_markup_power_management(tab, CLOSE_JSON_MARKUP);
2043 ***************************************************************************
2044 * Display huge pages statistics in JSON.
2047 * @a Activity structure with statistics.
2048 * @curr Index in array for current sample statistics.
2049 * @tab Indentation in output.
2050 * @itv Interval of time in 1/100th of a second.
2051 ***************************************************************************
2053 __print_funct_t json_print_huge_stats(struct activity *a, int curr, int tab,
2054 unsigned long long itv)
2057 *smc = (struct stats_huge *) a->buf[curr];
2059 xprintf0(tab, "\"hugepages\": {"
2060 "\"hugfree\": %llu, "
2061 "\"hugused\": %llu, "
2062 "\"hugused-percent\": %.2f, "
2063 "\"hugrsvd\": %llu, "
2064 "\"hugsurp\": %llu}",
2066 smc->tlhkb - smc->frhkb,
2068 SP_VALUE(smc->frhkb, smc->tlhkb, smc->tlhkb) : 0.0,
2074 ***************************************************************************
2075 * Display weighted CPU frequency statistics in JSON.
2078 * @a Activity structure with statistics.
2079 * @curr Index in array for current sample statistics.
2080 * @tab Indentation in output.
2081 * @itv Interval of time in 1/100th of a second.
2082 ***************************************************************************
2084 __print_funct_t json_print_pwr_wghfreq_stats(struct activity *a, int curr, int tab,
2085 unsigned long long itv)
2088 struct stats_pwr_wghfreq *spc, *spp, *spc_k, *spp_k;
2089 unsigned long long tis, tisfreq;
2093 if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
2094 goto close_json_markup;
2096 json_markup_power_management(tab, OPEN_JSON_MARKUP);
2099 xprintf(tab++, "\"cpu-weighted-frequency\": [");
2101 for (i = 0; (i < a->nr[curr]) && (i < a->bitmap->b_size + 1); i++) {
2103 spc = (struct stats_pwr_wghfreq *) ((char *) a->buf[curr] + i * a->msize * a->nr2);
2104 spp = (struct stats_pwr_wghfreq *) ((char *) a->buf[!curr] + i * a->msize * a->nr2);
2106 /* Should current CPU (including CPU "all") be displayed? */
2107 if (!(a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))))
2114 for (k = 0; k < a->nr2; k++) {
2116 spc_k = (struct stats_pwr_wghfreq *) ((char *) spc + k * a->msize);
2119 spp_k = (struct stats_pwr_wghfreq *) ((char *) spp + k * a->msize);
2121 tisfreq += (spc_k->freq / 1000) *
2122 (spc_k->time_in_state - spp_k->time_in_state);
2123 tis += (spc_k->time_in_state - spp_k->time_in_state);
2127 /* This is CPU "all" */
2128 strcpy(cpuno, "all");
2131 sprintf(cpuno, "%d", i - 1);
2139 xprintf0(tab, "{\"number\": \"%s\", "
2140 "\"weighted-frequency\": %.2f}",
2142 tis ? ((double) tisfreq) / tis : 0.0);
2146 xprintf0(--tab, "]");
2150 if (CLOSE_MARKUP(a->options)) {
2151 json_markup_power_management(tab, CLOSE_JSON_MARKUP);
2156 ***************************************************************************
2157 * Display USB devices statistics in JSON.
2160 * @a Activity structure with statistics.
2161 * @curr Index in array for current sample statistics.
2162 * @tab Indentation in output.
2163 * @itv Interval of time in 1/100th of a second.
2164 ***************************************************************************
2166 __print_funct_t json_print_pwr_usb_stats(struct activity *a, int curr, int tab,
2167 unsigned long long itv)
2170 struct stats_pwr_usb *suc;
2173 if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
2174 goto close_json_markup;
2176 json_markup_power_management(tab, OPEN_JSON_MARKUP);
2179 xprintf(tab++, "\"usb-devices\": [");
2181 for (i = 0; i < a->nr[curr]; i++) {
2182 suc = (struct stats_pwr_usb *) ((char *) a->buf[curr] + i * a->msize);
2189 xprintf0(tab, "{\"bus_number\": %d, "
2190 "\"idvendor\": \"%x\", "
2191 "\"idprod\": \"%x\", "
2192 "\"maxpower\": %u, "
2193 "\"manufact\": \"%s\", "
2194 "\"product\": \"%s\"}",
2198 suc->bmaxpower << 1,
2204 xprintf0(--tab, "]");
2208 if (CLOSE_MARKUP(a->options)) {
2209 json_markup_power_management(tab, CLOSE_JSON_MARKUP);
2214 ***************************************************************************
2215 * Display filesystems statistics in JSON.
2218 * @a Activity structure with statistics.
2219 * @curr Index in array for current sample statistics.
2220 * @tab Indentation in output.
2221 * @itv Interval of time in 1/100th of a second.
2222 ***************************************************************************
2224 __print_funct_t json_print_filesystem_stats(struct activity *a, int curr, int tab,
2225 unsigned long long itv)
2228 struct stats_filesystem *sfc;
2232 xprintf(tab++, "\"filesystems\": [");
2234 for (i = 0; i < a->nr[curr]; i++) {
2235 sfc = (struct stats_filesystem *) ((char *) a->buf[curr] + i * a->msize);
2237 /* Get name to display (persistent or standard fs name, or mount point) */
2238 dev_name = get_fs_name_to_display(a, flags, sfc);
2240 if (a->item_list != NULL) {
2241 /* A list of devices has been entered on the command line */
2242 if (!search_list_item(a->item_list, dev_name))
2243 /* Device not found */
2252 xprintf0(tab, "{\"%s\": \"%s\", "
2253 "\"MBfsfree\": %.0f, "
2254 "\"MBfsused\": %.0f, "
2255 "\"%%fsused\": %.2f, "
2256 "\"%%ufsused\": %.2f, "
2259 "\"%%Iused\": %.2f}",
2260 DISPLAY_MOUNT(a->opt_flags) ? "mountpoint" : "filesystem",
2262 (double) sfc->f_bfree / 1024 / 1024,
2263 (double) (sfc->f_blocks - sfc->f_bfree) / 1024 / 1024,
2264 sfc->f_blocks ? SP_VALUE(sfc->f_bfree, sfc->f_blocks, sfc->f_blocks)
2266 sfc->f_blocks ? SP_VALUE(sfc->f_bavail, sfc->f_blocks, sfc->f_blocks)
2269 sfc->f_files - sfc->f_ffree,
2270 sfc->f_files ? SP_VALUE(sfc->f_ffree, sfc->f_files, sfc->f_files)
2275 xprintf0(--tab, "]");
2279 ***************************************************************************
2280 * Display Fibre Channel HBA statistics in JSON.
2283 * @a Activity structure with statistics.
2284 * @curr Index in array for current sample statistics.
2285 * @tab Indentation in output.
2286 * @itv Interval of time in 1/100th of a second.
2287 ***************************************************************************
2289 __print_funct_t json_print_fchost_stats(struct activity *a, int curr, int tab,
2290 unsigned long long itv)
2292 int i, j, j0, found;
2293 struct stats_fchost *sfcc, *sfcp, sfczero;
2296 if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
2297 goto close_json_markup;
2299 memset(&sfczero, 0, sizeof(struct stats_fchost));
2301 json_markup_network(tab, OPEN_JSON_MARKUP);
2304 xprintf(tab++, "\"fchosts\": [");
2306 for (i = 0; i < a->nr[curr]; i++) {
2309 sfcc = (struct stats_fchost *) ((char *) a->buf[curr] + i * a->msize);
2311 if (a->nr[!curr] > 0) {
2312 /* Look for corresponding structure in previous iteration */
2315 if (j >= a->nr[!curr]) {
2316 j = a->nr[!curr] - 1;
2322 sfcp = (struct stats_fchost *) ((char *) a->buf[!curr] + j * a->msize);
2323 if (!strcmp(sfcc->fchost_name, sfcp->fchost_name)) {
2327 if (++j >= a->nr[!curr]) {
2335 /* This is a newly registered host */
2344 xprintf0(tab, "{\"fchost\": \"%s\", "
2345 "\"fch_rxf\": %.2f, "
2346 "\"fch_txf\": %.2f, "
2347 "\"fch_rxw\": %.2f, "
2348 "\"fch_txw\": %.2f}",
2350 S_VALUE(sfcp->f_rxframes, sfcc->f_rxframes, itv),
2351 S_VALUE(sfcp->f_txframes, sfcc->f_txframes, itv),
2352 S_VALUE(sfcp->f_rxwords, sfcc->f_rxwords, itv),
2353 S_VALUE(sfcp->f_txwords, sfcc->f_txwords, itv));
2357 xprintf0(--tab, "]");
2362 if (CLOSE_MARKUP(a->options)) {
2363 json_markup_network(tab, CLOSE_JSON_MARKUP);
2368 ***************************************************************************
2369 * Display softnet statistics in JSON.
2372 * @a Activity structure with statistics.
2373 * @curr Index in array for current sample statistics.
2374 * @tab Indentation in output.
2375 * @itv Interval of time in 1/100th of a second.
2376 ***************************************************************************
2378 __print_funct_t json_print_softnet_stats(struct activity *a, int curr, int tab,
2379 unsigned long long itv)
2382 struct stats_softnet *ssnc, *ssnp;
2385 unsigned char offline_cpu_bitmap[BITMAP_SIZE(NR_CPUS)] = {0};
2387 if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
2388 goto close_json_markup;
2390 json_markup_network(tab, OPEN_JSON_MARKUP);
2393 xprintf(tab++, "\"softnet\": [");
2395 /* @nr[curr] cannot normally be greater than @nr_ini */
2396 if (a->nr[curr] > a->nr_ini) {
2397 a->nr_ini = a->nr[curr];
2400 /* Compute statistics for CPU "all" */
2401 get_global_soft_statistics(a, !curr, curr, flags, offline_cpu_bitmap);
2403 for (i = 0; (i < a->nr_ini) && (i < a->bitmap->b_size + 1); i++) {
2406 * Should current CPU (including CPU "all") be displayed?
2407 * Note: a->nr is in [1, NR_CPUS + 1].
2408 * Bitmap size is provided for (NR_CPUS + 1) CPUs.
2409 * Anyway, NR_CPUS may vary between the version of sysstat
2410 * used by sadc to create a file, and the version of sysstat
2411 * used by sar to read it...
2413 if (!(a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))) ||
2414 offline_cpu_bitmap[i >> 3] & (1 << (i & 0x07)))
2419 * The size of a->buf[...] CPU structure may be different from the default
2420 * sizeof(struct stats_pwr_cpufreq) value if data have been read from a file!
2421 * That's why we don't use a syntax like:
2422 * ssnc = (struct stats_softnet *) a->buf[...] + i;
2424 ssnc = (struct stats_softnet *) ((char *) a->buf[curr] + i * a->msize);
2425 ssnp = (struct stats_softnet *) ((char *) a->buf[!curr] + i * a->msize);
2433 /* This is CPU "all" */
2434 strcpy(cpuno, "all");
2437 sprintf(cpuno, "%d", i - 1);
2440 xprintf0(tab, "{\"cpu\": \"%s\", "
2443 "\"squeezd\": %.2f, "
2444 "\"rx_rps\": %.2f, "
2445 "\"flw_lim\": %.2f}",
2447 S_VALUE(ssnp->processed, ssnc->processed, itv),
2448 S_VALUE(ssnp->dropped, ssnc->dropped, itv),
2449 S_VALUE(ssnp->time_squeeze, ssnc->time_squeeze, itv),
2450 S_VALUE(ssnp->received_rps, ssnc->received_rps, itv),
2451 S_VALUE(ssnp->flow_limit, ssnc->flow_limit, itv));
2455 xprintf0(--tab, "]");
2460 if (CLOSE_MARKUP(a->options)) {
2461 json_markup_network(tab, CLOSE_JSON_MARKUP);
2466 ***************************************************************************
2467 * Display pressure-stall CPU statistics in JSON.
2470 * @a Activity structure with statistics.
2471 * @curr Index in array for current sample statistics.
2472 * @tab Indentation in output.
2473 * @itv Interval of time in 1/100th of a second.
2474 ***************************************************************************
2476 __print_funct_t json_print_psicpu_stats(struct activity *a, int curr, int tab,
2477 unsigned long long itv)
2479 struct stats_psi_cpu
2480 *psic = (struct stats_psi_cpu *) a->buf[curr],
2481 *psip = (struct stats_psi_cpu *) a->buf[!curr];
2483 if (!IS_SELECTED(a->options))
2484 goto close_json_markup;
2486 json_markup_psi(tab, OPEN_JSON_MARKUP);
2489 xprintf0(tab, "\"psi-cpu\": {"
2490 "\"some_avg10\": %.2f, "
2491 "\"some_avg60\": %.2f, "
2492 "\"some_avg300\": %.2f, "
2493 "\"some_avg\": %.2f}",
2494 (double) psic->some_acpu_10 / 100,
2495 (double) psic->some_acpu_60 / 100,
2496 (double) psic->some_acpu_300 / 100,
2497 ((double) psic->some_cpu_total - psip->some_cpu_total) / (100 * itv));
2501 if (CLOSE_MARKUP(a->options)) {
2502 json_markup_psi(tab, CLOSE_JSON_MARKUP);
2507 ***************************************************************************
2508 * Display pressure-stall I/O statistics in JSON.
2511 * @a Activity structure with statistics.
2512 * @curr Index in array for current sample statistics.
2513 * @tab Indentation in output.
2514 * @itv Interval of time in 1/100th of a second.
2515 ***************************************************************************
2517 __print_funct_t json_print_psiio_stats(struct activity *a, int curr, int tab,
2518 unsigned long long itv)
2521 *psic = (struct stats_psi_io *) a->buf[curr],
2522 *psip = (struct stats_psi_io *) a->buf[!curr];
2524 if (!IS_SELECTED(a->options))
2525 goto close_json_markup;
2527 json_markup_psi(tab, OPEN_JSON_MARKUP);
2530 xprintf0(tab, "\"psi-io\": {"
2531 "\"some_avg10\": %.2f, "
2532 "\"some_avg60\": %.2f, "
2533 "\"some_avg300\": %.2f, "
2534 "\"some_avg\": %.2f, "
2535 "\"full_avg10\": %.2f, "
2536 "\"full_avg60\": %.2f, "
2537 "\"full_avg300\": %.2f, "
2538 "\"full_avg\": %.2f}",
2539 (double) psic->some_aio_10 / 100,
2540 (double) psic->some_aio_60 / 100,
2541 (double) psic->some_aio_300 / 100,
2542 ((double) psic->some_io_total - psip->some_io_total) / (100 * itv),
2543 (double) psic->full_aio_10 / 100,
2544 (double) psic->full_aio_60 / 100,
2545 (double) psic->full_aio_300 / 100,
2546 ((double) psic->full_io_total - psip->full_io_total) / (100 * itv));
2550 if (CLOSE_MARKUP(a->options)) {
2551 json_markup_psi(tab, CLOSE_JSON_MARKUP);
2556 ***************************************************************************
2557 * Display pressure-stall memory statistics in JSON.
2560 * @a Activity structure with statistics.
2561 * @curr Index in array for current sample statistics.
2562 * @tab Indentation in output.
2563 * @itv Interval of time in 1/100th of a second.
2564 ***************************************************************************
2566 __print_funct_t json_print_psimem_stats(struct activity *a, int curr, int tab,
2567 unsigned long long itv)
2569 struct stats_psi_mem
2570 *psic = (struct stats_psi_mem *) a->buf[curr],
2571 *psip = (struct stats_psi_mem *) a->buf[!curr];
2573 if (!IS_SELECTED(a->options))
2574 goto close_json_markup;
2576 json_markup_psi(tab, OPEN_JSON_MARKUP);
2579 xprintf0(tab, "\"psi-mem\": {"
2580 "\"some_avg10\": %.2f, "
2581 "\"some_avg60\": %.2f, "
2582 "\"some_avg300\": %.2f, "
2583 "\"some_avg\": %.2f, "
2584 "\"full_avg10\": %.2f, "
2585 "\"full_avg60\": %.2f, "
2586 "\"full_avg300\": %.2f, "
2587 "\"full_avg\": %.2f}",
2588 (double) psic->some_amem_10 / 100,
2589 (double) psic->some_amem_60 / 100,
2590 (double) psic->some_amem_300 / 100,
2591 ((double) psic->some_mem_total - psip->some_mem_total) / (100 * itv),
2592 (double) psic->full_amem_10 / 100,
2593 (double) psic->full_amem_60 / 100,
2594 (double) psic->full_amem_300 / 100,
2595 ((double) psic->full_mem_total - psip->full_mem_total) / (100 * itv));
2599 if (CLOSE_MARKUP(a->options)) {
2600 json_markup_psi(tab, CLOSE_JSON_MARKUP);