2
* json_stats.c: Funtions used by sadf to display statistics in JSON format.
3
* (C) 1999-2011 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
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 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
if (DISPLAY_CPU_DEF(a->opt_flags)) {
119
xprintf(tab++, "\"cpu-load\": [");
121
else if (DISPLAY_CPU_ALL(a->opt_flags)) {
122
xprintf(tab++, "\"cpu-load-all\": [");
125
for (i = 0; (i < a->nr) && (i < a->bitmap->b_size + 1); i++) {
127
scc = (struct stats_cpu *) ((char *) a->buf[curr] + i * a->msize);
128
scp = (struct stats_cpu *) ((char *) a->buf[!curr] + i * a->msize);
130
/* Should current CPU (including CPU "all") be displayed? */
131
if (a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))) {
133
/* Yes: Display current CPU stats */
141
/* This is CPU "all" */
142
strcpy(cpuno, "all");
145
sprintf(cpuno, "%d", i - 1);
148
* If the CPU is offline then it is omited from /proc/stat:
149
* All the fields couldn't have been read and the sum of them is zero.
150
* (Remember that guest time is already included in user mode.)
152
if ((scc->cpu_user + scc->cpu_nice + scc->cpu_sys +
153
scc->cpu_iowait + scc->cpu_idle + scc->cpu_steal +
154
scc->cpu_hardirq + scc->cpu_softirq) == 0) {
156
* Set current struct fields (which have been set to zero)
157
* to values from previous iteration. Hence their values won't
158
* jump from zero when the CPU comes back online.
167
* Recalculate interval for current proc.
168
* If result is 0 then current CPU is a tickless one.
170
g_itv = get_per_cpu_interval(scc, scp);
175
/* Current CPU is offline or tickless */
176
if (DISPLAY_CPU_DEF(a->opt_flags)) {
177
xprintf0(tab, "{\"cpu\": \"%d\", "
184
i - 1, 0.0, 0.0, 0.0, 0.0, 0.0,
185
cpu_offline ? 0.0 : 100.0);
187
else if (DISPLAY_CPU_ALL(a->opt_flags)) {
188
xprintf0(tab, "{\"cpu\": \"%d\", "
198
i - 1, 0.0, 0.0, 0.0, 0.0,
200
cpu_offline ? 0.0 : 100.0);
206
if (DISPLAY_CPU_DEF(a->opt_flags)) {
207
xprintf0(tab, "{\"cpu\": \"%s\", "
215
ll_sp_value(scp->cpu_user, scc->cpu_user, g_itv),
216
ll_sp_value(scp->cpu_nice, scc->cpu_nice, g_itv),
217
ll_sp_value(scp->cpu_sys + scp->cpu_hardirq + scp->cpu_softirq,
218
scc->cpu_sys + scc->cpu_hardirq + scc->cpu_softirq,
220
ll_sp_value(scp->cpu_iowait, scc->cpu_iowait, g_itv),
221
ll_sp_value(scp->cpu_steal, scc->cpu_steal, g_itv),
222
scc->cpu_idle < scp->cpu_idle ?
224
ll_sp_value(scp->cpu_idle, scc->cpu_idle, g_itv));
226
else if (DISPLAY_CPU_ALL(a->opt_flags)) {
227
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
ll_sp_value(scp->cpu_nice, scc->cpu_nice, g_itv),
243
ll_sp_value(scp->cpu_sys, scc->cpu_sys, g_itv),
244
ll_sp_value(scp->cpu_iowait, scc->cpu_iowait, g_itv),
245
ll_sp_value(scp->cpu_steal, scc->cpu_steal, g_itv),
246
ll_sp_value(scp->cpu_hardirq, scc->cpu_hardirq, g_itv),
247
ll_sp_value(scp->cpu_softirq, scc->cpu_softirq, g_itv),
248
ll_sp_value(scp->cpu_guest, scc->cpu_guest, g_itv),
249
scc->cpu_idle < scp->cpu_idle ?
251
ll_sp_value(scp->cpu_idle, scc->cpu_idle, g_itv));
257
xprintf0(--tab, "]");
261
***************************************************************************
262
* Display task creation and context switch statistics in JSON.
265
* @a Activity structure with statistics.
266
* @curr Index in array for current sample statistics.
267
* @tab Indentation in output.
268
* @itv Interval of time in jiffies.
269
***************************************************************************
271
__print_funct_t json_print_pcsw_stats(struct activity *a, int curr, int tab,
272
unsigned long long itv)
275
*spc = (struct stats_pcsw *) a->buf[curr],
276
*spp = (struct stats_pcsw *) a->buf[!curr];
278
/* proc/s and cswch/s */
279
xprintf0(tab, "\"process-and-context-switch\": {"
282
S_VALUE(spp->processes, spc->processes, itv),
283
ll_s_value(spp->context_switch, spc->context_switch, itv));
287
***************************************************************************
288
* Display interrupts statistics in JSON.
291
* @a Activity structure with statistics.
292
* @curr Index in array for current sample statistics.
293
* @tab Indentation in output.
294
* @itv Interval of time in jiffies.
295
***************************************************************************
297
__print_funct_t json_print_irq_stats(struct activity *a, int curr, int tab,
298
unsigned long long itv)
301
struct stats_irq *sic, *sip;
305
xprintf(tab++, "\"interrupts\": [");
307
for (i = 0; (i < a->nr) && (i < a->bitmap->b_size + 1); i++) {
309
sic = (struct stats_irq *) ((char *) a->buf[curr] + i * a->msize);
310
sip = (struct stats_irq *) ((char *) a->buf[!curr] + i * a->msize);
312
/* Should current interrupt (including int "sum") be displayed? */
313
if (a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))) {
315
/* Yes: Display it */
323
/* This is interrupt "sum" */
324
strcpy(irqno, "sum");
327
sprintf(irqno, "%d", i - 1);
330
xprintf0(tab, "{\"intr\": \"%s\", "
333
ll_s_value(sip->irq_nr, sic->irq_nr, itv));
338
xprintf0(--tab, "]");
342
***************************************************************************
343
* Display swapping statistics in JSON.
346
* @a Activity structure with statistics.
347
* @curr Index in array for current sample statistics.
348
* @tab Indentation in output.
349
* @itv Interval of time in jiffies.
350
***************************************************************************
352
__print_funct_t json_print_swap_stats(struct activity *a, int curr, int tab,
353
unsigned long long itv)
356
*ssc = (struct stats_swap *) a->buf[curr],
357
*ssp = (struct stats_swap *) a->buf[!curr];
359
xprintf0(tab, "\"swap-pages\": {"
361
"\"pswpout\": %.2f}",
362
S_VALUE(ssp->pswpin, ssc->pswpin, itv),
363
S_VALUE(ssp->pswpout, ssc->pswpout, itv));
367
***************************************************************************
368
* Display paging statistics in JSON.
371
* @a Activity structure with statistics.
372
* @curr Index in array for current sample statistics.
373
* @tab Indentation in output.
374
* @itv Interval of time in jiffies.
375
***************************************************************************
377
__print_funct_t json_print_paging_stats(struct activity *a, int curr, int tab,
378
unsigned long long itv)
381
*spc = (struct stats_paging *) a->buf[curr],
382
*spp = (struct stats_paging *) a->buf[!curr];
384
xprintf0(tab, "\"paging\": {"
386
"\"pgpgout\": %.2f, "
390
"\"pgscank\": %.2f, "
391
"\"pgscand\": %.2f, "
392
"\"pgsteal\": %.2f, "
393
"\"vmeff-percent\": %.2f}",
394
S_VALUE(spp->pgpgin, spc->pgpgin, itv),
395
S_VALUE(spp->pgpgout, spc->pgpgout, itv),
396
S_VALUE(spp->pgfault, spc->pgfault, itv),
397
S_VALUE(spp->pgmajfault, spc->pgmajfault, itv),
398
S_VALUE(spp->pgfree, spc->pgfree, itv),
399
S_VALUE(spp->pgscan_kswapd, spc->pgscan_kswapd, itv),
400
S_VALUE(spp->pgscan_direct, spc->pgscan_direct, itv),
401
S_VALUE(spp->pgsteal, spc->pgsteal, itv),
402
(spc->pgscan_kswapd + spc->pgscan_direct -
403
spp->pgscan_kswapd - spp->pgscan_direct) ?
404
SP_VALUE(spp->pgsteal, spc->pgsteal,
405
spc->pgscan_kswapd + spc->pgscan_direct -
406
spp->pgscan_kswapd - spp->pgscan_direct) : 0.0);
410
***************************************************************************
411
* Display I/O and transfer rate statistics in JSON.
414
* @a Activity structure with statistics.
415
* @curr Index in array for current sample statistics.
416
* @tab Indentation in output.
417
* @itv Interval of time in jiffies.
418
***************************************************************************
420
__print_funct_t json_print_io_stats(struct activity *a, int curr, int tab,
421
unsigned long long itv)
424
*sic = (struct stats_io *) a->buf[curr],
425
*sip = (struct stats_io *) a->buf[!curr];
427
xprintf0(tab, "\"io\": {"
435
S_VALUE(sip->dk_drive, sic->dk_drive, itv),
436
S_VALUE(sip->dk_drive_rio, sic->dk_drive_rio, itv),
437
S_VALUE(sip->dk_drive_rblk, sic->dk_drive_rblk, itv),
438
S_VALUE(sip->dk_drive_wio, sic->dk_drive_wio, itv),
439
S_VALUE(sip->dk_drive_wblk, sic->dk_drive_wblk, itv));
443
***************************************************************************
444
* Display memory statistics in JSON.
447
* @a Activity structure with statistics.
448
* @curr Index in array for current sample statistics.
449
* @tab Indentation in output.
450
* @itv Interval of time in jiffies.
451
***************************************************************************
453
__print_funct_t json_print_memory_stats(struct activity *a, int curr, int tab,
454
unsigned long long itv)
457
*smc = (struct stats_memory *) a->buf[curr],
458
*smp = (struct stats_memory *) a->buf[!curr];
461
xprintf0(tab, "\"memory\": {");
463
if (DISPLAY_MEM_AMT(a->opt_flags)) {
467
printf("\"memfree\": %lu, "
469
"\"memused-percent\": %.2f, "
473
"\"commit-percent\": %.2f, "
477
smc->tlmkb - smc->frmkb,
479
SP_VALUE(smc->frmkb, smc->tlmkb, smc->tlmkb) :
484
(smc->tlmkb + smc->tlskb) ?
485
SP_VALUE(0, smc->comkb, smc->tlmkb + smc->tlskb) :
491
if (DISPLAY_SWAP(a->opt_flags)) {
498
printf("\"swpfree\": %lu, "
500
"\"swpused-percent\": %.2f, "
502
"\"swpcad-percent\": %.2f",
504
smc->tlskb - smc->frskb,
506
SP_VALUE(smc->frskb, smc->tlskb, smc->tlskb) :
509
(smc->tlskb - smc->frskb) ?
510
SP_VALUE(0, smc->caskb, smc->tlskb - smc->frskb) :
514
if (DISPLAY_MEMORY(a->opt_flags)) {
520
printf("\"frmpg\": %.2f, "
523
S_VALUE((double) KB_TO_PG(smp->frmkb),
524
(double) KB_TO_PG(smc->frmkb), itv),
525
S_VALUE((double) KB_TO_PG(smp->bufkb),
526
(double) KB_TO_PG(smc->bufkb), itv),
527
S_VALUE((double) KB_TO_PG(smp->camkb),
528
(double) KB_TO_PG(smc->camkb), itv));
535
***************************************************************************
536
* Display kernel tables statistics in JSON.
539
* @a Activity structure with statistics.
540
* @curr Index in array for current sample statistics.
541
* @tab Indentation in output.
542
* @itv Interval of time in jiffies.
543
***************************************************************************
545
__print_funct_t json_print_ktables_stats(struct activity *a, int curr, int tab,
546
unsigned long long itv)
549
*skc = (struct stats_ktables *) a->buf[curr];
551
xprintf0(tab, "\"kernel\": {"
552
"\"dentunusd\": %u, "
563
***************************************************************************
564
* Display queue and load statistics in JSON.
567
* @a Activity structure with statistics.
568
* @curr Index in array for current sample statistics.
569
* @tab Indentation in output.
570
* @itv Interval of time in jiffies.
571
***************************************************************************
573
__print_funct_t json_print_queue_stats(struct activity *a, int curr, int tab,
574
unsigned long long itv)
577
*sqc = (struct stats_queue *) a->buf[curr];
579
xprintf0(tab, "\"queue\": {"
582
"\"ldavg-1\": %.2f, "
583
"\"ldavg-5\": %.2f, "
584
"\"ldavg-15\": %.2f, "
588
(double) sqc->load_avg_1 / 100,
589
(double) sqc->load_avg_5 / 100,
590
(double) sqc->load_avg_15 / 100,
595
***************************************************************************
596
* Display serial lines statistics in JSON.
599
* @a Activity structure with statistics.
600
* @curr Index in array for current sample statistics.
601
* @tab Indentation in output.
602
* @itv Interval of time in jiffies.
603
***************************************************************************
605
__print_funct_t json_print_serial_stats(struct activity *a, int curr, int tab,
606
unsigned long long itv)
609
struct stats_serial *ssc, *ssp;
612
xprintf(tab++, "\"serial\": [");
614
for (i = 0; i < a->nr; i++) {
616
ssc = (struct stats_serial *) ((char *) a->buf[curr] + i * a->msize);
617
ssp = (struct stats_serial *) ((char *) a->buf[!curr] + i * a->msize);
622
if (ssc->line == ssp->line) {
629
xprintf0(tab, "{\"line\": %d, "
632
"\"framerr\": %.2f, "
633
"\"prtyerr\": %.2f, "
637
S_VALUE(ssp->rx, ssc->rx, itv),
638
S_VALUE(ssp->tx, ssc->tx, itv),
639
S_VALUE(ssp->frame, ssc->frame, itv),
640
S_VALUE(ssp->parity, ssc->parity, itv),
641
S_VALUE(ssp->brk, ssc->brk, itv),
642
S_VALUE(ssp->overrun, ssc->overrun, itv));
647
xprintf0(--tab, "]");
651
***************************************************************************
652
* Display disks statistics in JSON.
655
* @a Activity structure with statistics.
656
* @curr Index in array for current sample statistics.
657
* @tab Indentation in output.
658
* @itv Interval of time in jiffies.
659
***************************************************************************
661
__print_funct_t json_print_disk_stats(struct activity *a, int curr, int tab,
662
unsigned long long itv)
665
struct stats_disk *sdc, *sdp;
666
struct ext_disk_stats xds;
670
xprintf(tab++, "\"disk\": [");
672
for (i = 0; i < a->nr; i++) {
674
sdc = (struct stats_disk *) ((char *) a->buf[curr] + i * a->msize);
676
if (!(sdc->major + sdc->minor))
679
j = check_disk_reg(a, curr, !curr, i);
680
sdp = (struct stats_disk *) ((char *) a->buf[!curr] + j * a->msize);
682
/* Compute extended statistics values */
683
compute_ext_disk_stats(sdc, sdp, itv, &xds);
687
if ((USE_PRETTY_OPTION(flags)) && (sdc->major == dm_major)) {
688
dev_name = transform_devmapname(sdc->major, sdc->minor);
692
dev_name = get_devname(sdc->major, sdc->minor,
693
USE_PRETTY_OPTION(flags));
701
xprintf0(tab, "{\"disk-device\": \"%s\", "
705
"\"avgrq-sz\": %.2f, "
706
"\"avgqu-sz\": %.2f, "
709
"\"util-percent\": %.2f}",
710
/* Confusion possible here between index and minor numbers */
712
S_VALUE(sdp->nr_ios, sdc->nr_ios, itv),
713
ll_s_value(sdp->rd_sect, sdc->rd_sect, itv),
714
ll_s_value(sdp->wr_sect, sdc->wr_sect, itv),
715
/* See iostat for explanations */
717
S_VALUE(sdp->rq_ticks, sdc->rq_ticks, itv) / 1000.0,
724
xprintf0(--tab, "]");
728
***************************************************************************
729
* Display network interfaces statistics in JSON.
732
* @a Activity structure with statistics.
733
* @curr Index in array for current sample statistics.
734
* @tab Indentation in output.
735
* @itv Interval of time in jiffies.
736
***************************************************************************
738
__print_funct_t json_print_net_dev_stats(struct activity *a, int curr, int tab,
739
unsigned long long itv)
742
struct stats_net_dev *sndc, *sndp;
745
if (!IS_SELECTED(a->options) || (a->nr <= 0))
746
goto close_json_markup;
748
json_markup_network(tab, OPEN_JSON_MARKUP);
751
xprintf(tab++, "\"net-dev\": [");
753
for (i = 0; i < a->nr; i++) {
755
sndc = (struct stats_net_dev *) ((char *) a->buf[curr] + i * a->msize);
757
if (!strcmp(sndc->interface, ""))
760
j = check_net_dev_reg(a, curr, !curr, i);
761
sndp = (struct stats_net_dev *) ((char *) a->buf[!curr] + j * a->msize);
768
xprintf0(tab, "{\"iface\": \"%s\", "
777
S_VALUE(sndp->rx_packets, sndc->rx_packets, itv),
778
S_VALUE(sndp->tx_packets, sndc->tx_packets, itv),
779
S_VALUE(sndp->rx_bytes, sndc->rx_bytes, itv) / 1024,
780
S_VALUE(sndp->tx_bytes, sndc->tx_bytes, itv) / 1024,
781
S_VALUE(sndp->rx_compressed, sndc->rx_compressed, itv),
782
S_VALUE(sndp->tx_compressed, sndc->tx_compressed, itv),
783
S_VALUE(sndp->multicast, sndc->multicast, itv));
787
xprintf0(--tab, "]");
792
if (CLOSE_MARKUP(a->options)) {
793
json_markup_network(tab, CLOSE_JSON_MARKUP);
798
***************************************************************************
799
* Display network interfaces error statistics in JSON.
802
* @a Activity structure with statistics.
803
* @curr Index in array for current sample statistics.
804
* @tab Indentation in output.
805
* @itv Interval of time in jiffies.
806
***************************************************************************
808
__print_funct_t json_print_net_edev_stats(struct activity *a, int curr, int tab,
809
unsigned long long itv)
812
struct stats_net_edev *snedc, *snedp;
815
if (!IS_SELECTED(a->options) || (a->nr <= 0))
816
goto close_json_markup;
818
json_markup_network(tab, OPEN_JSON_MARKUP);
821
xprintf(tab++, "\"net-edev\": [");
823
for (i = 0; i < a->nr; i++) {
825
snedc = (struct stats_net_edev *) ((char *) a->buf[curr] + i * a->msize);
827
if (!strcmp(snedc->interface, ""))
830
j = check_net_edev_reg(a, curr, !curr, i);
831
snedp = (struct stats_net_edev *) ((char *) a->buf[!curr] + j * a->msize);
838
xprintf0(tab, "{\"iface\": \"%s\", "
849
S_VALUE(snedp->rx_errors, snedc->rx_errors, itv),
850
S_VALUE(snedp->tx_errors, snedc->tx_errors, itv),
851
S_VALUE(snedp->collisions, snedc->collisions, itv),
852
S_VALUE(snedp->rx_dropped, snedc->rx_dropped, itv),
853
S_VALUE(snedp->tx_dropped, snedc->tx_dropped, itv),
854
S_VALUE(snedp->tx_carrier_errors, snedc->tx_carrier_errors, itv),
855
S_VALUE(snedp->rx_frame_errors, snedc->rx_frame_errors, itv),
856
S_VALUE(snedp->rx_fifo_errors, snedc->rx_fifo_errors, itv),
857
S_VALUE(snedp->tx_fifo_errors, snedc->tx_fifo_errors, itv));
861
xprintf0(--tab, "]");
866
if (CLOSE_MARKUP(a->options)) {
867
json_markup_network(tab, CLOSE_JSON_MARKUP);
872
***************************************************************************
873
* Display NFS client statistics in JSON.
876
* @a Activity structure with statistics.
877
* @curr Index in array for current sample statistics.
878
* @tab Indentation in output.
879
* @itv Interval of time in jiffies.
880
***************************************************************************
882
__print_funct_t json_print_net_nfs_stats(struct activity *a, int curr, int tab,
883
unsigned long long itv)
886
*snnc = (struct stats_net_nfs *) a->buf[curr],
887
*snnp = (struct stats_net_nfs *) a->buf[!curr];
889
if (!IS_SELECTED(a->options) || (a->nr <= 0))
890
goto close_json_markup;
892
json_markup_network(tab, OPEN_JSON_MARKUP);
895
xprintf0(tab, "\"net-nfs\": {"
897
"\"retrans\": %.2f, "
902
S_VALUE(snnp->nfs_rpccnt, snnc->nfs_rpccnt, itv),
903
S_VALUE(snnp->nfs_rpcretrans, snnc->nfs_rpcretrans, itv),
904
S_VALUE(snnp->nfs_readcnt, snnc->nfs_readcnt, itv),
905
S_VALUE(snnp->nfs_writecnt, snnc->nfs_writecnt, itv),
906
S_VALUE(snnp->nfs_accesscnt, snnc->nfs_accesscnt, itv),
907
S_VALUE(snnp->nfs_getattcnt, snnc->nfs_getattcnt, itv));
911
if (CLOSE_MARKUP(a->options)) {
912
json_markup_network(tab, CLOSE_JSON_MARKUP);
917
***************************************************************************
918
* Display NFS server statistics in JSON.
921
* @a Activity structure with statistics.
922
* @curr Index in array for current sample statistics.
923
* @tab Indentation in output.
924
* @itv Interval of time in jiffies.
925
***************************************************************************
927
__print_funct_t json_print_net_nfsd_stats(struct activity *a, int curr, int tab,
928
unsigned long long itv)
930
struct stats_net_nfsd
931
*snndc = (struct stats_net_nfsd *) a->buf[curr],
932
*snndp = (struct stats_net_nfsd *) a->buf[!curr];
934
if (!IS_SELECTED(a->options) || (a->nr <= 0))
935
goto close_json_markup;
937
json_markup_network(tab, OPEN_JSON_MARKUP);
940
xprintf0(tab, "\"net-nfsd\": {"
942
"\"badcall\": %.2f, "
950
"\"saccess\": %.2f, "
951
"\"sgetatt\": %.2f}",
952
S_VALUE(snndp->nfsd_rpccnt, snndc->nfsd_rpccnt, itv),
953
S_VALUE(snndp->nfsd_rpcbad, snndc->nfsd_rpcbad, itv),
954
S_VALUE(snndp->nfsd_netcnt, snndc->nfsd_netcnt, itv),
955
S_VALUE(snndp->nfsd_netudpcnt, snndc->nfsd_netudpcnt, itv),
956
S_VALUE(snndp->nfsd_nettcpcnt, snndc->nfsd_nettcpcnt, itv),
957
S_VALUE(snndp->nfsd_rchits, snndc->nfsd_rchits, itv),
958
S_VALUE(snndp->nfsd_rcmisses, snndc->nfsd_rcmisses, itv),
959
S_VALUE(snndp->nfsd_readcnt, snndc->nfsd_readcnt, itv),
960
S_VALUE(snndp->nfsd_writecnt, snndc->nfsd_writecnt, itv),
961
S_VALUE(snndp->nfsd_accesscnt, snndc->nfsd_accesscnt, itv),
962
S_VALUE(snndp->nfsd_getattcnt, snndc->nfsd_getattcnt, itv));
966
if (CLOSE_MARKUP(a->options)) {
967
json_markup_network(tab, CLOSE_JSON_MARKUP);
972
***************************************************************************
973
* Display network socket statistics in JSON.
976
* @a Activity structure with statistics.
977
* @curr Index in array for current sample statistics.
978
* @tab Indentation in output.
979
* @itv Interval of time in jiffies.
980
***************************************************************************
982
__print_funct_t json_print_net_sock_stats(struct activity *a, int curr, int tab,
983
unsigned long long itv)
985
struct stats_net_sock
986
*snsc = (struct stats_net_sock *) a->buf[curr];
988
if (!IS_SELECTED(a->options) || (a->nr <= 0))
989
goto close_json_markup;
991
json_markup_network(tab, OPEN_JSON_MARKUP);
994
xprintf0(tab, "\"net-sock\": {"
1010
if (CLOSE_MARKUP(a->options)) {
1011
json_markup_network(tab, CLOSE_JSON_MARKUP);
1016
***************************************************************************
1017
* Display IP network 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 jiffies.
1024
***************************************************************************
1026
__print_funct_t json_print_net_ip_stats(struct activity *a, int curr, int tab,
1027
unsigned long long itv)
1030
*snic = (struct stats_net_ip *) a->buf[curr],
1031
*snip = (struct stats_net_ip *) a->buf[!curr];
1033
if (!IS_SELECTED(a->options) || (a->nr <= 0))
1034
goto close_json_markup;
1036
json_markup_network(tab, OPEN_JSON_MARKUP);
1039
xprintf0(tab, "\"net-ip\": {"
1041
"\"fwddgm\": %.2f, "
1046
"\"fragok\": %.2f, "
1047
"\"fragcrt\": %.2f}",
1048
S_VALUE(snip->InReceives, snic->InReceives, itv),
1049
S_VALUE(snip->ForwDatagrams, snic->ForwDatagrams, itv),
1050
S_VALUE(snip->InDelivers, snic->InDelivers, itv),
1051
S_VALUE(snip->OutRequests, snic->OutRequests, itv),
1052
S_VALUE(snip->ReasmReqds, snic->ReasmReqds, itv),
1053
S_VALUE(snip->ReasmOKs, snic->ReasmOKs, itv),
1054
S_VALUE(snip->FragOKs, snic->FragOKs, itv),
1055
S_VALUE(snip->FragCreates, snic->FragCreates, itv));
1059
if (CLOSE_MARKUP(a->options)) {
1060
json_markup_network(tab, CLOSE_JSON_MARKUP);
1065
***************************************************************************
1066
* Display IP network error statistics in JSON.
1069
* @a Activity structure with statistics.
1070
* @curr Index in array for current sample statistics.
1071
* @tab Indentation in output.
1072
* @itv Interval of time in jiffies.
1073
***************************************************************************
1075
__print_funct_t json_print_net_eip_stats(struct activity *a, int curr, int tab,
1076
unsigned long long itv)
1078
struct stats_net_eip
1079
*sneic = (struct stats_net_eip *) a->buf[curr],
1080
*sneip = (struct stats_net_eip *) a->buf[!curr];
1082
if (!IS_SELECTED(a->options) || (a->nr <= 0))
1083
goto close_json_markup;
1085
json_markup_network(tab, OPEN_JSON_MARKUP);
1088
xprintf0(tab, "\"net-eip\": {"
1089
"\"ihdrerr\": %.2f, "
1090
"\"iadrerr\": %.2f, "
1091
"\"iukwnpr\": %.2f, "
1097
S_VALUE(sneip->InHdrErrors, sneic->InHdrErrors, itv),
1098
S_VALUE(sneip->InAddrErrors, sneic->InAddrErrors, itv),
1099
S_VALUE(sneip->InUnknownProtos, sneic->InUnknownProtos, itv),
1100
S_VALUE(sneip->InDiscards, sneic->InDiscards, itv),
1101
S_VALUE(sneip->OutDiscards, sneic->OutDiscards, itv),
1102
S_VALUE(sneip->OutNoRoutes, sneic->OutNoRoutes, itv),
1103
S_VALUE(sneip->ReasmFails, sneic->ReasmFails, itv),
1104
S_VALUE(sneip->FragFails, sneic->FragFails, itv));
1108
if (CLOSE_MARKUP(a->options)) {
1109
json_markup_network(tab, CLOSE_JSON_MARKUP);
1114
***************************************************************************
1115
* Display ICMP network statistics in JSON.
1118
* @a Activity structure with statistics.
1119
* @curr Index in array for current sample statistics.
1120
* @tab Indentation in output.
1121
* @itv Interval of time in jiffies.
1122
***************************************************************************
1124
__print_funct_t json_print_net_icmp_stats(struct activity *a, int curr, int tab,
1125
unsigned long long itv)
1127
struct stats_net_icmp
1128
*snic = (struct stats_net_icmp *) a->buf[curr],
1129
*snip = (struct stats_net_icmp *) a->buf[!curr];
1131
if (!IS_SELECTED(a->options) || (a->nr <= 0))
1132
goto close_json_markup;
1134
json_markup_network(tab, OPEN_JSON_MARKUP);
1137
xprintf0(tab, "\"net-icmp\": {"
1148
"\"iadrmk\": %.2f, "
1149
"\"iadrmkr\": %.2f, "
1150
"\"oadrmk\": %.2f, "
1151
"\"oadrmkr\": %.2f}",
1152
S_VALUE(snip->InMsgs, snic->InMsgs, itv),
1153
S_VALUE(snip->OutMsgs, snic->OutMsgs, itv),
1154
S_VALUE(snip->InEchos, snic->InEchos, itv),
1155
S_VALUE(snip->InEchoReps, snic->InEchoReps, itv),
1156
S_VALUE(snip->OutEchos, snic->OutEchos, itv),
1157
S_VALUE(snip->OutEchoReps, snic->OutEchoReps, itv),
1158
S_VALUE(snip->InTimestamps, snic->InTimestamps, itv),
1159
S_VALUE(snip->InTimestampReps, snic->InTimestampReps, itv),
1160
S_VALUE(snip->OutTimestamps, snic->OutTimestamps, itv),
1161
S_VALUE(snip->OutTimestampReps, snic->OutTimestampReps, itv),
1162
S_VALUE(snip->InAddrMasks, snic->InAddrMasks, itv),
1163
S_VALUE(snip->InAddrMaskReps, snic->InAddrMaskReps, itv),
1164
S_VALUE(snip->OutAddrMasks, snic->OutAddrMasks, itv),
1165
S_VALUE(snip->OutAddrMaskReps, snic->OutAddrMaskReps, itv));
1169
if (CLOSE_MARKUP(a->options)) {
1170
json_markup_network(tab, CLOSE_JSON_MARKUP);
1175
***************************************************************************
1176
* Display ICMP error message statistics in JSON.
1179
* @a Activity structure with statistics.
1180
* @curr Index in array for current sample statistics.
1181
* @tab Indentation in output.
1182
* @itv Interval of time in jiffies.
1183
***************************************************************************
1185
__print_funct_t json_print_net_eicmp_stats(struct activity *a, int curr, int tab,
1186
unsigned long long itv)
1188
struct stats_net_eicmp
1189
*sneic = (struct stats_net_eicmp *) a->buf[curr],
1190
*sneip = (struct stats_net_eicmp *) a->buf[!curr];
1192
if (!IS_SELECTED(a->options) || (a->nr <= 0))
1193
goto close_json_markup;
1195
json_markup_network(tab, OPEN_JSON_MARKUP);
1198
xprintf0(tab, "\"net-eicmp\": {"
1201
"\"idstunr\": %.2f, "
1202
"\"odstunr\": %.2f, "
1205
"\"iparmpb\": %.2f, "
1206
"\"oparmpb\": %.2f, "
1209
"\"iredir\": %.2f, "
1210
"\"oredir\": %.2f}",
1211
S_VALUE(sneip->InErrors, sneic->InErrors, itv),
1212
S_VALUE(sneip->OutErrors, sneic->OutErrors, itv),
1213
S_VALUE(sneip->InDestUnreachs, sneic->InDestUnreachs, itv),
1214
S_VALUE(sneip->OutDestUnreachs, sneic->OutDestUnreachs, itv),
1215
S_VALUE(sneip->InTimeExcds, sneic->InTimeExcds, itv),
1216
S_VALUE(sneip->OutTimeExcds, sneic->OutTimeExcds, itv),
1217
S_VALUE(sneip->InParmProbs, sneic->InParmProbs, itv),
1218
S_VALUE(sneip->OutParmProbs, sneic->OutParmProbs, itv),
1219
S_VALUE(sneip->InSrcQuenchs, sneic->InSrcQuenchs, itv),
1220
S_VALUE(sneip->OutSrcQuenchs, sneic->OutSrcQuenchs, itv),
1221
S_VALUE(sneip->InRedirects, sneic->InRedirects, itv),
1222
S_VALUE(sneip->OutRedirects, sneic->OutRedirects, itv));
1226
if (CLOSE_MARKUP(a->options)) {
1227
json_markup_network(tab, CLOSE_JSON_MARKUP);
1232
***************************************************************************
1233
* Display TCP network statistics in JSON.
1236
* @a Activity structure with statistics.
1237
* @curr Index in array for current sample statistics.
1238
* @tab Indentation in output.
1239
* @itv Interval of time in jiffies.
1240
***************************************************************************
1242
__print_funct_t json_print_net_tcp_stats(struct activity *a, int curr, int tab,
1243
unsigned long long itv)
1245
struct stats_net_tcp
1246
*sntc = (struct stats_net_tcp *) a->buf[curr],
1247
*sntp = (struct stats_net_tcp *) a->buf[!curr];
1249
if (!IS_SELECTED(a->options) || (a->nr <= 0))
1250
goto close_json_markup;
1252
json_markup_network(tab, OPEN_JSON_MARKUP);
1255
xprintf0(tab, "\"net-tcp\": {"
1256
"\"active\": %.2f, "
1257
"\"passive\": %.2f, "
1260
S_VALUE(sntp->ActiveOpens, sntc->ActiveOpens, itv),
1261
S_VALUE(sntp->PassiveOpens, sntc->PassiveOpens, itv),
1262
S_VALUE(sntp->InSegs, sntc->InSegs, itv),
1263
S_VALUE(sntp->OutSegs, sntc->OutSegs, itv));
1267
if (CLOSE_MARKUP(a->options)) {
1268
json_markup_network(tab, CLOSE_JSON_MARKUP);
1273
***************************************************************************
1274
* Display TCP network error statistics in JSON.
1277
* @a Activity structure with statistics.
1278
* @curr Index in array for current sample statistics.
1279
* @tab Indentation in XML output.
1280
* @itv Interval of time in jiffies.
1281
***************************************************************************
1283
__print_funct_t json_print_net_etcp_stats(struct activity *a, int curr, int tab,
1284
unsigned long long itv)
1286
struct stats_net_etcp
1287
*snetc = (struct stats_net_etcp *) a->buf[curr],
1288
*snetp = (struct stats_net_etcp *) a->buf[!curr];
1290
if (!IS_SELECTED(a->options) || (a->nr <= 0))
1291
goto close_json_markup;
1293
json_markup_network(tab, OPEN_JSON_MARKUP);
1296
xprintf0(tab, "\"net-etcp\": {"
1297
"\"atmptf\": %.2f, "
1298
"\"estres\": %.2f, "
1299
"\"retrans\": %.2f, "
1300
"\"isegerr\": %.2f, "
1302
S_VALUE(snetp->AttemptFails, snetc->AttemptFails, itv),
1303
S_VALUE(snetp->EstabResets, snetc->EstabResets, itv),
1304
S_VALUE(snetp->RetransSegs, snetc->RetransSegs, itv),
1305
S_VALUE(snetp->InErrs, snetc->InErrs, itv),
1306
S_VALUE(snetp->OutRsts, snetc->OutRsts, itv));
1310
if (CLOSE_MARKUP(a->options)) {
1311
json_markup_network(tab, CLOSE_JSON_MARKUP);
1316
***************************************************************************
1317
* Display UDP network statistics in JSON.
1320
* @a Activity structure with statistics.
1321
* @curr Index in array for current sample statistics.
1322
* @tab Indentation in output.
1323
* @itv Interval of time in jiffies.
1324
***************************************************************************
1326
__print_funct_t json_print_net_udp_stats(struct activity *a, int curr, int tab,
1327
unsigned long long itv)
1329
struct stats_net_udp
1330
*snuc = (struct stats_net_udp *) a->buf[curr],
1331
*snup = (struct stats_net_udp *) a->buf[!curr];
1333
if (!IS_SELECTED(a->options) || (a->nr <= 0))
1334
goto close_json_markup;
1336
json_markup_network(tab, OPEN_JSON_MARKUP);
1339
xprintf0(tab, "\"net-udp\": {"
1342
"\"noport\": %.2f, "
1343
"\"idgmerr\": %.2f}",
1344
S_VALUE(snup->InDatagrams, snuc->InDatagrams, itv),
1345
S_VALUE(snup->OutDatagrams, snuc->OutDatagrams, itv),
1346
S_VALUE(snup->NoPorts, snuc->NoPorts, itv),
1347
S_VALUE(snup->InErrors, snuc->InErrors, itv));
1351
if (CLOSE_MARKUP(a->options)) {
1352
json_markup_network(tab, CLOSE_JSON_MARKUP);
1357
***************************************************************************
1358
* Display IPv6 network socket statistics in JSON.
1361
* @a Activity structure with statistics.
1362
* @curr Index in array for current sample statistics.
1363
* @tab Indentation in output.
1364
* @itv Interval of time in jiffies.
1365
***************************************************************************
1367
__print_funct_t json_print_net_sock6_stats(struct activity *a, int curr, int tab,
1368
unsigned long long itv)
1370
struct stats_net_sock6
1371
*snsc = (struct stats_net_sock6 *) a->buf[curr];
1373
if (!IS_SELECTED(a->options) || (a->nr <= 0))
1374
goto close_json_markup;
1376
json_markup_network(tab, OPEN_JSON_MARKUP);
1379
xprintf0(tab, "\"net-sock6\": {"
1383
"\"ip6-frag\": %u}",
1391
if (CLOSE_MARKUP(a->options)) {
1392
json_markup_network(tab, CLOSE_JSON_MARKUP);
1397
***************************************************************************
1398
* Display IPv6 network statistics in JSON.
1401
* @a Activity structure with statistics.
1402
* @curr Index in array for current sample statistics.
1403
* @tab Indentation in output.
1404
* @itv Interval of time in jiffies.
1405
***************************************************************************
1407
__print_funct_t json_print_net_ip6_stats(struct activity *a, int curr, int tab,
1408
unsigned long long itv)
1410
struct stats_net_ip6
1411
*snic = (struct stats_net_ip6 *) a->buf[curr],
1412
*snip = (struct stats_net_ip6 *) a->buf[!curr];
1414
if (!IS_SELECTED(a->options) || (a->nr <= 0))
1415
goto close_json_markup;
1417
json_markup_network(tab, OPEN_JSON_MARKUP);
1420
xprintf0(tab, "\"net-ip6\": {"
1422
"\"fwddgm6\": %.2f, "
1425
"\"asmrq6\": %.2f, "
1426
"\"asmok6\": %.2f, "
1427
"\"imcpck6\": %.2f, "
1428
"\"omcpck6\": %.2f, "
1429
"\"fragok6\": %.2f, "
1430
"\"fragcr6\": %.2f}",
1431
S_VALUE(snip->InReceives6, snic->InReceives6, itv),
1432
S_VALUE(snip->OutForwDatagrams6, snic->OutForwDatagrams6, itv),
1433
S_VALUE(snip->InDelivers6, snic->InDelivers6, itv),
1434
S_VALUE(snip->OutRequests6, snic->OutRequests6, itv),
1435
S_VALUE(snip->ReasmReqds6, snic->ReasmReqds6, itv),
1436
S_VALUE(snip->ReasmOKs6, snic->ReasmOKs6, itv),
1437
S_VALUE(snip->InMcastPkts6, snic->InMcastPkts6, itv),
1438
S_VALUE(snip->OutMcastPkts6, snic->OutMcastPkts6, itv),
1439
S_VALUE(snip->FragOKs6, snic->FragOKs6, itv),
1440
S_VALUE(snip->FragCreates6, snic->FragCreates6, itv));
1444
if (CLOSE_MARKUP(a->options)) {
1445
json_markup_network(tab, CLOSE_JSON_MARKUP);
1450
***************************************************************************
1451
* Display IPv6 network error statistics in JSON.
1454
* @a Activity structure with statistics.
1455
* @curr Index in array for current sample statistics.
1456
* @tab Indentation in output.
1457
* @itv Interval of time in jiffies.
1458
***************************************************************************
1460
__print_funct_t json_print_net_eip6_stats(struct activity *a, int curr, int tab,
1461
unsigned long long itv)
1463
struct stats_net_eip6
1464
*sneic = (struct stats_net_eip6 *) a->buf[curr],
1465
*sneip = (struct stats_net_eip6 *) a->buf[!curr];
1467
if (!IS_SELECTED(a->options) || (a->nr <= 0))
1468
goto close_json_markup;
1470
json_markup_network(tab, OPEN_JSON_MARKUP);
1473
xprintf0(tab, "\"net-eip6\": {"
1474
"\"ihdrer6\": %.2f, "
1475
"\"iadrer6\": %.2f, "
1476
"\"iukwnp6\": %.2f, "
1477
"\"i2big6\": %.2f, "
1478
"\"idisc6\": %.2f, "
1479
"\"odisc6\": %.2f, "
1480
"\"inort6\": %.2f, "
1481
"\"onort6\": %.2f, "
1483
"\"fragf6\": %.2f, "
1484
"\"itrpck6\": %.2f}",
1485
S_VALUE(sneip->InHdrErrors6, sneic->InHdrErrors6, itv),
1486
S_VALUE(sneip->InAddrErrors6, sneic->InAddrErrors6, itv),
1487
S_VALUE(sneip->InUnknownProtos6, sneic->InUnknownProtos6, itv),
1488
S_VALUE(sneip->InTooBigErrors6, sneic->InTooBigErrors6, itv),
1489
S_VALUE(sneip->InDiscards6, sneic->InDiscards6, itv),
1490
S_VALUE(sneip->OutDiscards6, sneic->OutDiscards6, itv),
1491
S_VALUE(sneip->InNoRoutes6, sneic->InNoRoutes6, itv),
1492
S_VALUE(sneip->OutNoRoutes6, sneic->OutNoRoutes6, itv),
1493
S_VALUE(sneip->ReasmFails6, sneic->ReasmFails6, itv),
1494
S_VALUE(sneip->FragFails6, sneic->FragFails6, itv),
1495
S_VALUE(sneip->InTruncatedPkts6, sneic->InTruncatedPkts6, itv));
1499
if (CLOSE_MARKUP(a->options)) {
1500
json_markup_network(tab, CLOSE_JSON_MARKUP);
1505
***************************************************************************
1506
* Display ICMPv6 network statistics in JSON.
1509
* @a Activity structure with statistics.
1510
* @curr Index in array for current sample statistics.
1511
* @tab Indentation in output.
1512
* @itv Interval of time in jiffies.
1513
***************************************************************************
1515
__print_funct_t json_print_net_icmp6_stats(struct activity *a, int curr, int tab,
1516
unsigned long long itv)
1518
struct stats_net_icmp6
1519
*snic = (struct stats_net_icmp6 *) a->buf[curr],
1520
*snip = (struct stats_net_icmp6 *) a->buf[!curr];
1522
if (!IS_SELECTED(a->options) || (a->nr <= 0))
1523
goto close_json_markup;
1525
json_markup_network(tab, OPEN_JSON_MARKUP);
1528
xprintf0(tab, "\"net-icmp6\": {"
1532
"\"iechr6\": %.2f, "
1533
"\"oechr6\": %.2f, "
1534
"\"igmbq6\": %.2f, "
1535
"\"igmbr6\": %.2f, "
1536
"\"ogmbr6\": %.2f, "
1537
"\"igmbrd6\": %.2f, "
1538
"\"ogmbrd6\": %.2f, "
1539
"\"irtsol6\": %.2f, "
1540
"\"ortsol6\": %.2f, "
1541
"\"irtad6\": %.2f, "
1542
"\"inbsol6\": %.2f, "
1543
"\"onbsol6\": %.2f, "
1544
"\"inbad6\": %.2f, "
1545
"\"onbad6\": %.2f}",
1546
S_VALUE(snip->InMsgs6, snic->InMsgs6, itv),
1547
S_VALUE(snip->OutMsgs6, snic->OutMsgs6, itv),
1548
S_VALUE(snip->InEchos6, snic->InEchos6, itv),
1549
S_VALUE(snip->InEchoReplies6, snic->InEchoReplies6, itv),
1550
S_VALUE(snip->OutEchoReplies6, snic->OutEchoReplies6, itv),
1551
S_VALUE(snip->InGroupMembQueries6, snic->InGroupMembQueries6, itv),
1552
S_VALUE(snip->InGroupMembResponses6, snic->InGroupMembResponses6, itv),
1553
S_VALUE(snip->OutGroupMembResponses6, snic->OutGroupMembResponses6, itv),
1554
S_VALUE(snip->InGroupMembReductions6, snic->InGroupMembReductions6, itv),
1555
S_VALUE(snip->OutGroupMembReductions6, snic->OutGroupMembReductions6, itv),
1556
S_VALUE(snip->InRouterSolicits6, snic->InRouterSolicits6, itv),
1557
S_VALUE(snip->OutRouterSolicits6, snic->OutRouterSolicits6, itv),
1558
S_VALUE(snip->InRouterAdvertisements6, snic->InRouterAdvertisements6, itv),
1559
S_VALUE(snip->InNeighborSolicits6, snic->InNeighborSolicits6, itv),
1560
S_VALUE(snip->OutNeighborSolicits6, snic->OutNeighborSolicits6, itv),
1561
S_VALUE(snip->InNeighborAdvertisements6, snic->InNeighborAdvertisements6, itv),
1562
S_VALUE(snip->OutNeighborAdvertisements6, snic->OutNeighborAdvertisements6, itv));
1566
if (CLOSE_MARKUP(a->options)) {
1567
json_markup_network(tab, CLOSE_JSON_MARKUP);
1572
***************************************************************************
1573
* Display ICMPv6 error message statistics in JSON.
1576
* @a Activity structure with statistics.
1577
* @curr Index in array for current sample statistics.
1578
* @tab Indentation in output.
1579
* @itv Interval of time in jiffies.
1580
***************************************************************************
1582
__print_funct_t json_print_net_eicmp6_stats(struct activity *a, int curr, int tab,
1583
unsigned long long itv)
1585
struct stats_net_eicmp6
1586
*sneic = (struct stats_net_eicmp6 *) a->buf[curr],
1587
*sneip = (struct stats_net_eicmp6 *) a->buf[!curr];
1589
if (!IS_SELECTED(a->options) || (a->nr <= 0))
1590
goto close_json_markup;
1592
json_markup_network(tab, OPEN_JSON_MARKUP);
1595
xprintf0(tab, "\"net-eicmp6\": {"
1597
"\"idtunr6\": %.2f, "
1598
"\"odtunr6\": %.2f, "
1599
"\"itmex6\": %.2f, "
1600
"\"otmex6\": %.2f, "
1601
"\"iprmpb6\": %.2f, "
1602
"\"oprmpb6\": %.2f, "
1603
"\"iredir6\": %.2f, "
1604
"\"oredir6\": %.2f, "
1605
"\"ipck2b6\": %.2f, "
1606
"\"opck2b6\": %.2f}",
1607
S_VALUE(sneip->InErrors6, sneic->InErrors6, itv),
1608
S_VALUE(sneip->InDestUnreachs6, sneic->InDestUnreachs6, itv),
1609
S_VALUE(sneip->OutDestUnreachs6, sneic->OutDestUnreachs6, itv),
1610
S_VALUE(sneip->InTimeExcds6, sneic->InTimeExcds6, itv),
1611
S_VALUE(sneip->OutTimeExcds6, sneic->OutTimeExcds6, itv),
1612
S_VALUE(sneip->InParmProblems6, sneic->InParmProblems6, itv),
1613
S_VALUE(sneip->OutParmProblems6, sneic->OutParmProblems6, itv),
1614
S_VALUE(sneip->InRedirects6, sneic->InRedirects6, itv),
1615
S_VALUE(sneip->OutRedirects6, sneic->OutRedirects6, itv),
1616
S_VALUE(sneip->InPktTooBigs6, sneic->InPktTooBigs6, itv),
1617
S_VALUE(sneip->OutPktTooBigs6, sneic->OutPktTooBigs6, itv));
1621
if (CLOSE_MARKUP(a->options)) {
1622
json_markup_network(tab, CLOSE_JSON_MARKUP);
1627
***************************************************************************
1628
* Display UDPv6 network statistics in JSON.
1631
* @a Activity structure with statistics.
1632
* @curr Index in array for current sample statistics.
1633
* @tab Indentation in output.
1634
* @itv Interval of time in jiffies.
1635
***************************************************************************
1637
__print_funct_t json_print_net_udp6_stats(struct activity *a, int curr, int tab,
1638
unsigned long long itv)
1640
struct stats_net_udp6
1641
*snuc = (struct stats_net_udp6 *) a->buf[curr],
1642
*snup = (struct stats_net_udp6 *) a->buf[!curr];
1644
if (!IS_SELECTED(a->options) || (a->nr <= 0))
1645
goto close_json_markup;
1647
json_markup_network(tab, OPEN_JSON_MARKUP);
1650
xprintf0(tab, "\"net-udp6\": {"
1653
"\"noport6\": %.2f, "
1654
"\"idgmer6\": %.2f}",
1655
S_VALUE(snup->InDatagrams6, snuc->InDatagrams6, itv),
1656
S_VALUE(snup->OutDatagrams6, snuc->OutDatagrams6, itv),
1657
S_VALUE(snup->NoPorts6, snuc->NoPorts6, itv),
1658
S_VALUE(snup->InErrors6, snuc->InErrors6, itv));
1662
if (CLOSE_MARKUP(a->options)) {
1663
json_markup_network(tab, CLOSE_JSON_MARKUP);
1668
***************************************************************************
1669
* Display CPU frequency statistics in JSON.
1672
* @a Activity structure with statistics.
1673
* @curr Index in array for current sample statistics.
1674
* @tab Indentation in output.
1675
* @itv Interval of time in jiffies.
1676
***************************************************************************
1678
__print_funct_t json_print_pwr_cpufreq_stats(struct activity *a, int curr, int tab,
1679
unsigned long long itv)
1682
struct stats_pwr_cpufreq *spc;
1686
if (!IS_SELECTED(a->options) || (a->nr <= 0))
1687
goto close_json_markup;
1689
json_markup_power_management(tab, OPEN_JSON_MARKUP);
1692
xprintf(tab++, "\"cpu-frequency\": [");
1694
for (i = 0; (i < a->nr) && (i < a->bitmap->b_size + 1); i++) {
1696
spc = (struct stats_pwr_cpufreq *) ((char *) a->buf[curr] + i * a->msize);
1698
/* Should current CPU (including CPU "all") be displayed? */
1699
if (a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))) {
1701
/* Yes: Display it */
1703
/* This is CPU "all" */
1704
strcpy(cpuno, "all");
1707
sprintf(cpuno, "%d", i - 1);
1715
xprintf0(tab, "{\"number\": \"%s\", "
1716
"\"frequency\": %.2f}",
1718
((double) spc->cpufreq) / 100);
1723
xprintf0(--tab, "]");
1727
if (CLOSE_MARKUP(a->options)) {
1728
json_markup_power_management(tab, CLOSE_JSON_MARKUP);
1733
***************************************************************************
1734
* Display fan statistics in JSON.
1737
* @a Activity structure with statistics.
1738
* @curr Index in array for current sample statistics.
1739
* @tab Indentation in output.
1740
* @itv Interval of time in jiffies.
1741
***************************************************************************
1743
__print_funct_t json_print_pwr_fan_stats(struct activity *a, int curr, int tab,
1744
unsigned long long itv)
1747
struct stats_pwr_fan *spc;
1750
if (!IS_SELECTED(a->options) || (a->nr <= 0))
1751
goto close_json_markup;
1753
json_markup_power_management(tab, OPEN_JSON_MARKUP);
1756
xprintf(tab++, "\"fan-speed\": [");
1758
for (i = 0; i < a->nr; i++) {
1759
spc = (struct stats_pwr_fan *) ((char *) a->buf[curr] + i * a->msize);
1766
xprintf0(tab, "{\"number\": %d, "
1769
"\"device\": \"%s\"}",
1771
(unsigned long long) spc->rpm,
1772
(unsigned long long) (spc->rpm - spc->rpm_min),
1777
xprintf0(--tab, "]");
1781
if (CLOSE_MARKUP(a->options)) {
1782
json_markup_power_management(tab, CLOSE_JSON_MARKUP);
1787
***************************************************************************
1788
* Display temperature statistics in JSON.
1791
* @a Activity structure with statistics.
1792
* @curr Index in array for current sample statistics.
1793
* @tab Indentation in output.
1794
* @itv Interval of time in jiffies.
1795
***************************************************************************
1797
__print_funct_t json_print_pwr_temp_stats(struct activity *a, int curr, int tab,
1798
unsigned long long itv)
1801
struct stats_pwr_temp *spc;
1804
if (!IS_SELECTED(a->options) || (a->nr <= 0))
1805
goto close_json_markup;
1807
json_markup_power_management(tab, OPEN_JSON_MARKUP);
1810
xprintf(tab++, "\"temperature\": [");
1812
for (i = 0; i < a->nr; i++) {
1813
spc = (struct stats_pwr_temp *) ((char *) a->buf[curr] + i * a->msize);
1820
xprintf0(tab, "{\"number\": %d, "
1822
"\"percent-temp\": %.2f, "
1823
"\"device\": \"%s\"}",
1826
(spc->temp_max - spc->temp_min) ?
1827
(spc->temp - spc->temp_min) / (spc->temp_max - spc->temp_min) * 100 :
1833
xprintf0(--tab, "]");
1837
if (CLOSE_MARKUP(a->options)) {
1838
json_markup_power_management(tab, CLOSE_JSON_MARKUP);
1843
***************************************************************************
1844
* Display voltage inputs statistics in JSON.
1847
* @a Activity structure with statistics.
1848
* @curr Index in array for current sample statistics.
1849
* @tab Indentation in output.
1850
* @itv Interval of time in jiffies.
1851
***************************************************************************
1853
__print_funct_t json_print_pwr_in_stats(struct activity *a, int curr, int tab,
1854
unsigned long long itv)
1857
struct stats_pwr_in *spc;
1860
if (!IS_SELECTED(a->options) || (a->nr <= 0))
1861
goto close_json_markup;
1863
json_markup_power_management(tab, OPEN_JSON_MARKUP);
1866
xprintf(tab++, "\"voltage-input\": [");
1868
for (i = 0; i < a->nr; i++) {
1869
spc = (struct stats_pwr_in *) ((char *) a->buf[curr] + i * a->msize);
1876
xprintf0(tab, "{\"number\": %d, "
1878
"\"percent-in\": %.2f, "
1879
"\"device\": \"%s\"}",
1882
(spc->in_max - spc->in_min) ?
1883
(spc->in - spc->in_min) / (spc->in_max - spc->in_min) * 100 :
1889
xprintf0(--tab, "]");
1893
if (CLOSE_MARKUP(a->options)) {
1894
json_markup_power_management(tab, CLOSE_JSON_MARKUP);
1899
***************************************************************************
1900
* Display huge pages statistics in JSON.
1903
* @a Activity structure with statistics.
1904
* @curr Index in array for current sample statistics.
1905
* @tab Indentation in output.
1906
* @itv Interval of time in jiffies.
1907
***************************************************************************
1909
__print_funct_t json_print_huge_stats(struct activity *a, int curr, int tab,
1910
unsigned long long itv)
1913
*smc = (struct stats_huge *) a->buf[curr];
1915
xprintf0(tab, "\"hugepages\": {"
1916
"\"hugfree\": %lu, "
1917
"\"hugused\": %lu, "
1918
"\"hugused-percent\": %.2f}",
1920
smc->tlhkb - smc->frhkb,
1922
SP_VALUE(smc->frhkb, smc->tlhkb, smc->tlhkb) :
1927
***************************************************************************
1928
* Display weighted CPU frequency statistics in JSON.
1931
* @a Activity structure with statistics.
1932
* @curr Index in array for current sample statistics.
1933
* @tab Indentation in output.
1934
* @itv Interval of time in jiffies.
1935
***************************************************************************
1937
__print_funct_t json_print_pwr_wghfreq_stats(struct activity *a, int curr, int tab,
1938
unsigned long long itv)
1941
struct stats_pwr_wghfreq *spc, *spp, *spc_k, *spp_k;
1942
unsigned long long tis, tisfreq;
1946
if (!IS_SELECTED(a->options) || (a->nr <= 0))
1947
goto close_json_markup;
1949
json_markup_power_management(tab, OPEN_JSON_MARKUP);
1952
xprintf(tab++, "\"cpu-weighted-frequency\": [");
1954
for (i = 0; (i < a->nr) && (i < a->bitmap->b_size + 1); i++) {
1956
spc = (struct stats_pwr_wghfreq *) ((char *) a->buf[curr] + i * a->msize * a->nr2);
1957
spp = (struct stats_pwr_wghfreq *) ((char *) a->buf[!curr] + i * a->msize * a->nr2);
1959
/* Should current CPU (including CPU "all") be displayed? */
1960
if (a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))) {
1966
for (k = 0; k < a->nr2; k++) {
1968
spc_k = (struct stats_pwr_wghfreq *) ((char *) spc + k * a->msize);
1971
spp_k = (struct stats_pwr_wghfreq *) ((char *) spp + k * a->msize);
1973
tisfreq += (spc_k->freq / 1000) *
1974
(spc_k->time_in_state - spp_k->time_in_state);
1975
tis += (spc_k->time_in_state - spp_k->time_in_state);
1979
/* This is CPU "all" */
1980
strcpy(cpuno, "all");
1983
sprintf(cpuno, "%d", i - 1);
1991
xprintf0(tab, "{\"number\": \"%s\", "
1992
"\"weighted-frequency\": %.2f}",
1994
tis ? ((double) tisfreq) / tis : 0.0);
1999
xprintf0(--tab, "]");
2003
if (CLOSE_MARKUP(a->options)) {
2004
json_markup_power_management(tab, CLOSE_JSON_MARKUP);
2009
***************************************************************************
2010
* Display USB devices statistics in JSON.
2013
* @a Activity structure with statistics.
2014
* @curr Index in array for current sample statistics.
2015
* @tab Indentation in output.
2016
* @itv Interval of time in jiffies.
2017
***************************************************************************
2019
__print_funct_t json_print_pwr_usb_stats(struct activity *a, int curr, int tab,
2020
unsigned long long itv)
2023
struct stats_pwr_usb *suc;
2026
if (!IS_SELECTED(a->options) || (a->nr <= 0))
2027
goto close_json_markup;
2029
json_markup_power_management(tab, OPEN_JSON_MARKUP);
2032
xprintf(tab++, "\"usb-devices\": [");
2034
for (i = 0; i < a->nr; i++) {
2035
suc = (struct stats_pwr_usb *) ((char *) a->buf[curr] + i * a->msize);
2038
/* Bus#0 doesn't exist: We are at the end of the list */
2046
xprintf0(tab, "{\"bus_number\": %d, "
2047
"\"idvendor\": \"%x\", "
2048
"\"idprod\": \"%x\", "
2049
"\"maxpower\": %u, "
2050
"\"manufact\": \"%s\", "
2051
"\"product\": \"%s\"}",
2055
suc->bmaxpower << 1,
2061
xprintf0(--tab, "]");
2065
if (CLOSE_MARKUP(a->options)) {
2066
json_markup_power_management(tab, CLOSE_JSON_MARKUP);