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