]> granicus.if.org Git - sysstat/blob - xml_stats.c
sysstat-12.5.3
[sysstat] / xml_stats.c
1 /*
2  * xml_stats.c: Funtions used by sadf to display statistics in XML.
3  * (C) 1999-2021 by Sebastien GODARD (sysstat <at> orange.fr)
4  *
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.                                              *
10  *                                                                         *
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 *
14  * for more details.                                                       *
15  *                                                                         *
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  ***************************************************************************
20  */
21
22 #include <stdio.h>
23 #include <string.h>
24 #include <stdarg.h>
25
26 #include "sa.h"
27 #include "ioconf.h"
28 #include "xml_stats.h"
29
30 #ifdef USE_NLS
31 #include <locale.h>
32 #include <libintl.h>
33 #define _(string) gettext(string)
34 #else
35 #define _(string) (string)
36 #endif
37
38 extern uint64_t flags;
39
40 /*
41  ***************************************************************************
42  * Open or close <network> markup.
43  *
44  * IN:
45  * @tab         Number of tabulations.
46  * @action      Open or close action.
47  ***************************************************************************
48  */
49 void xml_markup_network(int tab, int action)
50 {
51         static int markup_state = CLOSE_XML_MARKUP;
52
53         if (action == markup_state)
54                 return;
55         markup_state = action;
56
57         if (action == OPEN_XML_MARKUP) {
58                 /* Open markup */
59                 xprintf(tab, "<network per=\"second\">");
60         }
61         else {
62                 /* Close markup */
63                 xprintf(tab, "</network>");
64         }
65 }
66
67 /*
68  ***************************************************************************
69  * Open or close <power-management> markup.
70  *
71  * IN:
72  * @tab         Number of tabulations.
73  * @action      Open or close action.
74  ***************************************************************************
75  */
76 void xml_markup_power_management(int tab, int action)
77 {
78         static int markup_state = CLOSE_XML_MARKUP;
79
80         if (action == markup_state)
81                 return;
82         markup_state = action;
83
84         if (action == OPEN_XML_MARKUP) {
85                 /* Open markup */
86                 xprintf(tab, "<power-management>");
87         }
88         else {
89                 /* Close markup */
90                 xprintf(tab, "</power-management>");
91         }
92 }
93
94 /*
95  ***************************************************************************
96  * Open or close <psi> markup.
97  *
98  * IN:
99  * @tab         Number of tabulations.
100  * @action      Open or close action.
101  ***************************************************************************
102  */
103 void xml_markup_psi(int tab, int action)
104 {
105         static int markup_state = CLOSE_XML_MARKUP;
106
107         if (action == markup_state)
108                 return;
109         markup_state = action;
110
111         if (action == OPEN_XML_MARKUP) {
112                 /* Open markup */
113                 xprintf(tab, "<psi per=\"second\">");
114         }
115         else {
116                 /* Close markup */
117                 xprintf(tab, "</psi>");
118         }
119 }
120
121 /*
122  ***************************************************************************
123  * Display CPU statistics in XML.
124  *
125  * IN:
126  * @a           Activity structure with statistics.
127  * @curr        Index in array for current sample statistics.
128  * @tab         Indentation in XML output.
129  * @itv         Interval of time in 1/100th of a second (independent of the
130  *              number of processors). Unused here.
131  ***************************************************************************
132  */
133 __print_funct_t xml_print_cpu_stats(struct activity *a, int curr, int tab,
134                                     unsigned long long itv)
135 {
136         int i;
137         unsigned long long deltot_jiffies = 1;
138         struct stats_cpu *scc, *scp;
139         unsigned char offline_cpu_bitmap[BITMAP_SIZE(NR_CPUS)] = {0};
140         char cpuno[16];
141
142         xprintf(tab++, "<cpu-load>");
143
144         /* @nr[curr] cannot normally be greater than @nr_ini */
145         if (a->nr[curr] > a->nr_ini) {
146                 a->nr_ini = a->nr[curr];
147         }
148
149         /*
150          * Compute CPU "all" as sum of all individual CPU (on SMP machines)
151          * and look for offline CPU.
152          */
153         if (a->nr_ini > 1) {
154                 deltot_jiffies = get_global_cpu_statistics(a, !curr, curr,
155                                                            flags, offline_cpu_bitmap);
156         }
157
158         for (i = 0; (i < a->nr_ini) && (i < a->bitmap->b_size + 1); i++) {
159
160                 /* Should current CPU (including CPU "all") be displayed? */
161                 if (!(a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))) ||
162                     offline_cpu_bitmap[i >> 3] & (1 << (i & 0x07)))
163                         /* Don't display CPU */
164                         continue;
165
166                 scc = (struct stats_cpu *) ((char *) a->buf[curr]  + i * a->msize);
167                 scp = (struct stats_cpu *) ((char *) a->buf[!curr] + i * a->msize);
168
169                 if (i == 0) {
170                         /* This is CPU "all" */
171                         strcpy(cpuno, "all");
172
173                         if (a->nr_ini == 1) {
174                                 /*
175                                  * This is a UP machine. In this case
176                                  * interval has still not been calculated.
177                                  */
178                                 deltot_jiffies = get_per_cpu_interval(scc, scp);
179                         }
180                         if (!deltot_jiffies) {
181                                 /* CPU "all" cannot be tickless */
182                                 deltot_jiffies = 1;
183                         }
184                 }
185                 else {
186                         sprintf(cpuno, "%d", i - 1);
187
188                         /*
189                          * Recalculate interval for current proc.
190                          * If result is 0 then current CPU is a tickless one.
191                          */
192                         deltot_jiffies = get_per_cpu_interval(scc, scp);
193
194                         if (!deltot_jiffies) {
195                                 /* Current CPU is tickless */
196                                 if (DISPLAY_CPU_DEF(a->opt_flags)) {
197                                         xprintf(tab, "<cpu number=\"%d\" "
198                                                 "user=\"%.2f\" "
199                                                 "nice=\"%.2f\" "
200                                                 "system=\"%.2f\" "
201                                                 "iowait=\"%.2f\" "
202                                                 "steal=\"%.2f\" "
203                                                 "idle=\"%.2f\"/>",
204                                                 i - 1, 0.0, 0.0, 0.0, 0.0, 0.0, 100.0);
205                                 }
206                                 else if (DISPLAY_CPU_ALL(a->opt_flags)) {
207                                         xprintf(tab, "<cpu number=\"%d\" "
208                                                 "usr=\"%.2f\" "
209                                                 "nice=\"%.2f\" "
210                                                 "sys=\"%.2f\" "
211                                                 "iowait=\"%.2f\" "
212                                                 "steal=\"%.2f\" "
213                                                 "irq=\"%.2f\" "
214                                                 "soft=\"%.2f\" "
215                                                 "guest=\"%.2f\" "
216                                                 "gnice=\"%.2f\" "
217                                                 "idle=\"%.2f\"/>",
218                                                 i - 1, 0.0, 0.0, 0.0, 0.0,
219                                                 0.0, 0.0, 0.0, 0.0, 0.0, 100.0);
220                                 }
221                                 continue;
222                         }
223                 }
224
225                 if (DISPLAY_CPU_DEF(a->opt_flags)) {
226                         xprintf(tab, "<cpu number=\"%s\" "
227                                 "user=\"%.2f\" "
228                                 "nice=\"%.2f\" "
229                                 "system=\"%.2f\" "
230                                 "iowait=\"%.2f\" "
231                                 "steal=\"%.2f\" "
232                                 "idle=\"%.2f\"/>",
233                                 cpuno,
234                                 ll_sp_value(scp->cpu_user, scc->cpu_user, deltot_jiffies),
235                                 ll_sp_value(scp->cpu_nice, scc->cpu_nice, deltot_jiffies),
236                                 ll_sp_value(scp->cpu_sys + scp->cpu_hardirq + scp->cpu_softirq,
237                                             scc->cpu_sys + scc->cpu_hardirq + scc->cpu_softirq,
238                                             deltot_jiffies),
239                                 ll_sp_value(scp->cpu_iowait, scc->cpu_iowait, deltot_jiffies),
240                                 ll_sp_value(scp->cpu_steal,  scc->cpu_steal, deltot_jiffies),
241                                 scc->cpu_idle < scp->cpu_idle ?
242                                 0.0 :
243                                 ll_sp_value(scp->cpu_idle, scc->cpu_idle, deltot_jiffies));
244                 }
245                 else if (DISPLAY_CPU_ALL(a->opt_flags)) {
246                         xprintf(tab, "<cpu number=\"%s\" "
247                                 "usr=\"%.2f\" "
248                                 "nice=\"%.2f\" "
249                                 "sys=\"%.2f\" "
250                                 "iowait=\"%.2f\" "
251                                 "steal=\"%.2f\" "
252                                 "irq=\"%.2f\" "
253                                 "soft=\"%.2f\" "
254                                 "guest=\"%.2f\" "
255                                 "gnice=\"%.2f\" "
256                                 "idle=\"%.2f\"/>",
257                                 cpuno,
258                                 (scc->cpu_user - scc->cpu_guest) < (scp->cpu_user - scp->cpu_guest) ?
259                                 0.0 :
260                                 ll_sp_value(scp->cpu_user - scp->cpu_guest,
261                                             scc->cpu_user - scc->cpu_guest, deltot_jiffies),
262                                 (scc->cpu_nice - scc->cpu_guest_nice) < (scp->cpu_nice - scp->cpu_guest_nice) ?
263                                 0.0 :
264                                 ll_sp_value(scp->cpu_nice - scp->cpu_guest_nice,
265                                             scc->cpu_nice - scc->cpu_guest_nice, deltot_jiffies),
266                                 ll_sp_value(scp->cpu_sys, scc->cpu_sys, deltot_jiffies),
267                                 ll_sp_value(scp->cpu_iowait, scc->cpu_iowait, deltot_jiffies),
268                                 ll_sp_value(scp->cpu_steal, scc->cpu_steal, deltot_jiffies),
269                                 ll_sp_value(scp->cpu_hardirq, scc->cpu_hardirq, deltot_jiffies),
270                                 ll_sp_value(scp->cpu_softirq, scc->cpu_softirq, deltot_jiffies),
271                                 ll_sp_value(scp->cpu_guest, scc->cpu_guest, deltot_jiffies),
272                                 ll_sp_value(scp->cpu_guest_nice, scc->cpu_guest_nice, deltot_jiffies),
273                                 scc->cpu_idle < scp->cpu_idle ?
274                                 0.0 :
275                                 ll_sp_value(scp->cpu_idle, scc->cpu_idle, deltot_jiffies));
276                 }
277         }
278
279         xprintf(--tab, "</cpu-load>");
280 }
281
282 /*
283  ***************************************************************************
284  * Display task creation and context switch statistics in XML.
285  *
286  * IN:
287  * @a           Activity structure with statistics.
288  * @curr        Index in array for current sample statistics.
289  * @tab         Indentation in XML output.
290  * @itv         Interval of time in 1/100th of a second.
291  ***************************************************************************
292  */
293 __print_funct_t xml_print_pcsw_stats(struct activity *a, int curr, int tab,
294                                      unsigned long long itv)
295 {
296         struct stats_pcsw
297                 *spc = (struct stats_pcsw *) a->buf[curr],
298                 *spp = (struct stats_pcsw *) a->buf[!curr];
299
300         /* proc/s and cswch/s */
301         xprintf(tab, "<process-and-context-switch per=\"second\" "
302                 "proc=\"%.2f\" "
303                 "cswch=\"%.2f\"/>",
304                 S_VALUE(spp->processes, spc->processes, itv),
305                 S_VALUE(spp->context_switch, spc->context_switch, itv));
306 }
307
308 /*
309  ***************************************************************************
310  * Display interrupts statistics in XML.
311  *
312  * IN:
313  * @a           Activity structure with statistics.
314  * @curr        Index in array for current sample statistics.
315  * @tab         Indentation in XML output.
316  * @itv         Interval of time in 1/100th of a second.
317  ***************************************************************************
318  */
319 __print_funct_t xml_print_irq_stats(struct activity *a, int curr, int tab,
320                                     unsigned long long itv)
321 {
322         int i;
323         struct stats_irq *sic, *sip;
324         char irqno[16];
325
326         xprintf(tab++, "<interrupts>");
327         xprintf(tab++, "<int-global per=\"second\">");
328
329         for (i = 0; (i < a->nr[curr]) && (i < a->bitmap->b_size + 1); i++) {
330
331                 sic = (struct stats_irq *) ((char *) a->buf[curr]  + i * a->msize);
332                 sip = (struct stats_irq *) ((char *) a->buf[!curr] + i * a->msize);
333
334                 /* Should current interrupt (including int "sum") be displayed? */
335                 if (a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))) {
336
337                         /* Yes: Display it */
338                         if (!i) {
339                                 /* This is interrupt "sum" */
340                                 strcpy(irqno, "sum");
341                         }
342                         else {
343                                 sprintf(irqno, "%d", i - 1);
344                         }
345
346                         xprintf(tab, "<irq intr=\"%s\" value=\"%.2f\"/>", irqno,
347                                 S_VALUE(sip->irq_nr, sic->irq_nr, itv));
348                 }
349         }
350
351         xprintf(--tab, "</int-global>");
352         xprintf(--tab, "</interrupts>");
353 }
354
355 /*
356  ***************************************************************************
357  * Display swapping statistics in XML.
358  *
359  * IN:
360  * @a           Activity structure with statistics.
361  * @curr        Index in array for current sample statistics.
362  * @tab         Indentation in XML output.
363  * @itv         Interval of time in 1/100th of a second.
364  ***************************************************************************
365  */
366 __print_funct_t xml_print_swap_stats(struct activity *a, int curr, int tab,
367                                      unsigned long long itv)
368 {
369         struct stats_swap
370                 *ssc = (struct stats_swap *) a->buf[curr],
371                 *ssp = (struct stats_swap *) a->buf[!curr];
372
373         xprintf(tab, "<swap-pages per=\"second\" "
374                 "pswpin=\"%.2f\" "
375                 "pswpout=\"%.2f\"/>",
376                 S_VALUE(ssp->pswpin,  ssc->pswpin,  itv),
377                 S_VALUE(ssp->pswpout, ssc->pswpout, itv));
378 }
379
380 /*
381  ***************************************************************************
382  * Display paging statistics in XML.
383  *
384  * IN:
385  * @a           Activity structure with statistics.
386  * @curr        Index in array for current sample statistics.
387  * @tab         Indentation in XML output.
388  * @itv         Interval of time in 1/100th of a second.
389  ***************************************************************************
390  */
391 __print_funct_t xml_print_paging_stats(struct activity *a, int curr, int tab,
392                                        unsigned long long itv)
393 {
394         struct stats_paging
395                 *spc = (struct stats_paging *) a->buf[curr],
396                 *spp = (struct stats_paging *) a->buf[!curr];
397
398         xprintf(tab, "<paging per=\"second\" "
399                 "pgpgin=\"%.2f\" "
400                 "pgpgout=\"%.2f\" "
401                 "fault=\"%.2f\" "
402                 "majflt=\"%.2f\" "
403                 "pgfree=\"%.2f\" "
404                 "pgscank=\"%.2f\" "
405                 "pgscand=\"%.2f\" "
406                 "pgsteal=\"%.2f\" "
407                 "vmeff-percent=\"%.2f\"/>",
408                 S_VALUE(spp->pgpgin,        spc->pgpgin,        itv),
409                 S_VALUE(spp->pgpgout,       spc->pgpgout,       itv),
410                 S_VALUE(spp->pgfault,       spc->pgfault,       itv),
411                 S_VALUE(spp->pgmajfault,    spc->pgmajfault,    itv),
412                 S_VALUE(spp->pgfree,        spc->pgfree,        itv),
413                 S_VALUE(spp->pgscan_kswapd, spc->pgscan_kswapd, itv),
414                 S_VALUE(spp->pgscan_direct, spc->pgscan_direct, itv),
415                 S_VALUE(spp->pgsteal,       spc->pgsteal,       itv),
416                 (spc->pgscan_kswapd + spc->pgscan_direct -
417                  spp->pgscan_kswapd - spp->pgscan_direct) ?
418                 SP_VALUE(spp->pgsteal, spc->pgsteal,
419                          spc->pgscan_kswapd + spc->pgscan_direct -
420                          spp->pgscan_kswapd - spp->pgscan_direct) : 0.0);
421 }
422
423 /*
424  ***************************************************************************
425  * Display I/O and transfer rate statistics in XML.
426  *
427  * IN:
428  * @a           Activity structure with statistics.
429  * @curr        Index in array for current sample statistics.
430  * @tab         Indentation in XML output.
431  * @itv         Interval of time in 1/100th of a second.
432  ***************************************************************************
433  */
434 __print_funct_t xml_print_io_stats(struct activity *a, int curr, int tab,
435                                    unsigned long long itv)
436 {
437         struct stats_io
438                 *sic = (struct stats_io *) a->buf[curr],
439                 *sip = (struct stats_io *) a->buf[!curr];
440
441         xprintf(tab, "<io per=\"second\">");
442
443         /*
444          * If we get negative values, this is probably because
445          * one or more devices/filesystems have been unmounted.
446          * We display 0.0 in this case though we should rather tell
447          * the user that the value cannot be calculated here.
448          */
449         xprintf(++tab, "<tps>%.2f</tps>",
450                 sic->dk_drive < sip->dk_drive ? 0.0 :
451                 S_VALUE(sip->dk_drive, sic->dk_drive, itv));
452
453         xprintf(tab, "<io-reads rtps=\"%.2f\" bread=\"%.2f\"/>",
454                 sic->dk_drive_rio < sip->dk_drive_rio ? 0.0 :
455                 S_VALUE(sip->dk_drive_rio, sic->dk_drive_rio, itv),
456                 sic->dk_drive_rblk < sip->dk_drive_rblk ? 0.0 :
457                 S_VALUE(sip->dk_drive_rblk, sic->dk_drive_rblk, itv));
458
459         xprintf(tab, "<io-writes wtps=\"%.2f\" bwrtn=\"%.2f\"/>",
460                 sic->dk_drive_wio < sip->dk_drive_wio ? 0.0 :
461                 S_VALUE(sip->dk_drive_wio, sic->dk_drive_wio, itv),
462                 sic->dk_drive_wblk < sip->dk_drive_wblk ? 0.0 :
463                 S_VALUE(sip->dk_drive_wblk, sic->dk_drive_wblk, itv));
464
465         xprintf(tab, "<io-discard dtps=\"%.2f\" bdscd=\"%.2f\"/>",
466                 sic->dk_drive_dio < sip->dk_drive_dio ? 0.0 :
467                 S_VALUE(sip->dk_drive_dio, sic->dk_drive_dio, itv),
468                 sic->dk_drive_dblk < sip->dk_drive_dblk ? 0.0 :
469                 S_VALUE(sip->dk_drive_dblk, sic->dk_drive_dblk, itv));
470
471         xprintf(--tab, "</io>");
472 }
473
474 /*
475  ***************************************************************************
476  * Display memory statistics in XML.
477  *
478  * IN:
479  * @a           Activity structure with statistics.
480  * @curr        Index in array for current sample statistics.
481  * @tab         Indentation in XML output.
482  * @itv         Interval of time in 1/100th of a second.
483  ***************************************************************************
484  */
485 __print_funct_t xml_print_memory_stats(struct activity *a, int curr, int tab,
486                                        unsigned long long itv)
487 {
488         struct stats_memory
489                 *smc = (struct stats_memory *) a->buf[curr];
490         unsigned long long nousedmem;
491
492         xprintf(tab, "<memory unit=\"kB\">");
493
494         if (DISPLAY_MEMORY(a->opt_flags)) {
495
496                 nousedmem = smc->frmkb + smc->bufkb + smc->camkb + smc->slabkb;
497                 if (nousedmem > smc->tlmkb) {
498                         nousedmem = smc->tlmkb;
499                 }
500
501                 xprintf(++tab, "<memfree>%llu</memfree>",
502                         smc->frmkb);
503
504                 xprintf(tab, "<avail>%llu</avail>",
505                         smc->availablekb);
506
507                 xprintf(tab, "<memused>%llu</memused>",
508                         smc->tlmkb - nousedmem);
509
510                 xprintf(tab, "<memused-percent>%.2f</memused-percent>",
511                         smc->tlmkb ?
512                         SP_VALUE(nousedmem, smc->tlmkb, smc->tlmkb) :
513                         0.0);
514
515                 xprintf(tab, "<buffers>%llu</buffers>",
516                         smc->bufkb);
517
518                 xprintf(tab, "<cached>%llu</cached>",
519                         smc->camkb);
520
521                 xprintf(tab, "<commit>%llu</commit>",
522                         smc->comkb);
523
524                 xprintf(tab, "<commit-percent>%.2f</commit-percent>",
525                         (smc->tlmkb + smc->tlskb) ?
526                         SP_VALUE(0, smc->comkb, smc->tlmkb + smc->tlskb) :
527                         0.0);
528
529                 xprintf(tab, "<active>%llu</active>",
530                         smc->activekb);
531
532                 xprintf(tab, "<inactive>%llu</inactive>",
533                         smc->inactkb);
534
535                 xprintf(tab--, "<dirty>%llu</dirty>",
536                         smc->dirtykb);
537
538                 if (DISPLAY_MEM_ALL(a->opt_flags)) {
539                         xprintf(++tab, "<anonpg>%llu</anonpg>",
540                                 smc->anonpgkb);
541
542                         xprintf(tab, "<slab>%llu</slab>",
543                                 smc->slabkb);
544
545                         xprintf(tab, "<kstack>%llu</kstack>",
546                                 smc->kstackkb);
547
548                         xprintf(tab, "<pgtbl>%llu</pgtbl>",
549                                 smc->pgtblkb);
550
551                         xprintf(tab--, "<vmused>%llu</vmused>",
552                                 smc->vmusedkb);
553                 }
554         }
555
556         if (DISPLAY_SWAP(a->opt_flags)) {
557
558                 xprintf(++tab, "<swpfree>%llu</swpfree>",
559                         smc->frskb);
560
561                 xprintf(tab, "<swpused>%llu</swpused>",
562                         smc->tlskb - smc->frskb);
563
564                 xprintf(tab, "<swpused-percent>%.2f</swpused-percent>",
565                         smc->tlskb ?
566                         SP_VALUE(smc->frskb, smc->tlskb, smc->tlskb) :
567                         0.0);
568
569                 xprintf(tab, "<swpcad>%llu</swpcad>",
570                         smc->caskb);
571
572                 xprintf(tab--, "<swpcad-percent>%.2f</swpcad-percent>",
573                         (smc->tlskb - smc->frskb) ?
574                         SP_VALUE(0, smc->caskb, smc->tlskb - smc->frskb) :
575                         0.0);
576         }
577
578         xprintf(tab, "</memory>");
579 }
580
581 /*
582  ***************************************************************************
583  * Display kernel tables statistics in XML.
584  *
585  * IN:
586  * @a           Activity structure with statistics.
587  * @curr        Index in array for current sample statistics.
588  * @tab         Indentation in XML output.
589  * @itv         Interval of time in 1/100th of a second.
590  ***************************************************************************
591  */
592 __print_funct_t xml_print_ktables_stats(struct activity *a, int curr, int tab,
593                                         unsigned long long itv)
594 {
595         struct stats_ktables
596                 *skc = (struct stats_ktables *) a->buf[curr];
597
598         xprintf(tab, "<kernel "
599                 "dentunusd=\"%llu\" "
600                 "file-nr=\"%llu\" "
601                 "inode-nr=\"%llu\" "
602                 "pty-nr=\"%llu\"/>",
603                 skc->dentry_stat,
604                 skc->file_used,
605                 skc->inode_used,
606                 skc->pty_nr);
607 }
608
609 /*
610  ***************************************************************************
611  * Display queue and load statistics in XML.
612  *
613  * IN:
614  * @a           Activity structure with statistics.
615  * @curr        Index in array for current sample statistics.
616  * @tab         Indentation in XML output.
617  * @itv         Interval of time in 1/100th of a second.
618  ***************************************************************************
619  */
620 __print_funct_t xml_print_queue_stats(struct activity *a, int curr, int tab,
621                                       unsigned long long itv)
622 {
623         struct stats_queue
624                 *sqc = (struct stats_queue *) a->buf[curr];
625
626         xprintf(tab, "<queue "
627                 "runq-sz=\"%llu\" "
628                 "plist-sz=\"%llu\" "
629                 "ldavg-1=\"%.2f\" "
630                 "ldavg-5=\"%.2f\" "
631                 "ldavg-15=\"%.2f\" "
632                 "blocked=\"%llu\"/>",
633                 sqc->nr_running,
634                 sqc->nr_threads,
635                 (double) sqc->load_avg_1 / 100,
636                 (double) sqc->load_avg_5 / 100,
637                 (double) sqc->load_avg_15 / 100,
638                 sqc->procs_blocked);
639 }
640
641 /*
642  ***************************************************************************
643  * Display serial lines statistics in XML.
644  *
645  * IN:
646  * @a           Activity structure with statistics.
647  * @curr        Index in array for current sample statistics.
648  * @tab         Indentation in XML output.
649  * @itv         Interval of time in 1/100th of a second.
650  ***************************************************************************
651  */
652 __print_funct_t xml_print_serial_stats(struct activity *a, int curr, int tab,
653                                        unsigned long long itv)
654 {
655         int i, j, j0, found;
656         struct stats_serial *ssc, *ssp;
657
658         xprintf(tab++, "<serial per=\"second\">");
659
660         for (i = 0; i < a->nr[curr]; i++) {
661
662                 found = FALSE;
663
664                 if (a->nr[!curr] > 0) {
665                         ssc = (struct stats_serial *) ((char *) a->buf[curr]  + i * a->msize);
666
667                         /* Look for corresponding serial line in previous iteration */
668                         j = i;
669
670                         if (j >= a->nr[!curr]) {
671                                 j = a->nr[!curr] - 1;
672                         }
673
674                         j0 = j;
675
676                         do {
677                                 ssp = (struct stats_serial *) ((char *) a->buf[!curr] + j * a->msize);
678                                 if (ssc->line == ssp->line) {
679                                         found = TRUE;
680                                         break;
681                                 }
682                                 if (++j >= a->nr[!curr]) {
683                                         j = 0;
684                                 }
685                         }
686                         while (j != j0);
687                 }
688
689                 if (!found)
690                         continue;
691
692                 xprintf(tab, "<tty line=\"%d\" "
693                         "rcvin=\"%.2f\" "
694                         "xmtin=\"%.2f\" "
695                         "framerr=\"%.2f\" "
696                         "prtyerr=\"%.2f\" "
697                         "brk=\"%.2f\" "
698                         "ovrun=\"%.2f\"/>",
699                         ssc->line,
700                         S_VALUE(ssp->rx,      ssc->rx,      itv),
701                         S_VALUE(ssp->tx,      ssc->tx,      itv),
702                         S_VALUE(ssp->frame,   ssc->frame,   itv),
703                         S_VALUE(ssp->parity,  ssc->parity,  itv),
704                         S_VALUE(ssp->brk,     ssc->brk,     itv),
705                         S_VALUE(ssp->overrun, ssc->overrun, itv));
706         }
707
708         xprintf(--tab, "</serial>");
709 }
710
711 /*
712  ***************************************************************************
713  * Display disks statistics in XML.
714  *
715  * IN:
716  * @a           Activity structure with statistics.
717  * @curr        Index in array for current sample statistics.
718  * @tab         Indentation in XML output.
719  * @itv         Interval of time in 1/100th of a second.
720  ***************************************************************************
721  */
722 __print_funct_t xml_print_disk_stats(struct activity *a, int curr, int tab,
723                                      unsigned long long itv)
724 {
725         int i, j;
726         struct stats_disk *sdc, *sdp, sdpzero;
727         struct ext_disk_stats xds;
728         char *dev_name;
729
730         memset(&sdpzero, 0, STATS_DISK_SIZE);
731
732         xprintf(tab++, "<disk per=\"second\">");
733
734         for (i = 0; i < a->nr[curr]; i++) {
735
736                 sdc = (struct stats_disk *) ((char *) a->buf[curr] + i * a->msize);
737
738                 j = check_disk_reg(a, curr, !curr, i);
739                 if (j < 0) {
740                         /* This is a newly registered interface. Previous stats are zero */
741                         sdp = &sdpzero;
742                 }
743                 else {
744                         sdp = (struct stats_disk *) ((char *) a->buf[!curr] + j * a->msize);
745                 }
746
747                 /* Get device name */
748                 dev_name = get_device_name(sdc->major, sdc->minor, sdc->wwn, sdc->part_nr,
749                                            DISPLAY_PRETTY(flags), DISPLAY_PERSIST_NAME_S(flags),
750                                            USE_STABLE_ID(flags), NULL);
751
752                 if (a->item_list != NULL) {
753                         /* A list of devices has been entered on the command line */
754                         if (!search_list_item(a->item_list, dev_name))
755                                 /* Device not found */
756                                 continue;
757                 }
758
759                 /* Compute extended statistics values */
760                 compute_ext_disk_stats(sdc, sdp, itv, &xds);
761
762                 xprintf(tab, "<disk-device dev=\"%s\" "
763                         "tps=\"%.2f\" "
764                         "rd_sec=\"%.2f\" "
765                         "wr_sec=\"%.2f\" "
766                         "dc_sec=\"%.2f\" "
767                         "rkB=\"%.2f\" "
768                         "wkB=\"%.2f\" "
769                         "dkB=\"%.2f\" "
770                         "avgrq-sz=\"%.2f\" "
771                         "areq-sz=\"%.2f\" "
772                         "avgqu-sz=\"%.2f\" "
773                         "aqu-sz=\"%.2f\" "
774                         "await=\"%.2f\" "
775                         "util-percent=\"%.2f\"/>",
776                         /* Confusion possible here between index and minor numbers */
777                         dev_name,
778                         S_VALUE(sdp->nr_ios, sdc->nr_ios, itv),
779                         S_VALUE(sdp->rd_sect, sdc->rd_sect, itv), /* Unit = sectors (for backward compatibility) */
780                         S_VALUE(sdp->wr_sect, sdc->wr_sect, itv),
781                         S_VALUE(sdp->dc_sect, sdc->dc_sect, itv),
782                         S_VALUE(sdp->rd_sect, sdc->rd_sect, itv) / 2,
783                         S_VALUE(sdp->wr_sect, sdc->wr_sect, itv) / 2,
784                         S_VALUE(sdp->dc_sect, sdc->dc_sect, itv) / 2,
785                         /* See iostat for explanations */
786                         xds.arqsz,      /* Unit = sectors (for backward compatibility) */
787                         xds.arqsz / 2,
788                         S_VALUE(sdp->rq_ticks, sdc->rq_ticks, itv) / 1000.0,    /* For backward compatibility */
789                         S_VALUE(sdp->rq_ticks, sdc->rq_ticks, itv) / 1000.0,
790                         xds.await,
791                         xds.util / 10.0);
792         }
793
794         xprintf(--tab, "</disk>");
795 }
796
797 /*
798  ***************************************************************************
799  * Display network interfaces statistics in XML.
800  *
801  * IN:
802  * @a           Activity structure with statistics.
803  * @curr        Index in array for current sample statistics.
804  * @tab         Indentation in XML output.
805  * @itv         Interval of time in 1/100th of a second.
806  ***************************************************************************
807  */
808 __print_funct_t xml_print_net_dev_stats(struct activity *a, int curr, int tab,
809                                         unsigned long long itv)
810 {
811         int i, j;
812         struct stats_net_dev *sndc, *sndp, sndzero;
813         double rxkb, txkb, ifutil;
814
815         if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
816                 goto close_xml_markup;
817
818         memset(&sndzero, 0, STATS_NET_DEV_SIZE);
819
820         xml_markup_network(tab, OPEN_XML_MARKUP);
821         tab++;
822
823         for (i = 0; i < a->nr[curr]; i++) {
824
825                 sndc = (struct stats_net_dev *) ((char *) a->buf[curr] + i * a->msize);
826
827                 if (a->item_list != NULL) {
828                         /* A list of devices has been entered on the command line */
829                         if (!search_list_item(a->item_list, sndc->interface))
830                                 /* Device not found */
831                                 continue;
832                 }
833
834                 j = check_net_dev_reg(a, curr, !curr, i);
835                 if (j < 0) {
836                         /* This is a newly registered interface. Previous stats are zero */
837                         sndp = &sndzero;
838                 }
839                 else {
840                         sndp = (struct stats_net_dev *) ((char *) a->buf[!curr] + j * a->msize);
841                 }
842
843                 rxkb = S_VALUE(sndp->rx_bytes, sndc->rx_bytes, itv);
844                 txkb = S_VALUE(sndp->tx_bytes, sndc->tx_bytes, itv);
845                 ifutil = compute_ifutil(sndc, rxkb, txkb);
846
847                 xprintf(tab, "<net-dev iface=\"%s\" "
848                         "rxpck=\"%.2f\" "
849                         "txpck=\"%.2f\" "
850                         "rxkB=\"%.2f\" "
851                         "txkB=\"%.2f\" "
852                         "rxcmp=\"%.2f\" "
853                         "txcmp=\"%.2f\" "
854                         "rxmcst=\"%.2f\" "
855                         "ifutil-percent=\"%.2f\"/>",
856                         sndc->interface,
857                         S_VALUE(sndp->rx_packets,    sndc->rx_packets,    itv),
858                         S_VALUE(sndp->tx_packets,    sndc->tx_packets,    itv),
859                         rxkb / 1024,
860                         txkb / 1024,
861                         S_VALUE(sndp->rx_compressed, sndc->rx_compressed, itv),
862                         S_VALUE(sndp->tx_compressed, sndc->tx_compressed, itv),
863                         S_VALUE(sndp->multicast,     sndc->multicast,     itv),
864                         ifutil);
865         }
866         tab--;
867
868 close_xml_markup:
869         if (CLOSE_MARKUP(a->options)) {
870                 xml_markup_network(tab, CLOSE_XML_MARKUP);
871         }
872 }
873
874 /*
875  ***************************************************************************
876  * Display network interfaces errors statistics in XML.
877  *
878  * IN:
879  * @a           Activity structure with statistics.
880  * @curr        Index in array for current sample statistics.
881  * @tab         Indentation in XML output.
882  * @itv         Interval of time in 1/100th of a second.
883  ***************************************************************************
884  */
885 __print_funct_t xml_print_net_edev_stats(struct activity *a, int curr, int tab,
886                                          unsigned long long itv)
887 {
888         int i, j;
889         struct stats_net_edev *snedc, *snedp, snedzero;
890
891         if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
892                 goto close_xml_markup;
893
894         memset(&snedzero, 0, STATS_NET_EDEV_SIZE);
895
896         xml_markup_network(tab, OPEN_XML_MARKUP);
897         tab++;
898
899         for (i = 0; i < a->nr[curr]; i++) {
900
901                 snedc = (struct stats_net_edev *) ((char *) a->buf[curr] + i * a->msize);
902
903                 if (a->item_list != NULL) {
904                         /* A list of devices has been entered on the command line */
905                         if (!search_list_item(a->item_list, snedc->interface))
906                                 /* Device not found */
907                                 continue;
908                 }
909
910                 j = check_net_edev_reg(a, curr, !curr, i);
911                 if (j < 0) {
912                         /* This is a newly registered interface. Previous stats are zero */
913                         snedp = &snedzero;
914                 }
915                 else {
916                         snedp = (struct stats_net_edev *) ((char *) a->buf[!curr] + j * a->msize);
917                 }
918
919                 xprintf(tab, "<net-edev iface=\"%s\" "
920                         "rxerr=\"%.2f\" "
921                         "txerr=\"%.2f\" "
922                         "coll=\"%.2f\" "
923                         "rxdrop=\"%.2f\" "
924                         "txdrop=\"%.2f\" "
925                         "txcarr=\"%.2f\" "
926                         "rxfram=\"%.2f\" "
927                         "rxfifo=\"%.2f\" "
928                         "txfifo=\"%.2f\"/>",
929                         snedc->interface,
930                         S_VALUE(snedp->rx_errors,         snedc->rx_errors,         itv),
931                         S_VALUE(snedp->tx_errors,         snedc->tx_errors,         itv),
932                         S_VALUE(snedp->collisions,        snedc->collisions,        itv),
933                         S_VALUE(snedp->rx_dropped,        snedc->rx_dropped,        itv),
934                         S_VALUE(snedp->tx_dropped,        snedc->tx_dropped,        itv),
935                         S_VALUE(snedp->tx_carrier_errors, snedc->tx_carrier_errors, itv),
936                         S_VALUE(snedp->rx_frame_errors,   snedc->rx_frame_errors,   itv),
937                         S_VALUE(snedp->rx_fifo_errors,    snedc->rx_fifo_errors,    itv),
938                         S_VALUE(snedp->tx_fifo_errors,    snedc->tx_fifo_errors,    itv));
939         }
940         tab--;
941
942 close_xml_markup:
943         if (CLOSE_MARKUP(a->options)) {
944                 xml_markup_network(tab, CLOSE_XML_MARKUP);
945         }
946 }
947
948 /*
949  ***************************************************************************
950  * Display NFS client statistics in XML.
951  *
952  * IN:
953  * @a           Activity structure with statistics.
954  * @curr        Index in array for current sample statistics.
955  * @tab         Indentation in XML output.
956  * @itv         Interval of time in 1/100th of a second.
957  ***************************************************************************
958  */
959 __print_funct_t xml_print_net_nfs_stats(struct activity *a, int curr, int tab,
960                                         unsigned long long itv)
961 {
962         struct stats_net_nfs
963                 *snnc = (struct stats_net_nfs *) a->buf[curr],
964                 *snnp = (struct stats_net_nfs *) a->buf[!curr];
965
966         if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
967                 goto close_xml_markup;
968
969         xml_markup_network(tab, OPEN_XML_MARKUP);
970         tab++;
971
972         xprintf(tab, "<net-nfs "
973                 "call=\"%.2f\" "
974                 "retrans=\"%.2f\" "
975                 "read=\"%.2f\" "
976                 "write=\"%.2f\" "
977                 "access=\"%.2f\" "
978                 "getatt=\"%.2f\"/>",
979                 S_VALUE(snnp->nfs_rpccnt,     snnc->nfs_rpccnt,     itv),
980                 S_VALUE(snnp->nfs_rpcretrans, snnc->nfs_rpcretrans, itv),
981                 S_VALUE(snnp->nfs_readcnt,    snnc->nfs_readcnt,    itv),
982                 S_VALUE(snnp->nfs_writecnt,   snnc->nfs_writecnt,   itv),
983                 S_VALUE(snnp->nfs_accesscnt,  snnc->nfs_accesscnt,  itv),
984                 S_VALUE(snnp->nfs_getattcnt,  snnc->nfs_getattcnt,  itv));
985         tab--;
986
987 close_xml_markup:
988         if (CLOSE_MARKUP(a->options)) {
989                 xml_markup_network(tab, CLOSE_XML_MARKUP);
990         }
991 }
992
993 /*
994  ***************************************************************************
995  * Display NFS server statistics in XML.
996  *
997  * IN:
998  * @a           Activity structure with statistics.
999  * @curr        Index in array for current sample statistics.
1000  * @tab         Indentation in XML output.
1001  * @itv         Interval of time in 1/100th of a second.
1002  ***************************************************************************
1003  */
1004 __print_funct_t xml_print_net_nfsd_stats(struct activity *a, int curr, int tab,
1005                                          unsigned long long itv)
1006 {
1007         struct stats_net_nfsd
1008                 *snndc = (struct stats_net_nfsd *) a->buf[curr],
1009                 *snndp = (struct stats_net_nfsd *) a->buf[!curr];
1010
1011         if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
1012                 goto close_xml_markup;
1013
1014         xml_markup_network(tab, OPEN_XML_MARKUP);
1015         tab++;
1016
1017         xprintf(tab, "<net-nfsd "
1018                 "scall=\"%.2f\" "
1019                 "badcall=\"%.2f\" "
1020                 "packet=\"%.2f\" "
1021                 "udp=\"%.2f\" "
1022                 "tcp=\"%.2f\" "
1023                 "hit=\"%.2f\" "
1024                 "miss=\"%.2f\" "
1025                 "sread=\"%.2f\" "
1026                 "swrite=\"%.2f\" "
1027                 "saccess=\"%.2f\" "
1028                 "sgetatt=\"%.2f\"/>",
1029                 S_VALUE(snndp->nfsd_rpccnt,    snndc->nfsd_rpccnt,    itv),
1030                 S_VALUE(snndp->nfsd_rpcbad,    snndc->nfsd_rpcbad,    itv),
1031                 S_VALUE(snndp->nfsd_netcnt,    snndc->nfsd_netcnt,    itv),
1032                 S_VALUE(snndp->nfsd_netudpcnt, snndc->nfsd_netudpcnt, itv),
1033                 S_VALUE(snndp->nfsd_nettcpcnt, snndc->nfsd_nettcpcnt, itv),
1034                 S_VALUE(snndp->nfsd_rchits,    snndc->nfsd_rchits,    itv),
1035                 S_VALUE(snndp->nfsd_rcmisses,  snndc->nfsd_rcmisses,  itv),
1036                 S_VALUE(snndp->nfsd_readcnt,   snndc->nfsd_readcnt,   itv),
1037                 S_VALUE(snndp->nfsd_writecnt,  snndc->nfsd_writecnt,  itv),
1038                 S_VALUE(snndp->nfsd_accesscnt, snndc->nfsd_accesscnt, itv),
1039                 S_VALUE(snndp->nfsd_getattcnt, snndc->nfsd_getattcnt, itv));
1040         tab--;
1041
1042 close_xml_markup:
1043         if (CLOSE_MARKUP(a->options)) {
1044                 xml_markup_network(tab, CLOSE_XML_MARKUP);
1045         }
1046 }
1047
1048 /*
1049  ***************************************************************************
1050  * Display network socket statistics in XML.
1051  *
1052  * IN:
1053  * @a           Activity structure with statistics.
1054  * @curr        Index in array for current sample statistics.
1055  * @tab         Indentation in XML output.
1056  * @itv         Interval of time in 1/100th of a second.
1057  ***************************************************************************
1058  */
1059 __print_funct_t xml_print_net_sock_stats(struct activity *a, int curr, int tab,
1060                                          unsigned long long itv)
1061 {
1062         struct stats_net_sock
1063                 *snsc = (struct stats_net_sock *) a->buf[curr];
1064
1065         if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
1066                 goto close_xml_markup;
1067
1068         xml_markup_network(tab, OPEN_XML_MARKUP);
1069         tab++;
1070
1071         xprintf(tab, "<net-sock "
1072                 "totsck=\"%u\" "
1073                 "tcpsck=\"%u\" "
1074                 "udpsck=\"%u\" "
1075                 "rawsck=\"%u\" "
1076                 "ip-frag=\"%u\" "
1077                 "tcp-tw=\"%u\"/>",
1078                 snsc->sock_inuse,
1079                 snsc->tcp_inuse,
1080                 snsc->udp_inuse,
1081                 snsc->raw_inuse,
1082                 snsc->frag_inuse,
1083                 snsc->tcp_tw);
1084         tab--;
1085
1086 close_xml_markup:
1087         if (CLOSE_MARKUP(a->options)) {
1088                 xml_markup_network(tab, CLOSE_XML_MARKUP);
1089         }
1090 }
1091
1092 /*
1093  ***************************************************************************
1094  * Display IP network statistics in XML.
1095  *
1096  * IN:
1097  * @a           Activity structure with statistics.
1098  * @curr        Index in array for current sample statistics.
1099  * @tab         Indentation in XML output.
1100  * @itv         Interval of time in 1/100th of a second.
1101  ***************************************************************************
1102  */
1103 __print_funct_t xml_print_net_ip_stats(struct activity *a, int curr, int tab,
1104                                        unsigned long long itv)
1105 {
1106         struct stats_net_ip
1107                 *snic = (struct stats_net_ip *) a->buf[curr],
1108                 *snip = (struct stats_net_ip *) a->buf[!curr];
1109
1110         if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
1111                 goto close_xml_markup;
1112
1113         xml_markup_network(tab, OPEN_XML_MARKUP);
1114         tab++;
1115
1116         xprintf(tab, "<net-ip "
1117                 "irec=\"%.2f\" "
1118                 "fwddgm=\"%.2f\" "
1119                 "idel=\"%.2f\" "
1120                 "orq=\"%.2f\" "
1121                 "asmrq=\"%.2f\" "
1122                 "asmok=\"%.2f\" "
1123                 "fragok=\"%.2f\" "
1124                 "fragcrt=\"%.2f\"/>",
1125                 S_VALUE(snip->InReceives,    snic->InReceives,    itv),
1126                 S_VALUE(snip->ForwDatagrams, snic->ForwDatagrams, itv),
1127                 S_VALUE(snip->InDelivers,    snic->InDelivers,    itv),
1128                 S_VALUE(snip->OutRequests,   snic->OutRequests,   itv),
1129                 S_VALUE(snip->ReasmReqds,    snic->ReasmReqds,    itv),
1130                 S_VALUE(snip->ReasmOKs,      snic->ReasmOKs,      itv),
1131                 S_VALUE(snip->FragOKs,       snic->FragOKs,       itv),
1132                 S_VALUE(snip->FragCreates,   snic->FragCreates,   itv));
1133         tab--;
1134
1135 close_xml_markup:
1136         if (CLOSE_MARKUP(a->options)) {
1137                 xml_markup_network(tab, CLOSE_XML_MARKUP);
1138         }
1139 }
1140
1141 /*
1142  ***************************************************************************
1143  * Display IP network errors statistics in XML.
1144  *
1145  * IN:
1146  * @a           Activity structure with statistics.
1147  * @curr        Index in array for current sample statistics.
1148  * @tab         Indentation in XML output.
1149  * @itv         Interval of time in 1/100th of a second.
1150  ***************************************************************************
1151  */
1152 __print_funct_t xml_print_net_eip_stats(struct activity *a, int curr, int tab,
1153                                         unsigned long long itv)
1154 {
1155         struct stats_net_eip
1156                 *sneic = (struct stats_net_eip *) a->buf[curr],
1157                 *sneip = (struct stats_net_eip *) a->buf[!curr];
1158
1159         if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
1160                 goto close_xml_markup;
1161
1162         xml_markup_network(tab, OPEN_XML_MARKUP);
1163         tab++;
1164
1165         xprintf(tab, "<net-eip "
1166                 "ihdrerr=\"%.2f\" "
1167                 "iadrerr=\"%.2f\" "
1168                 "iukwnpr=\"%.2f\" "
1169                 "idisc=\"%.2f\" "
1170                 "odisc=\"%.2f\" "
1171                 "onort=\"%.2f\" "
1172                 "asmf=\"%.2f\" "
1173                 "fragf=\"%.2f\"/>",
1174                 S_VALUE(sneip->InHdrErrors,     sneic->InHdrErrors,     itv),
1175                 S_VALUE(sneip->InAddrErrors,    sneic->InAddrErrors,    itv),
1176                 S_VALUE(sneip->InUnknownProtos, sneic->InUnknownProtos, itv),
1177                 S_VALUE(sneip->InDiscards,      sneic->InDiscards,      itv),
1178                 S_VALUE(sneip->OutDiscards,     sneic->OutDiscards,     itv),
1179                 S_VALUE(sneip->OutNoRoutes,     sneic->OutNoRoutes,     itv),
1180                 S_VALUE(sneip->ReasmFails,      sneic->ReasmFails,      itv),
1181                 S_VALUE(sneip->FragFails,       sneic->FragFails,       itv));
1182         tab--;
1183
1184 close_xml_markup:
1185         if (CLOSE_MARKUP(a->options)) {
1186                 xml_markup_network(tab, CLOSE_XML_MARKUP);
1187         }
1188 }
1189
1190 /*
1191  ***************************************************************************
1192  * Display ICMP network statistics in XML.
1193  *
1194  * IN:
1195  * @a           Activity structure with statistics.
1196  * @curr        Index in array for current sample statistics.
1197  * @tab         Indentation in XML output.
1198  * @itv         Interval of time in 1/100th of a second.
1199  ***************************************************************************
1200  */
1201 __print_funct_t xml_print_net_icmp_stats(struct activity *a, int curr, int tab,
1202                                          unsigned long long itv)
1203 {
1204         struct stats_net_icmp
1205                 *snic = (struct stats_net_icmp *) a->buf[curr],
1206                 *snip = (struct stats_net_icmp *) a->buf[!curr];
1207
1208         if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
1209                 goto close_xml_markup;
1210
1211         xml_markup_network(tab, OPEN_XML_MARKUP);
1212         tab++;
1213
1214         xprintf(tab, "<net-icmp "
1215                 "imsg=\"%.2f\" "
1216                 "omsg=\"%.2f\" "
1217                 "iech=\"%.2f\" "
1218                 "iechr=\"%.2f\" "
1219                 "oech=\"%.2f\" "
1220                 "oechr=\"%.2f\" "
1221                 "itm=\"%.2f\" "
1222                 "itmr=\"%.2f\" "
1223                 "otm=\"%.2f\" "
1224                 "otmr=\"%.2f\" "
1225                 "iadrmk=\"%.2f\" "
1226                 "iadrmkr=\"%.2f\" "
1227                 "oadrmk=\"%.2f\" "
1228                 "oadrmkr=\"%.2f\"/>",
1229                 S_VALUE(snip->InMsgs,           snic->InMsgs,           itv),
1230                 S_VALUE(snip->OutMsgs,          snic->OutMsgs,          itv),
1231                 S_VALUE(snip->InEchos,          snic->InEchos,          itv),
1232                 S_VALUE(snip->InEchoReps,       snic->InEchoReps,       itv),
1233                 S_VALUE(snip->OutEchos,         snic->OutEchos,         itv),
1234                 S_VALUE(snip->OutEchoReps,      snic->OutEchoReps,      itv),
1235                 S_VALUE(snip->InTimestamps,     snic->InTimestamps,     itv),
1236                 S_VALUE(snip->InTimestampReps,  snic->InTimestampReps,  itv),
1237                 S_VALUE(snip->OutTimestamps,    snic->OutTimestamps,    itv),
1238                 S_VALUE(snip->OutTimestampReps, snic->OutTimestampReps, itv),
1239                 S_VALUE(snip->InAddrMasks,      snic->InAddrMasks,      itv),
1240                 S_VALUE(snip->InAddrMaskReps,   snic->InAddrMaskReps,   itv),
1241                 S_VALUE(snip->OutAddrMasks,     snic->OutAddrMasks,     itv),
1242                 S_VALUE(snip->OutAddrMaskReps,  snic->OutAddrMaskReps,  itv));
1243         tab--;
1244
1245 close_xml_markup:
1246         if (CLOSE_MARKUP(a->options)) {
1247                 xml_markup_network(tab, CLOSE_XML_MARKUP);
1248         }
1249 }
1250
1251 /*
1252  ***************************************************************************
1253  * Display ICMP error messages statistics in XML.
1254  *
1255  * IN:
1256  * @a           Activity structure with statistics.
1257  * @curr        Index in array for current sample statistics.
1258  * @tab         Indentation in XML output.
1259  * @itv         Interval of time in 1/100th of a second.
1260  ***************************************************************************
1261  */
1262 __print_funct_t xml_print_net_eicmp_stats(struct activity *a, int curr, int tab,
1263                                           unsigned long long itv)
1264 {
1265         struct stats_net_eicmp
1266                 *sneic = (struct stats_net_eicmp *) a->buf[curr],
1267                 *sneip = (struct stats_net_eicmp *) a->buf[!curr];
1268
1269         if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
1270                 goto close_xml_markup;
1271
1272         xml_markup_network(tab, OPEN_XML_MARKUP);
1273         tab++;
1274
1275         xprintf(tab, "<net-eicmp "
1276                 "ierr=\"%.2f\" "
1277                 "oerr=\"%.2f\" "
1278                 "idstunr=\"%.2f\" "
1279                 "odstunr=\"%.2f\" "
1280                 "itmex=\"%.2f\" "
1281                 "otmex=\"%.2f\" "
1282                 "iparmpb=\"%.2f\" "
1283                 "oparmpb=\"%.2f\" "
1284                 "isrcq=\"%.2f\" "
1285                 "osrcq=\"%.2f\" "
1286                 "iredir=\"%.2f\" "
1287                 "oredir=\"%.2f\"/>",
1288                 S_VALUE(sneip->InErrors,        sneic->InErrors,        itv),
1289                 S_VALUE(sneip->OutErrors,       sneic->OutErrors,       itv),
1290                 S_VALUE(sneip->InDestUnreachs,  sneic->InDestUnreachs,  itv),
1291                 S_VALUE(sneip->OutDestUnreachs, sneic->OutDestUnreachs, itv),
1292                 S_VALUE(sneip->InTimeExcds,     sneic->InTimeExcds,     itv),
1293                 S_VALUE(sneip->OutTimeExcds,    sneic->OutTimeExcds,    itv),
1294                 S_VALUE(sneip->InParmProbs,     sneic->InParmProbs,     itv),
1295                 S_VALUE(sneip->OutParmProbs,    sneic->OutParmProbs,    itv),
1296                 S_VALUE(sneip->InSrcQuenchs,    sneic->InSrcQuenchs,    itv),
1297                 S_VALUE(sneip->OutSrcQuenchs,   sneic->OutSrcQuenchs,   itv),
1298                 S_VALUE(sneip->InRedirects,     sneic->InRedirects,     itv),
1299                 S_VALUE(sneip->OutRedirects,    sneic->OutRedirects,    itv));
1300         tab--;
1301
1302 close_xml_markup:
1303         if (CLOSE_MARKUP(a->options)) {
1304                 xml_markup_network(tab, CLOSE_XML_MARKUP);
1305         }
1306 }
1307
1308 /*
1309  ***************************************************************************
1310  * Display TCP network statistics in XML.
1311  *
1312  * IN:
1313  * @a           Activity structure with statistics.
1314  * @curr        Index in array for current sample statistics.
1315  * @tab         Indentation in XML output.
1316  * @itv         Interval of time in 1/100th of a second.
1317  ***************************************************************************
1318  */
1319 __print_funct_t xml_print_net_tcp_stats(struct activity *a, int curr, int tab,
1320                                         unsigned long long itv)
1321 {
1322         struct stats_net_tcp
1323                 *sntc = (struct stats_net_tcp *) a->buf[curr],
1324                 *sntp = (struct stats_net_tcp *) a->buf[!curr];
1325
1326         if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
1327                 goto close_xml_markup;
1328
1329         xml_markup_network(tab, OPEN_XML_MARKUP);
1330         tab++;
1331
1332         xprintf(tab, "<net-tcp "
1333                 "active=\"%.2f\" "
1334                 "passive=\"%.2f\" "
1335                 "iseg=\"%.2f\" "
1336                 "oseg=\"%.2f\"/>",
1337                 S_VALUE(sntp->ActiveOpens,  sntc->ActiveOpens,  itv),
1338                 S_VALUE(sntp->PassiveOpens, sntc->PassiveOpens, itv),
1339                 S_VALUE(sntp->InSegs,       sntc->InSegs,       itv),
1340                 S_VALUE(sntp->OutSegs,      sntc->OutSegs,      itv));
1341         tab--;
1342
1343 close_xml_markup:
1344         if (CLOSE_MARKUP(a->options)) {
1345                 xml_markup_network(tab, CLOSE_XML_MARKUP);
1346         }
1347 }
1348
1349 /*
1350  ***************************************************************************
1351  * Display TCP network errors statistics in XML.
1352  *
1353  * IN:
1354  * @a           Activity structure with statistics.
1355  * @curr        Index in array for current sample statistics.
1356  * @tab         Indentation in XML output.
1357  * @itv         Interval of time in 1/100th of a second.
1358  ***************************************************************************
1359  */
1360 __print_funct_t xml_print_net_etcp_stats(struct activity *a, int curr, int tab,
1361                                          unsigned long long itv)
1362 {
1363         struct stats_net_etcp
1364                 *snetc = (struct stats_net_etcp *) a->buf[curr],
1365                 *snetp = (struct stats_net_etcp *) a->buf[!curr];
1366
1367         if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
1368                 goto close_xml_markup;
1369
1370         xml_markup_network(tab, OPEN_XML_MARKUP);
1371         tab++;
1372
1373         xprintf(tab, "<net-etcp "
1374                 "atmptf=\"%.2f\" "
1375                 "estres=\"%.2f\" "
1376                 "retrans=\"%.2f\" "
1377                 "isegerr=\"%.2f\" "
1378                 "orsts=\"%.2f\"/>",
1379                 S_VALUE(snetp->AttemptFails, snetc->AttemptFails,  itv),
1380                 S_VALUE(snetp->EstabResets,  snetc->EstabResets,  itv),
1381                 S_VALUE(snetp->RetransSegs,  snetc->RetransSegs,  itv),
1382                 S_VALUE(snetp->InErrs,       snetc->InErrs,  itv),
1383                 S_VALUE(snetp->OutRsts,      snetc->OutRsts,  itv));
1384         tab--;
1385
1386 close_xml_markup:
1387         if (CLOSE_MARKUP(a->options)) {
1388                 xml_markup_network(tab, CLOSE_XML_MARKUP);
1389         }
1390 }
1391
1392 /*
1393  ***************************************************************************
1394  * Display UDP network statistics in XML.
1395  *
1396  * IN:
1397  * @a           Activity structure with statistics.
1398  * @curr        Index in array for current sample statistics.
1399  * @tab         Indentation in XML output.
1400  * @itv         Interval of time in 1/100th of a second.
1401  ***************************************************************************
1402  */
1403 __print_funct_t xml_print_net_udp_stats(struct activity *a, int curr, int tab,
1404                                         unsigned long long itv)
1405 {
1406         struct stats_net_udp
1407                 *snuc = (struct stats_net_udp *) a->buf[curr],
1408                 *snup = (struct stats_net_udp *) a->buf[!curr];
1409
1410         if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
1411                 goto close_xml_markup;
1412
1413         xml_markup_network(tab, OPEN_XML_MARKUP);
1414         tab++;
1415
1416         xprintf(tab, "<net-udp "
1417                 "idgm=\"%.2f\" "
1418                 "odgm=\"%.2f\" "
1419                 "noport=\"%.2f\" "
1420                 "idgmerr=\"%.2f\"/>",
1421                 S_VALUE(snup->InDatagrams,  snuc->InDatagrams,  itv),
1422                 S_VALUE(snup->OutDatagrams, snuc->OutDatagrams, itv),
1423                 S_VALUE(snup->NoPorts,      snuc->NoPorts,      itv),
1424                 S_VALUE(snup->InErrors,     snuc->InErrors,     itv));
1425         tab--;
1426
1427 close_xml_markup:
1428         if (CLOSE_MARKUP(a->options)) {
1429                 xml_markup_network(tab, CLOSE_XML_MARKUP);
1430         }
1431 }
1432
1433 /*
1434  ***************************************************************************
1435  * Display IPv6 network socket statistics in XML.
1436  *
1437  * IN:
1438  * @a           Activity structure with statistics.
1439  * @curr        Index in array for current sample statistics.
1440  * @tab         Indentation in XML output.
1441  * @itv         Interval of time in 1/100th of a second.
1442  ***************************************************************************
1443  */
1444 __print_funct_t xml_print_net_sock6_stats(struct activity *a, int curr, int tab,
1445                                           unsigned long long itv)
1446 {
1447         struct stats_net_sock6
1448                 *snsc = (struct stats_net_sock6 *) a->buf[curr];
1449
1450         if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
1451                 goto close_xml_markup;
1452
1453         xml_markup_network(tab, OPEN_XML_MARKUP);
1454         tab++;
1455
1456         xprintf(tab, "<net-sock6 "
1457                 "tcp6sck=\"%u\" "
1458                 "udp6sck=\"%u\" "
1459                 "raw6sck=\"%u\" "
1460                 "ip6-frag=\"%u\"/>",
1461                 snsc->tcp6_inuse,
1462                 snsc->udp6_inuse,
1463                 snsc->raw6_inuse,
1464                 snsc->frag6_inuse);
1465         tab--;
1466
1467 close_xml_markup:
1468         if (CLOSE_MARKUP(a->options)) {
1469                 xml_markup_network(tab, CLOSE_XML_MARKUP);
1470         }
1471 }
1472
1473 /*
1474  ***************************************************************************
1475  * Display IPv6 network statistics in XML.
1476  *
1477  * IN:
1478  * @a           Activity structure with statistics.
1479  * @curr        Index in array for current sample statistics.
1480  * @tab         Indentation in XML output.
1481  * @itv         Interval of time in 1/100th of a second.
1482  ***************************************************************************
1483  */
1484 __print_funct_t xml_print_net_ip6_stats(struct activity *a, int curr, int tab,
1485                                         unsigned long long itv)
1486 {
1487         struct stats_net_ip6
1488                 *snic = (struct stats_net_ip6 *) a->buf[curr],
1489                 *snip = (struct stats_net_ip6 *) a->buf[!curr];
1490
1491         if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
1492                 goto close_xml_markup;
1493
1494         xml_markup_network(tab, OPEN_XML_MARKUP);
1495         tab++;
1496
1497         xprintf(tab, "<net-ip6 "
1498                 "irec6=\"%.2f\" "
1499                 "fwddgm6=\"%.2f\" "
1500                 "idel6=\"%.2f\" "
1501                 "orq6=\"%.2f\" "
1502                 "asmrq6=\"%.2f\" "
1503                 "asmok6=\"%.2f\" "
1504                 "imcpck6=\"%.2f\" "
1505                 "omcpck6=\"%.2f\" "
1506                 "fragok6=\"%.2f\" "
1507                 "fragcr6=\"%.2f\"/>",
1508                 S_VALUE(snip->InReceives6,       snic->InReceives6,       itv),
1509                 S_VALUE(snip->OutForwDatagrams6, snic->OutForwDatagrams6, itv),
1510                 S_VALUE(snip->InDelivers6,       snic->InDelivers6,       itv),
1511                 S_VALUE(snip->OutRequests6,      snic->OutRequests6,      itv),
1512                 S_VALUE(snip->ReasmReqds6,       snic->ReasmReqds6,       itv),
1513                 S_VALUE(snip->ReasmOKs6,         snic->ReasmOKs6,         itv),
1514                 S_VALUE(snip->InMcastPkts6,      snic->InMcastPkts6,      itv),
1515                 S_VALUE(snip->OutMcastPkts6,     snic->OutMcastPkts6,     itv),
1516                 S_VALUE(snip->FragOKs6,          snic->FragOKs6,          itv),
1517                 S_VALUE(snip->FragCreates6,      snic->FragCreates6,      itv));
1518         tab--;
1519
1520 close_xml_markup:
1521         if (CLOSE_MARKUP(a->options)) {
1522                 xml_markup_network(tab, CLOSE_XML_MARKUP);
1523         }
1524 }
1525
1526 /*
1527  ***************************************************************************
1528  * Display IPv6 network errors statistics in XML.
1529  *
1530  * IN:
1531  * @a           Activity structure with statistics.
1532  * @curr        Index in array for current sample statistics.
1533  * @tab         Indentation in XML output.
1534  * @itv         Interval of time in 1/100th of a second.
1535  ***************************************************************************
1536  */
1537 __print_funct_t xml_print_net_eip6_stats(struct activity *a, int curr, int tab,
1538                                          unsigned long long itv)
1539 {
1540         struct stats_net_eip6
1541                 *sneic = (struct stats_net_eip6 *) a->buf[curr],
1542                 *sneip = (struct stats_net_eip6 *) a->buf[!curr];
1543
1544         if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
1545                 goto close_xml_markup;
1546
1547         xml_markup_network(tab, OPEN_XML_MARKUP);
1548         tab++;
1549
1550         xprintf(tab, "<net-eip6 "
1551                 "ihdrer6=\"%.2f\" "
1552                 "iadrer6=\"%.2f\" "
1553                 "iukwnp6=\"%.2f\" "
1554                 "i2big6=\"%.2f\" "
1555                 "idisc6=\"%.2f\" "
1556                 "odisc6=\"%.2f\" "
1557                 "inort6=\"%.2f\" "
1558                 "onort6=\"%.2f\" "
1559                 "asmf6=\"%.2f\" "
1560                 "fragf6=\"%.2f\" "
1561                 "itrpck6=\"%.2f\"/>",
1562                 S_VALUE(sneip->InHdrErrors6,     sneic->InHdrErrors6,     itv),
1563                 S_VALUE(sneip->InAddrErrors6,    sneic->InAddrErrors6,    itv),
1564                 S_VALUE(sneip->InUnknownProtos6, sneic->InUnknownProtos6, itv),
1565                 S_VALUE(sneip->InTooBigErrors6,  sneic->InTooBigErrors6,  itv),
1566                 S_VALUE(sneip->InDiscards6,      sneic->InDiscards6,      itv),
1567                 S_VALUE(sneip->OutDiscards6,     sneic->OutDiscards6,     itv),
1568                 S_VALUE(sneip->InNoRoutes6,      sneic->InNoRoutes6,      itv),
1569                 S_VALUE(sneip->OutNoRoutes6,     sneic->OutNoRoutes6,     itv),
1570                 S_VALUE(sneip->ReasmFails6,      sneic->ReasmFails6,      itv),
1571                 S_VALUE(sneip->FragFails6,       sneic->FragFails6,       itv),
1572                 S_VALUE(sneip->InTruncatedPkts6, sneic->InTruncatedPkts6, itv));
1573         tab--;
1574
1575 close_xml_markup:
1576         if (CLOSE_MARKUP(a->options)) {
1577                 xml_markup_network(tab, CLOSE_XML_MARKUP);
1578         }
1579 }
1580
1581 /*
1582  ***************************************************************************
1583  * Display ICMPv6 network statistics in XML.
1584  *
1585  * IN:
1586  * @a           Activity structure with statistics.
1587  * @curr        Index in array for current sample statistics.
1588  * @tab         Indentation in XML output.
1589  * @itv         Interval of time in 1/100th of a second.
1590  ***************************************************************************
1591  */
1592 __print_funct_t xml_print_net_icmp6_stats(struct activity *a, int curr, int tab,
1593                                           unsigned long long itv)
1594 {
1595         struct stats_net_icmp6
1596                 *snic = (struct stats_net_icmp6 *) a->buf[curr],
1597                 *snip = (struct stats_net_icmp6 *) a->buf[!curr];
1598
1599         if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
1600                 goto close_xml_markup;
1601
1602         xml_markup_network(tab, OPEN_XML_MARKUP);
1603         tab++;
1604
1605         xprintf(tab, "<net-icmp6 "
1606                 "imsg6=\"%.2f\" "
1607                 "omsg6=\"%.2f\" "
1608                 "iech6=\"%.2f\" "
1609                 "iechr6=\"%.2f\" "
1610                 "oechr6=\"%.2f\" "
1611                 "igmbq6=\"%.2f\" "
1612                 "igmbr6=\"%.2f\" "
1613                 "ogmbr6=\"%.2f\" "
1614                 "igmbrd6=\"%.2f\" "
1615                 "ogmbrd6=\"%.2f\" "
1616                 "irtsol6=\"%.2f\" "
1617                 "ortsol6=\"%.2f\" "
1618                 "irtad6=\"%.2f\" "
1619                 "inbsol6=\"%.2f\" "
1620                 "onbsol6=\"%.2f\" "
1621                 "inbad6=\"%.2f\" "
1622                 "onbad6=\"%.2f\"/>",
1623                 S_VALUE(snip->InMsgs6,                    snic->InMsgs6,                    itv),
1624                 S_VALUE(snip->OutMsgs6,                   snic->OutMsgs6,                   itv),
1625                 S_VALUE(snip->InEchos6,                   snic->InEchos6,                   itv),
1626                 S_VALUE(snip->InEchoReplies6,             snic->InEchoReplies6,             itv),
1627                 S_VALUE(snip->OutEchoReplies6,            snic->OutEchoReplies6,            itv),
1628                 S_VALUE(snip->InGroupMembQueries6,        snic->InGroupMembQueries6,        itv),
1629                 S_VALUE(snip->InGroupMembResponses6,      snic->InGroupMembResponses6,      itv),
1630                 S_VALUE(snip->OutGroupMembResponses6,     snic->OutGroupMembResponses6,     itv),
1631                 S_VALUE(snip->InGroupMembReductions6,     snic->InGroupMembReductions6,     itv),
1632                 S_VALUE(snip->OutGroupMembReductions6,    snic->OutGroupMembReductions6,    itv),
1633                 S_VALUE(snip->InRouterSolicits6,          snic->InRouterSolicits6,          itv),
1634                 S_VALUE(snip->OutRouterSolicits6,         snic->OutRouterSolicits6,         itv),
1635                 S_VALUE(snip->InRouterAdvertisements6,    snic->InRouterAdvertisements6,    itv),
1636                 S_VALUE(snip->InNeighborSolicits6,        snic->InNeighborSolicits6,        itv),
1637                 S_VALUE(snip->OutNeighborSolicits6,       snic->OutNeighborSolicits6,       itv),
1638                 S_VALUE(snip->InNeighborAdvertisements6,  snic->InNeighborAdvertisements6,  itv),
1639                 S_VALUE(snip->OutNeighborAdvertisements6, snic->OutNeighborAdvertisements6, itv));
1640         tab--;
1641
1642 close_xml_markup:
1643         if (CLOSE_MARKUP(a->options)) {
1644                 xml_markup_network(tab, CLOSE_XML_MARKUP);
1645         }
1646 }
1647
1648 /*
1649  ***************************************************************************
1650  * Display ICMPv6 error messages statistics in XML.
1651  *
1652  * IN:
1653  * @a           Activity structure with statistics.
1654  * @curr        Index in array for current sample statistics.
1655  * @tab         Indentation in XML output.
1656  * @itv         Interval of time in 1/100th of a second.
1657  ***************************************************************************
1658  */
1659 __print_funct_t xml_print_net_eicmp6_stats(struct activity *a, int curr, int tab,
1660                                            unsigned long long itv)
1661 {
1662         struct stats_net_eicmp6
1663                 *sneic = (struct stats_net_eicmp6 *) a->buf[curr],
1664                 *sneip = (struct stats_net_eicmp6 *) a->buf[!curr];
1665
1666         if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
1667                 goto close_xml_markup;
1668
1669         xml_markup_network(tab, OPEN_XML_MARKUP);
1670         tab++;
1671
1672         xprintf(tab, "<net-eicmp6 "
1673                 "ierr6=\"%.2f\" "
1674                 "idtunr6=\"%.2f\" "
1675                 "odtunr6=\"%.2f\" "
1676                 "itmex6=\"%.2f\" "
1677                 "otmex6=\"%.2f\" "
1678                 "iprmpb6=\"%.2f\" "
1679                 "oprmpb6=\"%.2f\" "
1680                 "iredir6=\"%.2f\" "
1681                 "oredir6=\"%.2f\" "
1682                 "ipck2b6=\"%.2f\" "
1683                 "opck2b6=\"%.2f\"/>",
1684                 S_VALUE(sneip->InErrors6,        sneic->InErrors6,        itv),
1685                 S_VALUE(sneip->InDestUnreachs6,  sneic->InDestUnreachs6,  itv),
1686                 S_VALUE(sneip->OutDestUnreachs6, sneic->OutDestUnreachs6, itv),
1687                 S_VALUE(sneip->InTimeExcds6,     sneic->InTimeExcds6,     itv),
1688                 S_VALUE(sneip->OutTimeExcds6,    sneic->OutTimeExcds6,    itv),
1689                 S_VALUE(sneip->InParmProblems6,  sneic->InParmProblems6,  itv),
1690                 S_VALUE(sneip->OutParmProblems6, sneic->OutParmProblems6, itv),
1691                 S_VALUE(sneip->InRedirects6,     sneic->InRedirects6,     itv),
1692                 S_VALUE(sneip->OutRedirects6,    sneic->OutRedirects6,    itv),
1693                 S_VALUE(sneip->InPktTooBigs6,    sneic->InPktTooBigs6,    itv),
1694                 S_VALUE(sneip->OutPktTooBigs6,   sneic->OutPktTooBigs6,   itv));
1695         tab--;
1696
1697 close_xml_markup:
1698         if (CLOSE_MARKUP(a->options)) {
1699                 xml_markup_network(tab, CLOSE_XML_MARKUP);
1700         }
1701 }
1702
1703 /*
1704  ***************************************************************************
1705  * Display UDPv6 network statistics in XML.
1706  *
1707  * IN:
1708  * @a           Activity structure with statistics.
1709  * @curr        Index in array for current sample statistics.
1710  * @tab         Indentation in XML output.
1711  * @itv         Interval of time in 1/100th of a second.
1712  ***************************************************************************
1713  */
1714 __print_funct_t xml_print_net_udp6_stats(struct activity *a, int curr, int tab,
1715                                          unsigned long long itv)
1716 {
1717         struct stats_net_udp6
1718                 *snuc = (struct stats_net_udp6 *) a->buf[curr],
1719                 *snup = (struct stats_net_udp6 *) a->buf[!curr];
1720
1721         if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
1722                 goto close_xml_markup;
1723
1724         xml_markup_network(tab, OPEN_XML_MARKUP);
1725         tab++;
1726
1727         xprintf(tab, "<net-udp6 "
1728                 "idgm6=\"%.2f\" "
1729                 "odgm6=\"%.2f\" "
1730                 "noport6=\"%.2f\" "
1731                 "idgmer6=\"%.2f\"/>",
1732                 S_VALUE(snup->InDatagrams6,  snuc->InDatagrams6,  itv),
1733                 S_VALUE(snup->OutDatagrams6, snuc->OutDatagrams6, itv),
1734                 S_VALUE(snup->NoPorts6,      snuc->NoPorts6,      itv),
1735                 S_VALUE(snup->InErrors6,     snuc->InErrors6,     itv));
1736         tab--;
1737
1738 close_xml_markup:
1739         if (CLOSE_MARKUP(a->options)) {
1740                 xml_markup_network(tab, CLOSE_XML_MARKUP);
1741         }
1742 }
1743
1744 /*
1745  ***************************************************************************
1746  * Display CPU frequency statistics in XML.
1747  *
1748  * IN:
1749  * @a           Activity structure with statistics.
1750  * @curr        Index in array for current sample statistics.
1751  * @tab         Indentation in XML output.
1752  * @itv         Interval of time in 1/100th of a second.
1753  ***************************************************************************
1754  */
1755 __print_funct_t xml_print_pwr_cpufreq_stats(struct activity *a, int curr, int tab,
1756                                             unsigned long long itv)
1757 {
1758         int i;
1759         struct stats_pwr_cpufreq *spc;
1760         char cpuno[16];
1761
1762         if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
1763                 goto close_xml_markup;
1764
1765         xml_markup_power_management(tab, OPEN_XML_MARKUP);
1766         tab++;
1767
1768         xprintf(tab++, "<cpu-frequency unit=\"MHz\">");
1769
1770         for (i = 0; (i < a->nr[curr]) && (i < a->bitmap->b_size + 1); i++) {
1771
1772                 spc = (struct stats_pwr_cpufreq *) ((char *) a->buf[curr] + i * a->msize);
1773
1774                 /* Should current CPU (including CPU "all") be displayed? */
1775                 if (!(a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))))
1776                         /* No */
1777                         continue;
1778
1779                 /* Yes: Display it */
1780                 if (!i) {
1781                         /* This is CPU "all" */
1782                         strcpy(cpuno, "all");
1783                 }
1784                 else {
1785                         sprintf(cpuno, "%d", i - 1);
1786                 }
1787
1788                 xprintf(tab, "<cpufreq number=\"%s\" "
1789                         "frequency=\"%.2f\"/>",
1790                         cpuno,
1791                         ((double) spc->cpufreq) / 100);
1792         }
1793
1794         xprintf(--tab, "</cpu-frequency>");
1795         tab--;
1796
1797 close_xml_markup:
1798         if (CLOSE_MARKUP(a->options)) {
1799                 xml_markup_power_management(tab, CLOSE_XML_MARKUP);
1800         }
1801 }
1802
1803 /*
1804  ***************************************************************************
1805  * Display fan statistics in XML.
1806  *
1807  * IN:
1808  * @a           Activity structure with statistics.
1809  * @curr        Index in array for current sample statistics.
1810  * @tab         Indentation in XML output.
1811  * @itv         Interval of time in 1/100th of a second.
1812  ***************************************************************************
1813  */
1814 __print_funct_t xml_print_pwr_fan_stats(struct activity *a, int curr, int tab,
1815                                         unsigned long long itv)
1816 {
1817         int i;
1818         struct stats_pwr_fan *spc;
1819
1820         if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
1821                 goto close_xml_markup;
1822
1823         xml_markup_power_management(tab, OPEN_XML_MARKUP);
1824         tab++;
1825
1826         xprintf(tab++, "<fan-speed unit=\"rpm\">");
1827
1828         for (i = 0; i < a->nr[curr]; i++) {
1829                 spc = (struct stats_pwr_fan *) ((char *) a->buf[curr] + i * a->msize);
1830
1831                 xprintf(tab, "<fan number=\"%d\" rpm=\"%llu\" drpm=\"%llu\" device=\"%s\"/>",
1832                         i + 1,
1833                         (unsigned long long) spc->rpm,
1834                         (unsigned long long) (spc->rpm - spc->rpm_min),
1835                         spc->device);
1836         }
1837
1838         xprintf(--tab, "</fan-speed>");
1839         tab--;
1840
1841 close_xml_markup:
1842         if (CLOSE_MARKUP(a->options)) {
1843                 xml_markup_power_management(tab, CLOSE_XML_MARKUP);
1844         }
1845 }
1846
1847 /*
1848  ***************************************************************************
1849  * Display temperature statistics in XML.
1850  *
1851  * IN:
1852  * @a           Activity structure with statistics.
1853  * @curr        Index in array for current sample statistics.
1854  * @tab         Indentation in XML output.
1855  * @itv         Interval of time in 1/100th of a second.
1856  ***************************************************************************
1857  */
1858 __print_funct_t xml_print_pwr_temp_stats(struct activity *a, int curr, int tab,
1859                                          unsigned long long itv)
1860 {
1861         int i;
1862         struct stats_pwr_temp *spc;
1863
1864         if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
1865                 goto close_xml_markup;
1866
1867         xml_markup_power_management(tab, OPEN_XML_MARKUP);
1868         tab++;
1869
1870         xprintf(tab++, "<temperature unit=\"degree Celsius\">");
1871
1872         for (i = 0; i < a->nr[curr]; i++) {
1873                 spc = (struct stats_pwr_temp *) ((char *) a->buf[curr] + i * a->msize);
1874
1875                 xprintf(tab, "<temp number=\"%d\" degC=\"%.2f\" percent-temp=\"%.2f\" device=\"%s\"/>",
1876                         i + 1,
1877                         spc->temp,
1878                         (spc->temp_max - spc->temp_min) ?
1879                         (spc->temp - spc->temp_min) / (spc->temp_max - spc->temp_min) * 100 :
1880                         0.0,
1881                         spc->device);
1882         }
1883
1884         xprintf(--tab, "</temperature>");
1885         tab--;
1886
1887 close_xml_markup:
1888         if (CLOSE_MARKUP(a->options)) {
1889                 xml_markup_power_management(tab, CLOSE_XML_MARKUP);
1890         }
1891 }
1892
1893 /*
1894  ***************************************************************************
1895  * Display voltage inputs statistics in XML.
1896  *
1897  * IN:
1898  * @a           Activity structure with statistics.
1899  * @curr        Index in array for current sample statistics.
1900  * @tab         Indentation in XML output.
1901  * @itv         Interval of time in 1/100th of a second.
1902  ***************************************************************************
1903  */
1904 __print_funct_t xml_print_pwr_in_stats(struct activity *a, int curr, int tab,
1905                                        unsigned long long itv)
1906 {
1907         int i;
1908         struct stats_pwr_in *spc;
1909
1910         if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
1911                 goto close_xml_markup;
1912
1913         xml_markup_power_management(tab, OPEN_XML_MARKUP);
1914         tab++;
1915
1916         xprintf(tab++, "<voltage-input unit=\"V\">");
1917
1918         for (i = 0; i < a->nr[curr]; i++) {
1919                 spc = (struct stats_pwr_in *) ((char *) a->buf[curr] + i * a->msize);
1920
1921                 xprintf(tab, "<in number=\"%d\" inV=\"%.2f\" percent-in=\"%.2f\" device=\"%s\"/>",
1922                         i,
1923                         spc->in,
1924                         (spc->in_max - spc->in_min) ?
1925                         (spc->in - spc->in_min) / (spc->in_max - spc->in_min) * 100 :
1926                         0.0,
1927                         spc->device);
1928         }
1929
1930         xprintf(--tab, "</voltage-input>");
1931         tab--;
1932
1933 close_xml_markup:
1934         if (CLOSE_MARKUP(a->options)) {
1935                 xml_markup_power_management(tab, CLOSE_XML_MARKUP);
1936         }
1937 }
1938
1939 /*
1940  ***************************************************************************
1941  * Display huge pages statistics in XML.
1942  *
1943  * IN:
1944  * @a           Activity structure with statistics.
1945  * @curr        Index in array for current sample statistics.
1946  * @tab         Indentation in XML output.
1947  * @itv         Interval of time in 1/100th of a second.
1948  ***************************************************************************
1949  */
1950 __print_funct_t xml_print_huge_stats(struct activity *a, int curr, int tab,
1951                                      unsigned long long itv)
1952 {
1953         struct stats_huge
1954                 *smc = (struct stats_huge *) a->buf[curr];
1955
1956         xprintf(tab, "<hugepages unit=\"kB\">");
1957
1958         xprintf(++tab, "<hugfree>%llu</hugfree>",
1959                 smc->frhkb);
1960
1961         xprintf(tab, "<hugused>%llu</hugused>",
1962                 smc->tlhkb - smc->frhkb);
1963
1964         xprintf(tab, "<hugused-percent>%.2f</hugused-percent>",
1965                 smc->tlhkb ?
1966                 SP_VALUE(smc->frhkb, smc->tlhkb, smc->tlhkb) :
1967                 0.0);
1968
1969         xprintf(tab, "<hugrsvd>%llu</hugrsvd>",
1970                 smc->rsvdhkb);
1971
1972         xprintf(tab--, "<hugsurp>%llu</hugsurp>",
1973                 smc->surphkb);
1974
1975         xprintf(tab, "</hugepages>");
1976 }
1977
1978 /*
1979  ***************************************************************************
1980  * Display weighted CPU frequency statistics in XML.
1981  *
1982  * IN:
1983  * @a           Activity structure with statistics.
1984  * @curr        Index in array for current sample statistics.
1985  * @tab         Indentation in XML output.
1986  * @itv         Interval of time in 1/100th of a second.
1987  ***************************************************************************
1988  */
1989 __print_funct_t xml_print_pwr_wghfreq_stats(struct activity *a, int curr, int tab,
1990                                             unsigned long long itv)
1991 {
1992         int i, k;
1993         struct stats_pwr_wghfreq *spc, *spp, *spc_k, *spp_k;
1994         unsigned long long tis, tisfreq;
1995         char cpuno[16];
1996
1997         if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
1998                 goto close_xml_markup;
1999
2000         xml_markup_power_management(tab, OPEN_XML_MARKUP);
2001         tab++;
2002
2003         xprintf(tab++, "<cpu-weighted-frequency unit=\"MHz\">");
2004
2005         for (i = 0; (i < a->nr[curr]) && (i < a->bitmap->b_size + 1); i++) {
2006
2007                 spc = (struct stats_pwr_wghfreq *) ((char *) a->buf[curr]  + i * a->msize * a->nr2);
2008                 spp = (struct stats_pwr_wghfreq *) ((char *) a->buf[!curr] + i * a->msize * a->nr2);
2009
2010                 /* Should current CPU (including CPU "all") be displayed? */
2011                 if (!(a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))))
2012                         /* No */
2013                         continue;
2014
2015                 tisfreq = 0;
2016                 tis = 0;
2017
2018                 for (k = 0; k < a->nr2; k++) {
2019
2020                         spc_k = (struct stats_pwr_wghfreq *) ((char *) spc + k * a->msize);
2021                         if (!spc_k->freq)
2022                                 break;
2023                         spp_k = (struct stats_pwr_wghfreq *) ((char *) spp + k * a->msize);
2024
2025                         tisfreq += (spc_k->freq / 1000) *
2026                                    (spc_k->time_in_state - spp_k->time_in_state);
2027                         tis     += (spc_k->time_in_state - spp_k->time_in_state);
2028                 }
2029
2030                 if (!i) {
2031                         /* This is CPU "all" */
2032                         strcpy(cpuno, "all");
2033                 }
2034                 else {
2035                         sprintf(cpuno, "%d", i - 1);
2036                 }
2037
2038                 xprintf(tab, "<cpuwfreq number=\"%s\" "
2039                         "weighted-frequency=\"%.2f\"/>",
2040                         cpuno,
2041                         tis ? ((double) tisfreq) / tis : 0.0);
2042         }
2043
2044         xprintf(--tab, "</cpu-weighted-frequency>");
2045         tab--;
2046
2047 close_xml_markup:
2048         if (CLOSE_MARKUP(a->options)) {
2049                 xml_markup_power_management(tab, CLOSE_XML_MARKUP);
2050         }
2051 }
2052
2053 /*
2054  ***************************************************************************
2055  * Display USB devices statistics in XML.
2056  *
2057  * IN:
2058  * @a           Activity structure with statistics.
2059  * @curr        Index in array for current sample statistics.
2060  * @tab         Indentation in XML output.
2061  * @itv         Interval of time in 1/100th of a second.
2062  ***************************************************************************
2063  */
2064 __print_funct_t xml_print_pwr_usb_stats(struct activity *a, int curr, int tab,
2065                                         unsigned long long itv)
2066 {
2067         int i;
2068         struct stats_pwr_usb *suc;
2069
2070         if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
2071                 goto close_xml_markup;
2072
2073         xml_markup_power_management(tab, OPEN_XML_MARKUP);
2074         tab++;
2075
2076         xprintf(tab++, "<usb-devices>");
2077
2078         for (i = 0; i < a->nr[curr]; i++) {
2079                 suc = (struct stats_pwr_usb *) ((char *) a->buf[curr] + i * a->msize);
2080
2081                 xprintf(tab, "<usb bus_number=\"%d\" idvendor=\"%x\" idprod=\"%x\" "
2082                              "maxpower=\"%u\" manufact=\"%s\" product=\"%s\"/>",
2083                         suc->bus_nr,
2084                         suc->vendor_id,
2085                         suc->product_id,
2086                         suc->bmaxpower << 1,
2087                         suc->manufacturer,
2088                         suc->product);
2089         }
2090
2091         xprintf(--tab, "</usb-devices>");
2092         tab--;
2093
2094 close_xml_markup:
2095         if (CLOSE_MARKUP(a->options)) {
2096                 xml_markup_power_management(tab, CLOSE_XML_MARKUP);
2097         }
2098 }
2099
2100 /*
2101  ***************************************************************************
2102  * Display filesystems statistics in XML.
2103  *
2104  * IN:
2105  * @a           Activity structure with statistics.
2106  * @curr        Index in array for current sample statistics.
2107  * @tab         Indentation in XML output.
2108  * @itv         Interval of time in 1/100th of a second.
2109  ***************************************************************************
2110  */
2111 __print_funct_t xml_print_filesystem_stats(struct activity *a, int curr, int tab,
2112                                            unsigned long long itv)
2113 {
2114         int i;
2115         struct stats_filesystem *sfc;
2116         char *dev_name;
2117
2118         xprintf(tab++, "<filesystems>");
2119
2120         for (i = 0; i < a->nr[curr]; i++) {
2121                 sfc = (struct stats_filesystem *) ((char *) a->buf[curr] + i * a->msize);
2122
2123                 /* Get name to display (persistent or standard fs name, or mount point) */
2124                 dev_name = get_fs_name_to_display(a, flags, sfc);
2125
2126                 if (a->item_list != NULL) {
2127                         /* A list of devices has been entered on the command line */
2128                         if (!search_list_item(a->item_list, dev_name))
2129                                 /* Device not found */
2130                                 continue;
2131                 }
2132
2133                 xprintf(tab, "<filesystem %s=\"%s\" "
2134                         "MBfsfree=\"%.0f\" "
2135                         "MBfsused=\"%.0f\" "
2136                         "fsused-percent=\"%.2f\" "
2137                         "ufsused-percent=\"%.2f\" "
2138                         "Ifree=\"%llu\" "
2139                         "Iused=\"%llu\" "
2140                         "Iused-percent=\"%.2f\"/>",
2141                         DISPLAY_MOUNT(a->opt_flags) ? "mountp" : "fsname",
2142                         dev_name,
2143                         (double) sfc->f_bfree / 1024 / 1024,
2144                         (double) (sfc->f_blocks - sfc->f_bfree) / 1024 / 1024,
2145                         /* f_blocks is not zero. But test it anyway ;-) */
2146                         sfc->f_blocks ? SP_VALUE(sfc->f_bfree, sfc->f_blocks, sfc->f_blocks)
2147                                       : 0.0,
2148                         sfc->f_blocks ? SP_VALUE(sfc->f_bavail, sfc->f_blocks, sfc->f_blocks)
2149                                       : 0.0,
2150                         sfc->f_ffree,
2151                         sfc->f_files - sfc->f_ffree,
2152                         sfc->f_files ? SP_VALUE(sfc->f_ffree, sfc->f_files, sfc->f_files)
2153                                      : 0.0);
2154         }
2155
2156         xprintf(--tab, "</filesystems>");
2157 }
2158
2159 /*
2160  ***************************************************************************
2161  * Display Fibre Channel HBA statistics in XML.
2162  *
2163  * IN:
2164  * @a           Activity structure with statistics.
2165  * @curr        Index in array for current sample statistics.
2166  * @tab         Indentation in XML output.
2167  * @itv         Interval of time in 1/100th of a second.
2168  ***************************************************************************
2169  */
2170 __print_funct_t xml_print_fchost_stats(struct activity *a, int curr, int tab,
2171                                        unsigned long long itv)
2172 {
2173         int i, j, j0, found;
2174         struct stats_fchost *sfcc, *sfcp, sfczero;
2175
2176         if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
2177                 goto close_xml_markup;
2178
2179         memset(&sfczero, 0, sizeof(struct stats_fchost));
2180
2181         xml_markup_network(tab, OPEN_XML_MARKUP);
2182         tab++;
2183
2184         for (i = 0; i < a->nr[curr]; i++) {
2185
2186                 found = FALSE;
2187                 sfcc = (struct stats_fchost *) ((char *) a->buf[curr] + i * a->msize);
2188
2189                 if (a->nr[!curr] > 0) {
2190                         /* Look for corresponding structure in previous iteration */
2191                         j = i;
2192
2193                         if (j >= a->nr[!curr]) {
2194                                 j = a->nr[!curr] - 1;
2195                         }
2196
2197                         j0 = j;
2198
2199                         do {
2200                                 sfcp = (struct stats_fchost *) ((char *) a->buf[!curr] + j * a->msize);
2201                                 if (!strcmp(sfcc->fchost_name, sfcp->fchost_name)) {
2202                                         found = TRUE;
2203                                         break;
2204                                 }
2205                                 if (++j >= a->nr[!curr]) {
2206                                         j = 0;
2207                                 }
2208                         }
2209                         while (j != j0);
2210                 }
2211
2212                 if (!found) {
2213                         /* This is a newly registered host */
2214                         sfcp = &sfczero;
2215                 }
2216
2217                 xprintf(tab, "<fchost name=\"%s\" "
2218                         "fch_rxf=\"%.2f\" "
2219                         "fch_txf=\"%.2f\" "
2220                         "fch_rxw=\"%.2f\" "
2221                         "fch_txw=\"%.2f\"/>",
2222                         sfcc->fchost_name,
2223                         S_VALUE(sfcp->f_rxframes, sfcc->f_rxframes, itv),
2224                         S_VALUE(sfcp->f_txframes, sfcc->f_txframes, itv),
2225                         S_VALUE(sfcp->f_rxwords,  sfcc->f_rxwords,  itv),
2226                         S_VALUE(sfcp->f_txwords,  sfcc->f_txwords,  itv));
2227         }
2228         tab--;
2229
2230 close_xml_markup:
2231         if (CLOSE_MARKUP(a->options)) {
2232                 xml_markup_network(tab, CLOSE_XML_MARKUP);
2233         }
2234 }
2235
2236 /*
2237  ***************************************************************************
2238  * Display softnet statistics in XML.
2239  *
2240  * IN:
2241  * @a           Activity structure with statistics.
2242  * @curr        Index in array for current sample statistics.
2243  * @tab         Indentation in XML output.
2244  * @itv         Interval of time in 1/100th of a second.
2245  ***************************************************************************
2246  */
2247 __print_funct_t xml_print_softnet_stats(struct activity *a, int curr, int tab,
2248                                         unsigned long long itv)
2249 {
2250         int i;
2251         struct stats_softnet *ssnc, *ssnp;
2252         char cpuno[16];
2253         unsigned char offline_cpu_bitmap[BITMAP_SIZE(NR_CPUS)] = {0};
2254
2255         if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
2256                 goto close_xml_markup;
2257
2258         xml_markup_network(tab, OPEN_XML_MARKUP);
2259         tab++;
2260
2261         /* @nr[curr] cannot normally be greater than @nr_ini */
2262         if (a->nr[curr] > a->nr_ini) {
2263                 a->nr_ini = a->nr[curr];
2264         }
2265
2266         /* Compute statistics for CPU "all" */
2267         get_global_soft_statistics(a, !curr, curr, flags, offline_cpu_bitmap);
2268
2269         for (i = 0; (i < a->nr_ini) && (i < a->bitmap->b_size + 1); i++) {
2270
2271                 /* Should current CPU (including CPU "all") be displayed? */
2272                 if (!(a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))) ||
2273                     offline_cpu_bitmap[i >> 3] & (1 << (i & 0x07)))
2274                         /* No */
2275                         continue;
2276
2277                 ssnc = (struct stats_softnet *) ((char *) a->buf[curr]  + i * a->msize);
2278                 ssnp = (struct stats_softnet *) ((char *) a->buf[!curr] + i * a->msize);
2279
2280                 /* Yes: Display it */
2281                 if (!i) {
2282                         /* This is CPU "all" */
2283                         strcpy(cpuno, "all");
2284                 }
2285                 else {
2286                         sprintf(cpuno, "%d", i - 1);
2287                 }
2288
2289                 xprintf(tab, "<softnet cpu=\"%s\" "
2290                         "total=\"%.2f\" "
2291                         "dropd=\"%.2f\" "
2292                         "squeezd=\"%.2f\" "
2293                         "rx_rps=\"%.2f\" "
2294                         "flw_lim=\"%.2f\"/>",
2295                          cpuno,
2296                          S_VALUE(ssnp->processed,    ssnc->processed,    itv),
2297                          S_VALUE(ssnp->dropped,      ssnc->dropped,      itv),
2298                          S_VALUE(ssnp->time_squeeze, ssnc->time_squeeze, itv),
2299                          S_VALUE(ssnp->received_rps, ssnc->received_rps, itv),
2300                          S_VALUE(ssnp->flow_limit,   ssnc->flow_limit,   itv));
2301         }
2302         tab--;
2303
2304 close_xml_markup:
2305         if (CLOSE_MARKUP(a->options)) {
2306                 xml_markup_network(tab, CLOSE_XML_MARKUP);
2307         }
2308 }
2309
2310 /*
2311  ***************************************************************************
2312  * Display pressure-stall CPU statistics in XML.
2313  *
2314  * IN:
2315  * @a           Activity structure with statistics.
2316  * @curr        Index in array for current sample statistics.
2317  * @tab         Indentation in XML output.
2318  * @itv         Interval of time in 1/100th of a second.
2319  ***************************************************************************
2320  */
2321 __print_funct_t xml_print_psicpu_stats(struct activity *a, int curr, int tab,
2322                                        unsigned long long itv)
2323 {
2324         struct stats_psi_cpu
2325                 *psic = (struct stats_psi_cpu *) a->buf[curr],
2326                 *psip = (struct stats_psi_cpu *) a->buf[!curr];
2327
2328         if (!IS_SELECTED(a->options))
2329                 goto close_xml_markup;
2330
2331         xml_markup_psi(tab, OPEN_XML_MARKUP);
2332         tab++;
2333
2334         xprintf(tab, "<psi-cpu "
2335                 "some_avg10=\"%.2f\" "
2336                 "some_avg60=\"%.2f\" "
2337                 "some_avg300=\"%.2f\" "
2338                 "some_avg=\"%.2f\"/>",
2339                 (double) psic->some_acpu_10  / 100,
2340                 (double) psic->some_acpu_60  / 100,
2341                 (double) psic->some_acpu_300 / 100,
2342                 ((double) psic->some_cpu_total - psip->some_cpu_total) / (100 * itv));
2343         tab--;
2344
2345 close_xml_markup:
2346         if (CLOSE_MARKUP(a->options)) {
2347                 xml_markup_psi(tab, CLOSE_XML_MARKUP);
2348         }
2349 }
2350
2351 /*
2352  ***************************************************************************
2353  * Display pressure-stall I/O statistics in XML.
2354  *
2355  * IN:
2356  * @a           Activity structure with statistics.
2357  * @curr        Index in array for current sample statistics.
2358  * @tab         Indentation in XML output.
2359  * @itv         Interval of time in 1/100th of a second.
2360  ***************************************************************************
2361  */
2362 __print_funct_t xml_print_psiio_stats(struct activity *a, int curr, int tab,
2363                                       unsigned long long itv)
2364 {
2365         struct stats_psi_io
2366                 *psic = (struct stats_psi_io *) a->buf[curr],
2367                 *psip = (struct stats_psi_io *) a->buf[!curr];
2368
2369         if (!IS_SELECTED(a->options))
2370                 goto close_xml_markup;
2371
2372         xml_markup_psi(tab, OPEN_XML_MARKUP);
2373         tab++;
2374
2375         xprintf(tab, "<psi-io "
2376                 "some_avg10=\"%.2f\" "
2377                 "some_avg60=\"%.2f\" "
2378                 "some_avg300=\"%.2f\" "
2379                 "some_avg=\"%.2f\" "
2380                 "full_avg10=\"%.2f\" "
2381                 "full_avg60=\"%.2f\" "
2382                 "full_avg300=\"%.2f\" "
2383                 "full_avg=\"%.2f\"/>",
2384                 (double) psic->some_aio_10  / 100,
2385                 (double) psic->some_aio_60  / 100,
2386                 (double) psic->some_aio_300 / 100,
2387                 ((double) psic->some_io_total - psip->some_io_total) / (100 * itv),
2388                 (double) psic->full_aio_10  / 100,
2389                 (double) psic->full_aio_60  / 100,
2390                 (double) psic->full_aio_300 / 100,
2391                 ((double) psic->full_io_total - psip->full_io_total) / (100 * itv));
2392         tab--;
2393
2394 close_xml_markup:
2395         if (CLOSE_MARKUP(a->options)) {
2396                 xml_markup_psi(tab, CLOSE_XML_MARKUP);
2397         }
2398 }
2399
2400 /*
2401  ***************************************************************************
2402  * Display pressure-stall memory statistics in XML.
2403  *
2404  * IN:
2405  * @a           Activity structure with statistics.
2406  * @curr        Index in array for current sample statistics.
2407  * @tab         Indentation in XML output.
2408  * @itv         Interval of time in 1/100th of a second.
2409  ***************************************************************************
2410  */
2411 __print_funct_t xml_print_psimem_stats(struct activity *a, int curr, int tab,
2412                                        unsigned long long itv)
2413 {
2414         struct stats_psi_mem
2415                 *psic = (struct stats_psi_mem *) a->buf[curr],
2416                 *psip = (struct stats_psi_mem *) a->buf[!curr];
2417
2418         if (!IS_SELECTED(a->options))
2419                 goto close_xml_markup;
2420
2421         xml_markup_psi(tab, OPEN_XML_MARKUP);
2422         tab++;
2423
2424         xprintf(tab, "<psi-mem "
2425                 "some_avg10=\"%.2f\" "
2426                 "some_avg60=\"%.2f\" "
2427                 "some_avg300=\"%.2f\" "
2428                 "some_avg=\"%.2f\" "
2429                 "full_avg10=\"%.2f\" "
2430                 "full_avg60=\"%.2f\" "
2431                 "full_avg300=\"%.2f\" "
2432                 "full_avg=\"%.2f\"/>",
2433                 (double) psic->some_amem_10  / 100,
2434                 (double) psic->some_amem_60  / 100,
2435                 (double) psic->some_amem_300 / 100,
2436                 ((double) psic->some_mem_total - psip->some_mem_total) / (100 * itv),
2437                 (double) psic->full_amem_10  / 100,
2438                 (double) psic->full_amem_60  / 100,
2439                 (double) psic->full_amem_300 / 100,
2440                 ((double) psic->full_mem_total - psip->full_mem_total) / (100 * itv));
2441         tab--;
2442
2443 close_xml_markup:
2444         if (CLOSE_MARKUP(a->options)) {
2445                 xml_markup_psi(tab, CLOSE_XML_MARKUP);
2446         }
2447 }