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