]> granicus.if.org Git - sysstat/blob - xml_stats.c
sadf: XML: Remove "per" attribute for memory activity
[sysstat] / xml_stats.c
1 /*
2  * xml_stats.c: Funtions used by sadf to display statistics in XML.
3  * (C) 1999-2019 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 unsigned int 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_sa_devname(sdc->major, sdc->minor,
749                                           sdc->wwn, sdc->part_nr, flags);
750
751                 if (a->item_list != NULL) {
752                         /* A list of devices has been entered on the command line */
753                         if (!search_list_item(a->item_list, dev_name))
754                                 /* Device not found */
755                                 continue;
756                 }
757
758                 /* Compute extended statistics values */
759                 compute_ext_disk_stats(sdc, sdp, itv, &xds);
760
761                 xprintf(tab, "<disk-device dev=\"%s\" "
762                         "tps=\"%.2f\" "
763                         "rd_sec=\"%.2f\" "
764                         "wr_sec=\"%.2f\" "
765                         "dc_sec=\"%.2f\" "
766                         "rkB=\"%.2f\" "
767                         "wkB=\"%.2f\" "
768                         "dkB=\"%.2f\" "
769                         "avgrq-sz=\"%.2f\" "
770                         "areq-sz=\"%.2f\" "
771                         "avgqu-sz=\"%.2f\" "
772                         "aqu-sz=\"%.2f\" "
773                         "await=\"%.2f\" "
774                         "util-percent=\"%.2f\"/>",
775                         /* Confusion possible here between index and minor numbers */
776                         dev_name,
777                         S_VALUE(sdp->nr_ios, sdc->nr_ios, itv),
778                         S_VALUE(sdp->rd_sect, sdc->rd_sect, itv), /* Unit = sectors (for backward compatibility) */
779                         S_VALUE(sdp->wr_sect, sdc->wr_sect, itv),
780                         S_VALUE(sdp->dc_sect, sdc->dc_sect, itv),
781                         S_VALUE(sdp->rd_sect, sdc->rd_sect, itv) / 2,
782                         S_VALUE(sdp->wr_sect, sdc->wr_sect, itv) / 2,
783                         S_VALUE(sdp->dc_sect, sdc->dc_sect, itv) / 2,
784                         /* See iostat for explanations */
785                         xds.arqsz,      /* Unit = sectors (for backward compatibility) */
786                         xds.arqsz / 2,
787                         S_VALUE(sdp->rq_ticks, sdc->rq_ticks, itv) / 1000.0,    /* For backward compatibility */
788                         S_VALUE(sdp->rq_ticks, sdc->rq_ticks, itv) / 1000.0,
789                         xds.await,
790                         xds.util / 10.0);
791         }
792
793         xprintf(--tab, "</disk>");
794 }
795
796 /*
797  ***************************************************************************
798  * Display network interfaces statistics in XML.
799  *
800  * IN:
801  * @a           Activity structure with statistics.
802  * @curr        Index in array for current sample statistics.
803  * @tab         Indentation in XML output.
804  * @itv         Interval of time in 1/100th of a second.
805  ***************************************************************************
806  */
807 __print_funct_t xml_print_net_dev_stats(struct activity *a, int curr, int tab,
808                                         unsigned long long itv)
809 {
810         int i, j;
811         struct stats_net_dev *sndc, *sndp, sndzero;
812         double rxkb, txkb, ifutil;
813
814         if (!IS_SELECTED(a->options) || (a->nr <= 0))
815                 goto close_xml_markup;
816
817         memset(&sndzero, 0, STATS_NET_DEV_SIZE);
818
819         xml_markup_network(tab, OPEN_XML_MARKUP);
820         tab++;
821
822         for (i = 0; i < a->nr[curr]; i++) {
823
824                 sndc = (struct stats_net_dev *) ((char *) a->buf[curr] + i * a->msize);
825
826                 if (a->item_list != NULL) {
827                         /* A list of devices has been entered on the command line */
828                         if (!search_list_item(a->item_list, sndc->interface))
829                                 /* Device not found */
830                                 continue;
831                 }
832
833                 j = check_net_dev_reg(a, curr, !curr, i);
834                 if (j < 0) {
835                         /* This is a newly registered interface. Previous stats are zero */
836                         sndp = &sndzero;
837                 }
838                 else {
839                         sndp = (struct stats_net_dev *) ((char *) a->buf[!curr] + j * a->msize);
840                 }
841
842                 rxkb = S_VALUE(sndp->rx_bytes, sndc->rx_bytes, itv);
843                 txkb = S_VALUE(sndp->tx_bytes, sndc->tx_bytes, itv);
844                 ifutil = compute_ifutil(sndc, rxkb, txkb);
845
846                 xprintf(tab, "<net-dev iface=\"%s\" "
847                         "rxpck=\"%.2f\" "
848                         "txpck=\"%.2f\" "
849                         "rxkB=\"%.2f\" "
850                         "txkB=\"%.2f\" "
851                         "rxcmp=\"%.2f\" "
852                         "txcmp=\"%.2f\" "
853                         "rxmcst=\"%.2f\" "
854                         "ifutil-percent=\"%.2f\"/>",
855                         sndc->interface,
856                         S_VALUE(sndp->rx_packets,    sndc->rx_packets,    itv),
857                         S_VALUE(sndp->tx_packets,    sndc->tx_packets,    itv),
858                         rxkb / 1024,
859                         txkb / 1024,
860                         S_VALUE(sndp->rx_compressed, sndc->rx_compressed, itv),
861                         S_VALUE(sndp->tx_compressed, sndc->tx_compressed, itv),
862                         S_VALUE(sndp->multicast,     sndc->multicast,     itv),
863                         ifutil);
864         }
865         tab--;
866
867 close_xml_markup:
868         if (CLOSE_MARKUP(a->options)) {
869                 xml_markup_network(tab, CLOSE_XML_MARKUP);
870         }
871 }
872
873 /*
874  ***************************************************************************
875  * Display network interfaces errors statistics in XML.
876  *
877  * IN:
878  * @a           Activity structure with statistics.
879  * @curr        Index in array for current sample statistics.
880  * @tab         Indentation in XML output.
881  * @itv         Interval of time in 1/100th of a second.
882  ***************************************************************************
883  */
884 __print_funct_t xml_print_net_edev_stats(struct activity *a, int curr, int tab,
885                                          unsigned long long itv)
886 {
887         int i, j;
888         struct stats_net_edev *snedc, *snedp, snedzero;
889
890         if (!IS_SELECTED(a->options) || (a->nr <= 0))
891                 goto close_xml_markup;
892
893         memset(&snedzero, 0, STATS_NET_EDEV_SIZE);
894
895         xml_markup_network(tab, OPEN_XML_MARKUP);
896         tab++;
897
898         for (i = 0; i < a->nr[curr]; i++) {
899
900                 snedc = (struct stats_net_edev *) ((char *) a->buf[curr] + i * a->msize);
901
902                 if (a->item_list != NULL) {
903                         /* A list of devices has been entered on the command line */
904                         if (!search_list_item(a->item_list, snedc->interface))
905                                 /* Device not found */
906                                 continue;
907                 }
908
909                 j = check_net_edev_reg(a, curr, !curr, i);
910                 if (j < 0) {
911                         /* This is a newly registered interface. Previous stats are zero */
912                         snedp = &snedzero;
913                 }
914                 else {
915                         snedp = (struct stats_net_edev *) ((char *) a->buf[!curr] + j * a->msize);
916                 }
917
918                 xprintf(tab, "<net-edev iface=\"%s\" "
919                         "rxerr=\"%.2f\" "
920                         "txerr=\"%.2f\" "
921                         "coll=\"%.2f\" "
922                         "rxdrop=\"%.2f\" "
923                         "txdrop=\"%.2f\" "
924                         "txcarr=\"%.2f\" "
925                         "rxfram=\"%.2f\" "
926                         "rxfifo=\"%.2f\" "
927                         "txfifo=\"%.2f\"/>",
928                         snedc->interface,
929                         S_VALUE(snedp->rx_errors,         snedc->rx_errors,         itv),
930                         S_VALUE(snedp->tx_errors,         snedc->tx_errors,         itv),
931                         S_VALUE(snedp->collisions,        snedc->collisions,        itv),
932                         S_VALUE(snedp->rx_dropped,        snedc->rx_dropped,        itv),
933                         S_VALUE(snedp->tx_dropped,        snedc->tx_dropped,        itv),
934                         S_VALUE(snedp->tx_carrier_errors, snedc->tx_carrier_errors, itv),
935                         S_VALUE(snedp->rx_frame_errors,   snedc->rx_frame_errors,   itv),
936                         S_VALUE(snedp->rx_fifo_errors,    snedc->rx_fifo_errors,    itv),
937                         S_VALUE(snedp->tx_fifo_errors,    snedc->tx_fifo_errors,    itv));
938         }
939         tab--;
940
941 close_xml_markup:
942         if (CLOSE_MARKUP(a->options)) {
943                 xml_markup_network(tab, CLOSE_XML_MARKUP);
944         }
945 }
946
947 /*
948  ***************************************************************************
949  * Display NFS client statistics in XML.
950  *
951  * IN:
952  * @a           Activity structure with statistics.
953  * @curr        Index in array for current sample statistics.
954  * @tab         Indentation in XML output.
955  * @itv         Interval of time in 1/100th of a second.
956  ***************************************************************************
957  */
958 __print_funct_t xml_print_net_nfs_stats(struct activity *a, int curr, int tab,
959                                         unsigned long long itv)
960 {
961         struct stats_net_nfs
962                 *snnc = (struct stats_net_nfs *) a->buf[curr],
963                 *snnp = (struct stats_net_nfs *) a->buf[!curr];
964
965         if (!IS_SELECTED(a->options) || (a->nr <= 0))
966                 goto close_xml_markup;
967
968         xml_markup_network(tab, OPEN_XML_MARKUP);
969         tab++;
970
971         xprintf(tab, "<net-nfs "
972                 "call=\"%.2f\" "
973                 "retrans=\"%.2f\" "
974                 "read=\"%.2f\" "
975                 "write=\"%.2f\" "
976                 "access=\"%.2f\" "
977                 "getatt=\"%.2f\"/>",
978                 S_VALUE(snnp->nfs_rpccnt,     snnc->nfs_rpccnt,     itv),
979                 S_VALUE(snnp->nfs_rpcretrans, snnc->nfs_rpcretrans, itv),
980                 S_VALUE(snnp->nfs_readcnt,    snnc->nfs_readcnt,    itv),
981                 S_VALUE(snnp->nfs_writecnt,   snnc->nfs_writecnt,   itv),
982                 S_VALUE(snnp->nfs_accesscnt,  snnc->nfs_accesscnt,  itv),
983                 S_VALUE(snnp->nfs_getattcnt,  snnc->nfs_getattcnt,  itv));
984         tab--;
985
986 close_xml_markup:
987         if (CLOSE_MARKUP(a->options)) {
988                 xml_markup_network(tab, CLOSE_XML_MARKUP);
989         }
990 }
991
992 /*
993  ***************************************************************************
994  * Display NFS server statistics in XML.
995  *
996  * IN:
997  * @a           Activity structure with statistics.
998  * @curr        Index in array for current sample statistics.
999  * @tab         Indentation in XML output.
1000  * @itv         Interval of time in 1/100th of a second.
1001  ***************************************************************************
1002  */
1003 __print_funct_t xml_print_net_nfsd_stats(struct activity *a, int curr, int tab,
1004                                          unsigned long long itv)
1005 {
1006         struct stats_net_nfsd
1007                 *snndc = (struct stats_net_nfsd *) a->buf[curr],
1008                 *snndp = (struct stats_net_nfsd *) a->buf[!curr];
1009
1010         if (!IS_SELECTED(a->options) || (a->nr <= 0))
1011                 goto close_xml_markup;
1012
1013         xml_markup_network(tab, OPEN_XML_MARKUP);
1014         tab++;
1015
1016         xprintf(tab, "<net-nfsd "
1017                 "scall=\"%.2f\" "
1018                 "badcall=\"%.2f\" "
1019                 "packet=\"%.2f\" "
1020                 "udp=\"%.2f\" "
1021                 "tcp=\"%.2f\" "
1022                 "hit=\"%.2f\" "
1023                 "miss=\"%.2f\" "
1024                 "sread=\"%.2f\" "
1025                 "swrite=\"%.2f\" "
1026                 "saccess=\"%.2f\" "
1027                 "sgetatt=\"%.2f\"/>",
1028                 S_VALUE(snndp->nfsd_rpccnt,    snndc->nfsd_rpccnt,    itv),
1029                 S_VALUE(snndp->nfsd_rpcbad,    snndc->nfsd_rpcbad,    itv),
1030                 S_VALUE(snndp->nfsd_netcnt,    snndc->nfsd_netcnt,    itv),
1031                 S_VALUE(snndp->nfsd_netudpcnt, snndc->nfsd_netudpcnt, itv),
1032                 S_VALUE(snndp->nfsd_nettcpcnt, snndc->nfsd_nettcpcnt, itv),
1033                 S_VALUE(snndp->nfsd_rchits,    snndc->nfsd_rchits,    itv),
1034                 S_VALUE(snndp->nfsd_rcmisses,  snndc->nfsd_rcmisses,  itv),
1035                 S_VALUE(snndp->nfsd_readcnt,   snndc->nfsd_readcnt,   itv),
1036                 S_VALUE(snndp->nfsd_writecnt,  snndc->nfsd_writecnt,  itv),
1037                 S_VALUE(snndp->nfsd_accesscnt, snndc->nfsd_accesscnt, itv),
1038                 S_VALUE(snndp->nfsd_getattcnt, snndc->nfsd_getattcnt, itv));
1039         tab--;
1040
1041 close_xml_markup:
1042         if (CLOSE_MARKUP(a->options)) {
1043                 xml_markup_network(tab, CLOSE_XML_MARKUP);
1044         }
1045 }
1046
1047 /*
1048  ***************************************************************************
1049  * Display network socket statistics in XML.
1050  *
1051  * IN:
1052  * @a           Activity structure with statistics.
1053  * @curr        Index in array for current sample statistics.
1054  * @tab         Indentation in XML output.
1055  * @itv         Interval of time in 1/100th of a second.
1056  ***************************************************************************
1057  */
1058 __print_funct_t xml_print_net_sock_stats(struct activity *a, int curr, int tab,
1059                                          unsigned long long itv)
1060 {
1061         struct stats_net_sock
1062                 *snsc = (struct stats_net_sock *) a->buf[curr];
1063
1064         if (!IS_SELECTED(a->options) || (a->nr <= 0))
1065                 goto close_xml_markup;
1066
1067         xml_markup_network(tab, OPEN_XML_MARKUP);
1068         tab++;
1069
1070         xprintf(tab, "<net-sock "
1071                 "totsck=\"%u\" "
1072                 "tcpsck=\"%u\" "
1073                 "udpsck=\"%u\" "
1074                 "rawsck=\"%u\" "
1075                 "ip-frag=\"%u\" "
1076                 "tcp-tw=\"%u\"/>",
1077                 snsc->sock_inuse,
1078                 snsc->tcp_inuse,
1079                 snsc->udp_inuse,
1080                 snsc->raw_inuse,
1081                 snsc->frag_inuse,
1082                 snsc->tcp_tw);
1083         tab--;
1084
1085 close_xml_markup:
1086         if (CLOSE_MARKUP(a->options)) {
1087                 xml_markup_network(tab, CLOSE_XML_MARKUP);
1088         }
1089 }
1090
1091 /*
1092  ***************************************************************************
1093  * Display IP network statistics in XML.
1094  *
1095  * IN:
1096  * @a           Activity structure with statistics.
1097  * @curr        Index in array for current sample statistics.
1098  * @tab         Indentation in XML output.
1099  * @itv         Interval of time in 1/100th of a second.
1100  ***************************************************************************
1101  */
1102 __print_funct_t xml_print_net_ip_stats(struct activity *a, int curr, int tab,
1103                                        unsigned long long itv)
1104 {
1105         struct stats_net_ip
1106                 *snic = (struct stats_net_ip *) a->buf[curr],
1107                 *snip = (struct stats_net_ip *) a->buf[!curr];
1108
1109         if (!IS_SELECTED(a->options) || (a->nr <= 0))
1110                 goto close_xml_markup;
1111
1112         xml_markup_network(tab, OPEN_XML_MARKUP);
1113         tab++;
1114
1115         xprintf(tab, "<net-ip "
1116                 "irec=\"%.2f\" "
1117                 "fwddgm=\"%.2f\" "
1118                 "idel=\"%.2f\" "
1119                 "orq=\"%.2f\" "
1120                 "asmrq=\"%.2f\" "
1121                 "asmok=\"%.2f\" "
1122                 "fragok=\"%.2f\" "
1123                 "fragcrt=\"%.2f\"/>",
1124                 S_VALUE(snip->InReceives,    snic->InReceives,    itv),
1125                 S_VALUE(snip->ForwDatagrams, snic->ForwDatagrams, itv),
1126                 S_VALUE(snip->InDelivers,    snic->InDelivers,    itv),
1127                 S_VALUE(snip->OutRequests,   snic->OutRequests,   itv),
1128                 S_VALUE(snip->ReasmReqds,    snic->ReasmReqds,    itv),
1129                 S_VALUE(snip->ReasmOKs,      snic->ReasmOKs,      itv),
1130                 S_VALUE(snip->FragOKs,       snic->FragOKs,       itv),
1131                 S_VALUE(snip->FragCreates,   snic->FragCreates,   itv));
1132         tab--;
1133
1134 close_xml_markup:
1135         if (CLOSE_MARKUP(a->options)) {
1136                 xml_markup_network(tab, CLOSE_XML_MARKUP);
1137         }
1138 }
1139
1140 /*
1141  ***************************************************************************
1142  * Display IP network errors statistics in XML.
1143  *
1144  * IN:
1145  * @a           Activity structure with statistics.
1146  * @curr        Index in array for current sample statistics.
1147  * @tab         Indentation in XML output.
1148  * @itv         Interval of time in 1/100th of a second.
1149  ***************************************************************************
1150  */
1151 __print_funct_t xml_print_net_eip_stats(struct activity *a, int curr, int tab,
1152                                         unsigned long long itv)
1153 {
1154         struct stats_net_eip
1155                 *sneic = (struct stats_net_eip *) a->buf[curr],
1156                 *sneip = (struct stats_net_eip *) a->buf[!curr];
1157
1158         if (!IS_SELECTED(a->options) || (a->nr <= 0))
1159                 goto close_xml_markup;
1160
1161         xml_markup_network(tab, OPEN_XML_MARKUP);
1162         tab++;
1163
1164         xprintf(tab, "<net-eip "
1165                 "ihdrerr=\"%.2f\" "
1166                 "iadrerr=\"%.2f\" "
1167                 "iukwnpr=\"%.2f\" "
1168                 "idisc=\"%.2f\" "
1169                 "odisc=\"%.2f\" "
1170                 "onort=\"%.2f\" "
1171                 "asmf=\"%.2f\" "
1172                 "fragf=\"%.2f\"/>",
1173                 S_VALUE(sneip->InHdrErrors,     sneic->InHdrErrors,     itv),
1174                 S_VALUE(sneip->InAddrErrors,    sneic->InAddrErrors,    itv),
1175                 S_VALUE(sneip->InUnknownProtos, sneic->InUnknownProtos, itv),
1176                 S_VALUE(sneip->InDiscards,      sneic->InDiscards,      itv),
1177                 S_VALUE(sneip->OutDiscards,     sneic->OutDiscards,     itv),
1178                 S_VALUE(sneip->OutNoRoutes,     sneic->OutNoRoutes,     itv),
1179                 S_VALUE(sneip->ReasmFails,      sneic->ReasmFails,      itv),
1180                 S_VALUE(sneip->FragFails,       sneic->FragFails,       itv));
1181         tab--;
1182
1183 close_xml_markup:
1184         if (CLOSE_MARKUP(a->options)) {
1185                 xml_markup_network(tab, CLOSE_XML_MARKUP);
1186         }
1187 }
1188
1189 /*
1190  ***************************************************************************
1191  * Display ICMP network statistics in XML.
1192  *
1193  * IN:
1194  * @a           Activity structure with statistics.
1195  * @curr        Index in array for current sample statistics.
1196  * @tab         Indentation in XML output.
1197  * @itv         Interval of time in 1/100th of a second.
1198  ***************************************************************************
1199  */
1200 __print_funct_t xml_print_net_icmp_stats(struct activity *a, int curr, int tab,
1201                                          unsigned long long itv)
1202 {
1203         struct stats_net_icmp
1204                 *snic = (struct stats_net_icmp *) a->buf[curr],
1205                 *snip = (struct stats_net_icmp *) a->buf[!curr];
1206
1207         if (!IS_SELECTED(a->options) || (a->nr <= 0))
1208                 goto close_xml_markup;
1209
1210         xml_markup_network(tab, OPEN_XML_MARKUP);
1211         tab++;
1212
1213         xprintf(tab, "<net-icmp "
1214                 "imsg=\"%.2f\" "
1215                 "omsg=\"%.2f\" "
1216                 "iech=\"%.2f\" "
1217                 "iechr=\"%.2f\" "
1218                 "oech=\"%.2f\" "
1219                 "oechr=\"%.2f\" "
1220                 "itm=\"%.2f\" "
1221                 "itmr=\"%.2f\" "
1222                 "otm=\"%.2f\" "
1223                 "otmr=\"%.2f\" "
1224                 "iadrmk=\"%.2f\" "
1225                 "iadrmkr=\"%.2f\" "
1226                 "oadrmk=\"%.2f\" "
1227                 "oadrmkr=\"%.2f\"/>",
1228                 S_VALUE(snip->InMsgs,           snic->InMsgs,           itv),
1229                 S_VALUE(snip->OutMsgs,          snic->OutMsgs,          itv),
1230                 S_VALUE(snip->InEchos,          snic->InEchos,          itv),
1231                 S_VALUE(snip->InEchoReps,       snic->InEchoReps,       itv),
1232                 S_VALUE(snip->OutEchos,         snic->OutEchos,         itv),
1233                 S_VALUE(snip->OutEchoReps,      snic->OutEchoReps,      itv),
1234                 S_VALUE(snip->InTimestamps,     snic->InTimestamps,     itv),
1235                 S_VALUE(snip->InTimestampReps,  snic->InTimestampReps,  itv),
1236                 S_VALUE(snip->OutTimestamps,    snic->OutTimestamps,    itv),
1237                 S_VALUE(snip->OutTimestampReps, snic->OutTimestampReps, itv),
1238                 S_VALUE(snip->InAddrMasks,      snic->InAddrMasks,      itv),
1239                 S_VALUE(snip->InAddrMaskReps,   snic->InAddrMaskReps,   itv),
1240                 S_VALUE(snip->OutAddrMasks,     snic->OutAddrMasks,     itv),
1241                 S_VALUE(snip->OutAddrMaskReps,  snic->OutAddrMaskReps,  itv));
1242         tab--;
1243
1244 close_xml_markup:
1245         if (CLOSE_MARKUP(a->options)) {
1246                 xml_markup_network(tab, CLOSE_XML_MARKUP);
1247         }
1248 }
1249
1250 /*
1251  ***************************************************************************
1252  * Display ICMP error messages statistics in XML.
1253  *
1254  * IN:
1255  * @a           Activity structure with statistics.
1256  * @curr        Index in array for current sample statistics.
1257  * @tab         Indentation in XML output.
1258  * @itv         Interval of time in 1/100th of a second.
1259  ***************************************************************************
1260  */
1261 __print_funct_t xml_print_net_eicmp_stats(struct activity *a, int curr, int tab,
1262                                           unsigned long long itv)
1263 {
1264         struct stats_net_eicmp
1265                 *sneic = (struct stats_net_eicmp *) a->buf[curr],
1266                 *sneip = (struct stats_net_eicmp *) a->buf[!curr];
1267
1268         if (!IS_SELECTED(a->options) || (a->nr <= 0))
1269                 goto close_xml_markup;
1270
1271         xml_markup_network(tab, OPEN_XML_MARKUP);
1272         tab++;
1273
1274         xprintf(tab, "<net-eicmp "
1275                 "ierr=\"%.2f\" "
1276                 "oerr=\"%.2f\" "
1277                 "idstunr=\"%.2f\" "
1278                 "odstunr=\"%.2f\" "
1279                 "itmex=\"%.2f\" "
1280                 "otmex=\"%.2f\" "
1281                 "iparmpb=\"%.2f\" "
1282                 "oparmpb=\"%.2f\" "
1283                 "isrcq=\"%.2f\" "
1284                 "osrcq=\"%.2f\" "
1285                 "iredir=\"%.2f\" "
1286                 "oredir=\"%.2f\"/>",
1287                 S_VALUE(sneip->InErrors,        sneic->InErrors,        itv),
1288                 S_VALUE(sneip->OutErrors,       sneic->OutErrors,       itv),
1289                 S_VALUE(sneip->InDestUnreachs,  sneic->InDestUnreachs,  itv),
1290                 S_VALUE(sneip->OutDestUnreachs, sneic->OutDestUnreachs, itv),
1291                 S_VALUE(sneip->InTimeExcds,     sneic->InTimeExcds,     itv),
1292                 S_VALUE(sneip->OutTimeExcds,    sneic->OutTimeExcds,    itv),
1293                 S_VALUE(sneip->InParmProbs,     sneic->InParmProbs,     itv),
1294                 S_VALUE(sneip->OutParmProbs,    sneic->OutParmProbs,    itv),
1295                 S_VALUE(sneip->InSrcQuenchs,    sneic->InSrcQuenchs,    itv),
1296                 S_VALUE(sneip->OutSrcQuenchs,   sneic->OutSrcQuenchs,   itv),
1297                 S_VALUE(sneip->InRedirects,     sneic->InRedirects,     itv),
1298                 S_VALUE(sneip->OutRedirects,    sneic->OutRedirects,    itv));
1299         tab--;
1300
1301 close_xml_markup:
1302         if (CLOSE_MARKUP(a->options)) {
1303                 xml_markup_network(tab, CLOSE_XML_MARKUP);
1304         }
1305 }
1306
1307 /*
1308  ***************************************************************************
1309  * Display TCP network statistics in XML.
1310  *
1311  * IN:
1312  * @a           Activity structure with statistics.
1313  * @curr        Index in array for current sample statistics.
1314  * @tab         Indentation in XML output.
1315  * @itv         Interval of time in 1/100th of a second.
1316  ***************************************************************************
1317  */
1318 __print_funct_t xml_print_net_tcp_stats(struct activity *a, int curr, int tab,
1319                                         unsigned long long itv)
1320 {
1321         struct stats_net_tcp
1322                 *sntc = (struct stats_net_tcp *) a->buf[curr],
1323                 *sntp = (struct stats_net_tcp *) a->buf[!curr];
1324
1325         if (!IS_SELECTED(a->options) || (a->nr <= 0))
1326                 goto close_xml_markup;
1327
1328         xml_markup_network(tab, OPEN_XML_MARKUP);
1329         tab++;
1330
1331         xprintf(tab, "<net-tcp "
1332                 "active=\"%.2f\" "
1333                 "passive=\"%.2f\" "
1334                 "iseg=\"%.2f\" "
1335                 "oseg=\"%.2f\"/>",
1336                 S_VALUE(sntp->ActiveOpens,  sntc->ActiveOpens,  itv),
1337                 S_VALUE(sntp->PassiveOpens, sntc->PassiveOpens, itv),
1338                 S_VALUE(sntp->InSegs,       sntc->InSegs,       itv),
1339                 S_VALUE(sntp->OutSegs,      sntc->OutSegs,      itv));
1340         tab--;
1341
1342 close_xml_markup:
1343         if (CLOSE_MARKUP(a->options)) {
1344                 xml_markup_network(tab, CLOSE_XML_MARKUP);
1345         }
1346 }
1347
1348 /*
1349  ***************************************************************************
1350  * Display TCP network errors statistics in XML.
1351  *
1352  * IN:
1353  * @a           Activity structure with statistics.
1354  * @curr        Index in array for current sample statistics.
1355  * @tab         Indentation in XML output.
1356  * @itv         Interval of time in 1/100th of a second.
1357  ***************************************************************************
1358  */
1359 __print_funct_t xml_print_net_etcp_stats(struct activity *a, int curr, int tab,
1360                                          unsigned long long itv)
1361 {
1362         struct stats_net_etcp
1363                 *snetc = (struct stats_net_etcp *) a->buf[curr],
1364                 *snetp = (struct stats_net_etcp *) a->buf[!curr];
1365
1366         if (!IS_SELECTED(a->options) || (a->nr <= 0))
1367                 goto close_xml_markup;
1368
1369         xml_markup_network(tab, OPEN_XML_MARKUP);
1370         tab++;
1371
1372         xprintf(tab, "<net-etcp "
1373                 "atmptf=\"%.2f\" "
1374                 "estres=\"%.2f\" "
1375                 "retrans=\"%.2f\" "
1376                 "isegerr=\"%.2f\" "
1377                 "orsts=\"%.2f\"/>",
1378                 S_VALUE(snetp->AttemptFails, snetc->AttemptFails,  itv),
1379                 S_VALUE(snetp->EstabResets,  snetc->EstabResets,  itv),
1380                 S_VALUE(snetp->RetransSegs,  snetc->RetransSegs,  itv),
1381                 S_VALUE(snetp->InErrs,       snetc->InErrs,  itv),
1382                 S_VALUE(snetp->OutRsts,      snetc->OutRsts,  itv));
1383         tab--;
1384
1385 close_xml_markup:
1386         if (CLOSE_MARKUP(a->options)) {
1387                 xml_markup_network(tab, CLOSE_XML_MARKUP);
1388         }
1389 }
1390
1391 /*
1392  ***************************************************************************
1393  * Display UDP network statistics in XML.
1394  *
1395  * IN:
1396  * @a           Activity structure with statistics.
1397  * @curr        Index in array for current sample statistics.
1398  * @tab         Indentation in XML output.
1399  * @itv         Interval of time in 1/100th of a second.
1400  ***************************************************************************
1401  */
1402 __print_funct_t xml_print_net_udp_stats(struct activity *a, int curr, int tab,
1403                                         unsigned long long itv)
1404 {
1405         struct stats_net_udp
1406                 *snuc = (struct stats_net_udp *) a->buf[curr],
1407                 *snup = (struct stats_net_udp *) a->buf[!curr];
1408
1409         if (!IS_SELECTED(a->options) || (a->nr <= 0))
1410                 goto close_xml_markup;
1411
1412         xml_markup_network(tab, OPEN_XML_MARKUP);
1413         tab++;
1414
1415         xprintf(tab, "<net-udp "
1416                 "idgm=\"%.2f\" "
1417                 "odgm=\"%.2f\" "
1418                 "noport=\"%.2f\" "
1419                 "idgmerr=\"%.2f\"/>",
1420                 S_VALUE(snup->InDatagrams,  snuc->InDatagrams,  itv),
1421                 S_VALUE(snup->OutDatagrams, snuc->OutDatagrams, itv),
1422                 S_VALUE(snup->NoPorts,      snuc->NoPorts,      itv),
1423                 S_VALUE(snup->InErrors,     snuc->InErrors,     itv));
1424         tab--;
1425
1426 close_xml_markup:
1427         if (CLOSE_MARKUP(a->options)) {
1428                 xml_markup_network(tab, CLOSE_XML_MARKUP);
1429         }
1430 }
1431
1432 /*
1433  ***************************************************************************
1434  * Display IPv6 network socket statistics in XML.
1435  *
1436  * IN:
1437  * @a           Activity structure with statistics.
1438  * @curr        Index in array for current sample statistics.
1439  * @tab         Indentation in XML output.
1440  * @itv         Interval of time in 1/100th of a second.
1441  ***************************************************************************
1442  */
1443 __print_funct_t xml_print_net_sock6_stats(struct activity *a, int curr, int tab,
1444                                           unsigned long long itv)
1445 {
1446         struct stats_net_sock6
1447                 *snsc = (struct stats_net_sock6 *) a->buf[curr];
1448
1449         if (!IS_SELECTED(a->options) || (a->nr <= 0))
1450                 goto close_xml_markup;
1451
1452         xml_markup_network(tab, OPEN_XML_MARKUP);
1453         tab++;
1454
1455         xprintf(tab, "<net-sock6 "
1456                 "tcp6sck=\"%u\" "
1457                 "udp6sck=\"%u\" "
1458                 "raw6sck=\"%u\" "
1459                 "ip6-frag=\"%u\"/>",
1460                 snsc->tcp6_inuse,
1461                 snsc->udp6_inuse,
1462                 snsc->raw6_inuse,
1463                 snsc->frag6_inuse);
1464         tab--;
1465
1466 close_xml_markup:
1467         if (CLOSE_MARKUP(a->options)) {
1468                 xml_markup_network(tab, CLOSE_XML_MARKUP);
1469         }
1470 }
1471
1472 /*
1473  ***************************************************************************
1474  * Display IPv6 network statistics in XML.
1475  *
1476  * IN:
1477  * @a           Activity structure with statistics.
1478  * @curr        Index in array for current sample statistics.
1479  * @tab         Indentation in XML output.
1480  * @itv         Interval of time in 1/100th of a second.
1481  ***************************************************************************
1482  */
1483 __print_funct_t xml_print_net_ip6_stats(struct activity *a, int curr, int tab,
1484                                         unsigned long long itv)
1485 {
1486         struct stats_net_ip6
1487                 *snic = (struct stats_net_ip6 *) a->buf[curr],
1488                 *snip = (struct stats_net_ip6 *) a->buf[!curr];
1489
1490         if (!IS_SELECTED(a->options) || (a->nr <= 0))
1491                 goto close_xml_markup;
1492
1493         xml_markup_network(tab, OPEN_XML_MARKUP);
1494         tab++;
1495
1496         xprintf(tab, "<net-ip6 "
1497                 "irec6=\"%.2f\" "
1498                 "fwddgm6=\"%.2f\" "
1499                 "idel6=\"%.2f\" "
1500                 "orq6=\"%.2f\" "
1501                 "asmrq6=\"%.2f\" "
1502                 "asmok6=\"%.2f\" "
1503                 "imcpck6=\"%.2f\" "
1504                 "omcpck6=\"%.2f\" "
1505                 "fragok6=\"%.2f\" "
1506                 "fragcr6=\"%.2f\"/>",
1507                 S_VALUE(snip->InReceives6,       snic->InReceives6,       itv),
1508                 S_VALUE(snip->OutForwDatagrams6, snic->OutForwDatagrams6, itv),
1509                 S_VALUE(snip->InDelivers6,       snic->InDelivers6,       itv),
1510                 S_VALUE(snip->OutRequests6,      snic->OutRequests6,      itv),
1511                 S_VALUE(snip->ReasmReqds6,       snic->ReasmReqds6,       itv),
1512                 S_VALUE(snip->ReasmOKs6,         snic->ReasmOKs6,         itv),
1513                 S_VALUE(snip->InMcastPkts6,      snic->InMcastPkts6,      itv),
1514                 S_VALUE(snip->OutMcastPkts6,     snic->OutMcastPkts6,     itv),
1515                 S_VALUE(snip->FragOKs6,          snic->FragOKs6,          itv),
1516                 S_VALUE(snip->FragCreates6,      snic->FragCreates6,      itv));
1517         tab--;
1518
1519 close_xml_markup:
1520         if (CLOSE_MARKUP(a->options)) {
1521                 xml_markup_network(tab, CLOSE_XML_MARKUP);
1522         }
1523 }
1524
1525 /*
1526  ***************************************************************************
1527  * Display IPv6 network errors statistics in XML.
1528  *
1529  * IN:
1530  * @a           Activity structure with statistics.
1531  * @curr        Index in array for current sample statistics.
1532  * @tab         Indentation in XML output.
1533  * @itv         Interval of time in 1/100th of a second.
1534  ***************************************************************************
1535  */
1536 __print_funct_t xml_print_net_eip6_stats(struct activity *a, int curr, int tab,
1537                                          unsigned long long itv)
1538 {
1539         struct stats_net_eip6
1540                 *sneic = (struct stats_net_eip6 *) a->buf[curr],
1541                 *sneip = (struct stats_net_eip6 *) a->buf[!curr];
1542
1543         if (!IS_SELECTED(a->options) || (a->nr <= 0))
1544                 goto close_xml_markup;
1545
1546         xml_markup_network(tab, OPEN_XML_MARKUP);
1547         tab++;
1548
1549         xprintf(tab, "<net-eip6 "
1550                 "ihdrer6=\"%.2f\" "
1551                 "iadrer6=\"%.2f\" "
1552                 "iukwnp6=\"%.2f\" "
1553                 "i2big6=\"%.2f\" "
1554                 "idisc6=\"%.2f\" "
1555                 "odisc6=\"%.2f\" "
1556                 "inort6=\"%.2f\" "
1557                 "onort6=\"%.2f\" "
1558                 "asmf6=\"%.2f\" "
1559                 "fragf6=\"%.2f\" "
1560                 "itrpck6=\"%.2f\"/>",
1561                 S_VALUE(sneip->InHdrErrors6,     sneic->InHdrErrors6,     itv),
1562                 S_VALUE(sneip->InAddrErrors6,    sneic->InAddrErrors6,    itv),
1563                 S_VALUE(sneip->InUnknownProtos6, sneic->InUnknownProtos6, itv),
1564                 S_VALUE(sneip->InTooBigErrors6,  sneic->InTooBigErrors6,  itv),
1565                 S_VALUE(sneip->InDiscards6,      sneic->InDiscards6,      itv),
1566                 S_VALUE(sneip->OutDiscards6,     sneic->OutDiscards6,     itv),
1567                 S_VALUE(sneip->InNoRoutes6,      sneic->InNoRoutes6,      itv),
1568                 S_VALUE(sneip->OutNoRoutes6,     sneic->OutNoRoutes6,     itv),
1569                 S_VALUE(sneip->ReasmFails6,      sneic->ReasmFails6,      itv),
1570                 S_VALUE(sneip->FragFails6,       sneic->FragFails6,       itv),
1571                 S_VALUE(sneip->InTruncatedPkts6, sneic->InTruncatedPkts6, itv));
1572         tab--;
1573
1574 close_xml_markup:
1575         if (CLOSE_MARKUP(a->options)) {
1576                 xml_markup_network(tab, CLOSE_XML_MARKUP);
1577         }
1578 }
1579
1580 /*
1581  ***************************************************************************
1582  * Display ICMPv6 network statistics in XML.
1583  *
1584  * IN:
1585  * @a           Activity structure with statistics.
1586  * @curr        Index in array for current sample statistics.
1587  * @tab         Indentation in XML output.
1588  * @itv         Interval of time in 1/100th of a second.
1589  ***************************************************************************
1590  */
1591 __print_funct_t xml_print_net_icmp6_stats(struct activity *a, int curr, int tab,
1592                                           unsigned long long itv)
1593 {
1594         struct stats_net_icmp6
1595                 *snic = (struct stats_net_icmp6 *) a->buf[curr],
1596                 *snip = (struct stats_net_icmp6 *) a->buf[!curr];
1597
1598         if (!IS_SELECTED(a->options) || (a->nr <= 0))
1599                 goto close_xml_markup;
1600
1601         xml_markup_network(tab, OPEN_XML_MARKUP);
1602         tab++;
1603
1604         xprintf(tab, "<net-icmp6 "
1605                 "imsg6=\"%.2f\" "
1606                 "omsg6=\"%.2f\" "
1607                 "iech6=\"%.2f\" "
1608                 "iechr6=\"%.2f\" "
1609                 "oechr6=\"%.2f\" "
1610                 "igmbq6=\"%.2f\" "
1611                 "igmbr6=\"%.2f\" "
1612                 "ogmbr6=\"%.2f\" "
1613                 "igmbrd6=\"%.2f\" "
1614                 "ogmbrd6=\"%.2f\" "
1615                 "irtsol6=\"%.2f\" "
1616                 "ortsol6=\"%.2f\" "
1617                 "irtad6=\"%.2f\" "
1618                 "inbsol6=\"%.2f\" "
1619                 "onbsol6=\"%.2f\" "
1620                 "inbad6=\"%.2f\" "
1621                 "onbad6=\"%.2f\"/>",
1622                 S_VALUE(snip->InMsgs6,                    snic->InMsgs6,                    itv),
1623                 S_VALUE(snip->OutMsgs6,                   snic->OutMsgs6,                   itv),
1624                 S_VALUE(snip->InEchos6,                   snic->InEchos6,                   itv),
1625                 S_VALUE(snip->InEchoReplies6,             snic->InEchoReplies6,             itv),
1626                 S_VALUE(snip->OutEchoReplies6,            snic->OutEchoReplies6,            itv),
1627                 S_VALUE(snip->InGroupMembQueries6,        snic->InGroupMembQueries6,        itv),
1628                 S_VALUE(snip->InGroupMembResponses6,      snic->InGroupMembResponses6,      itv),
1629                 S_VALUE(snip->OutGroupMembResponses6,     snic->OutGroupMembResponses6,     itv),
1630                 S_VALUE(snip->InGroupMembReductions6,     snic->InGroupMembReductions6,     itv),
1631                 S_VALUE(snip->OutGroupMembReductions6,    snic->OutGroupMembReductions6,    itv),
1632                 S_VALUE(snip->InRouterSolicits6,          snic->InRouterSolicits6,          itv),
1633                 S_VALUE(snip->OutRouterSolicits6,         snic->OutRouterSolicits6,         itv),
1634                 S_VALUE(snip->InRouterAdvertisements6,    snic->InRouterAdvertisements6,    itv),
1635                 S_VALUE(snip->InNeighborSolicits6,        snic->InNeighborSolicits6,        itv),
1636                 S_VALUE(snip->OutNeighborSolicits6,       snic->OutNeighborSolicits6,       itv),
1637                 S_VALUE(snip->InNeighborAdvertisements6,  snic->InNeighborAdvertisements6,  itv),
1638                 S_VALUE(snip->OutNeighborAdvertisements6, snic->OutNeighborAdvertisements6, itv));
1639         tab--;
1640
1641 close_xml_markup:
1642         if (CLOSE_MARKUP(a->options)) {
1643                 xml_markup_network(tab, CLOSE_XML_MARKUP);
1644         }
1645 }
1646
1647 /*
1648  ***************************************************************************
1649  * Display ICMPv6 error messages statistics in XML.
1650  *
1651  * IN:
1652  * @a           Activity structure with statistics.
1653  * @curr        Index in array for current sample statistics.
1654  * @tab         Indentation in XML output.
1655  * @itv         Interval of time in 1/100th of a second.
1656  ***************************************************************************
1657  */
1658 __print_funct_t xml_print_net_eicmp6_stats(struct activity *a, int curr, int tab,
1659                                            unsigned long long itv)
1660 {
1661         struct stats_net_eicmp6
1662                 *sneic = (struct stats_net_eicmp6 *) a->buf[curr],
1663                 *sneip = (struct stats_net_eicmp6 *) a->buf[!curr];
1664
1665         if (!IS_SELECTED(a->options) || (a->nr <= 0))
1666                 goto close_xml_markup;
1667
1668         xml_markup_network(tab, OPEN_XML_MARKUP);
1669         tab++;
1670
1671         xprintf(tab, "<net-eicmp6 "
1672                 "ierr6=\"%.2f\" "
1673                 "idtunr6=\"%.2f\" "
1674                 "odtunr6=\"%.2f\" "
1675                 "itmex6=\"%.2f\" "
1676                 "otmex6=\"%.2f\" "
1677                 "iprmpb6=\"%.2f\" "
1678                 "oprmpb6=\"%.2f\" "
1679                 "iredir6=\"%.2f\" "
1680                 "oredir6=\"%.2f\" "
1681                 "ipck2b6=\"%.2f\" "
1682                 "opck2b6=\"%.2f\"/>",
1683                 S_VALUE(sneip->InErrors6,        sneic->InErrors6,        itv),
1684                 S_VALUE(sneip->InDestUnreachs6,  sneic->InDestUnreachs6,  itv),
1685                 S_VALUE(sneip->OutDestUnreachs6, sneic->OutDestUnreachs6, itv),
1686                 S_VALUE(sneip->InTimeExcds6,     sneic->InTimeExcds6,     itv),
1687                 S_VALUE(sneip->OutTimeExcds6,    sneic->OutTimeExcds6,    itv),
1688                 S_VALUE(sneip->InParmProblems6,  sneic->InParmProblems6,  itv),
1689                 S_VALUE(sneip->OutParmProblems6, sneic->OutParmProblems6, itv),
1690                 S_VALUE(sneip->InRedirects6,     sneic->InRedirects6,     itv),
1691                 S_VALUE(sneip->OutRedirects6,    sneic->OutRedirects6,    itv),
1692                 S_VALUE(sneip->InPktTooBigs6,    sneic->InPktTooBigs6,    itv),
1693                 S_VALUE(sneip->OutPktTooBigs6,   sneic->OutPktTooBigs6,   itv));
1694         tab--;
1695
1696 close_xml_markup:
1697         if (CLOSE_MARKUP(a->options)) {
1698                 xml_markup_network(tab, CLOSE_XML_MARKUP);
1699         }
1700 }
1701
1702 /*
1703  ***************************************************************************
1704  * Display UDPv6 network statistics in XML.
1705  *
1706  * IN:
1707  * @a           Activity structure with statistics.
1708  * @curr        Index in array for current sample statistics.
1709  * @tab         Indentation in XML output.
1710  * @itv         Interval of time in 1/100th of a second.
1711  ***************************************************************************
1712  */
1713 __print_funct_t xml_print_net_udp6_stats(struct activity *a, int curr, int tab,
1714                                          unsigned long long itv)
1715 {
1716         struct stats_net_udp6
1717                 *snuc = (struct stats_net_udp6 *) a->buf[curr],
1718                 *snup = (struct stats_net_udp6 *) a->buf[!curr];
1719
1720         if (!IS_SELECTED(a->options) || (a->nr <= 0))
1721                 goto close_xml_markup;
1722
1723         xml_markup_network(tab, OPEN_XML_MARKUP);
1724         tab++;
1725
1726         xprintf(tab, "<net-udp6 "
1727                 "idgm6=\"%.2f\" "
1728                 "odgm6=\"%.2f\" "
1729                 "noport6=\"%.2f\" "
1730                 "idgmer6=\"%.2f\"/>",
1731                 S_VALUE(snup->InDatagrams6,  snuc->InDatagrams6,  itv),
1732                 S_VALUE(snup->OutDatagrams6, snuc->OutDatagrams6, itv),
1733                 S_VALUE(snup->NoPorts6,      snuc->NoPorts6,      itv),
1734                 S_VALUE(snup->InErrors6,     snuc->InErrors6,     itv));
1735         tab--;
1736
1737 close_xml_markup:
1738         if (CLOSE_MARKUP(a->options)) {
1739                 xml_markup_network(tab, CLOSE_XML_MARKUP);
1740         }
1741 }
1742
1743 /*
1744  ***************************************************************************
1745  * Display CPU frequency statistics in XML.
1746  *
1747  * IN:
1748  * @a           Activity structure with statistics.
1749  * @curr        Index in array for current sample statistics.
1750  * @tab         Indentation in XML output.
1751  * @itv         Interval of time in 1/100th of a second.
1752  ***************************************************************************
1753  */
1754 __print_funct_t xml_print_pwr_cpufreq_stats(struct activity *a, int curr, int tab,
1755                                             unsigned long long itv)
1756 {
1757         int i;
1758         struct stats_pwr_cpufreq *spc;
1759         char cpuno[16];
1760
1761         if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
1762                 goto close_xml_markup;
1763
1764         xml_markup_power_management(tab, OPEN_XML_MARKUP);
1765         tab++;
1766
1767         xprintf(tab++, "<cpu-frequency unit=\"MHz\">");
1768
1769         for (i = 0; (i < a->nr[curr]) && (i < a->bitmap->b_size + 1); i++) {
1770
1771                 spc = (struct stats_pwr_cpufreq *) ((char *) a->buf[curr] + i * a->msize);
1772
1773                 /* Should current CPU (including CPU "all") be displayed? */
1774                 if (!(a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))))
1775                         /* No */
1776                         continue;
1777
1778                 /* Yes: Display it */
1779                 if (!i) {
1780                         /* This is CPU "all" */
1781                         strcpy(cpuno, "all");
1782                 }
1783                 else {
1784                         sprintf(cpuno, "%d", i - 1);
1785                 }
1786
1787                 xprintf(tab, "<cpufreq number=\"%s\" "
1788                         "frequency=\"%.2f\"/>",
1789                         cpuno,
1790                         ((double) spc->cpufreq) / 100);
1791         }
1792
1793         xprintf(--tab, "</cpu-frequency>");
1794         tab--;
1795
1796 close_xml_markup:
1797         if (CLOSE_MARKUP(a->options)) {
1798                 xml_markup_power_management(tab, CLOSE_XML_MARKUP);
1799         }
1800 }
1801
1802 /*
1803  ***************************************************************************
1804  * Display fan statistics in XML.
1805  *
1806  * IN:
1807  * @a           Activity structure with statistics.
1808  * @curr        Index in array for current sample statistics.
1809  * @tab         Indentation in XML output.
1810  * @itv         Interval of time in 1/100th of a second.
1811  ***************************************************************************
1812  */
1813 __print_funct_t xml_print_pwr_fan_stats(struct activity *a, int curr, int tab,
1814                                         unsigned long long itv)
1815 {
1816         int i;
1817         struct stats_pwr_fan *spc;
1818
1819         if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
1820                 goto close_xml_markup;
1821
1822         xml_markup_power_management(tab, OPEN_XML_MARKUP);
1823         tab++;
1824
1825         xprintf(tab++, "<fan-speed unit=\"rpm\">");
1826
1827         for (i = 0; i < a->nr[curr]; i++) {
1828                 spc = (struct stats_pwr_fan *) ((char *) a->buf[curr] + i * a->msize);
1829
1830                 xprintf(tab, "<fan number=\"%d\" rpm=\"%llu\" drpm=\"%llu\" device=\"%s\"/>",
1831                         i + 1,
1832                         (unsigned long long) spc->rpm,
1833                         (unsigned long long) (spc->rpm - spc->rpm_min),
1834                         spc->device);
1835         }
1836
1837         xprintf(--tab, "</fan-speed>");
1838         tab--;
1839
1840 close_xml_markup:
1841         if (CLOSE_MARKUP(a->options)) {
1842                 xml_markup_power_management(tab, CLOSE_XML_MARKUP);
1843         }
1844 }
1845
1846 /*
1847  ***************************************************************************
1848  * Display temperature statistics in XML.
1849  *
1850  * IN:
1851  * @a           Activity structure with statistics.
1852  * @curr        Index in array for current sample statistics.
1853  * @tab         Indentation in XML output.
1854  * @itv         Interval of time in 1/100th of a second.
1855  ***************************************************************************
1856  */
1857 __print_funct_t xml_print_pwr_temp_stats(struct activity *a, int curr, int tab,
1858                                          unsigned long long itv)
1859 {
1860         int i;
1861         struct stats_pwr_temp *spc;
1862
1863         if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
1864                 goto close_xml_markup;
1865
1866         xml_markup_power_management(tab, OPEN_XML_MARKUP);
1867         tab++;
1868
1869         xprintf(tab++, "<temperature unit=\"degree Celsius\">");
1870
1871         for (i = 0; i < a->nr[curr]; i++) {
1872                 spc = (struct stats_pwr_temp *) ((char *) a->buf[curr] + i * a->msize);
1873
1874                 xprintf(tab, "<temp number=\"%d\" degC=\"%.2f\" percent-temp=\"%.2f\" device=\"%s\"/>",
1875                         i + 1,
1876                         spc->temp,
1877                         (spc->temp_max - spc->temp_min) ?
1878                         (spc->temp - spc->temp_min) / (spc->temp_max - spc->temp_min) * 100 :
1879                         0.0,
1880                         spc->device);
1881         }
1882
1883         xprintf(--tab, "</temperature>");
1884         tab--;
1885
1886 close_xml_markup:
1887         if (CLOSE_MARKUP(a->options)) {
1888                 xml_markup_power_management(tab, CLOSE_XML_MARKUP);
1889         }
1890 }
1891
1892 /*
1893  ***************************************************************************
1894  * Display voltage inputs statistics in XML.
1895  *
1896  * IN:
1897  * @a           Activity structure with statistics.
1898  * @curr        Index in array for current sample statistics.
1899  * @tab         Indentation in XML output.
1900  * @itv         Interval of time in 1/100th of a second.
1901  ***************************************************************************
1902  */
1903 __print_funct_t xml_print_pwr_in_stats(struct activity *a, int curr, int tab,
1904                                        unsigned long long itv)
1905 {
1906         int i;
1907         struct stats_pwr_in *spc;
1908
1909         if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
1910                 goto close_xml_markup;
1911
1912         xml_markup_power_management(tab, OPEN_XML_MARKUP);
1913         tab++;
1914
1915         xprintf(tab++, "<voltage-input unit=\"V\">");
1916
1917         for (i = 0; i < a->nr[curr]; i++) {
1918                 spc = (struct stats_pwr_in *) ((char *) a->buf[curr] + i * a->msize);
1919
1920                 xprintf(tab, "<in number=\"%d\" inV=\"%.2f\" percent-in=\"%.2f\" device=\"%s\"/>",
1921                         i,
1922                         spc->in,
1923                         (spc->in_max - spc->in_min) ?
1924                         (spc->in - spc->in_min) / (spc->in_max - spc->in_min) * 100 :
1925                         0.0,
1926                         spc->device);
1927         }
1928
1929         xprintf(--tab, "</voltage-input>");
1930         tab--;
1931
1932 close_xml_markup:
1933         if (CLOSE_MARKUP(a->options)) {
1934                 xml_markup_power_management(tab, CLOSE_XML_MARKUP);
1935         }
1936 }
1937
1938 /*
1939  ***************************************************************************
1940  * Display huge pages statistics in XML.
1941  *
1942  * IN:
1943  * @a           Activity structure with statistics.
1944  * @curr        Index in array for current sample statistics.
1945  * @tab         Indentation in XML output.
1946  * @itv         Interval of time in 1/100th of a second.
1947  ***************************************************************************
1948  */
1949 __print_funct_t xml_print_huge_stats(struct activity *a, int curr, int tab,
1950                                      unsigned long long itv)
1951 {
1952         struct stats_huge
1953                 *smc = (struct stats_huge *) a->buf[curr];
1954
1955         xprintf(tab, "<hugepages unit=\"kB\">");
1956
1957         xprintf(++tab, "<hugfree>%llu</hugfree>",
1958                 smc->frhkb);
1959
1960         xprintf(tab, "<hugused>%llu</hugused>",
1961                 smc->tlhkb - smc->frhkb);
1962
1963         xprintf(tab, "<hugused-percent>%.2f</hugused-percent>",
1964                 smc->tlhkb ?
1965                 SP_VALUE(smc->frhkb, smc->tlhkb, smc->tlhkb) :
1966                 0.0);
1967
1968         xprintf(tab, "<hugrsvd>%llu</hugrsvd>",
1969                 smc->rsvdhkb);
1970
1971         xprintf(tab--, "<hugsurp>%llu</hugsurp>",
1972                 smc->surphkb);
1973
1974         xprintf(tab, "</hugepages>");
1975 }
1976
1977 /*
1978  ***************************************************************************
1979  * Display weighted CPU frequency statistics in XML.
1980  *
1981  * IN:
1982  * @a           Activity structure with statistics.
1983  * @curr        Index in array for current sample statistics.
1984  * @tab         Indentation in XML output.
1985  * @itv         Interval of time in 1/100th of a second.
1986  ***************************************************************************
1987  */
1988 __print_funct_t xml_print_pwr_wghfreq_stats(struct activity *a, int curr, int tab,
1989                                             unsigned long long itv)
1990 {
1991         int i, k;
1992         struct stats_pwr_wghfreq *spc, *spp, *spc_k, *spp_k;
1993         unsigned long long tis, tisfreq;
1994         char cpuno[16];
1995
1996         if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
1997                 goto close_xml_markup;
1998
1999         xml_markup_power_management(tab, OPEN_XML_MARKUP);
2000         tab++;
2001
2002         xprintf(tab++, "<cpu-weighted-frequency unit=\"MHz\">");
2003
2004         for (i = 0; (i < a->nr[curr]) && (i < a->bitmap->b_size + 1); i++) {
2005
2006                 spc = (struct stats_pwr_wghfreq *) ((char *) a->buf[curr]  + i * a->msize * a->nr2);
2007                 spp = (struct stats_pwr_wghfreq *) ((char *) a->buf[!curr] + i * a->msize * a->nr2);
2008
2009                 /* Should current CPU (including CPU "all") be displayed? */
2010                 if (!(a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))))
2011                         /* No */
2012                         continue;
2013
2014                 tisfreq = 0;
2015                 tis = 0;
2016
2017                 for (k = 0; k < a->nr2; k++) {
2018
2019                         spc_k = (struct stats_pwr_wghfreq *) ((char *) spc + k * a->msize);
2020                         if (!spc_k->freq)
2021                                 break;
2022                         spp_k = (struct stats_pwr_wghfreq *) ((char *) spp + k * a->msize);
2023
2024                         tisfreq += (spc_k->freq / 1000) *
2025                                    (spc_k->time_in_state - spp_k->time_in_state);
2026                         tis     += (spc_k->time_in_state - spp_k->time_in_state);
2027                 }
2028
2029                 if (!i) {
2030                         /* This is CPU "all" */
2031                         strcpy(cpuno, "all");
2032                 }
2033                 else {
2034                         sprintf(cpuno, "%d", i - 1);
2035                 }
2036
2037                 xprintf(tab, "<cpuwfreq number=\"%s\" "
2038                         "weighted-frequency=\"%.2f\"/>",
2039                         cpuno,
2040                         tis ? ((double) tisfreq) / tis : 0.0);
2041         }
2042
2043         xprintf(--tab, "</cpu-weighted-frequency>");
2044         tab--;
2045
2046 close_xml_markup:
2047         if (CLOSE_MARKUP(a->options)) {
2048                 xml_markup_power_management(tab, CLOSE_XML_MARKUP);
2049         }
2050 }
2051
2052 /*
2053  ***************************************************************************
2054  * Display USB devices statistics in XML.
2055  *
2056  * IN:
2057  * @a           Activity structure with statistics.
2058  * @curr        Index in array for current sample statistics.
2059  * @tab         Indentation in XML output.
2060  * @itv         Interval of time in 1/100th of a second.
2061  ***************************************************************************
2062  */
2063 __print_funct_t xml_print_pwr_usb_stats(struct activity *a, int curr, int tab,
2064                                         unsigned long long itv)
2065 {
2066         int i;
2067         struct stats_pwr_usb *suc;
2068
2069         if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
2070                 goto close_xml_markup;
2071
2072         xml_markup_power_management(tab, OPEN_XML_MARKUP);
2073         tab++;
2074
2075         xprintf(tab++, "<usb-devices>");
2076
2077         for (i = 0; i < a->nr[curr]; i++) {
2078                 suc = (struct stats_pwr_usb *) ((char *) a->buf[curr] + i * a->msize);
2079
2080                 xprintf(tab, "<usb bus_number=\"%d\" idvendor=\"%x\" idprod=\"%x\" "
2081                              "maxpower=\"%u\" manufact=\"%s\" product=\"%s\"/>",
2082                         suc->bus_nr,
2083                         suc->vendor_id,
2084                         suc->product_id,
2085                         suc->bmaxpower << 1,
2086                         suc->manufacturer,
2087                         suc->product);
2088         }
2089
2090         xprintf(--tab, "</usb-devices>");
2091         tab--;
2092
2093 close_xml_markup:
2094         if (CLOSE_MARKUP(a->options)) {
2095                 xml_markup_power_management(tab, CLOSE_XML_MARKUP);
2096         }
2097 }
2098
2099 /*
2100  ***************************************************************************
2101  * Display filesystems statistics in XML.
2102  *
2103  * IN:
2104  * @a           Activity structure with statistics.
2105  * @curr        Index in array for current sample statistics.
2106  * @tab         Indentation in XML output.
2107  * @itv         Interval of time in 1/100th of a second.
2108  ***************************************************************************
2109  */
2110 __print_funct_t xml_print_filesystem_stats(struct activity *a, int curr, int tab,
2111                                            unsigned long long itv)
2112 {
2113         int i;
2114         struct stats_filesystem *sfc;
2115
2116         xprintf(tab++, "<filesystems>");
2117
2118         for (i = 0; i < a->nr[curr]; i++) {
2119
2120                 sfc = (struct stats_filesystem *) ((char *) a->buf[curr] + i * a->msize);
2121
2122                 if (a->item_list != NULL) {
2123                         /* A list of devices has been entered on the command line */
2124                         if (!search_list_item(a->item_list,
2125                                               DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name))
2126                                 /* Device not found */
2127                                 continue;
2128                 }
2129
2130                 xprintf(tab, "<filesystem %s=\"%s\" "
2131                         "MBfsfree=\"%.0f\" "
2132                         "MBfsused=\"%.0f\" "
2133                         "fsused-percent=\"%.2f\" "
2134                         "ufsused-percent=\"%.2f\" "
2135                         "Ifree=\"%llu\" "
2136                         "Iused=\"%llu\" "
2137                         "Iused-percent=\"%.2f\"/>",
2138                         DISPLAY_MOUNT(a->opt_flags) ? "mountp" : "fsname",
2139                         DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name,
2140                         (double) sfc->f_bfree / 1024 / 1024,
2141                         (double) (sfc->f_blocks - sfc->f_bfree) / 1024 / 1024,
2142                         /* f_blocks is not zero. But test it anyway ;-) */
2143                         sfc->f_blocks ? SP_VALUE(sfc->f_bfree, sfc->f_blocks, sfc->f_blocks)
2144                                       : 0.0,
2145                         sfc->f_blocks ? SP_VALUE(sfc->f_bavail, sfc->f_blocks, sfc->f_blocks)
2146                                       : 0.0,
2147                         sfc->f_ffree,
2148                         sfc->f_files - sfc->f_ffree,
2149                         sfc->f_files ? SP_VALUE(sfc->f_ffree, sfc->f_files, sfc->f_files)
2150                                      : 0.0);
2151         }
2152
2153         xprintf(--tab, "</filesystems>");
2154 }
2155
2156 /*
2157  ***************************************************************************
2158  * Display Fibre Channel HBA statistics in XML.
2159  *
2160  * IN:
2161  * @a           Activity structure with statistics.
2162  * @curr        Index in array for current sample statistics.
2163  * @tab         Indentation in XML output.
2164  * @itv         Interval of time in 1/100th of a second.
2165  ***************************************************************************
2166  */
2167 __print_funct_t xml_print_fchost_stats(struct activity *a, int curr, int tab,
2168                                        unsigned long long itv)
2169 {
2170         int i, j, j0, found;
2171         struct stats_fchost *sfcc, *sfcp, sfczero;
2172
2173         if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
2174                 goto close_xml_markup;
2175
2176         memset(&sfczero, 0, sizeof(struct stats_fchost));
2177
2178         xml_markup_network(tab, OPEN_XML_MARKUP);
2179         tab++;
2180
2181         for (i = 0; i < a->nr[curr]; i++) {
2182
2183                 found = FALSE;
2184                 sfcc = (struct stats_fchost *) ((char *) a->buf[curr] + i * a->msize);
2185
2186                 if (a->nr[!curr] > 0) {
2187                         /* Look for corresponding structure in previous iteration */
2188                         j = i;
2189
2190                         if (j >= a->nr[!curr]) {
2191                                 j = a->nr[!curr] - 1;
2192                         }
2193
2194                         j0 = j;
2195
2196                         do {
2197                                 sfcp = (struct stats_fchost *) ((char *) a->buf[!curr] + j * a->msize);
2198                                 if (!strcmp(sfcc->fchost_name, sfcp->fchost_name)) {
2199                                         found = TRUE;
2200                                         break;
2201                                 }
2202                                 if (++j >= a->nr[!curr]) {
2203                                         j = 0;
2204                                 }
2205                         }
2206                         while (j != j0);
2207                 }
2208
2209                 if (!found) {
2210                         /* This is a newly registered host */
2211                         sfcp = &sfczero;
2212                 }
2213
2214                 xprintf(tab, "<fchost name=\"%s\" "
2215                         "fch_rxf=\"%.2f\" "
2216                         "fch_txf=\"%.2f\" "
2217                         "fch_rxw=\"%.2f\" "
2218                         "fch_txw=\"%.2f\"/>",
2219                         sfcc->fchost_name,
2220                         S_VALUE(sfcp->f_rxframes, sfcc->f_rxframes, itv),
2221                         S_VALUE(sfcp->f_txframes, sfcc->f_txframes, itv),
2222                         S_VALUE(sfcp->f_rxwords,  sfcc->f_rxwords,  itv),
2223                         S_VALUE(sfcp->f_txwords,  sfcc->f_txwords,  itv));
2224         }
2225         tab--;
2226
2227 close_xml_markup:
2228         if (CLOSE_MARKUP(a->options)) {
2229                 xml_markup_network(tab, CLOSE_XML_MARKUP);
2230         }
2231 }
2232
2233 /*
2234  ***************************************************************************
2235  * Display softnet statistics in XML.
2236  *
2237  * IN:
2238  * @a           Activity structure with statistics.
2239  * @curr        Index in array for current sample statistics.
2240  * @tab         Indentation in XML output.
2241  * @itv         Interval of time in 1/100th of a second.
2242  ***************************************************************************
2243  */
2244 __print_funct_t xml_print_softnet_stats(struct activity *a, int curr, int tab,
2245                                         unsigned long long itv)
2246 {
2247         int i;
2248         struct stats_softnet *ssnc, *ssnp;
2249         char cpuno[16];
2250         unsigned char offline_cpu_bitmap[BITMAP_SIZE(NR_CPUS)] = {0};
2251
2252         if (!IS_SELECTED(a->options) || (a->nr[curr] <= 0))
2253                 goto close_xml_markup;
2254
2255         xml_markup_network(tab, OPEN_XML_MARKUP);
2256         tab++;
2257
2258         /* @nr[curr] cannot normally be greater than @nr_ini */
2259         if (a->nr[curr] > a->nr_ini) {
2260                 a->nr_ini = a->nr[curr];
2261         }
2262
2263         /* Compute statistics for CPU "all" */
2264         get_global_soft_statistics(a, !curr, curr, flags, offline_cpu_bitmap);
2265
2266         for (i = 0; (i < a->nr_ini) && (i < a->bitmap->b_size + 1); i++) {
2267
2268                 /* Should current CPU (including CPU "all") be displayed? */
2269                 if (!(a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))) ||
2270                     offline_cpu_bitmap[i >> 3] & (1 << (i & 0x07)))
2271                         /* No */
2272                         continue;
2273
2274                 ssnc = (struct stats_softnet *) ((char *) a->buf[curr]  + i * a->msize);
2275                 ssnp = (struct stats_softnet *) ((char *) a->buf[!curr] + i * a->msize);
2276
2277                 /* Yes: Display it */
2278                 if (!i) {
2279                         /* This is CPU "all" */
2280                         strcpy(cpuno, "all");
2281                 }
2282                 else {
2283                         sprintf(cpuno, "%d", i - 1);
2284                 }
2285
2286                 xprintf(tab, "<softnet cpu=\"%s\" "
2287                         "total=\"%.2f\" "
2288                         "dropd=\"%.2f\" "
2289                         "squeezd=\"%.2f\" "
2290                         "rx_rps=\"%.2f\" "
2291                         "flw_lim=\"%.2f\"/>",
2292                          cpuno,
2293                          S_VALUE(ssnp->processed,    ssnc->processed,    itv),
2294                          S_VALUE(ssnp->dropped,      ssnc->dropped,      itv),
2295                          S_VALUE(ssnp->time_squeeze, ssnc->time_squeeze, itv),
2296                          S_VALUE(ssnp->received_rps, ssnc->received_rps, itv),
2297                          S_VALUE(ssnp->flow_limit,   ssnc->flow_limit,   itv));
2298         }
2299         tab--;
2300
2301 close_xml_markup:
2302         if (CLOSE_MARKUP(a->options)) {
2303                 xml_markup_network(tab, CLOSE_XML_MARKUP);
2304         }
2305 }
2306
2307 /*
2308  ***************************************************************************
2309  * Display pressure-stall CPU statistics in XML.
2310  *
2311  * IN:
2312  * @a           Activity structure with statistics.
2313  * @curr        Index in array for current sample statistics.
2314  * @tab         Indentation in XML output.
2315  * @itv         Interval of time in 1/100th of a second.
2316  ***************************************************************************
2317  */
2318 __print_funct_t xml_print_psicpu_stats(struct activity *a, int curr, int tab,
2319                                        unsigned long long itv)
2320 {
2321         struct stats_psi_cpu
2322                 *psic = (struct stats_psi_cpu *) a->buf[curr],
2323                 *psip = (struct stats_psi_cpu *) a->buf[!curr];
2324
2325         if (!IS_SELECTED(a->options))
2326                 goto close_xml_markup;
2327
2328         xml_markup_psi(tab, OPEN_XML_MARKUP);
2329         tab++;
2330
2331         xprintf(tab, "<psi-cpu "
2332                 "some_avg10=\"%.2f\" "
2333                 "some_avg60=\"%.2f\" "
2334                 "some_avg300=\"%.2f\" "
2335                 "some_avg=\"%.2f\"/>",
2336                 (double) psic->some_acpu_10  / 100,
2337                 (double) psic->some_acpu_60  / 100,
2338                 (double) psic->some_acpu_300 / 100,
2339                 ((double) psic->some_cpu_total - psip->some_cpu_total) / (100 * itv));
2340         tab--;
2341
2342 close_xml_markup:
2343         if (CLOSE_MARKUP(a->options)) {
2344                 xml_markup_psi(tab, CLOSE_XML_MARKUP);
2345         }
2346 }
2347
2348 /*
2349  ***************************************************************************
2350  * Display pressure-stall I/O statistics in XML.
2351  *
2352  * IN:
2353  * @a           Activity structure with statistics.
2354  * @curr        Index in array for current sample statistics.
2355  * @tab         Indentation in XML output.
2356  * @itv         Interval of time in 1/100th of a second.
2357  ***************************************************************************
2358  */
2359 __print_funct_t xml_print_psiio_stats(struct activity *a, int curr, int tab,
2360                                       unsigned long long itv)
2361 {
2362         struct stats_psi_io
2363                 *psic = (struct stats_psi_io *) a->buf[curr],
2364                 *psip = (struct stats_psi_io *) a->buf[!curr];
2365
2366         if (!IS_SELECTED(a->options))
2367                 goto close_xml_markup;
2368
2369         xml_markup_psi(tab, OPEN_XML_MARKUP);
2370         tab++;
2371
2372         xprintf(tab, "<psi-io "
2373                 "some_avg10=\"%.2f\" "
2374                 "some_avg60=\"%.2f\" "
2375                 "some_avg300=\"%.2f\" "
2376                 "some_avg=\"%.2f\" "
2377                 "full_avg10=\"%.2f\" "
2378                 "full_avg60=\"%.2f\" "
2379                 "full_avg300=\"%.2f\" "
2380                 "full_avg=\"%.2f\"/>",
2381                 (double) psic->some_aio_10  / 100,
2382                 (double) psic->some_aio_60  / 100,
2383                 (double) psic->some_aio_300 / 100,
2384                 ((double) psic->some_io_total - psip->some_io_total) / (100 * itv),
2385                 (double) psic->full_aio_10  / 100,
2386                 (double) psic->full_aio_60  / 100,
2387                 (double) psic->full_aio_300 / 100,
2388                 ((double) psic->full_io_total - psip->full_io_total) / (100 * itv));
2389         tab--;
2390
2391 close_xml_markup:
2392         if (CLOSE_MARKUP(a->options)) {
2393                 xml_markup_psi(tab, CLOSE_XML_MARKUP);
2394         }
2395 }
2396
2397 /*
2398  ***************************************************************************
2399  * Display pressure-stall memory statistics in XML.
2400  *
2401  * IN:
2402  * @a           Activity structure with statistics.
2403  * @curr        Index in array for current sample statistics.
2404  * @tab         Indentation in XML output.
2405  * @itv         Interval of time in 1/100th of a second.
2406  ***************************************************************************
2407  */
2408 __print_funct_t xml_print_psimem_stats(struct activity *a, int curr, int tab,
2409                                        unsigned long long itv)
2410 {
2411         struct stats_psi_mem
2412                 *psic = (struct stats_psi_mem *) a->buf[curr],
2413                 *psip = (struct stats_psi_mem *) a->buf[!curr];
2414
2415         if (!IS_SELECTED(a->options))
2416                 goto close_xml_markup;
2417
2418         xml_markup_psi(tab, OPEN_XML_MARKUP);
2419         tab++;
2420
2421         xprintf(tab, "<psi-mem "
2422                 "some_avg10=\"%.2f\" "
2423                 "some_avg60=\"%.2f\" "
2424                 "some_avg300=\"%.2f\" "
2425                 "some_avg=\"%.2f\" "
2426                 "full_avg10=\"%.2f\" "
2427                 "full_avg60=\"%.2f\" "
2428                 "full_avg300=\"%.2f\" "
2429                 "full_avg=\"%.2f\"/>",
2430                 (double) psic->some_amem_10  / 100,
2431                 (double) psic->some_amem_60  / 100,
2432                 (double) psic->some_amem_300 / 100,
2433                 ((double) psic->some_mem_total - psip->some_mem_total) / (100 * itv),
2434                 (double) psic->full_amem_10  / 100,
2435                 (double) psic->full_amem_60  / 100,
2436                 (double) psic->full_amem_300 / 100,
2437                 ((double) psic->full_mem_total - psip->full_mem_total) / (100 * itv));
2438         tab--;
2439
2440 close_xml_markup:
2441         if (CLOSE_MARKUP(a->options)) {
2442                 xml_markup_psi(tab, CLOSE_XML_MARKUP);
2443         }
2444 }