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