2 * json_stats.c: Funtions used by sadf to display statistics in JSON format.
3 * (C) 1999-2016 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 ***************************************************************************
29 #include "json_stats.h"
34 #define _(string) gettext(string)
36 #define _(string) (string)
39 extern unsigned int flags;
40 extern unsigned int dm_major;
43 ***************************************************************************
44 * Open or close "network" markup.
47 * @tab Number of tabulations.
48 * @action Open or close action.
49 ***************************************************************************
51 void json_markup_network(int tab, int action)
53 static int markup_state = CLOSE_JSON_MARKUP;
55 if (action == markup_state)
57 markup_state = action;
59 if (action == OPEN_JSON_MARKUP) {
61 xprintf(tab, "\"network\": {");
71 ***************************************************************************
72 * Open or close "power-management" markup.
75 * @tab Number of tabulations.
76 * @action Open or close action.
77 ***************************************************************************
79 void json_markup_power_management(int tab, int action)
81 static int markup_state = CLOSE_JSON_MARKUP;
83 if (action == markup_state)
85 markup_state = action;
87 if (action == OPEN_JSON_MARKUP) {
89 xprintf(tab, "\"power-management\": {");
99 ***************************************************************************
100 * Display CPU statistics in JSON.
103 * @a Activity structure with statistics.
104 * @curr Index in array for current sample statistics.
105 * @tab Indentation in output.
106 * @g_itv Interval of time in jiffies mutliplied by the number of
108 ***************************************************************************
110 __print_funct_t json_print_cpu_stats(struct activity *a, int curr, int tab,
111 unsigned long long g_itv)
115 struct stats_cpu *scc, *scp;
118 xprintf(tab++, "\"cpu-load\": [");
120 for (i = 0; (i < a->nr) && (i < a->bitmap->b_size + 1); i++) {
122 scc = (struct stats_cpu *) ((char *) a->buf[curr] + i * a->msize);
123 scp = (struct stats_cpu *) ((char *) a->buf[!curr] + i * a->msize);
125 /* Should current CPU (including CPU "all") be displayed? */
126 if (!(a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))))
130 /* Yes: Display current CPU stats */
138 /* This is CPU "all" */
139 strcpy(cpuno, "all");
142 sprintf(cpuno, "%d", i - 1);
145 * If the CPU is offline then it is omited from /proc/stat:
146 * All the fields couldn't have been read and the sum of them is zero.
147 * (Remember that guest/guest_nice times are already included in
150 if ((scc->cpu_user + scc->cpu_nice + scc->cpu_sys +
151 scc->cpu_iowait + scc->cpu_idle + scc->cpu_steal +
152 scc->cpu_hardirq + scc->cpu_softirq) == 0) {
154 * Set current struct fields (which have been set to zero)
155 * to values from previous iteration. Hence their values won't
156 * jump from zero when the CPU comes back online.
165 * Recalculate interval for current proc.
166 * If result is 0 then current CPU is a tickless one.
168 g_itv = get_per_cpu_interval(scc, scp);
173 /* Current CPU is offline or tickless */
174 if (DISPLAY_CPU_DEF(a->opt_flags)) {
175 xprintf0(tab, "{\"cpu\": \"%d\", "
182 i - 1, 0.0, 0.0, 0.0, 0.0, 0.0,
183 cpu_offline ? 0.0 : 100.0);
185 else if (DISPLAY_CPU_ALL(a->opt_flags)) {
186 xprintf0(tab, "{\"cpu\": \"%d\", "
197 i - 1, 0.0, 0.0, 0.0, 0.0,
198 0.0, 0.0, 0.0, 0.0, 0.0,
199 cpu_offline ? 0.0 : 100.0);
205 if (DISPLAY_CPU_DEF(a->opt_flags)) {
206 xprintf0(tab, "{\"cpu\": \"%s\", "
214 ll_sp_value(scp->cpu_user, scc->cpu_user, g_itv),
215 ll_sp_value(scp->cpu_nice, scc->cpu_nice, g_itv),
216 ll_sp_value(scp->cpu_sys + scp->cpu_hardirq + scp->cpu_softirq,
217 scc->cpu_sys + scc->cpu_hardirq + scc->cpu_softirq,
219 ll_sp_value(scp->cpu_iowait, scc->cpu_iowait, g_itv),
220 ll_sp_value(scp->cpu_steal, scc->cpu_steal, g_itv),
221 scc->cpu_idle < scp->cpu_idle ?
223 ll_sp_value(scp->cpu_idle, scc->cpu_idle, g_itv));
225 else if (DISPLAY_CPU_ALL(a->opt_flags)) {
226 xprintf0(tab, "{\"cpu\": \"%s\", "
238 (scc->cpu_user - scc->cpu_guest) < (scp->cpu_user - scp->cpu_guest) ?
240 ll_sp_value(scp->cpu_user - scp->cpu_guest,
241 scc->cpu_user - scc->cpu_guest, g_itv),
242 (scc->cpu_nice - scc->cpu_guest_nice) < (scp->cpu_nice - scp->cpu_guest_nice) ?
244 ll_sp_value(scp->cpu_nice - scp->cpu_guest_nice,
245 scc->cpu_nice - scc->cpu_guest_nice, g_itv),
246 ll_sp_value(scp->cpu_sys, scc->cpu_sys, g_itv),
247 ll_sp_value(scp->cpu_iowait, scc->cpu_iowait, g_itv),
248 ll_sp_value(scp->cpu_steal, scc->cpu_steal, g_itv),
249 ll_sp_value(scp->cpu_hardirq, scc->cpu_hardirq, g_itv),
250 ll_sp_value(scp->cpu_softirq, scc->cpu_softirq, g_itv),
251 ll_sp_value(scp->cpu_guest, scc->cpu_guest, g_itv),
252 ll_sp_value(scp->cpu_guest_nice, scc->cpu_guest_nice, g_itv),
253 scc->cpu_idle < scp->cpu_idle ?
255 ll_sp_value(scp->cpu_idle, scc->cpu_idle, g_itv));
260 xprintf0(--tab, "]");
264 ***************************************************************************
265 * Display task creation and context switch statistics in JSON.
268 * @a Activity structure with statistics.
269 * @curr Index in array for current sample statistics.
270 * @tab Indentation in output.
271 * @itv Interval of time in jiffies.
272 ***************************************************************************
274 __print_funct_t json_print_pcsw_stats(struct activity *a, int curr, int tab,
275 unsigned long long itv)
278 *spc = (struct stats_pcsw *) a->buf[curr],
279 *spp = (struct stats_pcsw *) a->buf[!curr];
281 /* proc/s and cswch/s */
282 xprintf0(tab, "\"process-and-context-switch\": {"
285 S_VALUE(spp->processes, spc->processes, itv),
286 S_VALUE(spp->context_switch, spc->context_switch, itv));
290 ***************************************************************************
291 * Display interrupts statistics in JSON.
294 * @a Activity structure with statistics.
295 * @curr Index in array for current sample statistics.
296 * @tab Indentation in output.
297 * @itv Interval of time in jiffies.
298 ***************************************************************************
300 __print_funct_t json_print_irq_stats(struct activity *a, int curr, int tab,
301 unsigned long long itv)
304 struct stats_irq *sic, *sip;
308 xprintf(tab++, "\"interrupts\": [");
310 for (i = 0; (i < a->nr) && (i < a->bitmap->b_size + 1); i++) {
312 sic = (struct stats_irq *) ((char *) a->buf[curr] + i * a->msize);
313 sip = (struct stats_irq *) ((char *) a->buf[!curr] + i * a->msize);
315 /* Should current interrupt (including int "sum") be displayed? */
316 if (a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))) {
318 /* Yes: Display it */
326 /* This is interrupt "sum" */
327 strcpy(irqno, "sum");
330 sprintf(irqno, "%d", i - 1);
333 xprintf0(tab, "{\"intr\": \"%s\", "
336 S_VALUE(sip->irq_nr, sic->irq_nr, itv));
341 xprintf0(--tab, "]");
345 ***************************************************************************
346 * Display swapping statistics in JSON.
349 * @a Activity structure with statistics.
350 * @curr Index in array for current sample statistics.
351 * @tab Indentation in output.
352 * @itv Interval of time in jiffies.
353 ***************************************************************************
355 __print_funct_t json_print_swap_stats(struct activity *a, int curr, int tab,
356 unsigned long long itv)
359 *ssc = (struct stats_swap *) a->buf[curr],
360 *ssp = (struct stats_swap *) a->buf[!curr];
362 xprintf0(tab, "\"swap-pages\": {"
364 "\"pswpout\": %.2f}",
365 S_VALUE(ssp->pswpin, ssc->pswpin, itv),
366 S_VALUE(ssp->pswpout, ssc->pswpout, itv));
370 ***************************************************************************
371 * Display paging statistics in JSON.
374 * @a Activity structure with statistics.
375 * @curr Index in array for current sample statistics.
376 * @tab Indentation in output.
377 * @itv Interval of time in jiffies.
378 ***************************************************************************
380 __print_funct_t json_print_paging_stats(struct activity *a, int curr, int tab,
381 unsigned long long itv)
384 *spc = (struct stats_paging *) a->buf[curr],
385 *spp = (struct stats_paging *) a->buf[!curr];
387 xprintf0(tab, "\"paging\": {"
389 "\"pgpgout\": %.2f, "
393 "\"pgscank\": %.2f, "
394 "\"pgscand\": %.2f, "
395 "\"pgsteal\": %.2f, "
396 "\"vmeff-percent\": %.2f}",
397 S_VALUE(spp->pgpgin, spc->pgpgin, itv),
398 S_VALUE(spp->pgpgout, spc->pgpgout, itv),
399 S_VALUE(spp->pgfault, spc->pgfault, itv),
400 S_VALUE(spp->pgmajfault, spc->pgmajfault, itv),
401 S_VALUE(spp->pgfree, spc->pgfree, itv),
402 S_VALUE(spp->pgscan_kswapd, spc->pgscan_kswapd, itv),
403 S_VALUE(spp->pgscan_direct, spc->pgscan_direct, itv),
404 S_VALUE(spp->pgsteal, spc->pgsteal, itv),
405 (spc->pgscan_kswapd + spc->pgscan_direct -
406 spp->pgscan_kswapd - spp->pgscan_direct) ?
407 SP_VALUE(spp->pgsteal, spc->pgsteal,
408 spc->pgscan_kswapd + spc->pgscan_direct -
409 spp->pgscan_kswapd - spp->pgscan_direct) : 0.0);
413 ***************************************************************************
414 * Display I/O and transfer rate statistics in JSON.
417 * @a Activity structure with statistics.
418 * @curr Index in array for current sample statistics.
419 * @tab Indentation in output.
420 * @itv Interval of time in jiffies.
421 ***************************************************************************
423 __print_funct_t json_print_io_stats(struct activity *a, int curr, int tab,
424 unsigned long long itv)
427 *sic = (struct stats_io *) a->buf[curr],
428 *sip = (struct stats_io *) a->buf[!curr];
430 xprintf0(tab, "\"io\": {"
439 * If we get negative values, this is probably because
440 * one or more devices/filesystems have been unmounted.
441 * We display 0.0 in this case though we should rather tell
442 * the user that the value cannot be calculated here.
444 sic->dk_drive < sip->dk_drive ? 0.0 :
445 S_VALUE(sip->dk_drive, sic->dk_drive, itv),
446 sic->dk_drive_rio < sip->dk_drive_rio ? 0.0 :
447 S_VALUE(sip->dk_drive_rio, sic->dk_drive_rio, itv),
448 sic->dk_drive_rblk < sip->dk_drive_rblk ? 0.0 :
449 S_VALUE(sip->dk_drive_rblk, sic->dk_drive_rblk, itv),
450 sic->dk_drive_wio < sip->dk_drive_wio ? 0.0 :
451 S_VALUE(sip->dk_drive_wio, sic->dk_drive_wio, itv),
452 sic->dk_drive_wblk < sip->dk_drive_wblk ? 0.0 :
453 S_VALUE(sip->dk_drive_wblk, sic->dk_drive_wblk, itv));
457 ***************************************************************************
458 * Display memory statistics in JSON.
461 * @a Activity structure with statistics.
462 * @curr Index in array for current sample statistics.
463 * @tab Indentation in output.
464 * @itv Interval of time in jiffies.
465 ***************************************************************************
467 __print_funct_t json_print_memory_stats(struct activity *a, int curr, int tab,
468 unsigned long long itv)
471 *smc = (struct stats_memory *) a->buf[curr],
472 *smp = (struct stats_memory *) a->buf[!curr];
475 xprintf0(tab, "\"memory\": {");
477 if (DISPLAY_MEM_AMT(a->opt_flags)) {
481 printf("\"memfree\": %lu, "
483 "\"memused-percent\": %.2f, "
487 "\"commit-percent\": %.2f, "
489 "\"inactive\": %lu, "
492 smc->tlmkb - smc->frmkb,
494 SP_VALUE(smc->frmkb, smc->tlmkb, smc->tlmkb) :
499 (smc->tlmkb + smc->tlskb) ?
500 SP_VALUE(0, smc->comkb, smc->tlmkb + smc->tlskb) :
506 if (DISPLAY_MEM_ALL(a->opt_flags)) {
507 /* Display extended memory stats */
508 printf(", \"anonpg\": %lu, "
521 if (DISPLAY_SWAP(a->opt_flags)) {
528 printf("\"swpfree\": %lu, "
530 "\"swpused-percent\": %.2f, "
532 "\"swpcad-percent\": %.2f",
534 smc->tlskb - smc->frskb,
536 SP_VALUE(smc->frskb, smc->tlskb, smc->tlskb) :
539 (smc->tlskb - smc->frskb) ?
540 SP_VALUE(0, smc->caskb, smc->tlskb - smc->frskb) :
544 if (DISPLAY_MEMORY(a->opt_flags)) {
550 printf("\"frmpg\": %.2f, "
553 S_VALUE((double) KB_TO_PG(smp->frmkb),
554 (double) KB_TO_PG(smc->frmkb), itv),
555 S_VALUE((double) KB_TO_PG(smp->bufkb),
556 (double) KB_TO_PG(smc->bufkb), itv),
557 S_VALUE((double) KB_TO_PG(smp->camkb),
558 (double) KB_TO_PG(smc->camkb), itv));
565 ***************************************************************************
566 * Display kernel tables statistics in JSON.
569 * @a Activity structure with statistics.
570 * @curr Index in array for current sample statistics.
571 * @tab Indentation in output.
572 * @itv Interval of time in jiffies.
573 ***************************************************************************
575 __print_funct_t json_print_ktables_stats(struct activity *a, int curr, int tab,
576 unsigned long long itv)
579 *skc = (struct stats_ktables *) a->buf[curr];
581 xprintf0(tab, "\"kernel\": {"
582 "\"dentunusd\": %u, "
593 ***************************************************************************
594 * Display queue and load statistics in JSON.
597 * @a Activity structure with statistics.
598 * @curr Index in array for current sample statistics.
599 * @tab Indentation in output.
600 * @itv Interval of time in jiffies.
601 ***************************************************************************
603 __print_funct_t json_print_queue_stats(struct activity *a, int curr, int tab,
604 unsigned long long itv)
607 *sqc = (struct stats_queue *) a->buf[curr];
609 xprintf0(tab, "\"queue\": {"
612 "\"ldavg-1\": %.2f, "
613 "\"ldavg-5\": %.2f, "
614 "\"ldavg-15\": %.2f, "
618 (double) sqc->load_avg_1 / 100,
619 (double) sqc->load_avg_5 / 100,
620 (double) sqc->load_avg_15 / 100,
625 ***************************************************************************
626 * Display serial lines statistics in JSON.
629 * @a Activity structure with statistics.
630 * @curr Index in array for current sample statistics.
631 * @tab Indentation in output.
632 * @itv Interval of time in jiffies.
633 ***************************************************************************
635 __print_funct_t json_print_serial_stats(struct activity *a, int curr, int tab,
636 unsigned long long itv)
639 struct stats_serial *ssc, *ssp;
642 xprintf(tab++, "\"serial\": [");
644 for (i = 0; i < a->nr; i++) {
646 ssc = (struct stats_serial *) ((char *) a->buf[curr] + i * a->msize);
647 ssp = (struct stats_serial *) ((char *) a->buf[!curr] + i * a->msize);
652 if (ssc->line == ssp->line) {
659 xprintf0(tab, "{\"line\": %d, "
662 "\"framerr\": %.2f, "
663 "\"prtyerr\": %.2f, "
667 S_VALUE(ssp->rx, ssc->rx, itv),
668 S_VALUE(ssp->tx, ssc->tx, itv),
669 S_VALUE(ssp->frame, ssc->frame, itv),
670 S_VALUE(ssp->parity, ssc->parity, itv),
671 S_VALUE(ssp->brk, ssc->brk, itv),
672 S_VALUE(ssp->overrun, ssc->overrun, itv));
677 xprintf0(--tab, "]");
681 ***************************************************************************
682 * Display disks statistics in JSON.
685 * @a Activity structure with statistics.
686 * @curr Index in array for current sample statistics.
687 * @tab Indentation in output.
688 * @itv Interval of time in jiffies.
689 ***************************************************************************
691 __print_funct_t json_print_disk_stats(struct activity *a, int curr, int tab,
692 unsigned long long itv)
695 struct stats_disk *sdc, *sdp;
696 struct ext_disk_stats xds;
698 char *dev_name, *persist_dev_name;
700 xprintf(tab++, "\"disk\": [");
702 for (i = 0; i < a->nr; i++) {
704 sdc = (struct stats_disk *) ((char *) a->buf[curr] + i * a->msize);
706 if (!(sdc->major + sdc->minor))
709 j = check_disk_reg(a, curr, !curr, i);
710 sdp = (struct stats_disk *) ((char *) a->buf[!curr] + j * a->msize);
712 /* Compute extended statistics values */
713 compute_ext_disk_stats(sdc, sdp, itv, &xds);
716 persist_dev_name = NULL;
718 if (DISPLAY_PERSIST_NAME_S(flags)) {
719 persist_dev_name = get_persistent_name_from_pretty(get_devname(sdc->major, sdc->minor, TRUE));
722 if (persist_dev_name) {
723 dev_name = persist_dev_name;
726 if ((USE_PRETTY_OPTION(flags)) && (sdc->major == dm_major)) {
727 dev_name = transform_devmapname(sdc->major, sdc->minor);
731 dev_name = get_devname(sdc->major, sdc->minor,
732 USE_PRETTY_OPTION(flags));
741 xprintf0(tab, "{\"disk-device\": \"%s\", "
745 "\"avgrq-sz\": %.2f, "
746 "\"avgqu-sz\": %.2f, "
749 "\"util-percent\": %.2f}",
750 /* Confusion possible here between index and minor numbers */
752 S_VALUE(sdp->nr_ios, sdc->nr_ios, itv),
753 S_VALUE(sdp->rd_sect, sdc->rd_sect, itv),
754 S_VALUE(sdp->wr_sect, sdc->wr_sect, itv),
755 /* See iostat for explanations */
757 S_VALUE(sdp->rq_ticks, sdc->rq_ticks, itv) / 1000.0,
764 xprintf0(--tab, "]");
768 ***************************************************************************
769 * Display network interfaces statistics in JSON.
772 * @a Activity structure with statistics.
773 * @curr Index in array for current sample statistics.
774 * @tab Indentation in output.
775 * @itv Interval of time in jiffies.
776 ***************************************************************************
778 __print_funct_t json_print_net_dev_stats(struct activity *a, int curr, int tab,
779 unsigned long long itv)
782 struct stats_net_dev *sndc, *sndp;
784 double rxkb, txkb, ifutil;
786 if (!IS_SELECTED(a->options) || (a->nr <= 0))
787 goto close_json_markup;
789 json_markup_network(tab, OPEN_JSON_MARKUP);
792 xprintf(tab++, "\"net-dev\": [");
794 for (i = 0; i < a->nr; i++) {
796 sndc = (struct stats_net_dev *) ((char *) a->buf[curr] + i * a->msize);
798 if (!strcmp(sndc->interface, ""))
801 j = check_net_dev_reg(a, curr, !curr, i);
802 sndp = (struct stats_net_dev *) ((char *) a->buf[!curr] + j * a->msize);
809 rxkb = S_VALUE(sndp->rx_bytes, sndc->rx_bytes, itv);
810 txkb = S_VALUE(sndp->tx_bytes, sndc->tx_bytes, itv);
811 ifutil = compute_ifutil(sndc, rxkb, txkb);
813 xprintf0(tab, "{\"iface\": \"%s\", "
821 "\"ifutil-percent\": %.2f}",
823 S_VALUE(sndp->rx_packets, sndc->rx_packets, itv),
824 S_VALUE(sndp->tx_packets, sndc->tx_packets, itv),
827 S_VALUE(sndp->rx_compressed, sndc->rx_compressed, itv),
828 S_VALUE(sndp->tx_compressed, sndc->tx_compressed, itv),
829 S_VALUE(sndp->multicast, sndc->multicast, itv),
834 xprintf0(--tab, "]");
839 if (CLOSE_MARKUP(a->options)) {
840 json_markup_network(tab, CLOSE_JSON_MARKUP);
845 ***************************************************************************
846 * Display network interfaces errors statistics in JSON.
849 * @a Activity structure with statistics.
850 * @curr Index in array for current sample statistics.
851 * @tab Indentation in output.
852 * @itv Interval of time in jiffies.
853 ***************************************************************************
855 __print_funct_t json_print_net_edev_stats(struct activity *a, int curr, int tab,
856 unsigned long long itv)
859 struct stats_net_edev *snedc, *snedp;
862 if (!IS_SELECTED(a->options) || (a->nr <= 0))
863 goto close_json_markup;
865 json_markup_network(tab, OPEN_JSON_MARKUP);
868 xprintf(tab++, "\"net-edev\": [");
870 for (i = 0; i < a->nr; i++) {
872 snedc = (struct stats_net_edev *) ((char *) a->buf[curr] + i * a->msize);
874 if (!strcmp(snedc->interface, ""))
877 j = check_net_edev_reg(a, curr, !curr, i);
878 snedp = (struct stats_net_edev *) ((char *) a->buf[!curr] + j * a->msize);
885 xprintf0(tab, "{\"iface\": \"%s\", "
896 S_VALUE(snedp->rx_errors, snedc->rx_errors, itv),
897 S_VALUE(snedp->tx_errors, snedc->tx_errors, itv),
898 S_VALUE(snedp->collisions, snedc->collisions, itv),
899 S_VALUE(snedp->rx_dropped, snedc->rx_dropped, itv),
900 S_VALUE(snedp->tx_dropped, snedc->tx_dropped, itv),
901 S_VALUE(snedp->tx_carrier_errors, snedc->tx_carrier_errors, itv),
902 S_VALUE(snedp->rx_frame_errors, snedc->rx_frame_errors, itv),
903 S_VALUE(snedp->rx_fifo_errors, snedc->rx_fifo_errors, itv),
904 S_VALUE(snedp->tx_fifo_errors, snedc->tx_fifo_errors, itv));
908 xprintf0(--tab, "]");
913 if (CLOSE_MARKUP(a->options)) {
914 json_markup_network(tab, CLOSE_JSON_MARKUP);
919 ***************************************************************************
920 * Display NFS client statistics in JSON.
923 * @a Activity structure with statistics.
924 * @curr Index in array for current sample statistics.
925 * @tab Indentation in output.
926 * @itv Interval of time in jiffies.
927 ***************************************************************************
929 __print_funct_t json_print_net_nfs_stats(struct activity *a, int curr, int tab,
930 unsigned long long itv)
933 *snnc = (struct stats_net_nfs *) a->buf[curr],
934 *snnp = (struct stats_net_nfs *) a->buf[!curr];
936 if (!IS_SELECTED(a->options) || (a->nr <= 0))
937 goto close_json_markup;
939 json_markup_network(tab, OPEN_JSON_MARKUP);
942 xprintf0(tab, "\"net-nfs\": {"
944 "\"retrans\": %.2f, "
949 S_VALUE(snnp->nfs_rpccnt, snnc->nfs_rpccnt, itv),
950 S_VALUE(snnp->nfs_rpcretrans, snnc->nfs_rpcretrans, itv),
951 S_VALUE(snnp->nfs_readcnt, snnc->nfs_readcnt, itv),
952 S_VALUE(snnp->nfs_writecnt, snnc->nfs_writecnt, itv),
953 S_VALUE(snnp->nfs_accesscnt, snnc->nfs_accesscnt, itv),
954 S_VALUE(snnp->nfs_getattcnt, snnc->nfs_getattcnt, itv));
958 if (CLOSE_MARKUP(a->options)) {
959 json_markup_network(tab, CLOSE_JSON_MARKUP);
964 ***************************************************************************
965 * Display NFS server statistics in JSON.
968 * @a Activity structure with statistics.
969 * @curr Index in array for current sample statistics.
970 * @tab Indentation in output.
971 * @itv Interval of time in jiffies.
972 ***************************************************************************
974 __print_funct_t json_print_net_nfsd_stats(struct activity *a, int curr, int tab,
975 unsigned long long itv)
977 struct stats_net_nfsd
978 *snndc = (struct stats_net_nfsd *) a->buf[curr],
979 *snndp = (struct stats_net_nfsd *) a->buf[!curr];
981 if (!IS_SELECTED(a->options) || (a->nr <= 0))
982 goto close_json_markup;
984 json_markup_network(tab, OPEN_JSON_MARKUP);
987 xprintf0(tab, "\"net-nfsd\": {"
989 "\"badcall\": %.2f, "
997 "\"saccess\": %.2f, "
998 "\"sgetatt\": %.2f}",
999 S_VALUE(snndp->nfsd_rpccnt, snndc->nfsd_rpccnt, itv),
1000 S_VALUE(snndp->nfsd_rpcbad, snndc->nfsd_rpcbad, itv),
1001 S_VALUE(snndp->nfsd_netcnt, snndc->nfsd_netcnt, itv),
1002 S_VALUE(snndp->nfsd_netudpcnt, snndc->nfsd_netudpcnt, itv),
1003 S_VALUE(snndp->nfsd_nettcpcnt, snndc->nfsd_nettcpcnt, itv),
1004 S_VALUE(snndp->nfsd_rchits, snndc->nfsd_rchits, itv),
1005 S_VALUE(snndp->nfsd_rcmisses, snndc->nfsd_rcmisses, itv),
1006 S_VALUE(snndp->nfsd_readcnt, snndc->nfsd_readcnt, itv),
1007 S_VALUE(snndp->nfsd_writecnt, snndc->nfsd_writecnt, itv),
1008 S_VALUE(snndp->nfsd_accesscnt, snndc->nfsd_accesscnt, itv),
1009 S_VALUE(snndp->nfsd_getattcnt, snndc->nfsd_getattcnt, itv));
1013 if (CLOSE_MARKUP(a->options)) {
1014 json_markup_network(tab, CLOSE_JSON_MARKUP);
1019 ***************************************************************************
1020 * Display network socket statistics in JSON.
1023 * @a Activity structure with statistics.
1024 * @curr Index in array for current sample statistics.
1025 * @tab Indentation in output.
1026 * @itv Interval of time in jiffies.
1027 ***************************************************************************
1029 __print_funct_t json_print_net_sock_stats(struct activity *a, int curr, int tab,
1030 unsigned long long itv)
1032 struct stats_net_sock
1033 *snsc = (struct stats_net_sock *) a->buf[curr];
1035 if (!IS_SELECTED(a->options) || (a->nr <= 0))
1036 goto close_json_markup;
1038 json_markup_network(tab, OPEN_JSON_MARKUP);
1041 xprintf0(tab, "\"net-sock\": {"
1057 if (CLOSE_MARKUP(a->options)) {
1058 json_markup_network(tab, CLOSE_JSON_MARKUP);
1063 ***************************************************************************
1064 * Display IP network statistics in JSON.
1067 * @a Activity structure with statistics.
1068 * @curr Index in array for current sample statistics.
1069 * @tab Indentation in output.
1070 * @itv Interval of time in jiffies.
1071 ***************************************************************************
1073 __print_funct_t json_print_net_ip_stats(struct activity *a, int curr, int tab,
1074 unsigned long long itv)
1077 *snic = (struct stats_net_ip *) a->buf[curr],
1078 *snip = (struct stats_net_ip *) a->buf[!curr];
1080 if (!IS_SELECTED(a->options) || (a->nr <= 0))
1081 goto close_json_markup;
1083 json_markup_network(tab, OPEN_JSON_MARKUP);
1086 xprintf0(tab, "\"net-ip\": {"
1088 "\"fwddgm\": %.2f, "
1093 "\"fragok\": %.2f, "
1094 "\"fragcrt\": %.2f}",
1095 S_VALUE(snip->InReceives, snic->InReceives, itv),
1096 S_VALUE(snip->ForwDatagrams, snic->ForwDatagrams, itv),
1097 S_VALUE(snip->InDelivers, snic->InDelivers, itv),
1098 S_VALUE(snip->OutRequests, snic->OutRequests, itv),
1099 S_VALUE(snip->ReasmReqds, snic->ReasmReqds, itv),
1100 S_VALUE(snip->ReasmOKs, snic->ReasmOKs, itv),
1101 S_VALUE(snip->FragOKs, snic->FragOKs, itv),
1102 S_VALUE(snip->FragCreates, snic->FragCreates, itv));
1106 if (CLOSE_MARKUP(a->options)) {
1107 json_markup_network(tab, CLOSE_JSON_MARKUP);
1112 ***************************************************************************
1113 * Display IP network errors statistics in JSON.
1116 * @a Activity structure with statistics.
1117 * @curr Index in array for current sample statistics.
1118 * @tab Indentation in output.
1119 * @itv Interval of time in jiffies.
1120 ***************************************************************************
1122 __print_funct_t json_print_net_eip_stats(struct activity *a, int curr, int tab,
1123 unsigned long long itv)
1125 struct stats_net_eip
1126 *sneic = (struct stats_net_eip *) a->buf[curr],
1127 *sneip = (struct stats_net_eip *) a->buf[!curr];
1129 if (!IS_SELECTED(a->options) || (a->nr <= 0))
1130 goto close_json_markup;
1132 json_markup_network(tab, OPEN_JSON_MARKUP);
1135 xprintf0(tab, "\"net-eip\": {"
1136 "\"ihdrerr\": %.2f, "
1137 "\"iadrerr\": %.2f, "
1138 "\"iukwnpr\": %.2f, "
1144 S_VALUE(sneip->InHdrErrors, sneic->InHdrErrors, itv),
1145 S_VALUE(sneip->InAddrErrors, sneic->InAddrErrors, itv),
1146 S_VALUE(sneip->InUnknownProtos, sneic->InUnknownProtos, itv),
1147 S_VALUE(sneip->InDiscards, sneic->InDiscards, itv),
1148 S_VALUE(sneip->OutDiscards, sneic->OutDiscards, itv),
1149 S_VALUE(sneip->OutNoRoutes, sneic->OutNoRoutes, itv),
1150 S_VALUE(sneip->ReasmFails, sneic->ReasmFails, itv),
1151 S_VALUE(sneip->FragFails, sneic->FragFails, itv));
1155 if (CLOSE_MARKUP(a->options)) {
1156 json_markup_network(tab, CLOSE_JSON_MARKUP);
1161 ***************************************************************************
1162 * Display ICMP network statistics in JSON.
1165 * @a Activity structure with statistics.
1166 * @curr Index in array for current sample statistics.
1167 * @tab Indentation in output.
1168 * @itv Interval of time in jiffies.
1169 ***************************************************************************
1171 __print_funct_t json_print_net_icmp_stats(struct activity *a, int curr, int tab,
1172 unsigned long long itv)
1174 struct stats_net_icmp
1175 *snic = (struct stats_net_icmp *) a->buf[curr],
1176 *snip = (struct stats_net_icmp *) a->buf[!curr];
1178 if (!IS_SELECTED(a->options) || (a->nr <= 0))
1179 goto close_json_markup;
1181 json_markup_network(tab, OPEN_JSON_MARKUP);
1184 xprintf0(tab, "\"net-icmp\": {"
1195 "\"iadrmk\": %.2f, "
1196 "\"iadrmkr\": %.2f, "
1197 "\"oadrmk\": %.2f, "
1198 "\"oadrmkr\": %.2f}",
1199 S_VALUE(snip->InMsgs, snic->InMsgs, itv),
1200 S_VALUE(snip->OutMsgs, snic->OutMsgs, itv),
1201 S_VALUE(snip->InEchos, snic->InEchos, itv),
1202 S_VALUE(snip->InEchoReps, snic->InEchoReps, itv),
1203 S_VALUE(snip->OutEchos, snic->OutEchos, itv),
1204 S_VALUE(snip->OutEchoReps, snic->OutEchoReps, itv),
1205 S_VALUE(snip->InTimestamps, snic->InTimestamps, itv),
1206 S_VALUE(snip->InTimestampReps, snic->InTimestampReps, itv),
1207 S_VALUE(snip->OutTimestamps, snic->OutTimestamps, itv),
1208 S_VALUE(snip->OutTimestampReps, snic->OutTimestampReps, itv),
1209 S_VALUE(snip->InAddrMasks, snic->InAddrMasks, itv),
1210 S_VALUE(snip->InAddrMaskReps, snic->InAddrMaskReps, itv),
1211 S_VALUE(snip->OutAddrMasks, snic->OutAddrMasks, itv),
1212 S_VALUE(snip->OutAddrMaskReps, snic->OutAddrMaskReps, itv));
1216 if (CLOSE_MARKUP(a->options)) {
1217 json_markup_network(tab, CLOSE_JSON_MARKUP);
1222 ***************************************************************************
1223 * Display ICMP errors message statistics in JSON.
1226 * @a Activity structure with statistics.
1227 * @curr Index in array for current sample statistics.
1228 * @tab Indentation in output.
1229 * @itv Interval of time in jiffies.
1230 ***************************************************************************
1232 __print_funct_t json_print_net_eicmp_stats(struct activity *a, int curr, int tab,
1233 unsigned long long itv)
1235 struct stats_net_eicmp
1236 *sneic = (struct stats_net_eicmp *) a->buf[curr],
1237 *sneip = (struct stats_net_eicmp *) a->buf[!curr];
1239 if (!IS_SELECTED(a->options) || (a->nr <= 0))
1240 goto close_json_markup;
1242 json_markup_network(tab, OPEN_JSON_MARKUP);
1245 xprintf0(tab, "\"net-eicmp\": {"
1248 "\"idstunr\": %.2f, "
1249 "\"odstunr\": %.2f, "
1252 "\"iparmpb\": %.2f, "
1253 "\"oparmpb\": %.2f, "
1256 "\"iredir\": %.2f, "
1257 "\"oredir\": %.2f}",
1258 S_VALUE(sneip->InErrors, sneic->InErrors, itv),
1259 S_VALUE(sneip->OutErrors, sneic->OutErrors, itv),
1260 S_VALUE(sneip->InDestUnreachs, sneic->InDestUnreachs, itv),
1261 S_VALUE(sneip->OutDestUnreachs, sneic->OutDestUnreachs, itv),
1262 S_VALUE(sneip->InTimeExcds, sneic->InTimeExcds, itv),
1263 S_VALUE(sneip->OutTimeExcds, sneic->OutTimeExcds, itv),
1264 S_VALUE(sneip->InParmProbs, sneic->InParmProbs, itv),
1265 S_VALUE(sneip->OutParmProbs, sneic->OutParmProbs, itv),
1266 S_VALUE(sneip->InSrcQuenchs, sneic->InSrcQuenchs, itv),
1267 S_VALUE(sneip->OutSrcQuenchs, sneic->OutSrcQuenchs, itv),
1268 S_VALUE(sneip->InRedirects, sneic->InRedirects, itv),
1269 S_VALUE(sneip->OutRedirects, sneic->OutRedirects, itv));
1273 if (CLOSE_MARKUP(a->options)) {
1274 json_markup_network(tab, CLOSE_JSON_MARKUP);
1279 ***************************************************************************
1280 * Display TCP network statistics in JSON.
1283 * @a Activity structure with statistics.
1284 * @curr Index in array for current sample statistics.
1285 * @tab Indentation in output.
1286 * @itv Interval of time in jiffies.
1287 ***************************************************************************
1289 __print_funct_t json_print_net_tcp_stats(struct activity *a, int curr, int tab,
1290 unsigned long long itv)
1292 struct stats_net_tcp
1293 *sntc = (struct stats_net_tcp *) a->buf[curr],
1294 *sntp = (struct stats_net_tcp *) a->buf[!curr];
1296 if (!IS_SELECTED(a->options) || (a->nr <= 0))
1297 goto close_json_markup;
1299 json_markup_network(tab, OPEN_JSON_MARKUP);
1302 xprintf0(tab, "\"net-tcp\": {"
1303 "\"active\": %.2f, "
1304 "\"passive\": %.2f, "
1307 S_VALUE(sntp->ActiveOpens, sntc->ActiveOpens, itv),
1308 S_VALUE(sntp->PassiveOpens, sntc->PassiveOpens, itv),
1309 S_VALUE(sntp->InSegs, sntc->InSegs, itv),
1310 S_VALUE(sntp->OutSegs, sntc->OutSegs, itv));
1314 if (CLOSE_MARKUP(a->options)) {
1315 json_markup_network(tab, CLOSE_JSON_MARKUP);
1320 ***************************************************************************
1321 * Display TCP network errors statistics in JSON.
1324 * @a Activity structure with statistics.
1325 * @curr Index in array for current sample statistics.
1326 * @tab Indentation in XML output.
1327 * @itv Interval of time in jiffies.
1328 ***************************************************************************
1330 __print_funct_t json_print_net_etcp_stats(struct activity *a, int curr, int tab,
1331 unsigned long long itv)
1333 struct stats_net_etcp
1334 *snetc = (struct stats_net_etcp *) a->buf[curr],
1335 *snetp = (struct stats_net_etcp *) a->buf[!curr];
1337 if (!IS_SELECTED(a->options) || (a->nr <= 0))
1338 goto close_json_markup;
1340 json_markup_network(tab, OPEN_JSON_MARKUP);
1343 xprintf0(tab, "\"net-etcp\": {"
1344 "\"atmptf\": %.2f, "
1345 "\"estres\": %.2f, "
1346 "\"retrans\": %.2f, "
1347 "\"isegerr\": %.2f, "
1349 S_VALUE(snetp->AttemptFails, snetc->AttemptFails, itv),
1350 S_VALUE(snetp->EstabResets, snetc->EstabResets, itv),
1351 S_VALUE(snetp->RetransSegs, snetc->RetransSegs, itv),
1352 S_VALUE(snetp->InErrs, snetc->InErrs, itv),
1353 S_VALUE(snetp->OutRsts, snetc->OutRsts, itv));
1357 if (CLOSE_MARKUP(a->options)) {
1358 json_markup_network(tab, CLOSE_JSON_MARKUP);
1363 ***************************************************************************
1364 * Display UDP network statistics in JSON.
1367 * @a Activity structure with statistics.
1368 * @curr Index in array for current sample statistics.
1369 * @tab Indentation in output.
1370 * @itv Interval of time in jiffies.
1371 ***************************************************************************
1373 __print_funct_t json_print_net_udp_stats(struct activity *a, int curr, int tab,
1374 unsigned long long itv)
1376 struct stats_net_udp
1377 *snuc = (struct stats_net_udp *) a->buf[curr],
1378 *snup = (struct stats_net_udp *) a->buf[!curr];
1380 if (!IS_SELECTED(a->options) || (a->nr <= 0))
1381 goto close_json_markup;
1383 json_markup_network(tab, OPEN_JSON_MARKUP);
1386 xprintf0(tab, "\"net-udp\": {"
1389 "\"noport\": %.2f, "
1390 "\"idgmerr\": %.2f}",
1391 S_VALUE(snup->InDatagrams, snuc->InDatagrams, itv),
1392 S_VALUE(snup->OutDatagrams, snuc->OutDatagrams, itv),
1393 S_VALUE(snup->NoPorts, snuc->NoPorts, itv),
1394 S_VALUE(snup->InErrors, snuc->InErrors, itv));
1398 if (CLOSE_MARKUP(a->options)) {
1399 json_markup_network(tab, CLOSE_JSON_MARKUP);
1404 ***************************************************************************
1405 * Display IPv6 network socket statistics in JSON.
1408 * @a Activity structure with statistics.
1409 * @curr Index in array for current sample statistics.
1410 * @tab Indentation in output.
1411 * @itv Interval of time in jiffies.
1412 ***************************************************************************
1414 __print_funct_t json_print_net_sock6_stats(struct activity *a, int curr, int tab,
1415 unsigned long long itv)
1417 struct stats_net_sock6
1418 *snsc = (struct stats_net_sock6 *) a->buf[curr];
1420 if (!IS_SELECTED(a->options) || (a->nr <= 0))
1421 goto close_json_markup;
1423 json_markup_network(tab, OPEN_JSON_MARKUP);
1426 xprintf0(tab, "\"net-sock6\": {"
1430 "\"ip6-frag\": %u}",
1438 if (CLOSE_MARKUP(a->options)) {
1439 json_markup_network(tab, CLOSE_JSON_MARKUP);
1444 ***************************************************************************
1445 * Display IPv6 network statistics in JSON.
1448 * @a Activity structure with statistics.
1449 * @curr Index in array for current sample statistics.
1450 * @tab Indentation in output.
1451 * @itv Interval of time in jiffies.
1452 ***************************************************************************
1454 __print_funct_t json_print_net_ip6_stats(struct activity *a, int curr, int tab,
1455 unsigned long long itv)
1457 struct stats_net_ip6
1458 *snic = (struct stats_net_ip6 *) a->buf[curr],
1459 *snip = (struct stats_net_ip6 *) a->buf[!curr];
1461 if (!IS_SELECTED(a->options) || (a->nr <= 0))
1462 goto close_json_markup;
1464 json_markup_network(tab, OPEN_JSON_MARKUP);
1467 xprintf0(tab, "\"net-ip6\": {"
1469 "\"fwddgm6\": %.2f, "
1472 "\"asmrq6\": %.2f, "
1473 "\"asmok6\": %.2f, "
1474 "\"imcpck6\": %.2f, "
1475 "\"omcpck6\": %.2f, "
1476 "\"fragok6\": %.2f, "
1477 "\"fragcr6\": %.2f}",
1478 S_VALUE(snip->InReceives6, snic->InReceives6, itv),
1479 S_VALUE(snip->OutForwDatagrams6, snic->OutForwDatagrams6, itv),
1480 S_VALUE(snip->InDelivers6, snic->InDelivers6, itv),
1481 S_VALUE(snip->OutRequests6, snic->OutRequests6, itv),
1482 S_VALUE(snip->ReasmReqds6, snic->ReasmReqds6, itv),
1483 S_VALUE(snip->ReasmOKs6, snic->ReasmOKs6, itv),
1484 S_VALUE(snip->InMcastPkts6, snic->InMcastPkts6, itv),
1485 S_VALUE(snip->OutMcastPkts6, snic->OutMcastPkts6, itv),
1486 S_VALUE(snip->FragOKs6, snic->FragOKs6, itv),
1487 S_VALUE(snip->FragCreates6, snic->FragCreates6, itv));
1491 if (CLOSE_MARKUP(a->options)) {
1492 json_markup_network(tab, CLOSE_JSON_MARKUP);
1497 ***************************************************************************
1498 * Display IPv6 network errors statistics in JSON.
1501 * @a Activity structure with statistics.
1502 * @curr Index in array for current sample statistics.
1503 * @tab Indentation in output.
1504 * @itv Interval of time in jiffies.
1505 ***************************************************************************
1507 __print_funct_t json_print_net_eip6_stats(struct activity *a, int curr, int tab,
1508 unsigned long long itv)
1510 struct stats_net_eip6
1511 *sneic = (struct stats_net_eip6 *) a->buf[curr],
1512 *sneip = (struct stats_net_eip6 *) a->buf[!curr];
1514 if (!IS_SELECTED(a->options) || (a->nr <= 0))
1515 goto close_json_markup;
1517 json_markup_network(tab, OPEN_JSON_MARKUP);
1520 xprintf0(tab, "\"net-eip6\": {"
1521 "\"ihdrer6\": %.2f, "
1522 "\"iadrer6\": %.2f, "
1523 "\"iukwnp6\": %.2f, "
1524 "\"i2big6\": %.2f, "
1525 "\"idisc6\": %.2f, "
1526 "\"odisc6\": %.2f, "
1527 "\"inort6\": %.2f, "
1528 "\"onort6\": %.2f, "
1530 "\"fragf6\": %.2f, "
1531 "\"itrpck6\": %.2f}",
1532 S_VALUE(sneip->InHdrErrors6, sneic->InHdrErrors6, itv),
1533 S_VALUE(sneip->InAddrErrors6, sneic->InAddrErrors6, itv),
1534 S_VALUE(sneip->InUnknownProtos6, sneic->InUnknownProtos6, itv),
1535 S_VALUE(sneip->InTooBigErrors6, sneic->InTooBigErrors6, itv),
1536 S_VALUE(sneip->InDiscards6, sneic->InDiscards6, itv),
1537 S_VALUE(sneip->OutDiscards6, sneic->OutDiscards6, itv),
1538 S_VALUE(sneip->InNoRoutes6, sneic->InNoRoutes6, itv),
1539 S_VALUE(sneip->OutNoRoutes6, sneic->OutNoRoutes6, itv),
1540 S_VALUE(sneip->ReasmFails6, sneic->ReasmFails6, itv),
1541 S_VALUE(sneip->FragFails6, sneic->FragFails6, itv),
1542 S_VALUE(sneip->InTruncatedPkts6, sneic->InTruncatedPkts6, itv));
1546 if (CLOSE_MARKUP(a->options)) {
1547 json_markup_network(tab, CLOSE_JSON_MARKUP);
1552 ***************************************************************************
1553 * Display ICMPv6 network statistics in JSON.
1556 * @a Activity structure with statistics.
1557 * @curr Index in array for current sample statistics.
1558 * @tab Indentation in output.
1559 * @itv Interval of time in jiffies.
1560 ***************************************************************************
1562 __print_funct_t json_print_net_icmp6_stats(struct activity *a, int curr, int tab,
1563 unsigned long long itv)
1565 struct stats_net_icmp6
1566 *snic = (struct stats_net_icmp6 *) a->buf[curr],
1567 *snip = (struct stats_net_icmp6 *) a->buf[!curr];
1569 if (!IS_SELECTED(a->options) || (a->nr <= 0))
1570 goto close_json_markup;
1572 json_markup_network(tab, OPEN_JSON_MARKUP);
1575 xprintf0(tab, "\"net-icmp6\": {"
1579 "\"iechr6\": %.2f, "
1580 "\"oechr6\": %.2f, "
1581 "\"igmbq6\": %.2f, "
1582 "\"igmbr6\": %.2f, "
1583 "\"ogmbr6\": %.2f, "
1584 "\"igmbrd6\": %.2f, "
1585 "\"ogmbrd6\": %.2f, "
1586 "\"irtsol6\": %.2f, "
1587 "\"ortsol6\": %.2f, "
1588 "\"irtad6\": %.2f, "
1589 "\"inbsol6\": %.2f, "
1590 "\"onbsol6\": %.2f, "
1591 "\"inbad6\": %.2f, "
1592 "\"onbad6\": %.2f}",
1593 S_VALUE(snip->InMsgs6, snic->InMsgs6, itv),
1594 S_VALUE(snip->OutMsgs6, snic->OutMsgs6, itv),
1595 S_VALUE(snip->InEchos6, snic->InEchos6, itv),
1596 S_VALUE(snip->InEchoReplies6, snic->InEchoReplies6, itv),
1597 S_VALUE(snip->OutEchoReplies6, snic->OutEchoReplies6, itv),
1598 S_VALUE(snip->InGroupMembQueries6, snic->InGroupMembQueries6, itv),
1599 S_VALUE(snip->InGroupMembResponses6, snic->InGroupMembResponses6, itv),
1600 S_VALUE(snip->OutGroupMembResponses6, snic->OutGroupMembResponses6, itv),
1601 S_VALUE(snip->InGroupMembReductions6, snic->InGroupMembReductions6, itv),
1602 S_VALUE(snip->OutGroupMembReductions6, snic->OutGroupMembReductions6, itv),
1603 S_VALUE(snip->InRouterSolicits6, snic->InRouterSolicits6, itv),
1604 S_VALUE(snip->OutRouterSolicits6, snic->OutRouterSolicits6, itv),
1605 S_VALUE(snip->InRouterAdvertisements6, snic->InRouterAdvertisements6, itv),
1606 S_VALUE(snip->InNeighborSolicits6, snic->InNeighborSolicits6, itv),
1607 S_VALUE(snip->OutNeighborSolicits6, snic->OutNeighborSolicits6, itv),
1608 S_VALUE(snip->InNeighborAdvertisements6, snic->InNeighborAdvertisements6, itv),
1609 S_VALUE(snip->OutNeighborAdvertisements6, snic->OutNeighborAdvertisements6, itv));
1613 if (CLOSE_MARKUP(a->options)) {
1614 json_markup_network(tab, CLOSE_JSON_MARKUP);
1619 ***************************************************************************
1620 * Display ICMPv6 error messages statistics in JSON.
1623 * @a Activity structure with statistics.
1624 * @curr Index in array for current sample statistics.
1625 * @tab Indentation in output.
1626 * @itv Interval of time in jiffies.
1627 ***************************************************************************
1629 __print_funct_t json_print_net_eicmp6_stats(struct activity *a, int curr, int tab,
1630 unsigned long long itv)
1632 struct stats_net_eicmp6
1633 *sneic = (struct stats_net_eicmp6 *) a->buf[curr],
1634 *sneip = (struct stats_net_eicmp6 *) a->buf[!curr];
1636 if (!IS_SELECTED(a->options) || (a->nr <= 0))
1637 goto close_json_markup;
1639 json_markup_network(tab, OPEN_JSON_MARKUP);
1642 xprintf0(tab, "\"net-eicmp6\": {"
1644 "\"idtunr6\": %.2f, "
1645 "\"odtunr6\": %.2f, "
1646 "\"itmex6\": %.2f, "
1647 "\"otmex6\": %.2f, "
1648 "\"iprmpb6\": %.2f, "
1649 "\"oprmpb6\": %.2f, "
1650 "\"iredir6\": %.2f, "
1651 "\"oredir6\": %.2f, "
1652 "\"ipck2b6\": %.2f, "
1653 "\"opck2b6\": %.2f}",
1654 S_VALUE(sneip->InErrors6, sneic->InErrors6, itv),
1655 S_VALUE(sneip->InDestUnreachs6, sneic->InDestUnreachs6, itv),
1656 S_VALUE(sneip->OutDestUnreachs6, sneic->OutDestUnreachs6, itv),
1657 S_VALUE(sneip->InTimeExcds6, sneic->InTimeExcds6, itv),
1658 S_VALUE(sneip->OutTimeExcds6, sneic->OutTimeExcds6, itv),
1659 S_VALUE(sneip->InParmProblems6, sneic->InParmProblems6, itv),
1660 S_VALUE(sneip->OutParmProblems6, sneic->OutParmProblems6, itv),
1661 S_VALUE(sneip->InRedirects6, sneic->InRedirects6, itv),
1662 S_VALUE(sneip->OutRedirects6, sneic->OutRedirects6, itv),
1663 S_VALUE(sneip->InPktTooBigs6, sneic->InPktTooBigs6, itv),
1664 S_VALUE(sneip->OutPktTooBigs6, sneic->OutPktTooBigs6, itv));
1668 if (CLOSE_MARKUP(a->options)) {
1669 json_markup_network(tab, CLOSE_JSON_MARKUP);
1674 ***************************************************************************
1675 * Display UDPv6 network statistics in JSON.
1678 * @a Activity structure with statistics.
1679 * @curr Index in array for current sample statistics.
1680 * @tab Indentation in output.
1681 * @itv Interval of time in jiffies.
1682 ***************************************************************************
1684 __print_funct_t json_print_net_udp6_stats(struct activity *a, int curr, int tab,
1685 unsigned long long itv)
1687 struct stats_net_udp6
1688 *snuc = (struct stats_net_udp6 *) a->buf[curr],
1689 *snup = (struct stats_net_udp6 *) a->buf[!curr];
1691 if (!IS_SELECTED(a->options) || (a->nr <= 0))
1692 goto close_json_markup;
1694 json_markup_network(tab, OPEN_JSON_MARKUP);
1697 xprintf0(tab, "\"net-udp6\": {"
1700 "\"noport6\": %.2f, "
1701 "\"idgmer6\": %.2f}",
1702 S_VALUE(snup->InDatagrams6, snuc->InDatagrams6, itv),
1703 S_VALUE(snup->OutDatagrams6, snuc->OutDatagrams6, itv),
1704 S_VALUE(snup->NoPorts6, snuc->NoPorts6, itv),
1705 S_VALUE(snup->InErrors6, snuc->InErrors6, itv));
1709 if (CLOSE_MARKUP(a->options)) {
1710 json_markup_network(tab, CLOSE_JSON_MARKUP);
1715 ***************************************************************************
1716 * Display CPU frequency statistics in JSON.
1719 * @a Activity structure with statistics.
1720 * @curr Index in array for current sample statistics.
1721 * @tab Indentation in output.
1722 * @itv Interval of time in jiffies.
1723 ***************************************************************************
1725 __print_funct_t json_print_pwr_cpufreq_stats(struct activity *a, int curr, int tab,
1726 unsigned long long itv)
1729 struct stats_pwr_cpufreq *spc;
1733 if (!IS_SELECTED(a->options) || (a->nr <= 0))
1734 goto close_json_markup;
1736 json_markup_power_management(tab, OPEN_JSON_MARKUP);
1739 xprintf(tab++, "\"cpu-frequency\": [");
1741 for (i = 0; (i < a->nr) && (i < a->bitmap->b_size + 1); i++) {
1743 spc = (struct stats_pwr_cpufreq *) ((char *) a->buf[curr] + i * a->msize);
1745 /* Should current CPU (including CPU "all") be displayed? */
1746 if (a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))) {
1748 /* Yes: Display it */
1750 /* This is CPU "all" */
1751 strcpy(cpuno, "all");
1754 sprintf(cpuno, "%d", i - 1);
1762 xprintf0(tab, "{\"number\": \"%s\", "
1763 "\"frequency\": %.2f}",
1765 ((double) spc->cpufreq) / 100);
1770 xprintf0(--tab, "]");
1774 if (CLOSE_MARKUP(a->options)) {
1775 json_markup_power_management(tab, CLOSE_JSON_MARKUP);
1780 ***************************************************************************
1781 * Display fan statistics in JSON.
1784 * @a Activity structure with statistics.
1785 * @curr Index in array for current sample statistics.
1786 * @tab Indentation in output.
1787 * @itv Interval of time in jiffies.
1788 ***************************************************************************
1790 __print_funct_t json_print_pwr_fan_stats(struct activity *a, int curr, int tab,
1791 unsigned long long itv)
1794 struct stats_pwr_fan *spc;
1797 if (!IS_SELECTED(a->options) || (a->nr <= 0))
1798 goto close_json_markup;
1800 json_markup_power_management(tab, OPEN_JSON_MARKUP);
1803 xprintf(tab++, "\"fan-speed\": [");
1805 for (i = 0; i < a->nr; i++) {
1806 spc = (struct stats_pwr_fan *) ((char *) a->buf[curr] + i * a->msize);
1813 xprintf0(tab, "{\"number\": %d, "
1816 "\"device\": \"%s\"}",
1818 (unsigned long long) spc->rpm,
1819 (unsigned long long) (spc->rpm - spc->rpm_min),
1824 xprintf0(--tab, "]");
1828 if (CLOSE_MARKUP(a->options)) {
1829 json_markup_power_management(tab, CLOSE_JSON_MARKUP);
1834 ***************************************************************************
1835 * Display temperature statistics in JSON.
1838 * @a Activity structure with statistics.
1839 * @curr Index in array for current sample statistics.
1840 * @tab Indentation in output.
1841 * @itv Interval of time in jiffies.
1842 ***************************************************************************
1844 __print_funct_t json_print_pwr_temp_stats(struct activity *a, int curr, int tab,
1845 unsigned long long itv)
1848 struct stats_pwr_temp *spc;
1851 if (!IS_SELECTED(a->options) || (a->nr <= 0))
1852 goto close_json_markup;
1854 json_markup_power_management(tab, OPEN_JSON_MARKUP);
1857 xprintf(tab++, "\"temperature\": [");
1859 for (i = 0; i < a->nr; i++) {
1860 spc = (struct stats_pwr_temp *) ((char *) a->buf[curr] + i * a->msize);
1867 xprintf0(tab, "{\"number\": %d, "
1869 "\"percent-temp\": %.2f, "
1870 "\"device\": \"%s\"}",
1873 (spc->temp_max - spc->temp_min) ?
1874 (spc->temp - spc->temp_min) / (spc->temp_max - spc->temp_min) * 100 :
1880 xprintf0(--tab, "]");
1884 if (CLOSE_MARKUP(a->options)) {
1885 json_markup_power_management(tab, CLOSE_JSON_MARKUP);
1890 ***************************************************************************
1891 * Display voltage inputs statistics in JSON.
1894 * @a Activity structure with statistics.
1895 * @curr Index in array for current sample statistics.
1896 * @tab Indentation in output.
1897 * @itv Interval of time in jiffies.
1898 ***************************************************************************
1900 __print_funct_t json_print_pwr_in_stats(struct activity *a, int curr, int tab,
1901 unsigned long long itv)
1904 struct stats_pwr_in *spc;
1907 if (!IS_SELECTED(a->options) || (a->nr <= 0))
1908 goto close_json_markup;
1910 json_markup_power_management(tab, OPEN_JSON_MARKUP);
1913 xprintf(tab++, "\"voltage-input\": [");
1915 for (i = 0; i < a->nr; i++) {
1916 spc = (struct stats_pwr_in *) ((char *) a->buf[curr] + i * a->msize);
1923 xprintf0(tab, "{\"number\": %d, "
1925 "\"percent-in\": %.2f, "
1926 "\"device\": \"%s\"}",
1929 (spc->in_max - spc->in_min) ?
1930 (spc->in - spc->in_min) / (spc->in_max - spc->in_min) * 100 :
1936 xprintf0(--tab, "]");
1940 if (CLOSE_MARKUP(a->options)) {
1941 json_markup_power_management(tab, CLOSE_JSON_MARKUP);
1946 ***************************************************************************
1947 * Display huge pages statistics in JSON.
1950 * @a Activity structure with statistics.
1951 * @curr Index in array for current sample statistics.
1952 * @tab Indentation in output.
1953 * @itv Interval of time in jiffies.
1954 ***************************************************************************
1956 __print_funct_t json_print_huge_stats(struct activity *a, int curr, int tab,
1957 unsigned long long itv)
1960 *smc = (struct stats_huge *) a->buf[curr];
1962 xprintf0(tab, "\"hugepages\": {"
1963 "\"hugfree\": %lu, "
1964 "\"hugused\": %lu, "
1965 "\"hugused-percent\": %.2f}",
1967 smc->tlhkb - smc->frhkb,
1969 SP_VALUE(smc->frhkb, smc->tlhkb, smc->tlhkb) :
1974 ***************************************************************************
1975 * Display weighted CPU frequency statistics in JSON.
1978 * @a Activity structure with statistics.
1979 * @curr Index in array for current sample statistics.
1980 * @tab Indentation in output.
1981 * @itv Interval of time in jiffies.
1982 ***************************************************************************
1984 __print_funct_t json_print_pwr_wghfreq_stats(struct activity *a, int curr, int tab,
1985 unsigned long long itv)
1988 struct stats_pwr_wghfreq *spc, *spp, *spc_k, *spp_k;
1989 unsigned long long tis, tisfreq;
1993 if (!IS_SELECTED(a->options) || (a->nr <= 0))
1994 goto close_json_markup;
1996 json_markup_power_management(tab, OPEN_JSON_MARKUP);
1999 xprintf(tab++, "\"cpu-weighted-frequency\": [");
2001 for (i = 0; (i < a->nr) && (i < a->bitmap->b_size + 1); i++) {
2003 spc = (struct stats_pwr_wghfreq *) ((char *) a->buf[curr] + i * a->msize * a->nr2);
2004 spp = (struct stats_pwr_wghfreq *) ((char *) a->buf[!curr] + i * a->msize * a->nr2);
2006 /* Should current CPU (including CPU "all") be displayed? */
2007 if (a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))) {
2013 for (k = 0; k < a->nr2; k++) {
2015 spc_k = (struct stats_pwr_wghfreq *) ((char *) spc + k * a->msize);
2018 spp_k = (struct stats_pwr_wghfreq *) ((char *) spp + k * a->msize);
2020 tisfreq += (spc_k->freq / 1000) *
2021 (spc_k->time_in_state - spp_k->time_in_state);
2022 tis += (spc_k->time_in_state - spp_k->time_in_state);
2026 /* This is CPU "all" */
2027 strcpy(cpuno, "all");
2030 sprintf(cpuno, "%d", i - 1);
2038 xprintf0(tab, "{\"number\": \"%s\", "
2039 "\"weighted-frequency\": %.2f}",
2041 tis ? ((double) tisfreq) / tis : 0.0);
2046 xprintf0(--tab, "]");
2050 if (CLOSE_MARKUP(a->options)) {
2051 json_markup_power_management(tab, CLOSE_JSON_MARKUP);
2056 ***************************************************************************
2057 * Display USB devices statistics in JSON.
2060 * @a Activity structure with statistics.
2061 * @curr Index in array for current sample statistics.
2062 * @tab Indentation in output.
2063 * @itv Interval of time in jiffies.
2064 ***************************************************************************
2066 __print_funct_t json_print_pwr_usb_stats(struct activity *a, int curr, int tab,
2067 unsigned long long itv)
2070 struct stats_pwr_usb *suc;
2073 if (!IS_SELECTED(a->options) || (a->nr <= 0))
2074 goto close_json_markup;
2076 json_markup_power_management(tab, OPEN_JSON_MARKUP);
2079 xprintf(tab++, "\"usb-devices\": [");
2081 for (i = 0; i < a->nr; i++) {
2082 suc = (struct stats_pwr_usb *) ((char *) a->buf[curr] + i * a->msize);
2085 /* Bus#0 doesn't exist: We are at the end of the list */
2093 xprintf0(tab, "{\"bus_number\": %d, "
2094 "\"idvendor\": \"%x\", "
2095 "\"idprod\": \"%x\", "
2096 "\"maxpower\": %u, "
2097 "\"manufact\": \"%s\", "
2098 "\"product\": \"%s\"}",
2102 suc->bmaxpower << 1,
2108 xprintf0(--tab, "]");
2112 if (CLOSE_MARKUP(a->options)) {
2113 json_markup_power_management(tab, CLOSE_JSON_MARKUP);
2118 ***************************************************************************
2119 * Display filesystems statistics in JSON.
2122 * @a Activity structure with statistics.
2123 * @curr Index in array for current sample statistics.
2124 * @tab Indentation in output.
2125 * @itv Interval of time in jiffies.
2126 ***************************************************************************
2128 __print_funct_t json_print_filesystem_stats(struct activity *a, int curr, int tab,
2129 unsigned long long itv)
2132 struct stats_filesystem *sfc;
2135 xprintf(tab++, "\"filesystems\": [");
2137 for (i = 0; i < a->nr; i++) {
2138 sfc = (struct stats_filesystem *) ((char *) a->buf[curr] + i * a->msize);
2141 /* Size of filesystem is zero: We are at the end of the list */
2149 xprintf0(tab, "{\"%s\": \"%s\", "
2150 "\"MBfsfree\": %.0f, "
2151 "\"MBfsused\": %.0f, "
2152 "\"%%fsused\": %.2f, "
2153 "\"%%ufsused\": %.2f, "
2156 "\"%%Iused\": %.2f}",
2157 DISPLAY_MOUNT(a->opt_flags) ? "mountpoint" : "filesystem",
2158 DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name,
2159 (double) sfc->f_bfree / 1024 / 1024,
2160 (double) (sfc->f_blocks - sfc->f_bfree) / 1024 / 1024,
2161 sfc->f_blocks ? SP_VALUE(sfc->f_bfree, sfc->f_blocks, sfc->f_blocks)
2163 sfc->f_blocks ? SP_VALUE(sfc->f_bavail, sfc->f_blocks, sfc->f_blocks)
2166 sfc->f_files - sfc->f_ffree,
2167 sfc->f_files ? SP_VALUE(sfc->f_ffree, sfc->f_files, sfc->f_files)
2172 xprintf0(--tab, "]");
2176 ***************************************************************************
2177 * Display Fibre Channel HBA statistics in JSON.
2180 * @a Activity structure with statistics.
2181 * @curr Index in array for current sample statistics.
2182 * @tab Indentation in output.
2183 * @itv Interval of time in jiffies.
2184 ***************************************************************************
2186 __print_funct_t json_print_fchost_stats(struct activity *a, int curr, int tab,
2187 unsigned long long itv)
2190 struct stats_fchost *sfcc, *sfcp;
2193 if (!IS_SELECTED(a->options) || (a->nr <= 0))
2194 goto close_json_markup;
2196 json_markup_network(tab, OPEN_JSON_MARKUP);
2199 xprintf(tab++, "\"fchosts\": [");
2201 for (i = 0; i < a->nr; i++) {
2202 sfcc = (struct stats_fchost *) ((char *) a->buf[curr] + i * a->msize);
2203 sfcp = (struct stats_fchost *) ((char *) a->buf[!curr] + i * a->msize);
2205 if (!sfcc->fchost_name[0])
2206 /* We are at the end of the list */
2214 xprintf0(tab, "{\"fchost\": \"%s\", "
2215 "\"fch_rxf\": %.2f, "
2216 "\"fch_txf\": %.2f, "
2217 "\"fch_rxw\": %.2f, "
2218 "\"fch_txw\": %.2f}",
2220 S_VALUE(sfcp->f_rxframes, sfcc->f_rxframes, itv),
2221 S_VALUE(sfcp->f_txframes, sfcc->f_txframes, itv),
2222 S_VALUE(sfcp->f_rxwords, sfcc->f_rxwords, itv),
2223 S_VALUE(sfcp->f_txwords, sfcc->f_txwords, itv));
2227 xprintf0(--tab, "]");
2232 if (CLOSE_MARKUP(a->options)) {
2233 json_markup_network(tab, CLOSE_JSON_MARKUP);
2238 ***************************************************************************
2239 * Display softnet statistics in JSON.
2242 * @a Activity structure with statistics.
2243 * @curr Index in array for current sample statistics.
2244 * @tab Indentation in output.
2245 * @itv Interval of time in jiffies.
2246 ***************************************************************************
2248 __print_funct_t json_print_softnet_stats(struct activity *a, int curr, int tab,
2249 unsigned long long itv)
2251 if (!IS_SELECTED(a->options) || (a->nr <= 0))
2252 goto close_json_markup;
2254 json_markup_network(tab, OPEN_JSON_MARKUP);
2259 if (CLOSE_MARKUP(a->options)) {
2260 json_markup_network(tab, CLOSE_JSON_MARKUP);