]> granicus.if.org Git - sysstat/blob - rndr_stats.c
sar/sadc: Add stable identifier support for disks statistics
[sysstat] / rndr_stats.c
1 /*
2  * rndr_stats.c: Funtions used by sadf to display statistics in selected format.
3  * (C) 1999-2019 by Sebastien GODARD (sysstat <at> orange.fr)
4  *
5  ***************************************************************************
6  * This program is free software; you can redistribute it and/or modify it *
7  * under the terms of the GNU General Public License as published  by  the *
8  * Free Software Foundation; either version 2 of the License, or (at  your *
9  * option) any later version.                                              *
10  *                                                                         *
11  * This program is distributed in the hope that it  will  be  useful,  but *
12  * WITHOUT ANY WARRANTY; without the implied warranty  of  MERCHANTABILITY *
13  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License *
14  * for more details.                                                       *
15  *                                                                         *
16  * You should have received a copy of the GNU General Public License along *
17  * with this program; if not, write to the Free Software Foundation, Inc., *
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA              *
19  ***************************************************************************
20  */
21
22 #include <stdio.h>
23 #include <string.h>
24 #include <stdarg.h>
25
26 #include "sa.h"
27 #include "ioconf.h"
28 #include "rndr_stats.h"
29
30 #ifdef USE_NLS
31 #include <locale.h>
32 #include <libintl.h>
33 #define _(string) gettext(string)
34 #else
35 #define _(string) (string)
36 #endif
37
38 char *seps[] =  {"\t", ";"};
39
40 extern unsigned int flags;
41
42 /*
43  ***************************************************************************
44  * cons() -
45  *   encapsulate a pair of ints or pair of char * into a static Cons and
46  *   return a pointer to it.
47  *
48  * given:   t - type of Cons {iv, sv}
49  *          arg1 - unsigned long int (if iv), char * (if sv) to become
50  *                 element 'a'
51  *          arg2 - unsigned long int (if iv), char * (if sv) to become
52  *                 element 'b'
53  *
54  * does:    load a static Cons with values using the t parameter to
55  *          guide pulling values from the arglist
56  *
57  * return:  the address of its static Cons.  If you need to keep
58  *          the contents of this Cons, copy it somewhere before calling
59  *          cons() against to avoid overwrite.
60  *          ie. don't do this:  f( cons( iv, i, j ), cons( iv, a, b ) );
61  ***************************************************************************
62  */
63 static Cons *cons(tcons t, ...)
64 {
65         va_list ap;
66         static Cons c;
67
68         c.t = t;
69
70         va_start(ap, t);
71         if (t == iv) {
72                 c.a.i = va_arg(ap, unsigned long int);
73                 c.b.i = va_arg(ap, unsigned long int);
74         }
75         else {
76                 c.a.s = va_arg(ap, char *);
77                 c.b.s = va_arg(ap, char *);
78         }
79         va_end(ap);
80         return(&c);
81 }
82
83 /*
84  ***************************************************************************
85  * render():
86  *
87  * given:    isdb - flag, true if db printing, false if ppc printing
88  *           pre  - prefix string for output entries
89  *           rflags - PT_.... rendering flags
90  *           pptxt - printf-format text required for ppc output (may be null)
91  *           dbtxt - printf-format text required for db output (may be null)
92  *           mid - pptxt/dbtxt format args as a Cons.
93  *           lluval - %llu printable arg (PT_USEINT must be set)
94  *           dval  - %.2f printable arg (used unless PT_USEINT is set)
95  *           sval - %s printable arg (PT_USESTR must be set)
96  *
97  * does:     print [pre<sep>]([dbtxt,arg,arg<sep>]|[pptxt,arg,arg<sep>]) \
98  *                     (luval|dval)(<sep>|\n)
99  *
100  * return:   void.
101  ***************************************************************************
102  */
103 static void render(int isdb, char *pre, int rflags, const char *pptxt,
104                    const char *dbtxt, Cons *mid, unsigned long long lluval,
105                    double dval, char *sval)
106 {
107         static int newline = 1;
108         const char *txt[]  = {pptxt, dbtxt};
109
110         /* Start a new line? */
111         if (newline && !DISPLAY_HORIZONTALLY(flags)) {
112                 printf("%s", pre);
113         }
114
115         /* Terminate this one ? ppc always gets a newline */
116         newline = ((rflags & PT_NEWLIN) || !isdb);
117
118         if (txt[isdb]) {
119                 /* pp/dbtxt? */
120
121                 printf("%s", seps[isdb]);       /* Only if something actually gets printed */
122
123                 if (mid) {
124                         /* Got format args? */
125                         switch(mid->t) {
126                         case iv:
127                                 printf(txt[isdb], mid->a.i, mid->b.i);
128                                 break;
129                         case sv:
130                                 printf(txt[isdb], mid->a.s, mid->b.s);
131                                 break;
132                         }
133                 }
134                 else {
135                         printf("%s", txt[isdb]);
136                 }
137         }
138
139         if (rflags & PT_USEINT) {
140                 printf("%s%llu", seps[isdb], lluval);
141         }
142         else if (rflags & PT_USESTR) {
143                 printf("%s%s", seps[isdb], sval);
144         }
145         else if (rflags & PT_USERND) {
146                 printf("%s%.0f", seps[isdb], dval);
147         }
148         else {
149                 printf("%s%.2f", seps[isdb], dval);
150         }
151         if (newline) {
152                 printf("\n");
153         }
154 }
155
156 /*
157  ***************************************************************************
158  * Display CPU statistics in selected format.
159  *
160  * IN:
161  * @a           Activity structure with statistics.
162  * @isdb        Flag, true if db printing, false if ppc printing.
163  * @pre         Prefix string for output entries
164  * @curr        Index in array for current sample statistics.
165  * @itv         Interval of time in 1/100th of a second (independent of the
166  *              number of processors). Unused here.
167  ***************************************************************************
168  */
169 __print_funct_t render_cpu_stats(struct activity *a, int isdb, char *pre,
170                                  int curr, unsigned long long itv)
171 {
172         int i;
173         unsigned long long deltot_jiffies = 1;
174         struct stats_cpu *scc, *scp;
175         unsigned char offline_cpu_bitmap[BITMAP_SIZE(NR_CPUS)] = {0};
176         int pt_newlin
177                 = (DISPLAY_HORIZONTALLY(flags) ? PT_NOFLAG : PT_NEWLIN);
178
179         /* @nr[curr] cannot normally be greater than @nr_ini */
180         if (a->nr[curr] > a->nr_ini) {
181                 a->nr_ini = a->nr[curr];
182         }
183
184         /*
185          * Compute CPU "all" as sum of all individual CPU (on SMP machines)
186          * and look for offline CPU.
187          */
188         if (a->nr_ini > 1) {
189                 deltot_jiffies = get_global_cpu_statistics(a, !curr, curr,
190                                                            flags, offline_cpu_bitmap);
191         }
192
193         for (i = 0; (i < a->nr_ini) && (i < a->bitmap->b_size + 1); i++) {
194
195                 /* Should current CPU (including CPU "all") be displayed? */
196                 if (!(a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))) ||
197                     offline_cpu_bitmap[i >> 3] & (1 << (i & 0x07)))
198                         /* Don't display CPU */
199                         continue;
200
201                 scc = (struct stats_cpu *) ((char *) a->buf[curr]  + i * a->msize);
202                 scp = (struct stats_cpu *) ((char *) a->buf[!curr] + i * a->msize);
203
204                 if (i == 0) {
205                         /* This is CPU "all" */
206                         if (a->nr_ini == 1) {
207                                 /*
208                                  * This is a UP machine. In this case
209                                  * interval has still not been calculated.
210                                  */
211                                 deltot_jiffies = get_per_cpu_interval(scc, scp);
212                         }
213                         if (!deltot_jiffies) {
214                                 /* CPU "all" cannot be tickless */
215                                 deltot_jiffies = 1;
216                         }
217
218                         if (DISPLAY_CPU_DEF(a->opt_flags)) {
219                                 render(isdb, pre,
220                                        PT_NOFLAG,       /* that's zero but you know what it means */
221                                        "all\t%user",    /* ppctext */
222                                        "-1",            /* look! dbtext */
223                                        NULL,            /* no args */
224                                        NOVAL,           /* another 0, named for readability */
225                                        ll_sp_value(scp->cpu_user, scc->cpu_user, deltot_jiffies),
226                                        NULL);           /* No string arg */
227                         }
228                         else if (DISPLAY_CPU_ALL(a->opt_flags)) {
229                                 render(isdb, pre, PT_NOFLAG,
230                                        "all\t%usr", "-1", NULL,
231                                        NOVAL,
232                                        (scc->cpu_user - scc->cpu_guest) < (scp->cpu_user - scp->cpu_guest) ?
233                                        0.0 :
234                                        ll_sp_value(scp->cpu_user - scp->cpu_guest,
235                                                    scc->cpu_user - scc->cpu_guest,
236                                                    deltot_jiffies),
237                                        NULL);
238                         }
239
240                         if (DISPLAY_CPU_DEF(a->opt_flags)) {
241                                 render(isdb, pre, PT_NOFLAG,
242                                        "all\t%nice", NULL, NULL,
243                                        NOVAL,
244                                        ll_sp_value(scp->cpu_nice, scc->cpu_nice, deltot_jiffies),
245                                        NULL);
246                         }
247                         else if (DISPLAY_CPU_ALL(a->opt_flags)) {
248                                 render(isdb, pre, PT_NOFLAG,
249                                        "all\t%nice", NULL, NULL,
250                                        NOVAL,
251                                        (scc->cpu_nice - scc->cpu_guest_nice) < (scp->cpu_nice - scp->cpu_guest_nice) ?
252                                        0.0 :
253                                        ll_sp_value(scp->cpu_nice - scp->cpu_guest_nice,
254                                                    scc->cpu_nice - scc->cpu_guest_nice,
255                                                    deltot_jiffies),
256                                        NULL);
257                         }
258
259                         if (DISPLAY_CPU_DEF(a->opt_flags)) {
260                                 render(isdb, pre, PT_NOFLAG,
261                                        "all\t%system", NULL, NULL,
262                                        NOVAL,
263                                        ll_sp_value(scp->cpu_sys + scp->cpu_hardirq + scp->cpu_softirq,
264                                                    scc->cpu_sys + scc->cpu_hardirq + scc->cpu_softirq,
265                                                    deltot_jiffies),
266                                        NULL);
267                         }
268                         else if (DISPLAY_CPU_ALL(a->opt_flags)) {
269                                 render(isdb, pre, PT_NOFLAG,
270                                        "all\t%sys", NULL, NULL,
271                                        NOVAL,
272                                        ll_sp_value(scp->cpu_sys, scc->cpu_sys, deltot_jiffies),
273                                        NULL);
274                         }
275
276                         render(isdb, pre, PT_NOFLAG,
277                                "all\t%iowait", NULL, NULL,
278                                NOVAL,
279                                ll_sp_value(scp->cpu_iowait, scc->cpu_iowait, deltot_jiffies),
280                                NULL);
281
282                         render(isdb, pre, PT_NOFLAG,
283                                "all\t%steal", NULL, NULL,
284                                NOVAL,
285                                ll_sp_value(scp->cpu_steal, scc->cpu_steal, deltot_jiffies),
286                                NULL);
287
288                         if (DISPLAY_CPU_ALL(a->opt_flags)) {
289                                 render(isdb, pre, PT_NOFLAG,
290                                        "all\t%irq", NULL, NULL,
291                                        NOVAL,
292                                        ll_sp_value(scp->cpu_hardirq, scc->cpu_hardirq, deltot_jiffies),
293                                        NULL);
294
295                                 render(isdb, pre, PT_NOFLAG,
296                                        "all\t%soft", NULL, NULL,
297                                        NOVAL,
298                                        ll_sp_value(scp->cpu_softirq, scc->cpu_softirq, deltot_jiffies),
299                                        NULL);
300
301                                 render(isdb, pre, PT_NOFLAG,
302                                        "all\t%guest", NULL, NULL,
303                                        NOVAL,
304                                        ll_sp_value(scp->cpu_guest, scc->cpu_guest, deltot_jiffies),
305                                        NULL);
306
307                                 render(isdb, pre, PT_NOFLAG,
308                                        "all\t%gnice", NULL, NULL,
309                                        NOVAL,
310                                        ll_sp_value(scp->cpu_guest_nice, scc->cpu_guest_nice, deltot_jiffies),
311                                        NULL);
312                         }
313
314                         render(isdb, pre, pt_newlin,
315                                "all\t%idle", NULL, NULL,
316                                NOVAL,
317                                (scc->cpu_idle < scp->cpu_idle) ?
318                                0.0 :
319                                ll_sp_value(scp->cpu_idle, scc->cpu_idle, deltot_jiffies),
320                                NULL);
321                 }
322                 else {
323                         /*
324                          * Recalculate itv for current proc.
325                          * If the result is 0, then current CPU is a tickless one.
326                          */
327                         deltot_jiffies = get_per_cpu_interval(scc, scp);
328
329                         if (DISPLAY_CPU_DEF(a->opt_flags)) {
330                                 render(isdb, pre, PT_NOFLAG,
331                                        "cpu%d\t%%user",         /* ppc text with formatting */
332                                        "%d",                    /* db text with format char */
333                                        cons(iv, i - 1, NOVAL),  /* how we pass format args  */
334                                        NOVAL,
335                                        !deltot_jiffies ?
336                                        0.0 :                    /* CPU is tickless */
337                                        ll_sp_value(scp->cpu_user, scc->cpu_user, deltot_jiffies),
338                                        NULL);
339                         }
340                         else if (DISPLAY_CPU_ALL(a->opt_flags)) {
341                                 render(isdb, pre, PT_NOFLAG,
342                                        "cpu%d\t%%usr", "%d", cons(iv, i - 1, NOVAL),
343                                        NOVAL,
344                                        (!deltot_jiffies ||
345                                        ((scc->cpu_user - scc->cpu_guest) < (scp->cpu_user - scp->cpu_guest))) ?
346                                        0.0 :
347                                        ll_sp_value(scp->cpu_user - scp->cpu_guest,
348                                                    scc->cpu_user - scc->cpu_guest, deltot_jiffies),
349                                        NULL);
350                         }
351
352                         if (DISPLAY_CPU_DEF(a->opt_flags)) {
353                                 render(isdb, pre, PT_NOFLAG,
354                                        "cpu%d\t%%nice", NULL, cons(iv, i - 1, NOVAL),
355                                        NOVAL,
356                                        !deltot_jiffies ?
357                                        0.0 :
358                                        ll_sp_value(scp->cpu_nice, scc->cpu_nice, deltot_jiffies),
359                                        NULL);
360                         }
361                         else if (DISPLAY_CPU_ALL(a->opt_flags)) {
362                                 render(isdb, pre, PT_NOFLAG,
363                                        "cpu%d\t%%nice", NULL, cons(iv, i - 1, NOVAL),
364                                        NOVAL,
365                                        (!deltot_jiffies ||
366                                        ((scc->cpu_nice - scc->cpu_guest_nice) < (scp->cpu_nice - scp->cpu_guest_nice))) ?
367                                        0.0 :
368                                        ll_sp_value(scp->cpu_nice - scp->cpu_guest_nice,
369                                                    scc->cpu_nice - scc->cpu_guest_nice, deltot_jiffies),
370                                        NULL);
371                         }
372
373                         if (DISPLAY_CPU_DEF(a->opt_flags)) {
374                                 render(isdb, pre, PT_NOFLAG,
375                                        "cpu%d\t%%system", NULL, cons(iv, i - 1, NOVAL),
376                                        NOVAL,
377                                        !deltot_jiffies ?
378                                        0.0 :
379                                        ll_sp_value(scp->cpu_sys + scp->cpu_hardirq + scp->cpu_softirq,
380                                                    scc->cpu_sys + scc->cpu_hardirq + scc->cpu_softirq,
381                                                    deltot_jiffies),
382                                        NULL);
383                         }
384                         else if (DISPLAY_CPU_ALL(a->opt_flags)) {
385                                 render(isdb, pre, PT_NOFLAG,
386                                        "cpu%d\t%%sys", NULL, cons(iv, i - 1, NOVAL),
387                                        NOVAL,
388                                        !deltot_jiffies ?
389                                        0.0 :
390                                        ll_sp_value(scp->cpu_sys, scc->cpu_sys, deltot_jiffies),
391                                        NULL);
392                         }
393
394                         render(isdb, pre, PT_NOFLAG,
395                                "cpu%d\t%%iowait", NULL, cons(iv, i - 1, NOVAL),
396                                NOVAL,
397                                !deltot_jiffies ?
398                                0.0 :
399                                ll_sp_value(scp->cpu_iowait, scc->cpu_iowait, deltot_jiffies),
400                                NULL);
401
402                         render(isdb, pre, PT_NOFLAG,
403                                "cpu%d\t%%steal", NULL, cons(iv, i - 1, NOVAL),
404                                NOVAL,
405                                !deltot_jiffies ?
406                                0.0 :
407                                ll_sp_value(scp->cpu_steal, scc->cpu_steal, deltot_jiffies),
408                                NULL);
409
410                         if (DISPLAY_CPU_ALL(a->opt_flags)) {
411                                 render(isdb, pre, PT_NOFLAG,
412                                        "cpu%d\t%%irq", NULL, cons(iv, i - 1, NOVAL),
413                                        NOVAL,
414                                        !deltot_jiffies ?
415                                        0.0 :
416                                        ll_sp_value(scp->cpu_hardirq, scc->cpu_hardirq, deltot_jiffies),
417                                        NULL);
418
419                                 render(isdb, pre, PT_NOFLAG,
420                                        "cpu%d\t%%soft", NULL, cons(iv, i - 1, NOVAL),
421                                        NOVAL,
422                                        !deltot_jiffies ?
423                                        0.0 :
424                                        ll_sp_value(scp->cpu_softirq, scc->cpu_softirq, deltot_jiffies),
425                                        NULL);
426
427                                 render(isdb, pre, PT_NOFLAG,
428                                        "cpu%d\t%%guest", NULL, cons(iv, i - 1, NOVAL),
429                                        NOVAL,
430                                        !deltot_jiffies ?
431                                        0.0 :
432                                        ll_sp_value(scp->cpu_guest, scc->cpu_guest, deltot_jiffies),
433                                        NULL);
434
435                                 render(isdb, pre, PT_NOFLAG,
436                                        "cpu%d\t%%gnice", NULL, cons(iv, i - 1, NOVAL),
437                                        NOVAL,
438                                        !deltot_jiffies ?
439                                        0.0 :
440                                        ll_sp_value(scp->cpu_guest_nice, scc->cpu_guest_nice, deltot_jiffies),
441                                        NULL);
442                         }
443
444                         if (!deltot_jiffies) {
445                                 /* CPU is tickless */
446                                 render(isdb, pre, pt_newlin,
447                                        "cpu%d\t%%idle", NULL, cons(iv, i - 1, NOVAL),
448                                        NOVAL,
449                                        100.0,
450                                        NULL);
451                         }
452                         else {
453                                 render(isdb, pre, pt_newlin,
454                                        "cpu%d\t%%idle", NULL, cons(iv, i - 1, NOVAL),
455                                        NOVAL,
456                                        (scc->cpu_idle < scp->cpu_idle) ?
457                                        0.0 :
458                                        ll_sp_value(scp->cpu_idle, scc->cpu_idle, deltot_jiffies),
459                                        NULL);
460                         }
461                 }
462         }
463 }
464
465 /*
466  ***************************************************************************
467  * Display task creation and context switch statistics in selected format.
468  *
469  * IN:
470  * @a           Activity structure with statistics.
471  * @isdb        Flag, true if db printing, false if ppc printing.
472  * @pre         Prefix string for output entries
473  * @curr        Index in array for current sample statistics.
474  * @itv         Interval of time in 1/100th of a second.
475  ***************************************************************************
476  */
477 __print_funct_t render_pcsw_stats(struct activity *a, int isdb, char *pre,
478                                   int curr, unsigned long long itv)
479 {
480         struct stats_pcsw
481                 *spc = (struct stats_pcsw *) a->buf[curr],
482                 *spp = (struct stats_pcsw *) a->buf[!curr];
483         int pt_newlin
484                 = (DISPLAY_HORIZONTALLY(flags) ? PT_NOFLAG : PT_NEWLIN);
485
486         /* The first one as an example */
487         render(isdb,            /* db/ppc flag */
488                pre,             /* the preformatted line leader */
489                PT_NOFLAG,       /* is this the end of a db line? */
490                "-\tproc/s",     /* ppc text */
491                NULL,            /* db text */
492                NULL,            /* db/ppc text format args (Cons *) */
493                NOVAL,           /* %lu value (unused unless PT_USEINT) */
494                /* and %.2f value, used unless PT_USEINT */
495                S_VALUE(spp->processes, spc->processes, itv),
496                NULL);           /* %s value */
497
498         render(isdb, pre, pt_newlin,
499                "-\tcswch/s", NULL, NULL,
500                NOVAL,
501                S_VALUE(spp->context_switch, spc->context_switch, itv),
502                NULL);
503 }
504
505 /*
506  ***************************************************************************
507  * Display interrupts statistics in selected format.
508  *
509  * IN:
510  * @a           Activity structure with statistics.
511  * @isdb        Flag, true if db printing, false if ppc printing.
512  * @pre         Prefix string for output entries
513  * @curr        Index in array for current sample statistics.
514  * @itv         Interval of time in 1/100th of a second.
515  ***************************************************************************
516  */
517 __print_funct_t render_irq_stats(struct activity *a, int isdb, char *pre,
518                                  int curr, unsigned long long itv)
519 {
520         int i;
521         struct stats_irq *sic, *sip;
522         int pt_newlin
523                 = (DISPLAY_HORIZONTALLY(flags) ? PT_NOFLAG : PT_NEWLIN);
524
525         for (i = 0; (i < a->nr[curr]) && (i < a->bitmap->b_size + 1); i++) {
526
527                 sic = (struct stats_irq *) ((char *) a->buf[curr]  + i * a->msize);
528                 sip = (struct stats_irq *) ((char *) a->buf[!curr] + i * a->msize);
529
530                 /* Should current interrupt (including int "sum") be displayed? */
531                 if (a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))) {
532
533                         /* Yes: Display it */
534                         if (!i) {
535                                 /* This is interrupt "sum" */
536                                 render(isdb, pre, pt_newlin,
537                                        "sum\tintr/s", "-1", NULL,
538                                        NOVAL,
539                                        S_VALUE(sip->irq_nr, sic->irq_nr, itv),
540                                        NULL);
541                         }
542                         else {
543                                 render(isdb, pre, pt_newlin,
544                                        "i%03d\tintr/s", "%d", cons(iv, i - 1, NOVAL),
545                                        NOVAL,
546                                        S_VALUE(sip->irq_nr, sic->irq_nr, itv),
547                                        NULL);
548                         }
549                 }
550         }
551 }
552
553 /*
554  ***************************************************************************
555  * Display swapping statistics in selected format.
556  *
557  * IN:
558  * @a           Activity structure with statistics.
559  * @isdb        Flag, true if db printing, false if ppc printing.
560  * @pre         Prefix string for output entries
561  * @curr        Index in array for current sample statistics.
562  * @itv         Interval of time in 1/100th of a second.
563  ***************************************************************************
564  */
565 __print_funct_t render_swap_stats(struct activity *a, int isdb, char *pre,
566                                   int curr, unsigned long long itv)
567 {
568         struct stats_swap
569                 *ssc = (struct stats_swap *) a->buf[curr],
570                 *ssp = (struct stats_swap *) a->buf[!curr];
571         int pt_newlin
572                 = (DISPLAY_HORIZONTALLY(flags) ? PT_NOFLAG : PT_NEWLIN);
573
574         render(isdb, pre, PT_NOFLAG,
575                "-\tpswpin/s", NULL, NULL,
576                NOVAL,
577                S_VALUE(ssp->pswpin, ssc->pswpin, itv),
578                NULL);
579         render(isdb, pre, pt_newlin,
580                "-\tpswpout/s", NULL, NULL,
581                NOVAL,
582                S_VALUE(ssp->pswpout, ssc->pswpout, itv),
583                NULL);
584 }
585
586 /*
587  ***************************************************************************
588  * Display paging statistics in selected format.
589  *
590  * IN:
591  * @a           Activity structure with statistics.
592  * @isdb        Flag, true if db printing, false if ppc printing.
593  * @pre         Prefix string for output entries
594  * @curr        Index in array for current sample statistics.
595  * @itv         Interval of time in 1/100th of a second.
596  ***************************************************************************
597  */
598 __print_funct_t render_paging_stats(struct activity *a, int isdb, char *pre,
599                                     int curr, unsigned long long itv)
600 {
601         struct stats_paging
602                 *spc = (struct stats_paging *) a->buf[curr],
603                 *spp = (struct stats_paging *) a->buf[!curr];
604         int pt_newlin
605                 = (DISPLAY_HORIZONTALLY(flags) ? PT_NOFLAG : PT_NEWLIN);
606
607         render(isdb, pre, PT_NOFLAG,
608                "-\tpgpgin/s", NULL, NULL,
609                NOVAL,
610                S_VALUE(spp->pgpgin, spc->pgpgin, itv),
611                NULL);
612
613         render(isdb, pre, PT_NOFLAG,
614                "-\tpgpgout/s", NULL, NULL,
615                NOVAL,
616                S_VALUE(spp->pgpgout, spc->pgpgout, itv),
617                NULL);
618
619         render(isdb, pre, PT_NOFLAG,
620                "-\tfault/s", NULL, NULL,
621                NOVAL,
622                S_VALUE(spp->pgfault, spc->pgfault, itv),
623                NULL);
624
625         render(isdb, pre, PT_NOFLAG,
626                "-\tmajflt/s", NULL, NULL,
627                NOVAL,
628                S_VALUE(spp->pgmajfault, spc->pgmajfault, itv),
629                NULL);
630
631         render(isdb, pre, PT_NOFLAG,
632                "-\tpgfree/s", NULL, NULL,
633                NOVAL,
634                S_VALUE(spp->pgfree, spc->pgfree, itv),
635                NULL);
636
637         render(isdb, pre, PT_NOFLAG,
638                "-\tpgscank/s", NULL, NULL,
639                NOVAL,
640                S_VALUE(spp->pgscan_kswapd, spc->pgscan_kswapd, itv),
641                NULL);
642
643         render(isdb, pre, PT_NOFLAG,
644                "-\tpgscand/s", NULL, NULL,
645                NOVAL,
646                S_VALUE(spp->pgscan_direct, spc->pgscan_direct, itv),
647                NULL);
648
649         render(isdb, pre, PT_NOFLAG,
650                "-\tpgsteal/s", NULL, NULL,
651                NOVAL,
652                S_VALUE(spp->pgsteal, spc->pgsteal, itv),
653                NULL);
654
655         render(isdb, pre, pt_newlin,
656                "-\t%vmeff", NULL, NULL,
657                NOVAL,
658                (spc->pgscan_kswapd + spc->pgscan_direct -
659                 spp->pgscan_kswapd - spp->pgscan_direct) ?
660                SP_VALUE(spp->pgsteal, spc->pgsteal,
661                         spc->pgscan_kswapd + spc->pgscan_direct -
662                         spp->pgscan_kswapd - spp->pgscan_direct) : 0.0,
663                NULL);
664 }
665
666 /*
667  ***************************************************************************
668  * Display I/O and transfer rate statistics in selected format.
669  *
670  * IN:
671  * @a           Activity structure with statistics.
672  * @isdb        Flag, true if db printing, false if ppc printing.
673  * @pre         Prefix string for output entries
674  * @curr        Index in array for current sample statistics.
675  * @itv         Interval of time in 1/100th of a second.
676  ***************************************************************************
677  */
678 __print_funct_t render_io_stats(struct activity *a, int isdb, char *pre,
679                                 int curr, unsigned long long itv)
680 {
681         struct stats_io
682                 *sic = (struct stats_io *) a->buf[curr],
683                 *sip = (struct stats_io *) a->buf[!curr];
684         int pt_newlin
685                 = (DISPLAY_HORIZONTALLY(flags) ? PT_NOFLAG : PT_NEWLIN);
686
687         /*
688          * If we get negative values, this is probably because
689          * one or more devices/filesystems have been unmounted.
690          * We display 0.0 in this case though we should rather tell
691          * the user that the value cannot be calculated here.
692          */
693         render(isdb, pre, PT_NOFLAG,
694                "-\ttps", NULL, NULL,
695                NOVAL,
696                sic->dk_drive < sip->dk_drive ? 0.0 :
697                S_VALUE(sip->dk_drive, sic->dk_drive, itv),
698                NULL);
699
700         render(isdb, pre, PT_NOFLAG,
701                "-\trtps", NULL, NULL,
702                NOVAL,
703                sic->dk_drive_rio < sip->dk_drive_rio ? 0.0 :
704                S_VALUE(sip->dk_drive_rio, sic->dk_drive_rio, itv),
705                NULL);
706
707         render(isdb, pre, PT_NOFLAG,
708                "-\twtps", NULL, NULL,
709                NOVAL,
710                sic->dk_drive_wio < sip->dk_drive_wio ? 0.0 :
711                S_VALUE(sip->dk_drive_wio, sic->dk_drive_wio, itv),
712                NULL);
713
714         render(isdb, pre, PT_NOFLAG,
715                "-\tdtps", NULL, NULL,
716                NOVAL,
717                sic->dk_drive_dio < sip->dk_drive_dio ? 0.0 :
718                S_VALUE(sip->dk_drive_dio, sic->dk_drive_dio, itv),
719                NULL);
720
721         render(isdb, pre, PT_NOFLAG,
722                "-\tbread/s", NULL, NULL,
723                NOVAL,
724                sic->dk_drive_rblk < sip->dk_drive_rblk ? 0.0 :
725                S_VALUE(sip->dk_drive_rblk, sic->dk_drive_rblk, itv),
726                NULL);
727
728         render(isdb, pre, PT_NOFLAG,
729                "-\tbwrtn/s", NULL, NULL,
730                NOVAL,
731                sic->dk_drive_wblk < sip->dk_drive_wblk ? 0.0 :
732                S_VALUE(sip->dk_drive_wblk, sic->dk_drive_wblk, itv),
733                NULL);
734
735         render(isdb, pre, pt_newlin,
736                "-\tbdscd/s", NULL, NULL,
737                NOVAL,
738                sic->dk_drive_dblk < sip->dk_drive_dblk ? 0.0 :
739                S_VALUE(sip->dk_drive_dblk, sic->dk_drive_dblk, itv),
740                NULL);
741 }
742
743 /*
744  ***************************************************************************
745  * Display memory and swap statistics in selected format.
746  *
747  * IN:
748  * @a           Activity structure with statistics.
749  * @isdb        Flag, true if db printing, false if ppc printing.
750  * @pre         Prefix string for output entries
751  * @curr        Index in array for current sample statistics.
752  * @itv         Interval of time in 1/100th of a second.
753  ***************************************************************************
754  */
755 __print_funct_t render_memory_stats(struct activity *a, int isdb, char *pre,
756                                     int curr, unsigned long long itv)
757 {
758         struct stats_memory
759                 *smc = (struct stats_memory *) a->buf[curr];
760         int pt_newlin
761                 = (DISPLAY_HORIZONTALLY(flags) ? PT_NOFLAG : PT_NEWLIN);
762         int ptn;
763         unsigned long long nousedmem;
764
765         if (DISPLAY_MEMORY(a->opt_flags)) {
766
767                 nousedmem = smc->frmkb + smc->bufkb + smc->camkb + smc->slabkb;
768                 if (nousedmem > smc->tlmkb) {
769                         nousedmem = smc->tlmkb;
770                 }
771
772                 render(isdb, pre, PT_USEINT,
773                        "-\tkbmemfree", NULL, NULL,
774                        smc->frmkb, DNOVAL, NULL);
775
776                 render(isdb, pre, PT_USEINT,
777                        "-\tkbavail", NULL, NULL,
778                        smc->availablekb, DNOVAL, NULL);
779
780                 render(isdb, pre, PT_USEINT,
781                        "-\tkbmemused", NULL, NULL,
782                        smc->tlmkb - nousedmem, DNOVAL, NULL);
783
784                 render(isdb, pre, PT_NOFLAG,
785                        "-\t%memused", NULL, NULL, NOVAL,
786                        smc->tlmkb ?
787                        SP_VALUE(nousedmem, smc->tlmkb, smc->tlmkb) :
788                        0.0, NULL);
789
790                 render(isdb, pre, PT_USEINT,
791                        "-\tkbbuffers", NULL, NULL,
792                        smc->bufkb, DNOVAL, NULL);
793
794                 render(isdb, pre, PT_USEINT,
795                        "-\tkbcached", NULL, NULL,
796                        smc->camkb, DNOVAL, NULL);
797
798                 render(isdb, pre, PT_USEINT,
799                        "-\tkbcommit", NULL, NULL,
800                        smc->comkb, DNOVAL, NULL);
801
802                 render(isdb, pre, PT_NOFLAG,
803                        "-\t%commit", NULL, NULL, NOVAL,
804                        (smc->tlmkb + smc->tlskb) ?
805                        SP_VALUE(0, smc->comkb, smc->tlmkb + smc->tlskb) :
806                        0.0, NULL);
807
808                 render(isdb, pre, PT_USEINT,
809                        "-\tkbactive", NULL, NULL,
810                        smc->activekb, DNOVAL, NULL);
811
812                 render(isdb, pre, PT_USEINT,
813                        "-\tkbinact", NULL, NULL,
814                        smc->inactkb, DNOVAL, NULL);
815
816                 ptn = DISPLAY_MEM_ALL(a->opt_flags) ? 0 : pt_newlin;
817                 render(isdb, pre, PT_USEINT | ptn,
818                        "-\tkbdirty", NULL, NULL,
819                        smc->dirtykb, DNOVAL, NULL);
820
821                 if (DISPLAY_MEM_ALL(a->opt_flags)) {
822                         render(isdb, pre, PT_USEINT,
823                                "-\tkbanonpg", NULL, NULL,
824                                smc->anonpgkb, DNOVAL, NULL);
825
826                         render(isdb, pre, PT_USEINT,
827                                "-\tkbslab", NULL, NULL,
828                                smc->slabkb, DNOVAL, NULL);
829
830                         render(isdb, pre, PT_USEINT,
831                                "-\tkbkstack", NULL, NULL,
832                                smc->kstackkb, DNOVAL, NULL);
833
834                         render(isdb, pre, PT_USEINT,
835                                "-\tkbpgtbl", NULL, NULL,
836                                smc->pgtblkb, DNOVAL, NULL);
837
838                         render(isdb, pre, PT_USEINT | pt_newlin,
839                                "-\tkbvmused", NULL, NULL,
840                                smc->vmusedkb, DNOVAL, NULL);
841                 }
842         }
843
844         if (DISPLAY_SWAP(a->opt_flags)) {
845
846                 render(isdb, pre, PT_USEINT,
847                        "-\tkbswpfree", NULL, NULL,
848                        smc->frskb, DNOVAL, NULL);
849
850                 render(isdb, pre, PT_USEINT,
851                        "-\tkbswpused", NULL, NULL,
852                        smc->tlskb - smc->frskb, DNOVAL, NULL);
853
854                 render(isdb, pre, PT_NOFLAG,
855                        "-\t%swpused", NULL, NULL, NOVAL,
856                        smc->tlskb ?
857                        SP_VALUE(smc->frskb, smc->tlskb, smc->tlskb) :
858                        0.0, NULL);
859
860                 render(isdb, pre, PT_USEINT,
861                        "-\tkbswpcad", NULL, NULL,
862                        smc->caskb, DNOVAL, NULL);
863
864                 render(isdb, pre, pt_newlin,
865                        "-\t%swpcad", NULL, NULL, NOVAL,
866                        (smc->tlskb - smc->frskb) ?
867                        SP_VALUE(0, smc->caskb, smc->tlskb - smc->frskb) :
868                        0.0, NULL);
869         }
870 }
871
872 /*
873  ***************************************************************************
874  * Display kernel tables statistics in selected format.
875  *
876  * IN:
877  * @a           Activity structure with statistics.
878  * @isdb        Flag, true if db printing, false if ppc printing.
879  * @pre         Prefix string for output entries
880  * @curr        Index in array for current sample statistics.
881  * @itv         Interval of time in 1/100th of a second.
882  ***************************************************************************
883  */
884 __print_funct_t render_ktables_stats(struct activity *a, int isdb, char *pre,
885                                      int curr, unsigned long long itv)
886 {
887         struct stats_ktables
888                 *skc = (struct stats_ktables *) a->buf[curr];
889         int pt_newlin
890                 = (DISPLAY_HORIZONTALLY(flags) ? PT_NOFLAG : PT_NEWLIN);
891
892         render(isdb, pre, PT_USEINT,
893                "-\tdentunusd", NULL, NULL,
894                skc->dentry_stat, DNOVAL, NULL);
895
896         render(isdb, pre, PT_USEINT,
897                "-\tfile-nr", NULL, NULL,
898                skc->file_used, DNOVAL, NULL);
899
900         render(isdb, pre, PT_USEINT,
901                "-\tinode-nr", NULL, NULL,
902                skc->inode_used, DNOVAL, NULL);
903
904         render(isdb, pre, PT_USEINT | pt_newlin,
905                "-\tpty-nr", NULL, NULL,
906                skc->pty_nr, DNOVAL, NULL);
907 }
908
909 /*
910  ***************************************************************************
911  * Display queue and load statistics in selected format.
912  *
913  * IN:
914  * @a           Activity structure with statistics.
915  * @isdb        Flag, true if db printing, false if ppc printing.
916  * @pre         Prefix string for output entries
917  * @curr        Index in array for current sample statistics.
918  * @itv         Interval of time in 1/100th of a second.
919  ***************************************************************************
920  */
921 __print_funct_t render_queue_stats(struct activity *a, int isdb, char *pre,
922                                    int curr, unsigned long long itv)
923 {
924         struct stats_queue
925                 *sqc = (struct stats_queue *) a->buf[curr];
926         int pt_newlin
927                 = (DISPLAY_HORIZONTALLY(flags) ? PT_NOFLAG : PT_NEWLIN);
928
929         render(isdb, pre, PT_USEINT,
930                "-\trunq-sz", NULL, NULL,
931                sqc->nr_running, DNOVAL, NULL);
932
933         render(isdb, pre, PT_USEINT,
934                "-\tplist-sz", NULL, NULL,
935                sqc->nr_threads, DNOVAL, NULL);
936
937         render(isdb, pre, PT_NOFLAG,
938                "-\tldavg-1", NULL, NULL,
939                NOVAL,
940                (double) sqc->load_avg_1 / 100,
941                NULL);
942
943         render(isdb, pre, PT_NOFLAG,
944                "-\tldavg-5", NULL, NULL,
945                NOVAL,
946                (double) sqc->load_avg_5 / 100,
947                NULL);
948
949         render(isdb, pre, PT_NOFLAG,
950                "-\tldavg-15", NULL, NULL,
951                NOVAL,
952                (double) sqc->load_avg_15 / 100,
953                NULL);
954
955         render(isdb, pre, PT_USEINT | pt_newlin,
956                "-\tblocked", NULL, NULL,
957                sqc->procs_blocked, DNOVAL, NULL);
958 }
959
960 /*
961  ***************************************************************************
962  * Display serial lines statistics in selected format.
963  *
964  * IN:
965  * @a           Activity structure with statistics.
966  * @isdb        Flag, true if db printing, false if ppc printing.
967  * @pre         Prefix string for output entries
968  * @curr        Index in array for current sample statistics.
969  * @itv         Interval of time in 1/100th of a second.
970  ***************************************************************************
971  */
972 __print_funct_t render_serial_stats(struct activity *a, int isdb, char *pre,
973                                     int curr, unsigned long long itv)
974 {
975         int i, j, j0, found;
976         struct stats_serial *ssc, *ssp;
977         int pt_newlin
978                 = (DISPLAY_HORIZONTALLY(flags) ? PT_NOFLAG : PT_NEWLIN);
979
980         for (i = 0; i < a->nr[curr]; i++) {
981
982                 found = FALSE;
983
984                 if (a->nr[!curr] > 0) {
985                         ssc = (struct stats_serial *) ((char *) a->buf[curr]  + i * a->msize);
986
987                         /* Look for corresponding serial line in previous iteration */
988                         j = i;
989
990                         if (j >= a->nr[!curr]) {
991                                 j = a->nr[!curr] - 1;
992                         }
993
994                         j0 = j;
995
996                         do {
997                                 ssp = (struct stats_serial *) ((char *) a->buf[!curr] + j * a->msize);
998                                 if (ssc->line == ssp->line) {
999                                         found = TRUE;
1000                                         break;
1001                                 }
1002                                 if (++j >= a->nr[!curr]) {
1003                                         j = 0;
1004                                 }
1005                         }
1006                         while (j != j0);
1007                 }
1008
1009                 if (!found)
1010                         continue;
1011
1012                 render(isdb, pre, PT_NOFLAG,
1013                        "ttyS%d\trcvin/s", "%d",
1014                        cons(iv, ssc->line, NOVAL),
1015                        NOVAL,
1016                        S_VALUE(ssp->rx, ssc->rx, itv),
1017                        NULL);
1018
1019                 render(isdb, pre, PT_NOFLAG,
1020                        "ttyS%d\txmtin/s", NULL,
1021                        cons(iv, ssc->line, NOVAL),
1022                        NOVAL,
1023                        S_VALUE(ssp->tx, ssc->tx, itv),
1024                        NULL);
1025
1026                 render(isdb, pre, PT_NOFLAG,
1027                        "ttyS%d\tframerr/s", NULL,
1028                        cons(iv, ssc->line, NOVAL),
1029                        NOVAL,
1030                        S_VALUE(ssp->frame, ssc->frame, itv),
1031                        NULL);
1032
1033                 render(isdb, pre, PT_NOFLAG,
1034                        "ttyS%d\tprtyerr/s", NULL,
1035                        cons(iv, ssc->line, NOVAL),
1036                        NOVAL,
1037                        S_VALUE(ssp->parity, ssc->parity, itv),
1038                        NULL);
1039
1040                 render(isdb, pre, PT_NOFLAG,
1041                        "ttyS%d\tbrk/s", NULL,
1042                        cons(iv, ssc->line, NOVAL),
1043                        NOVAL,
1044                        S_VALUE(ssp->brk, ssc->brk, itv),
1045                        NULL);
1046
1047                 render(isdb, pre, pt_newlin,
1048                        "ttyS%d\tovrun/s", NULL,
1049                        cons(iv, ssc->line, NOVAL),
1050                        NOVAL,
1051                        S_VALUE(ssp->overrun, ssc->overrun, itv),
1052                        NULL);
1053         }
1054 }
1055
1056 /*
1057  ***************************************************************************
1058  * Display disks statistics in selected format.
1059  *
1060  * IN:
1061  * @a           Activity structure with statistics.
1062  * @isdb        Flag, true if db printing, false if ppc printing.
1063  * @pre         Prefix string for output entries
1064  * @curr        Index in array for current sample statistics.
1065  * @itv         Interval of time in 1/100th of a second.
1066  ***************************************************************************
1067  */
1068 __print_funct_t render_disk_stats(struct activity *a, int isdb, char *pre,
1069                                   int curr, unsigned long long itv)
1070 {
1071         int i, j;
1072         struct stats_disk *sdc, *sdp, sdpzero;
1073         struct ext_disk_stats xds;
1074         char *dev_name;
1075         int pt_newlin
1076                 = (DISPLAY_HORIZONTALLY(flags) ? PT_NOFLAG : PT_NEWLIN);
1077
1078         memset(&sdpzero, 0, STATS_DISK_SIZE);
1079
1080         for (i = 0; i < a->nr[curr]; i++) {
1081
1082                 sdc = (struct stats_disk *) ((char *) a->buf[curr] + i * a->msize);
1083
1084                 j = check_disk_reg(a, curr, !curr, i);
1085                 if (j < 0) {
1086                         /* This is a newly registered interface. Previous stats are zero */
1087                         sdp = &sdpzero;
1088                 }
1089                 else {
1090                         sdp = (struct stats_disk *) ((char *) a->buf[!curr] + j * a->msize);
1091                 }
1092
1093                 /* Get device name */
1094                 dev_name = get_sa_devname(sdc->major, sdc->minor,
1095                                           sdc->wwn, sdc->part_nr, flags);
1096
1097                 if (a->item_list != NULL) {
1098                         /* A list of devices has been entered on the command line */
1099                         if (!search_list_item(a->item_list, dev_name))
1100                                 /* Device not found */
1101                                 continue;
1102                 }
1103
1104                 /* Compute extended stats (service time, etc.) */
1105                 compute_ext_disk_stats(sdc, sdp, itv, &xds);
1106
1107                 render(isdb, pre, PT_NOFLAG,
1108                        "%s\ttps", "%s",
1109                        cons(sv, dev_name, NULL),
1110                        NOVAL,
1111                        S_VALUE(sdp->nr_ios, sdc->nr_ios, itv),
1112                        NULL);
1113
1114                 render(isdb, pre, PT_NOFLAG,
1115                        "%s\trkB/s", NULL,
1116                        cons(sv, dev_name, NULL),
1117                        NOVAL,
1118                        S_VALUE(sdp->rd_sect, sdc->rd_sect, itv) / 2,
1119                        NULL);
1120
1121                 render(isdb, pre, PT_NOFLAG,
1122                        "%s\twkB/s", NULL,
1123                        cons(sv, dev_name, NULL),
1124                        NOVAL,
1125                        S_VALUE(sdp->wr_sect, sdc->wr_sect, itv) / 2,
1126                        NULL);
1127
1128                 render(isdb, pre, PT_NOFLAG,
1129                        "%s\tdkB/s", NULL,
1130                        cons(sv, dev_name, NULL),
1131                        NOVAL,
1132                        S_VALUE(sdp->dc_sect, sdc->dc_sect, itv) / 2,
1133                        NULL);
1134
1135                 render(isdb, pre, PT_NOFLAG,
1136                        "%s\tareq-sz", NULL,
1137                        cons(sv, dev_name, NULL),
1138                        NOVAL,
1139                        xds.arqsz / 2,
1140                        NULL);
1141
1142                 render(isdb, pre, PT_NOFLAG,
1143                        "%s\taqu-sz", NULL,
1144                        cons(sv, dev_name, NULL),
1145                        NOVAL,
1146                        S_VALUE(sdp->rq_ticks, sdc->rq_ticks, itv) / 1000.0,
1147                        NULL);
1148
1149                 render(isdb, pre, PT_NOFLAG,
1150                        "%s\tawait", NULL,
1151                        cons(sv, dev_name, NULL),
1152                        NOVAL,
1153                        xds.await,
1154                        NULL);
1155
1156                 render(isdb, pre, pt_newlin,
1157                        "%s\t%%util", NULL,
1158                        cons(sv, dev_name, NULL),
1159                        NOVAL,
1160                        xds.util / 10.0,
1161                        NULL);
1162         }
1163 }
1164
1165 /*
1166  ***************************************************************************
1167  * Display network interfaces statistics in selected format.
1168  *
1169  * IN:
1170  * @a           Activity structure with statistics.
1171  * @isdb        Flag, true if db printing, false if ppc printing.
1172  * @pre         Prefix string for output entries
1173  * @curr        Index in array for current sample statistics.
1174  * @itv         Interval of time in 1/100th of a second.
1175  ***************************************************************************
1176  */
1177 __print_funct_t render_net_dev_stats(struct activity *a, int isdb, char *pre,
1178                                      int curr, unsigned long long itv)
1179 {
1180         int i, j;
1181         struct stats_net_dev *sndc, *sndp, sndzero;
1182         double rxkb, txkb, ifutil;
1183         int pt_newlin
1184                 = (DISPLAY_HORIZONTALLY(flags) ? PT_NOFLAG : PT_NEWLIN);
1185
1186         memset(&sndzero, 0, STATS_NET_DEV_SIZE);
1187
1188         for (i = 0; i < a->nr[curr]; i++) {
1189
1190                 sndc = (struct stats_net_dev *) ((char *) a->buf[curr] + i * a->msize);
1191
1192                 if (a->item_list != NULL) {
1193                         /* A list of devices has been entered on the command line */
1194                         if (!search_list_item(a->item_list, sndc->interface))
1195                                 /* Device not found */
1196                                 continue;
1197                 }
1198
1199                 j = check_net_dev_reg(a, curr, !curr, i);
1200                 if (j < 0) {
1201                         /* This is a newly registered interface. Previous stats are zero */
1202                         sndp = &sndzero;
1203                 }
1204                 else {
1205                         sndp = (struct stats_net_dev *) ((char *) a->buf[!curr] + j * a->msize);
1206                 }
1207
1208                 render(isdb, pre, PT_NOFLAG,
1209                        "%s\trxpck/s", "%s",
1210                        cons(sv, sndc->interface, NULL), /* What if the format args are strings? */
1211                        NOVAL,
1212                        S_VALUE(sndp->rx_packets, sndc->rx_packets, itv),
1213                        NULL);
1214
1215                 render(isdb, pre, PT_NOFLAG,
1216                        "%s\ttxpck/s", NULL,
1217                        cons(sv, sndc->interface, NULL),
1218                        NOVAL,
1219                        S_VALUE(sndp->tx_packets, sndc->tx_packets, itv),
1220                        NULL);
1221
1222                 rxkb = S_VALUE(sndp->rx_bytes, sndc->rx_bytes, itv);
1223                 render(isdb, pre, PT_NOFLAG,
1224                        "%s\trxkB/s", NULL,
1225                        cons(sv, sndc->interface, NULL),
1226                        NOVAL,
1227                        rxkb / 1024,
1228                        NULL);
1229
1230                 txkb = S_VALUE(sndp->tx_bytes, sndc->tx_bytes, itv);
1231                 render(isdb, pre, PT_NOFLAG,
1232                        "%s\ttxkB/s", NULL,
1233                        cons(sv, sndc->interface, NULL),
1234                        NOVAL,
1235                        txkb / 1024,
1236                        NULL);
1237
1238                 render(isdb, pre, PT_NOFLAG,
1239                        "%s\trxcmp/s", NULL,
1240                        cons(sv, sndc->interface, NULL),
1241                        NOVAL,
1242                        S_VALUE(sndp->rx_compressed, sndc->rx_compressed, itv),
1243                        NULL);
1244
1245                 render(isdb, pre, PT_NOFLAG,
1246                        "%s\ttxcmp/s", NULL,
1247                        cons(sv, sndc->interface, NULL),
1248                        NOVAL,
1249                        S_VALUE(sndp->tx_compressed, sndc->tx_compressed, itv),
1250                        NULL);
1251
1252                 render(isdb, pre, PT_NOFLAG,
1253                        "%s\trxmcst/s", NULL,
1254                        cons(sv, sndc->interface, NULL),
1255                        NOVAL,
1256                        S_VALUE(sndp->multicast, sndc->multicast, itv),
1257                        NULL);
1258
1259                 ifutil = compute_ifutil(sndc, rxkb, txkb);
1260                 render(isdb, pre, pt_newlin,
1261                        "%s\t%%ifutil", NULL,
1262                        cons(sv, sndc->interface, NULL),
1263                        NOVAL,
1264                        ifutil,
1265                        NULL);
1266         }
1267 }
1268
1269 /*
1270  ***************************************************************************
1271  * Display network interface errors statistics in selected format.
1272  *
1273  * IN:
1274  * @a           Activity structure with statistics.
1275  * @isdb        Flag, true if db printing, false if ppc printing.
1276  * @pre         Prefix string for output entries
1277  * @curr        Index in array for current sample statistics.
1278  * @itv         Interval of time in 1/100th of a second.
1279  ***************************************************************************
1280  */
1281 __print_funct_t render_net_edev_stats(struct activity *a, int isdb, char *pre,
1282                                       int curr, unsigned long long itv)
1283 {
1284         int i, j;
1285         struct stats_net_edev *snedc, *snedp, snedzero;
1286         int pt_newlin
1287                 = (DISPLAY_HORIZONTALLY(flags) ? PT_NOFLAG : PT_NEWLIN);
1288
1289         memset(&snedzero, 0, STATS_NET_EDEV_SIZE);
1290
1291         for (i = 0; i < a->nr[curr]; i++) {
1292
1293                 snedc = (struct stats_net_edev *) ((char *) a->buf[curr] + i * a->msize);
1294
1295                 if (a->item_list != NULL) {
1296                         /* A list of devices has been entered on the command line */
1297                         if (!search_list_item(a->item_list, snedc->interface))
1298                                 /* Device not found */
1299                                 continue;
1300                 }
1301
1302                 j = check_net_edev_reg(a, curr, !curr, i);
1303                 if (j < 0) {
1304                         /* This is a newly registered interface. Previous stats are zero */
1305                         snedp = &snedzero;
1306                 }
1307                 else {
1308                         snedp = (struct stats_net_edev *) ((char *) a->buf[!curr] + j * a->msize);
1309                 }
1310
1311                 render(isdb, pre, PT_NOFLAG,
1312                        "%s\trxerr/s", "%s",
1313                        cons(sv, snedc->interface, NULL),
1314                        NOVAL,
1315                        S_VALUE(snedp->rx_errors, snedc->rx_errors, itv),
1316                        NULL);
1317
1318                 render(isdb, pre, PT_NOFLAG,
1319                        "%s\ttxerr/s", NULL,
1320                        cons(sv, snedc->interface, NULL),
1321                        NOVAL,
1322                        S_VALUE(snedp->tx_errors, snedc->tx_errors, itv),
1323                        NULL);
1324
1325                 render(isdb, pre, PT_NOFLAG,
1326                        "%s\tcoll/s", NULL,
1327                        cons(sv, snedc->interface, NULL),
1328                        NOVAL,
1329                        S_VALUE(snedp->collisions, snedc->collisions, itv),
1330                        NULL);
1331
1332                 render(isdb, pre, PT_NOFLAG,
1333                        "%s\trxdrop/s", NULL,
1334                        cons(sv, snedc->interface, NULL),
1335                        NOVAL,
1336                        S_VALUE(snedp->rx_dropped, snedc->rx_dropped, itv),
1337                        NULL);
1338
1339                 render(isdb, pre, PT_NOFLAG,
1340                        "%s\ttxdrop/s", NULL,
1341                        cons(sv, snedc->interface, NULL),
1342                        NOVAL,
1343                        S_VALUE(snedp->tx_dropped, snedc->tx_dropped, itv),
1344                        NULL);
1345
1346                 render(isdb, pre, PT_NOFLAG,
1347                        "%s\ttxcarr/s", NULL,
1348                        cons(sv, snedc->interface, NULL),
1349                        NOVAL,
1350                        S_VALUE(snedp->tx_carrier_errors, snedc->tx_carrier_errors, itv),
1351                        NULL);
1352
1353                 render(isdb, pre, PT_NOFLAG,
1354                        "%s\trxfram/s", NULL,
1355                        cons(sv, snedc->interface, NULL),
1356                        NOVAL,
1357                        S_VALUE(snedp->rx_frame_errors, snedc->rx_frame_errors, itv),
1358                        NULL);
1359
1360                 render(isdb, pre, PT_NOFLAG,
1361                        "%s\trxfifo/s", NULL,
1362                        cons(sv, snedc->interface, NULL),
1363                        NOVAL,
1364                        S_VALUE(snedp->rx_fifo_errors, snedc->rx_fifo_errors, itv),
1365                        NULL);
1366
1367                 render(isdb, pre, pt_newlin,
1368                        "%s\ttxfifo/s", NULL,
1369                        cons(sv, snedc->interface, NULL),
1370                        NOVAL,
1371                        S_VALUE(snedp->tx_fifo_errors, snedc->tx_fifo_errors, itv),
1372                        NULL);
1373         }
1374 }
1375
1376 /*
1377  ***************************************************************************
1378  * Display NFS client statistics in selected format.
1379  *
1380  * IN:
1381  * @a           Activity structure with statistics.
1382  * @isdb        Flag, true if db printing, false if ppc printing.
1383  * @pre         Prefix string for output entries
1384  * @curr        Index in array for current sample statistics.
1385  * @itv         Interval of time in 1/100th of a second.
1386  ***************************************************************************
1387  */
1388 __print_funct_t render_net_nfs_stats(struct activity *a, int isdb, char *pre,
1389                                      int curr, unsigned long long itv)
1390 {
1391         struct stats_net_nfs
1392                 *snnc = (struct stats_net_nfs *) a->buf[curr],
1393                 *snnp = (struct stats_net_nfs *) a->buf[!curr];
1394         int pt_newlin
1395                 = (DISPLAY_HORIZONTALLY(flags) ? PT_NOFLAG : PT_NEWLIN);
1396
1397         render(isdb, pre, PT_NOFLAG,
1398                "-\tcall/s", NULL, NULL,
1399                NOVAL,
1400                S_VALUE(snnp->nfs_rpccnt, snnc->nfs_rpccnt, itv),
1401                NULL);
1402
1403         render(isdb, pre, PT_NOFLAG,
1404                "-\tretrans/s", NULL, NULL,
1405                NOVAL,
1406                S_VALUE(snnp->nfs_rpcretrans, snnc->nfs_rpcretrans, itv),
1407                NULL);
1408
1409         render(isdb, pre, PT_NOFLAG,
1410                "-\tread/s", NULL, NULL,
1411                NOVAL,
1412                S_VALUE(snnp->nfs_readcnt, snnc->nfs_readcnt, itv),
1413                NULL);
1414
1415         render(isdb, pre, PT_NOFLAG,
1416                "-\twrite/s", NULL, NULL,
1417                NOVAL,
1418                S_VALUE(snnp->nfs_writecnt, snnc->nfs_writecnt, itv),
1419                NULL);
1420
1421         render(isdb, pre, PT_NOFLAG,
1422                "-\taccess/s", NULL, NULL,
1423                NOVAL,
1424                S_VALUE(snnp->nfs_accesscnt, snnc->nfs_accesscnt, itv),
1425                NULL);
1426
1427         render(isdb, pre, pt_newlin,
1428                "-\tgetatt/s", NULL, NULL,
1429                NOVAL,
1430                S_VALUE(snnp->nfs_getattcnt, snnc->nfs_getattcnt, itv),
1431                NULL);
1432 }
1433
1434 /*
1435  ***************************************************************************
1436  * Display NFS server statistics in selected format.
1437  *
1438  * IN:
1439  * @a           Activity structure with statistics.
1440  * @isdb        Flag, true if db printing, false if ppc printing.
1441  * @pre         Prefix string for output entries
1442  * @curr        Index in array for current sample statistics.
1443  * @itv         Interval of time in 1/100th of a second.
1444  ***************************************************************************
1445  */
1446 __print_funct_t render_net_nfsd_stats(struct activity *a, int isdb, char *pre,
1447                                       int curr, unsigned long long itv)
1448 {
1449         struct stats_net_nfsd
1450                 *snndc = (struct stats_net_nfsd *) a->buf[curr],
1451                 *snndp = (struct stats_net_nfsd *) a->buf[!curr];
1452         int pt_newlin
1453                 = (DISPLAY_HORIZONTALLY(flags) ? PT_NOFLAG : PT_NEWLIN);
1454
1455         render(isdb, pre, PT_NOFLAG,
1456                "-\tscall/s", NULL, NULL,
1457                NOVAL,
1458                S_VALUE(snndp->nfsd_rpccnt, snndc->nfsd_rpccnt, itv),
1459                NULL);
1460
1461         render(isdb, pre, PT_NOFLAG,
1462                "-\tbadcall/s", NULL, NULL,
1463                NOVAL,
1464                S_VALUE(snndp->nfsd_rpcbad, snndc->nfsd_rpcbad, itv),
1465                NULL);
1466
1467         render(isdb, pre, PT_NOFLAG,
1468                "-\tpacket/s", NULL, NULL,
1469                NOVAL,
1470                S_VALUE(snndp->nfsd_netcnt, snndc->nfsd_netcnt, itv),
1471                NULL);
1472
1473         render(isdb, pre, PT_NOFLAG,
1474                "-\tudp/s", NULL, NULL,
1475                NOVAL,
1476                S_VALUE(snndp->nfsd_netudpcnt, snndc->nfsd_netudpcnt, itv),
1477                NULL);
1478
1479         render(isdb, pre, PT_NOFLAG,
1480                "-\ttcp/s", NULL, NULL,
1481                NOVAL,
1482                S_VALUE(snndp->nfsd_nettcpcnt, snndc->nfsd_nettcpcnt, itv),
1483                NULL);
1484
1485         render(isdb, pre, PT_NOFLAG,
1486                "-\thit/s", NULL, NULL,
1487                NOVAL,
1488                S_VALUE(snndp->nfsd_rchits, snndc->nfsd_rchits, itv),
1489                NULL);
1490
1491         render(isdb, pre, PT_NOFLAG,
1492                "-\tmiss/s", NULL, NULL,
1493                NOVAL,
1494                S_VALUE(snndp->nfsd_rcmisses, snndc->nfsd_rcmisses, itv),
1495                NULL);
1496
1497         render(isdb, pre, PT_NOFLAG,
1498                "-\tsread/s", NULL, NULL,
1499                NOVAL,
1500                S_VALUE(snndp->nfsd_readcnt, snndc->nfsd_readcnt, itv),
1501                NULL);
1502
1503         render(isdb, pre, PT_NOFLAG,
1504                "-\tswrite/s", NULL, NULL,
1505                NOVAL,
1506                S_VALUE(snndp->nfsd_writecnt, snndc->nfsd_writecnt, itv),
1507                NULL);
1508
1509         render(isdb, pre, PT_NOFLAG,
1510                "-\tsaccess/s", NULL, NULL,
1511                NOVAL,
1512                S_VALUE(snndp->nfsd_accesscnt, snndc->nfsd_accesscnt, itv),
1513                NULL);
1514
1515         render(isdb, pre, pt_newlin,
1516                "-\tsgetatt/s", NULL, NULL,
1517                NOVAL,
1518                S_VALUE(snndp->nfsd_getattcnt, snndc->nfsd_getattcnt, itv),
1519                NULL);
1520 }
1521
1522 /*
1523  ***************************************************************************
1524  * Display network sockets statistics in selected format.
1525  *
1526  * IN:
1527  * @a           Activity structure with statistics.
1528  * @isdb        Flag, true if db printing, false if ppc printing.
1529  * @pre         Prefix string for output entries
1530  * @curr        Index in array for current sample statistics.
1531  * @itv         Interval of time in 1/100th of a second.
1532  ***************************************************************************
1533  */
1534 __print_funct_t render_net_sock_stats(struct activity *a, int isdb, char *pre,
1535                                       int curr, unsigned long long itv)
1536 {
1537         struct stats_net_sock
1538                 *snsc = (struct stats_net_sock *) a->buf[curr];
1539         int pt_newlin
1540                 = (DISPLAY_HORIZONTALLY(flags) ? PT_NOFLAG : PT_NEWLIN);
1541
1542         render(isdb, pre, PT_USEINT,
1543                "-\ttotsck", NULL, NULL,
1544                (unsigned long long) snsc->sock_inuse, DNOVAL, NULL);
1545
1546         render(isdb, pre, PT_USEINT,
1547                "-\ttcpsck", NULL, NULL,
1548                (unsigned long long) snsc->tcp_inuse, DNOVAL, NULL);
1549
1550         render(isdb, pre, PT_USEINT,
1551                "-\tudpsck",  NULL, NULL,
1552                (unsigned long long) snsc->udp_inuse, DNOVAL, NULL);
1553
1554         render(isdb, pre, PT_USEINT,
1555                "-\trawsck", NULL, NULL,
1556                (unsigned long long) snsc->raw_inuse, DNOVAL, NULL);
1557
1558         render(isdb, pre, PT_USEINT,
1559                "-\tip-frag", NULL, NULL,
1560                (unsigned long long) snsc->frag_inuse, DNOVAL, NULL);
1561
1562         render(isdb, pre, PT_USEINT | pt_newlin,
1563                "-\ttcp-tw", NULL, NULL,
1564                (unsigned long long) snsc->tcp_tw, DNOVAL, NULL);
1565 }
1566
1567 /*
1568  ***************************************************************************
1569  * Display IP network statistics in selected format.
1570  *
1571  * IN:
1572  * @a           Activity structure with statistics.
1573  * @isdb        Flag, true if db printing, false if ppc printing.
1574  * @pre         Prefix string for output entries
1575  * @curr        Index in array for current sample statistics.
1576  * @itv         Interval of time in 1/100th of a second.
1577  ***************************************************************************
1578  */
1579 __print_funct_t render_net_ip_stats(struct activity *a, int isdb, char *pre,
1580                                     int curr, unsigned long long itv)
1581 {
1582         struct stats_net_ip
1583                 *snic = (struct stats_net_ip *) a->buf[curr],
1584                 *snip = (struct stats_net_ip *) a->buf[!curr];
1585         int pt_newlin
1586                 = (DISPLAY_HORIZONTALLY(flags) ? PT_NOFLAG : PT_NEWLIN);
1587
1588         render(isdb, pre, PT_NOFLAG,
1589                "-\tirec/s", NULL, NULL,
1590                NOVAL,
1591                S_VALUE(snip->InReceives, snic->InReceives, itv),
1592                NULL);
1593
1594         render(isdb, pre, PT_NOFLAG,
1595                "-\tfwddgm/s", NULL, NULL,
1596                NOVAL,
1597                S_VALUE(snip->ForwDatagrams, snic->ForwDatagrams, itv),
1598                NULL);
1599
1600         render(isdb, pre, PT_NOFLAG,
1601                "-\tidel/s", NULL, NULL,
1602                NOVAL,
1603                S_VALUE(snip->InDelivers, snic->InDelivers, itv),
1604                NULL);
1605
1606         render(isdb, pre, PT_NOFLAG,
1607                "-\torq/s", NULL, NULL,
1608                NOVAL,
1609                S_VALUE(snip->OutRequests, snic->OutRequests, itv),
1610                NULL);
1611
1612         render(isdb, pre, PT_NOFLAG,
1613                "-\tasmrq/s", NULL, NULL,
1614                NOVAL,
1615                S_VALUE(snip->ReasmReqds, snic->ReasmReqds, itv),
1616                NULL);
1617
1618         render(isdb, pre, PT_NOFLAG,
1619                "-\tasmok/s", NULL, NULL,
1620                NOVAL,
1621                S_VALUE(snip->ReasmOKs, snic->ReasmOKs, itv),
1622                NULL);
1623
1624         render(isdb, pre, PT_NOFLAG,
1625                "-\tfragok/s", NULL, NULL,
1626                NOVAL,
1627                S_VALUE(snip->FragOKs, snic->FragOKs, itv),
1628                NULL);
1629
1630         render(isdb, pre, pt_newlin,
1631                "-\tfragcrt/s", NULL, NULL,
1632                NOVAL,
1633                S_VALUE(snip->FragCreates, snic->FragCreates, itv),
1634                NULL);
1635 }
1636
1637 /*
1638  ***************************************************************************
1639  * Display IP network errors statistics in selected format.
1640  *
1641  * IN:
1642  * @a           Activity structure with statistics.
1643  * @isdb        Flag, true if db printing, false if ppc printing.
1644  * @pre         Prefix string for output entries
1645  * @curr        Index in array for current sample statistics.
1646  * @itv         Interval of time in 1/100th of a second.
1647  ***************************************************************************
1648  */
1649 __print_funct_t render_net_eip_stats(struct activity *a, int isdb, char *pre,
1650                                      int curr, unsigned long long itv)
1651 {
1652         struct stats_net_eip
1653                 *sneic = (struct stats_net_eip *) a->buf[curr],
1654                 *sneip = (struct stats_net_eip *) a->buf[!curr];
1655         int pt_newlin
1656                 = (DISPLAY_HORIZONTALLY(flags) ? PT_NOFLAG : PT_NEWLIN);
1657
1658         render(isdb, pre, PT_NOFLAG,
1659                "-\tihdrerr/s", NULL, NULL,
1660                NOVAL,
1661                S_VALUE(sneip->InHdrErrors, sneic->InHdrErrors, itv),
1662                NULL);
1663
1664         render(isdb, pre, PT_NOFLAG,
1665                "-\tiadrerr/s", NULL, NULL,
1666                NOVAL,
1667                S_VALUE(sneip->InAddrErrors, sneic->InAddrErrors, itv),
1668                NULL);
1669
1670         render(isdb, pre, PT_NOFLAG,
1671                "-\tiukwnpr/s", NULL, NULL,
1672                NOVAL,
1673                S_VALUE(sneip->InUnknownProtos, sneic->InUnknownProtos, itv),
1674                NULL);
1675
1676         render(isdb, pre, PT_NOFLAG,
1677                "-\tidisc/s", NULL, NULL,
1678                NOVAL,
1679                S_VALUE(sneip->InDiscards, sneic->InDiscards, itv),
1680                NULL);
1681
1682         render(isdb, pre, PT_NOFLAG,
1683                "-\todisc/s", NULL, NULL,
1684                NOVAL,
1685                S_VALUE(sneip->OutDiscards, sneic->OutDiscards, itv),
1686                NULL);
1687
1688         render(isdb, pre, PT_NOFLAG,
1689                "-\tonort/s", NULL, NULL,
1690                NOVAL,
1691                S_VALUE(sneip->OutNoRoutes, sneic->OutNoRoutes, itv),
1692                NULL);
1693
1694         render(isdb, pre, PT_NOFLAG,
1695                "-\tasmf/s", NULL, NULL,
1696                NOVAL,
1697                S_VALUE(sneip->ReasmFails, sneic->ReasmFails, itv),
1698                NULL);
1699
1700         render(isdb, pre, pt_newlin,
1701                "-\tfragf/s", NULL, NULL,
1702                NOVAL,
1703                S_VALUE(sneip->FragFails, sneic->FragFails, itv),
1704                NULL);
1705 }
1706
1707 /*
1708  ***************************************************************************
1709  * Display ICMP network statistics in selected format.
1710  *
1711  * IN:
1712  * @a           Activity structure with statistics.
1713  * @isdb        Flag, true if db printing, false if ppc printing.
1714  * @pre         Prefix string for output entries
1715  * @curr        Index in array for current sample statistics.
1716  * @itv         Interval of time in 1/100th of a second.
1717  ***************************************************************************
1718  */
1719 __print_funct_t render_net_icmp_stats(struct activity *a, int isdb, char *pre,
1720                                       int curr, unsigned long long itv)
1721 {
1722         struct stats_net_icmp
1723                 *snic = (struct stats_net_icmp *) a->buf[curr],
1724                 *snip = (struct stats_net_icmp *) a->buf[!curr];
1725         int pt_newlin
1726                 = (DISPLAY_HORIZONTALLY(flags) ? PT_NOFLAG : PT_NEWLIN);
1727
1728         render(isdb, pre, PT_NOFLAG,
1729                "-\timsg/s", NULL, NULL,
1730                NOVAL,
1731                S_VALUE(snip->InMsgs, snic->InMsgs, itv),
1732                NULL);
1733
1734         render(isdb, pre, PT_NOFLAG,
1735                "-\tomsg/s", NULL, NULL,
1736                NOVAL,
1737                S_VALUE(snip->OutMsgs, snic->OutMsgs, itv),
1738                NULL);
1739
1740         render(isdb, pre, PT_NOFLAG,
1741                "-\tiech/s", NULL, NULL,
1742                NOVAL,
1743                S_VALUE(snip->InEchos, snic->InEchos, itv),
1744                NULL);
1745
1746         render(isdb, pre, PT_NOFLAG,
1747                "-\tiechr/s", NULL, NULL,
1748                NOVAL,
1749                S_VALUE(snip->InEchoReps, snic->InEchoReps, itv),
1750                NULL);
1751
1752         render(isdb, pre, PT_NOFLAG,
1753                "-\toech/s", NULL, NULL,
1754                NOVAL,
1755                S_VALUE(snip->OutEchos, snic->OutEchos, itv),
1756                NULL);
1757
1758         render(isdb, pre, PT_NOFLAG,
1759                "-\toechr/s", NULL, NULL,
1760                NOVAL,
1761                S_VALUE(snip->OutEchoReps, snic->OutEchoReps, itv),
1762                NULL);
1763
1764         render(isdb, pre, PT_NOFLAG,
1765                "-\titm/s", NULL, NULL,
1766                NOVAL,
1767                S_VALUE(snip->InTimestamps, snic->InTimestamps, itv),
1768                NULL);
1769
1770         render(isdb, pre, PT_NOFLAG,
1771                "-\titmr/s", NULL, NULL,
1772                NOVAL,
1773                S_VALUE(snip->InTimestampReps, snic->InTimestampReps, itv),
1774                NULL);
1775
1776         render(isdb, pre, PT_NOFLAG,
1777                "-\totm/s", NULL, NULL,
1778                NOVAL,
1779                S_VALUE(snip->OutTimestamps, snic->OutTimestamps, itv),
1780                NULL);
1781
1782         render(isdb, pre, PT_NOFLAG,
1783                "-\totmr/s", NULL, NULL,
1784                NOVAL,
1785                S_VALUE(snip->OutTimestampReps, snic->OutTimestampReps, itv),
1786                NULL);
1787
1788         render(isdb, pre, PT_NOFLAG,
1789                "-\tiadrmk/s", NULL, NULL,
1790                NOVAL,
1791                S_VALUE(snip->InAddrMasks, snic->InAddrMasks, itv),
1792                NULL);
1793
1794         render(isdb, pre, PT_NOFLAG,
1795                "-\tiadrmkr/s", NULL, NULL,
1796                NOVAL,
1797                S_VALUE(snip->InAddrMaskReps, snic->InAddrMaskReps, itv),
1798                NULL);
1799
1800         render(isdb, pre, PT_NOFLAG,
1801                "-\toadrmk/s", NULL, NULL,
1802                NOVAL,
1803                S_VALUE(snip->OutAddrMasks, snic->OutAddrMasks, itv),
1804                NULL);
1805
1806         render(isdb, pre, pt_newlin,
1807                "-\toadrmkr/s", NULL, NULL,
1808                NOVAL,
1809                S_VALUE(snip->OutAddrMaskReps, snic->OutAddrMaskReps, itv),
1810                NULL);
1811 }
1812
1813 /*
1814  ***************************************************************************
1815  * Display ICMP error messages statistics in selected format.
1816  *
1817  * IN:
1818  * @a           Activity structure with statistics.
1819  * @isdb        Flag, true if db printing, false if ppc printing.
1820  * @pre         Prefix string for output entries
1821  * @curr        Index in array for current sample statistics.
1822  * @itv         Interval of time in 1/100th of a second.
1823  ***************************************************************************
1824  */
1825 __print_funct_t render_net_eicmp_stats(struct activity *a, int isdb, char *pre,
1826                                        int curr, unsigned long long itv)
1827 {
1828         struct stats_net_eicmp
1829                 *sneic = (struct stats_net_eicmp *) a->buf[curr],
1830                 *sneip = (struct stats_net_eicmp *) a->buf[!curr];
1831         int pt_newlin
1832                 = (DISPLAY_HORIZONTALLY(flags) ? PT_NOFLAG : PT_NEWLIN);
1833
1834         render(isdb, pre, PT_NOFLAG,
1835                "-\tierr/s", NULL, NULL,
1836                NOVAL,
1837                S_VALUE(sneip->InErrors, sneic->InErrors, itv),
1838                NULL);
1839
1840         render(isdb, pre, PT_NOFLAG,
1841                "-\toerr/s", NULL, NULL,
1842                NOVAL,
1843                S_VALUE(sneip->OutErrors, sneic->OutErrors, itv),
1844                NULL);
1845
1846         render(isdb, pre, PT_NOFLAG,
1847                "-\tidstunr/s", NULL, NULL,
1848                NOVAL,
1849                S_VALUE(sneip->InDestUnreachs, sneic->InDestUnreachs, itv),
1850                NULL);
1851
1852         render(isdb, pre, PT_NOFLAG,
1853                "-\todstunr/s", NULL, NULL,
1854                NOVAL,
1855                S_VALUE(sneip->OutDestUnreachs, sneic->OutDestUnreachs, itv),
1856                NULL);
1857
1858         render(isdb, pre, PT_NOFLAG,
1859                "-\titmex/s", NULL, NULL,
1860                NOVAL,
1861                S_VALUE(sneip->InTimeExcds, sneic->InTimeExcds, itv),
1862                NULL);
1863
1864         render(isdb, pre, PT_NOFLAG,
1865                "-\totmex/s", NULL, NULL,
1866                NOVAL,
1867                S_VALUE(sneip->OutTimeExcds, sneic->OutTimeExcds, itv),
1868                NULL);
1869
1870         render(isdb, pre, PT_NOFLAG,
1871                "-\tiparmpb/s", NULL, NULL,
1872                NOVAL,
1873                S_VALUE(sneip->InParmProbs, sneic->InParmProbs, itv),
1874                NULL);
1875
1876         render(isdb, pre, PT_NOFLAG,
1877                "-\toparmpb/s", NULL, NULL,
1878                NOVAL,
1879                S_VALUE(sneip->OutParmProbs, sneic->OutParmProbs, itv),
1880                NULL);
1881
1882         render(isdb, pre, PT_NOFLAG,
1883                "-\tisrcq/s", NULL, NULL,
1884                NOVAL,
1885                S_VALUE(sneip->InSrcQuenchs, sneic->InSrcQuenchs, itv),
1886                NULL);
1887
1888         render(isdb, pre, PT_NOFLAG,
1889                "-\tosrcq/s", NULL, NULL,
1890                NOVAL,
1891                S_VALUE(sneip->OutSrcQuenchs, sneic->OutSrcQuenchs, itv),
1892                NULL);
1893
1894         render(isdb, pre, PT_NOFLAG,
1895                "-\tiredir/s", NULL, NULL,
1896                NOVAL,
1897                S_VALUE(sneip->InRedirects, sneic->InRedirects, itv),
1898                NULL);
1899
1900         render(isdb, pre, pt_newlin,
1901                "-\toredir/s", NULL, NULL,
1902                NOVAL,
1903                S_VALUE(sneip->OutRedirects, sneic->OutRedirects, itv),
1904                NULL);
1905 }
1906
1907 /*
1908  ***************************************************************************
1909  * Display TCP network statistics in selected format.
1910  *
1911  * IN:
1912  * @a           Activity structure with statistics.
1913  * @isdb        Flag, true if db printing, false if ppc printing.
1914  * @pre         Prefix string for output entries
1915  * @curr        Index in array for current sample statistics.
1916  * @itv         Interval of time in 1/100th of a second.
1917  ***************************************************************************
1918  */
1919 __print_funct_t render_net_tcp_stats(struct activity *a, int isdb, char *pre,
1920                                      int curr, unsigned long long itv)
1921 {
1922         struct stats_net_tcp
1923                 *sntc = (struct stats_net_tcp *) a->buf[curr],
1924                 *sntp = (struct stats_net_tcp *) a->buf[!curr];
1925         int pt_newlin
1926                 = (DISPLAY_HORIZONTALLY(flags) ? PT_NOFLAG : PT_NEWLIN);
1927
1928         render(isdb, pre, PT_NOFLAG,
1929                "-\tactive/s", NULL, NULL,
1930                NOVAL,
1931                S_VALUE(sntp->ActiveOpens, sntc->ActiveOpens, itv),
1932                NULL);
1933
1934         render(isdb, pre, PT_NOFLAG,
1935                "-\tpassive/s", NULL, NULL,
1936                NOVAL,
1937                S_VALUE(sntp->PassiveOpens, sntc->PassiveOpens, itv),
1938                NULL);
1939
1940         render(isdb, pre, PT_NOFLAG,
1941                "-\tiseg/s", NULL, NULL,
1942                NOVAL,
1943                S_VALUE(sntp->InSegs, sntc->InSegs, itv),
1944                NULL);
1945
1946         render(isdb, pre, pt_newlin,
1947                "-\toseg/s", NULL, NULL,
1948                NOVAL,
1949                S_VALUE(sntp->OutSegs, sntc->OutSegs, itv),
1950                NULL);
1951 }
1952
1953 /*
1954  ***************************************************************************
1955  * Display TCP network errors statistics in selected format.
1956  *
1957  * IN:
1958  * @a           Activity structure with statistics.
1959  * @isdb        Flag, true if db printing, false if ppc printing.
1960  * @pre         Prefix string for output entries
1961  * @curr        Index in array for current sample statistics.
1962  * @itv         Interval of time in 1/100th of a second.
1963  ***************************************************************************
1964  */
1965 __print_funct_t render_net_etcp_stats(struct activity *a, int isdb, char *pre,
1966                                       int curr, unsigned long long itv)
1967 {
1968         struct stats_net_etcp
1969                 *snetc = (struct stats_net_etcp *) a->buf[curr],
1970                 *snetp = (struct stats_net_etcp *) a->buf[!curr];
1971         int pt_newlin
1972                 = (DISPLAY_HORIZONTALLY(flags) ? PT_NOFLAG : PT_NEWLIN);
1973
1974         render(isdb, pre, PT_NOFLAG,
1975                "-\tatmptf/s", NULL, NULL,
1976                NOVAL,
1977                S_VALUE(snetp->AttemptFails, snetc->AttemptFails, itv),
1978                NULL);
1979
1980         render(isdb, pre, PT_NOFLAG,
1981                "-\testres/s", NULL, NULL,
1982                NOVAL,
1983                S_VALUE(snetp->EstabResets, snetc->EstabResets, itv),
1984                NULL);
1985
1986         render(isdb, pre, PT_NOFLAG,
1987                "-\tretrans/s", NULL, NULL,
1988                NOVAL,
1989                S_VALUE(snetp->RetransSegs, snetc->RetransSegs, itv),
1990                NULL);
1991
1992         render(isdb, pre, PT_NOFLAG,
1993                "-\tisegerr/s", NULL, NULL,
1994                NOVAL,
1995                S_VALUE(snetp->InErrs, snetc->InErrs, itv),
1996                NULL);
1997
1998         render(isdb, pre, pt_newlin,
1999                "-\torsts/s", NULL, NULL,
2000                NOVAL,
2001                S_VALUE(snetp->OutRsts, snetc->OutRsts, itv),
2002                NULL);
2003 }
2004
2005 /*
2006  ***************************************************************************
2007  * Display UDP network statistics in selected format.
2008  *
2009  * IN:
2010  * @a           Activity structure with statistics.
2011  * @isdb        Flag, true if db printing, false if ppc printing.
2012  * @pre         Prefix string for output entries
2013  * @curr        Index in array for current sample statistics.
2014  * @itv         Interval of time in 1/100th of a second.
2015  ***************************************************************************
2016  */
2017 __print_funct_t render_net_udp_stats(struct activity *a, int isdb, char *pre,
2018                                      int curr, unsigned long long itv)
2019 {
2020         struct stats_net_udp
2021                 *snuc = (struct stats_net_udp *) a->buf[curr],
2022                 *snup = (struct stats_net_udp *) a->buf[!curr];
2023         int pt_newlin
2024                 = (DISPLAY_HORIZONTALLY(flags) ? PT_NOFLAG : PT_NEWLIN);
2025
2026         render(isdb, pre, PT_NOFLAG,
2027                "-\tidgm/s", NULL, NULL,
2028                NOVAL,
2029                S_VALUE(snup->InDatagrams, snuc->InDatagrams, itv),
2030                NULL);
2031
2032         render(isdb, pre, PT_NOFLAG,
2033                "-\todgm/s", NULL, NULL,
2034                NOVAL,
2035                S_VALUE(snup->OutDatagrams, snuc->OutDatagrams, itv),
2036                NULL);
2037
2038         render(isdb, pre, PT_NOFLAG,
2039                "-\tnoport/s", NULL, NULL,
2040                NOVAL,
2041                S_VALUE(snup->NoPorts, snuc->NoPorts, itv),
2042                NULL);
2043
2044         render(isdb, pre, pt_newlin,
2045                "-\tidgmerr/s", NULL, NULL,
2046                NOVAL,
2047                S_VALUE(snup->InErrors, snuc->InErrors, itv),
2048                NULL);
2049 }
2050
2051 /*
2052  ***************************************************************************
2053  * Display IPv6 network sockets statistics in selected format.
2054  *
2055  * IN:
2056  * @a           Activity structure with statistics.
2057  * @isdb        Flag, true if db printing, false if ppc printing.
2058  * @pre         Prefix string for output entries
2059  * @curr        Index in array for current sample statistics.
2060  * @itv         Interval of time in 1/100th of a second.
2061  ***************************************************************************
2062  */
2063 __print_funct_t render_net_sock6_stats(struct activity *a, int isdb, char *pre,
2064                                        int curr, unsigned long long itv)
2065 {
2066         struct stats_net_sock6
2067                 *snsc = (struct stats_net_sock6 *) a->buf[curr];
2068         int pt_newlin
2069                 = (DISPLAY_HORIZONTALLY(flags) ? PT_NOFLAG : PT_NEWLIN);
2070
2071         render(isdb, pre, PT_USEINT,
2072                "-\ttcp6sck", NULL, NULL,
2073                (unsigned long long) snsc->tcp6_inuse, DNOVAL, NULL);
2074
2075         render(isdb, pre, PT_USEINT,
2076                "-\tudp6sck",  NULL, NULL,
2077                (unsigned long long) snsc->udp6_inuse, DNOVAL, NULL);
2078
2079         render(isdb, pre, PT_USEINT,
2080                "-\traw6sck", NULL, NULL,
2081                (unsigned long long) snsc->raw6_inuse, DNOVAL, NULL);
2082
2083         render(isdb, pre, PT_USEINT | pt_newlin,
2084                "-\tip6-frag", NULL, NULL,
2085                (unsigned long long) snsc->frag6_inuse, DNOVAL, NULL);
2086 }
2087
2088 /*
2089  ***************************************************************************
2090  * Display IPv6 network statistics in selected format.
2091  *
2092  * IN:
2093  * @a           Activity structure with statistics.
2094  * @isdb        Flag, true if db printing, false if ppc printing.
2095  * @pre         Prefix string for output entries
2096  * @curr        Index in array for current sample statistics.
2097  * @itv         Interval of time in 1/100th of a second.
2098  ***************************************************************************
2099  */
2100 __print_funct_t render_net_ip6_stats(struct activity *a, int isdb, char *pre,
2101                                      int curr, unsigned long long itv)
2102 {
2103         struct stats_net_ip6
2104                 *snic = (struct stats_net_ip6 *) a->buf[curr],
2105                 *snip = (struct stats_net_ip6 *) a->buf[!curr];
2106         int pt_newlin
2107                 = (DISPLAY_HORIZONTALLY(flags) ? PT_NOFLAG : PT_NEWLIN);
2108
2109         render(isdb, pre, PT_NOFLAG,
2110                "-\tirec6/s", NULL, NULL,
2111                NOVAL,
2112                S_VALUE(snip->InReceives6, snic->InReceives6, itv),
2113                NULL);
2114
2115         render(isdb, pre, PT_NOFLAG,
2116                "-\tfwddgm6/s", NULL, NULL,
2117                NOVAL,
2118                S_VALUE(snip->OutForwDatagrams6, snic->OutForwDatagrams6, itv),
2119                NULL);
2120
2121         render(isdb, pre, PT_NOFLAG,
2122                "-\tidel6/s", NULL, NULL,
2123                NOVAL,
2124                S_VALUE(snip->InDelivers6, snic->InDelivers6, itv),
2125                NULL);
2126
2127         render(isdb, pre, PT_NOFLAG,
2128                "-\torq6/s", NULL, NULL,
2129                NOVAL,
2130                S_VALUE(snip->OutRequests6, snic->OutRequests6, itv),
2131                NULL);
2132
2133         render(isdb, pre, PT_NOFLAG,
2134                "-\tasmrq6/s", NULL, NULL,
2135                NOVAL,
2136                S_VALUE(snip->ReasmReqds6, snic->ReasmReqds6, itv),
2137                NULL);
2138
2139         render(isdb, pre, PT_NOFLAG,
2140                "-\tasmok6/s", NULL, NULL,
2141                NOVAL,
2142                S_VALUE(snip->ReasmOKs6, snic->ReasmOKs6, itv),
2143                NULL);
2144
2145         render(isdb, pre, PT_NOFLAG,
2146                "-\timcpck6/s", NULL, NULL,
2147                NOVAL,
2148                S_VALUE(snip->InMcastPkts6, snic->InMcastPkts6, itv),
2149                NULL);
2150
2151         render(isdb, pre, PT_NOFLAG,
2152                "-\tomcpck6/s", NULL, NULL,
2153                NOVAL,
2154                S_VALUE(snip->OutMcastPkts6, snic->OutMcastPkts6, itv),
2155                NULL);
2156
2157         render(isdb, pre, PT_NOFLAG,
2158                "-\tfragok6/s", NULL, NULL,
2159                NOVAL,
2160                S_VALUE(snip->FragOKs6, snic->FragOKs6, itv),
2161                NULL);
2162
2163         render(isdb, pre, pt_newlin,
2164                "-\tfragcr6/s", NULL, NULL,
2165                NOVAL,
2166                S_VALUE(snip->FragCreates6, snic->FragCreates6, itv),
2167                NULL);
2168 }
2169
2170 /*
2171  ***************************************************************************
2172  * Display IPv6 network errors statistics in selected format.
2173  *
2174  * IN:
2175  * @a           Activity structure with statistics.
2176  * @isdb        Flag, true if db printing, false if ppc printing.
2177  * @pre         Prefix string for output entries
2178  * @curr        Index in array for current sample statistics.
2179  * @itv         Interval of time in 1/100th of a second.
2180  ***************************************************************************
2181  */
2182 __print_funct_t render_net_eip6_stats(struct activity *a, int isdb, char *pre,
2183                                       int curr, unsigned long long itv)
2184 {
2185         struct stats_net_eip6
2186                 *sneic = (struct stats_net_eip6 *) a->buf[curr],
2187                 *sneip = (struct stats_net_eip6 *) a->buf[!curr];
2188         int pt_newlin
2189                 = (DISPLAY_HORIZONTALLY(flags) ? PT_NOFLAG : PT_NEWLIN);
2190
2191         render(isdb, pre, PT_NOFLAG,
2192                "-\tihdrer6/s", NULL, NULL,
2193                NOVAL,
2194                S_VALUE(sneip->InHdrErrors6, sneic->InHdrErrors6, itv),
2195                NULL);
2196
2197         render(isdb, pre, PT_NOFLAG,
2198                "-\tiadrer6/s", NULL, NULL,
2199                NOVAL,
2200                S_VALUE(sneip->InAddrErrors6, sneic->InAddrErrors6, itv),
2201                NULL);
2202
2203         render(isdb, pre, PT_NOFLAG,
2204                "-\tiukwnp6/s", NULL, NULL,
2205                NOVAL,
2206                S_VALUE(sneip->InUnknownProtos6, sneic->InUnknownProtos6, itv),
2207                NULL);
2208
2209         render(isdb, pre, PT_NOFLAG,
2210                "-\ti2big6/s", NULL, NULL,
2211                NOVAL,
2212                S_VALUE(sneip->InTooBigErrors6, sneic->InTooBigErrors6, itv),
2213                NULL);
2214
2215         render(isdb, pre, PT_NOFLAG,
2216                "-\tidisc6/s", NULL, NULL,
2217                NOVAL,
2218                S_VALUE(sneip->InDiscards6, sneic->InDiscards6, itv),
2219                NULL);
2220
2221         render(isdb, pre, PT_NOFLAG,
2222                "-\todisc6/s", NULL, NULL,
2223                NOVAL,
2224                S_VALUE(sneip->OutDiscards6, sneic->OutDiscards6, itv),
2225                NULL);
2226
2227         render(isdb, pre, PT_NOFLAG,
2228                "-\tinort6/s", NULL, NULL,
2229                NOVAL,
2230                S_VALUE(sneip->InNoRoutes6, sneic->InNoRoutes6, itv),
2231                NULL);
2232
2233         render(isdb, pre, PT_NOFLAG,
2234                "-\tonort6/s", NULL, NULL,
2235                NOVAL,
2236                S_VALUE(sneip->OutNoRoutes6, sneic->OutNoRoutes6, itv),
2237                NULL);
2238
2239         render(isdb, pre, PT_NOFLAG,
2240                "-\tasmf6/s", NULL, NULL,
2241                NOVAL,
2242                S_VALUE(sneip->ReasmFails6, sneic->ReasmFails6, itv),
2243                NULL);
2244
2245         render(isdb, pre, PT_NOFLAG,
2246                "-\tfragf6/s", NULL, NULL,
2247                NOVAL,
2248                S_VALUE(sneip->FragFails6, sneic->FragFails6, itv),
2249                NULL);
2250
2251         render(isdb, pre, pt_newlin,
2252                "-\titrpck6/s", NULL, NULL,
2253                NOVAL,
2254                S_VALUE(sneip->InTruncatedPkts6, sneic->InTruncatedPkts6, itv),
2255                NULL);
2256 }
2257
2258 /*
2259  ***************************************************************************
2260  * Display ICMPv6 network statistics in selected format.
2261  *
2262  * IN:
2263  * @a           Activity structure with statistics.
2264  * @isdb        Flag, true if db printing, false if ppc printing.
2265  * @pre         Prefix string for output entries
2266  * @curr        Index in array for current sample statistics.
2267  * @itv         Interval of time in 1/100th of a second.
2268  ***************************************************************************
2269  */
2270 __print_funct_t render_net_icmp6_stats(struct activity *a, int isdb, char *pre,
2271                                        int curr, unsigned long long itv)
2272 {
2273         struct stats_net_icmp6
2274                 *snic = (struct stats_net_icmp6 *) a->buf[curr],
2275                 *snip = (struct stats_net_icmp6 *) a->buf[!curr];
2276         int pt_newlin
2277                 = (DISPLAY_HORIZONTALLY(flags) ? PT_NOFLAG : PT_NEWLIN);
2278
2279         render(isdb, pre, PT_NOFLAG,
2280                "-\timsg6/s", NULL, NULL,
2281                NOVAL,
2282                S_VALUE(snip->InMsgs6, snic->InMsgs6, itv),
2283                NULL);
2284
2285         render(isdb, pre, PT_NOFLAG,
2286                "-\tomsg6/s", NULL, NULL,
2287                NOVAL,
2288                S_VALUE(snip->OutMsgs6, snic->OutMsgs6, itv),
2289                NULL);
2290
2291         render(isdb, pre, PT_NOFLAG,
2292                "-\tiech6/s", NULL, NULL,
2293                NOVAL,
2294                S_VALUE(snip->InEchos6, snic->InEchos6, itv),
2295                NULL);
2296
2297         render(isdb, pre, PT_NOFLAG,
2298                "-\tiechr6/s", NULL, NULL,
2299                NOVAL,
2300                S_VALUE(snip->InEchoReplies6, snic->InEchoReplies6, itv),
2301                NULL);
2302
2303         render(isdb, pre, PT_NOFLAG,
2304                "-\toechr6/s", NULL, NULL,
2305                NOVAL,
2306                S_VALUE(snip->OutEchoReplies6, snic->OutEchoReplies6, itv),
2307                NULL);
2308
2309         render(isdb, pre, PT_NOFLAG,
2310                "-\tigmbq6/s", NULL, NULL,
2311                NOVAL,
2312                S_VALUE(snip->InGroupMembQueries6, snic->InGroupMembQueries6, itv),
2313                NULL);
2314
2315         render(isdb, pre, PT_NOFLAG,
2316                "-\tigmbr6/s", NULL, NULL,
2317                NOVAL,
2318                S_VALUE(snip->InGroupMembResponses6, snic->InGroupMembResponses6, itv),
2319                NULL);
2320
2321         render(isdb, pre, PT_NOFLAG,
2322                "-\togmbr6/s", NULL, NULL,
2323                NOVAL,
2324                S_VALUE(snip->OutGroupMembResponses6, snic->OutGroupMembResponses6, itv),
2325                NULL);
2326
2327         render(isdb, pre, PT_NOFLAG,
2328                "-\tigmbrd6/s", NULL, NULL,
2329                NOVAL,
2330                S_VALUE(snip->InGroupMembReductions6, snic->InGroupMembReductions6, itv),
2331                NULL);
2332
2333         render(isdb, pre, PT_NOFLAG,
2334                "-\togmbrd6/s", NULL, NULL,
2335                NOVAL,
2336                S_VALUE(snip->OutGroupMembReductions6, snic->OutGroupMembReductions6, itv),
2337                NULL);
2338
2339         render(isdb, pre, PT_NOFLAG,
2340                "-\tirtsol6/s", NULL, NULL,
2341                NOVAL,
2342                S_VALUE(snip->InRouterSolicits6, snic->InRouterSolicits6, itv),
2343                NULL);
2344
2345         render(isdb, pre, PT_NOFLAG,
2346                "-\tortsol6/s", NULL, NULL,
2347                NOVAL,
2348                S_VALUE(snip->OutRouterSolicits6, snic->OutRouterSolicits6, itv),
2349                NULL);
2350
2351         render(isdb, pre, PT_NOFLAG,
2352                "-\tirtad6/s", NULL, NULL,
2353                NOVAL,
2354                S_VALUE(snip->InRouterAdvertisements6, snic->InRouterAdvertisements6, itv),
2355                NULL);
2356
2357         render(isdb, pre, PT_NOFLAG,
2358                "-\tinbsol6/s", NULL, NULL,
2359                NOVAL,
2360                S_VALUE(snip->InNeighborSolicits6, snic->InNeighborSolicits6, itv),
2361                NULL);
2362
2363         render(isdb, pre, PT_NOFLAG,
2364                "-\tonbsol6/s", NULL, NULL,
2365                NOVAL,
2366                S_VALUE(snip->OutNeighborSolicits6, snic->OutNeighborSolicits6, itv),
2367                NULL);
2368
2369         render(isdb, pre, PT_NOFLAG,
2370                "-\tinbad6/s", NULL, NULL,
2371                NOVAL,
2372                S_VALUE(snip->InNeighborAdvertisements6, snic->InNeighborAdvertisements6, itv),
2373                NULL);
2374
2375         render(isdb, pre, pt_newlin,
2376                "-\tonbad6/s", NULL, NULL,
2377                NOVAL,
2378                S_VALUE(snip->OutNeighborAdvertisements6, snic->OutNeighborAdvertisements6, itv),
2379                NULL);
2380 }
2381
2382 /*
2383  ***************************************************************************
2384  * Display ICMPv6 error messages statistics in selected format.
2385  *
2386  * IN:
2387  * @a           Activity structure with statistics.
2388  * @isdb        Flag, true if db printing, false if ppc printing.
2389  * @pre         Prefix string for output entries
2390  * @curr        Index in array for current sample statistics.
2391  * @itv         Interval of time in 1/100th of a second.
2392  ***************************************************************************
2393  */
2394 __print_funct_t render_net_eicmp6_stats(struct activity *a, int isdb, char *pre,
2395                                         int curr, unsigned long long itv)
2396 {
2397         struct stats_net_eicmp6
2398                 *sneic = (struct stats_net_eicmp6 *) a->buf[curr],
2399                 *sneip = (struct stats_net_eicmp6 *) a->buf[!curr];
2400         int pt_newlin
2401                 = (DISPLAY_HORIZONTALLY(flags) ? PT_NOFLAG : PT_NEWLIN);
2402
2403         render(isdb, pre, PT_NOFLAG,
2404                "-\tierr6/s", NULL, NULL,
2405                NOVAL,
2406                S_VALUE(sneip->InErrors6, sneic->InErrors6, itv),
2407                NULL);
2408
2409         render(isdb, pre, PT_NOFLAG,
2410                "-\tidtunr6/s", NULL, NULL,
2411                NOVAL,
2412                S_VALUE(sneip->InDestUnreachs6, sneic->InDestUnreachs6, itv),
2413                NULL);
2414
2415         render(isdb, pre, PT_NOFLAG,
2416                "-\todtunr6/s", NULL, NULL,
2417                NOVAL,
2418                S_VALUE(sneip->OutDestUnreachs6, sneic->OutDestUnreachs6, itv),
2419                NULL);
2420
2421         render(isdb, pre, PT_NOFLAG,
2422                "-\titmex6/s", NULL, NULL,
2423                NOVAL,
2424                S_VALUE(sneip->InTimeExcds6, sneic->InTimeExcds6, itv),
2425                NULL);
2426
2427         render(isdb, pre, PT_NOFLAG,
2428                "-\totmex6/s", NULL, NULL,
2429                NOVAL,
2430                S_VALUE(sneip->OutTimeExcds6, sneic->OutTimeExcds6, itv),
2431                NULL);
2432
2433         render(isdb, pre, PT_NOFLAG,
2434                "-\tiprmpb6/s", NULL, NULL,
2435                NOVAL,
2436                S_VALUE(sneip->InParmProblems6, sneic->InParmProblems6, itv),
2437                NULL);
2438
2439         render(isdb, pre, PT_NOFLAG,
2440                "-\toprmpb6/s", NULL, NULL,
2441                NOVAL,
2442                S_VALUE(sneip->OutParmProblems6, sneic->OutParmProblems6, itv),
2443                NULL);
2444
2445         render(isdb, pre, PT_NOFLAG,
2446                "-\tiredir6/s", NULL, NULL,
2447                NOVAL,
2448                S_VALUE(sneip->InRedirects6, sneic->InRedirects6, itv),
2449                NULL);
2450
2451         render(isdb, pre, PT_NOFLAG,
2452                "-\toredir6/s", NULL, NULL,
2453                NOVAL,
2454                S_VALUE(sneip->OutRedirects6, sneic->OutRedirects6, itv),
2455                NULL);
2456
2457         render(isdb, pre, PT_NOFLAG,
2458                "-\tipck2b6/s", NULL, NULL,
2459                NOVAL,
2460                S_VALUE(sneip->InPktTooBigs6, sneic->InPktTooBigs6, itv),
2461                NULL);
2462
2463         render(isdb, pre, pt_newlin,
2464                "-\topck2b6/s", NULL, NULL,
2465                NOVAL,
2466                S_VALUE(sneip->OutPktTooBigs6, sneic->OutPktTooBigs6, itv),
2467                NULL);
2468 }
2469
2470 /*
2471  ***************************************************************************
2472  * Display UDP6 network statistics in selected format.
2473  *
2474  * IN:
2475  * @a           Activity structure with statistics.
2476  * @isdb        Flag, true if db printing, false if ppc printing.
2477  * @pre         Prefix string for output entries
2478  * @curr        Index in array for current sample statistics.
2479  * @itv         Interval of time in 1/100th of a second.
2480  ***************************************************************************
2481  */
2482 __print_funct_t render_net_udp6_stats(struct activity *a, int isdb, char *pre,
2483                                       int curr, unsigned long long itv)
2484 {
2485         struct stats_net_udp6
2486                 *snuc = (struct stats_net_udp6 *) a->buf[curr],
2487                 *snup = (struct stats_net_udp6 *) a->buf[!curr];
2488         int pt_newlin
2489                 = (DISPLAY_HORIZONTALLY(flags) ? PT_NOFLAG : PT_NEWLIN);
2490
2491         render(isdb, pre, PT_NOFLAG,
2492                "-\tidgm6/s", NULL, NULL,
2493                NOVAL,
2494                S_VALUE(snup->InDatagrams6, snuc->InDatagrams6, itv),
2495                NULL);
2496
2497         render(isdb, pre, PT_NOFLAG,
2498                "-\todgm6/s", NULL, NULL,
2499                NOVAL,
2500                S_VALUE(snup->OutDatagrams6, snuc->OutDatagrams6, itv),
2501                NULL);
2502
2503         render(isdb, pre, PT_NOFLAG,
2504                "-\tnoport6/s", NULL, NULL,
2505                NOVAL,
2506                S_VALUE(snup->NoPorts6, snuc->NoPorts6, itv),
2507                NULL);
2508
2509         render(isdb, pre, pt_newlin,
2510                "-\tidgmer6/s", NULL, NULL,
2511                NOVAL,
2512                S_VALUE(snup->InErrors6, snuc->InErrors6, itv),
2513                NULL);
2514 }
2515
2516 /*
2517  ***************************************************************************
2518  * Display CPU frequency statistics in selected format.
2519  *
2520  * IN:
2521  * @a           Activity structure with statistics.
2522  * @isdb        Flag, true if db printing, false if ppc printing.
2523  * @pre         Prefix string for output entries
2524  * @curr        Index in array for current sample statistics.
2525  * @itv         Interval of time in 1/100th of a second.
2526  ***************************************************************************
2527  */
2528 __print_funct_t render_pwr_cpufreq_stats(struct activity *a, int isdb, char *pre,
2529                                          int curr, unsigned long long itv)
2530 {
2531         int i;
2532         struct stats_pwr_cpufreq *spc;
2533         int pt_newlin
2534                 = (DISPLAY_HORIZONTALLY(flags) ? PT_NOFLAG : PT_NEWLIN);
2535
2536         for (i = 0; (i < a->nr[curr]) && (i < a->bitmap->b_size + 1); i++) {
2537
2538                 spc = (struct stats_pwr_cpufreq *) ((char *) a->buf[curr] + i * a->msize);
2539
2540                 if (!spc->cpufreq)
2541                         /* This CPU is offline: Don't display it */
2542                         continue;
2543
2544                 /* Should current CPU (including CPU "all") be displayed? */
2545                 if (!(a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))))
2546                         /* No */
2547                         continue;
2548
2549                 if (!i) {
2550                         /* This is CPU "all" */
2551                         render(isdb, pre, pt_newlin,
2552                                "all\tMHz",
2553                                "-1", NULL,
2554                                NOVAL,
2555                                ((double) spc->cpufreq) / 100,
2556                                NULL);
2557                 }
2558                 else {
2559                         render(isdb, pre, pt_newlin,
2560                                "cpu%d\tMHz",
2561                                "%d", cons(iv, i - 1, NOVAL),
2562                                NOVAL,
2563                                ((double) spc->cpufreq) / 100,
2564                                NULL);
2565                 }
2566         }
2567 }
2568
2569 /*
2570  ***************************************************************************
2571  * Display fan statistics in selected format.
2572  *
2573  * IN:
2574  * @a           Activity structure with statistics.
2575  * @isdb        Flag, true if db printing, false if ppc printing.
2576  * @pre         Prefix string for output entries
2577  * @curr        Index in array for current sample statistics.
2578  * @itv         Interval of time in 1/100th of a second.
2579  ***************************************************************************
2580  */
2581 __print_funct_t render_pwr_fan_stats(struct activity *a, int isdb, char *pre,
2582                                      int curr, unsigned long long itv)
2583 {
2584         int i;
2585         struct stats_pwr_fan *spc;
2586         int pt_newlin
2587                 = (DISPLAY_HORIZONTALLY(flags) ? PT_NOFLAG : PT_NEWLIN);
2588
2589         for (i = 0; i < a->nr[curr]; i++) {
2590                 spc = (struct stats_pwr_fan *) ((char *) a->buf[curr] + i * a->msize);
2591
2592                 render(isdb, pre, PT_USESTR,
2593                        "fan%d\tDEVICE",
2594                        "%d",
2595                        cons(iv, i + 1, NOVAL),
2596                        NOVAL,
2597                        NOVAL,
2598                        spc->device);
2599
2600                 render(isdb, pre, PT_NOFLAG,
2601                        "fan%d\trpm",
2602                        NULL,
2603                        cons(iv, i + 1, NOVAL),
2604                        NOVAL,
2605                        spc->rpm,
2606                        NULL);
2607
2608                 render(isdb, pre, pt_newlin,
2609                        "fan%d\tdrpm",
2610                        NULL,
2611                        cons(iv, i + 1, NOVAL),
2612                        NOVAL,
2613                        spc->rpm - spc->rpm_min,
2614                        NULL);
2615         }
2616 }
2617
2618 /*
2619  ***************************************************************************
2620  * Display temperature statistics in selected format.
2621  *
2622  * IN:
2623  * @a           Activity structure with statistics.
2624  * @isdb        Flag, true if db printing, false if ppc printing.
2625  * @pre         Prefix string for output entries
2626  * @curr        Index in array for current sample statistics.
2627  * @itv         Interval of time in 1/100th of a second.
2628  ***************************************************************************
2629  */
2630 __print_funct_t render_pwr_temp_stats(struct activity *a, int isdb, char *pre,
2631                                       int curr, unsigned long long itv)
2632 {
2633         int i;
2634         struct stats_pwr_temp *spc;
2635         int pt_newlin
2636                 = (DISPLAY_HORIZONTALLY(flags) ? PT_NOFLAG : PT_NEWLIN);
2637
2638         for (i = 0; i < a->nr[curr]; i++) {
2639                 spc = (struct stats_pwr_temp *) ((char *) a->buf[curr] + i * a->msize);
2640
2641                 render(isdb, pre, PT_USESTR,
2642                        "temp%d\tDEVICE",
2643                        "%d",
2644                        cons(iv, i + 1, NOVAL),
2645                        NOVAL,
2646                        NOVAL,
2647                        spc->device);
2648
2649                 render(isdb, pre, PT_NOFLAG,
2650                        "temp%d\tdegC",
2651                        NULL,
2652                        cons(iv, i + 1, NOVAL),
2653                        NOVAL,
2654                        spc->temp,
2655                        NULL);
2656
2657                 render(isdb, pre, pt_newlin,
2658                        "temp%d\t%%temp",
2659                        NULL,
2660                        cons(iv, i + 1, NOVAL),
2661                        NOVAL,
2662                        (spc->temp_max - spc->temp_min) ?
2663                        (spc->temp - spc->temp_min) / (spc->temp_max - spc->temp_min) * 100 :
2664                        0.0,
2665                        NULL);
2666         }
2667 }
2668
2669 /*
2670  ***************************************************************************
2671  * Display voltage inputs statistics in selected format.
2672  *
2673  * IN:
2674  * @a           Activity structure with statistics.
2675  * @isdb        Flag, true if db printing, false if ppc printing.
2676  * @pre         Prefix string for output entries
2677  * @curr        Index in array for current sample statistics.
2678  * @itv         Interval of time in 1/100th of a second.
2679  ***************************************************************************
2680  */
2681 __print_funct_t render_pwr_in_stats(struct activity *a, int isdb, char *pre,
2682                                     int curr, unsigned long long itv)
2683 {
2684         int i;
2685         struct stats_pwr_in *spc;
2686         int pt_newlin
2687                 = (DISPLAY_HORIZONTALLY(flags) ? PT_NOFLAG : PT_NEWLIN);
2688
2689         for (i = 0; i < a->nr[curr]; i++) {
2690                 spc = (struct stats_pwr_in *) ((char *) a->buf[curr] + i * a->msize);
2691
2692                 render(isdb, pre, PT_USESTR,
2693                        "in%d\tDEVICE",
2694                        "%d",
2695                        cons(iv, i, NOVAL),
2696                        NOVAL,
2697                        NOVAL,
2698                        spc->device);
2699
2700                 render(isdb, pre, PT_NOFLAG,
2701                        "in%d\tinV",
2702                        NULL,
2703                        cons(iv, i, NOVAL),
2704                        NOVAL,
2705                        spc->in,
2706                        NULL);
2707
2708                 render(isdb, pre, pt_newlin,
2709                        "in%d\t%%in",
2710                        NULL,
2711                        cons(iv, i, NOVAL),
2712                        NOVAL,
2713                        (spc->in_max - spc->in_min) ?
2714                        (spc->in - spc->in_min) / (spc->in_max - spc->in_min) * 100 :
2715                        0.0,
2716                        NULL);
2717         }
2718 }
2719
2720 /*
2721  ***************************************************************************
2722  * Display huge pages statistics in selected format.
2723  *
2724  * IN:
2725  * @a           Activity structure with statistics.
2726  * @isdb        Flag, true if db printing, false if ppc printing.
2727  * @pre         Prefix string for output entries
2728  * @curr        Index in array for current sample statistics.
2729  * @itv         Interval of time in 1/100th of a second.
2730  ***************************************************************************
2731  */
2732 __print_funct_t render_huge_stats(struct activity *a, int isdb, char *pre,
2733                                   int curr, unsigned long long itv)
2734 {
2735         struct stats_huge
2736                 *smc = (struct stats_huge *) a->buf[curr];
2737         int pt_newlin
2738                 = (DISPLAY_HORIZONTALLY(flags) ? PT_NOFLAG : PT_NEWLIN);
2739
2740         render(isdb, pre, PT_USEINT,
2741                "-\tkbhugfree", NULL, NULL,
2742                smc->frhkb, DNOVAL, NULL);
2743
2744         render(isdb, pre, PT_USEINT,
2745                "-\tkbhugused", NULL, NULL,
2746                smc->tlhkb - smc->frhkb, DNOVAL, NULL);
2747
2748         render(isdb, pre, PT_NOFLAG,
2749                "-\t%hugused", NULL, NULL, NOVAL,
2750                smc->tlhkb ?
2751                SP_VALUE(smc->frhkb, smc->tlhkb, smc->tlhkb) :
2752                0.0, NULL);
2753
2754         render(isdb, pre, PT_USEINT,
2755                "-\tkbhugrsvd", NULL, NULL,
2756                smc->rsvdhkb, DNOVAL, NULL);
2757
2758         render(isdb, pre, PT_USEINT | pt_newlin,
2759                "-\tkbhugsurp", NULL, NULL,
2760                smc->surphkb, DNOVAL, NULL);
2761 }
2762
2763 /*
2764  ***************************************************************************
2765  * Display weighted CPU frequency statistics in selected format.
2766  *
2767  * IN:
2768  * @a           Activity structure with statistics.
2769  * @isdb        Flag, true if db printing, false if ppc printing.
2770  * @pre         Prefix string for output entries
2771  * @curr        Index in array for current sample statistics.
2772  * @itv         Interval of time in 1/100th of a second.
2773  ***************************************************************************
2774  */
2775 __print_funct_t render_pwr_wghfreq_stats(struct activity *a, int isdb, char *pre,
2776                                          int curr, unsigned long long itv)
2777 {
2778         int i, k;
2779         struct stats_pwr_wghfreq *spc, *spp, *spc_k, *spp_k;
2780         unsigned long long tis, tisfreq;
2781         int pt_newlin
2782                 = (DISPLAY_HORIZONTALLY(flags) ? PT_NOFLAG : PT_NEWLIN);
2783
2784         for (i = 0; (i < a->nr[curr]) && (i < a->bitmap->b_size + 1); i++) {
2785
2786                 spc = (struct stats_pwr_wghfreq *) ((char *) a->buf[curr]  + i * a->msize * a->nr2);
2787                 spp = (struct stats_pwr_wghfreq *) ((char *) a->buf[!curr] + i * a->msize * a->nr2);
2788
2789                 /* Should current CPU (including CPU "all") be displayed? */
2790                 if (!(a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))))
2791                         /* No */
2792                         continue;
2793
2794                 tisfreq = 0;
2795                 tis = 0;
2796
2797                 for (k = 0; k < a->nr2; k++) {
2798
2799                         spc_k = (struct stats_pwr_wghfreq *) ((char *) spc + k * a->msize);
2800                         if (!spc_k->freq)
2801                                 break;
2802                         spp_k = (struct stats_pwr_wghfreq *) ((char *) spp + k * a->msize);
2803
2804                         tisfreq += (spc_k->freq / 1000) *
2805                                    (spc_k->time_in_state - spp_k->time_in_state);
2806                         tis     += (spc_k->time_in_state - spp_k->time_in_state);
2807                 }
2808
2809                 if (!i) {
2810                         /* This is CPU "all" */
2811                         render(isdb, pre, pt_newlin,
2812                                "all\twghMHz",
2813                                "-1", NULL,
2814                                NOVAL,
2815                                tis ? ((double) tisfreq) / tis : 0.0,
2816                                NULL);
2817                 }
2818                 else {
2819                         render(isdb, pre, pt_newlin,
2820                                "cpu%d\twghMHz",
2821                                "%d", cons(iv, i - 1, NOVAL),
2822                                NOVAL,
2823                                tis ? ((double) tisfreq) / tis : 0.0,
2824                                NULL);
2825                 }
2826         }
2827 }
2828
2829 /*
2830  ***************************************************************************
2831  * Display USB devices statistics in selected format.
2832  *
2833  * IN:
2834  * @a           Activity structure with statistics.
2835  * @isdb        Flag, true if db printing, false if ppc printing.
2836  * @pre         Prefix string for output entries
2837  * @curr        Index in array for current sample statistics.
2838  * @itv         Interval of time in 1/100th of a second.
2839  ***************************************************************************
2840  */
2841 __print_funct_t render_pwr_usb_stats(struct activity *a, int isdb, char *pre,
2842                                      int curr, unsigned long long itv)
2843 {
2844         int i;
2845         struct stats_pwr_usb *suc;
2846         char id[9];
2847
2848         for (i = 0; i < a->nr[curr]; i++) {
2849                 suc = (struct stats_pwr_usb *) ((char *) a->buf[curr] + i * a->msize);
2850
2851                 sprintf(id, "%x", suc->vendor_id);
2852                 render(isdb, pre, PT_USESTR,
2853                        "bus%d\tidvendor",
2854                        "%d",
2855                        cons(iv, suc->bus_nr, NOVAL),
2856                        NOVAL,
2857                        NOVAL,
2858                        id);
2859
2860                 sprintf(id, "%x", suc->product_id);
2861                 render(isdb, pre, PT_USESTR,
2862                        "bus%d\tidprod",
2863                        NULL,
2864                        cons(iv, suc->bus_nr, NOVAL),
2865                        NOVAL,
2866                        NOVAL,
2867                        id);
2868
2869                 render(isdb, pre, PT_USEINT,
2870                        "bus%d\tmaxpower",
2871                        NULL,
2872                        cons(iv, suc->bus_nr, NOVAL),
2873                        (unsigned long long) (suc->bmaxpower << 1),
2874                        NOVAL,
2875                        NULL);
2876
2877                 render(isdb, pre, PT_USESTR,
2878                        "bus%d\tmanufact",
2879                        NULL,
2880                        cons(iv, suc->bus_nr, NOVAL),
2881                        NOVAL,
2882                        NOVAL,
2883                        suc->manufacturer);
2884
2885                 render(isdb, pre,
2886                        (DISPLAY_HORIZONTALLY(flags) ? PT_USESTR : PT_USESTR | PT_NEWLIN),
2887                        "bus%d\tproduct",
2888                        NULL,
2889                        cons(iv, suc->bus_nr, NOVAL),
2890                        NOVAL,
2891                        NOVAL,
2892                        suc->product);
2893         }
2894 }
2895
2896 /*
2897  ***************************************************************************
2898  * Display filesystems statistics in selected format.
2899  *
2900  * IN:
2901  * @a           Activity structure with statistics.
2902  * @isdb        Flag, true if db printing, false if ppc printing.
2903  * @pre         Prefix string for output entries
2904  * @curr        Index in array for current sample statistics.
2905  * @itv         Interval of time in 1/100th of a second.
2906  ***************************************************************************
2907  */
2908 __print_funct_t render_filesystem_stats(struct activity *a, int isdb, char *pre,
2909                                         int curr, unsigned long long itv)
2910 {
2911         int i;
2912         struct stats_filesystem *sfc;
2913
2914         for (i = 0; i < a->nr[curr]; i++) {
2915                 sfc = (struct stats_filesystem *) ((char *) a->buf[curr] + i * a->msize);
2916
2917                 if (a->item_list != NULL) {
2918                         /* A list of devices has been entered on the command line */
2919                         if (!search_list_item(a->item_list,
2920                                               DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name))
2921                                 /* Device not found */
2922                                 continue;
2923                 }
2924
2925                 render(isdb, pre, PT_USERND,
2926                        "%s\tMBfsfree",
2927                        "%s",
2928                        cons(sv, DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name, NOVAL),
2929                        NOVAL,
2930                        (double) sfc->f_bfree / 1024 / 1024,
2931                        NULL);
2932
2933                 render(isdb, pre, PT_USERND,
2934                        "%s\tMBfsused",
2935                        NULL,
2936                        cons(sv, DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name, NOVAL),
2937                        NOVAL,
2938                        (double) (sfc->f_blocks - sfc->f_bfree) / 1024 / 1024,
2939                        NULL);
2940
2941                 render(isdb, pre, PT_NOFLAG,
2942                        "%s\t%%fsused",
2943                        NULL,
2944                        cons(sv, DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name, NOVAL),
2945                        NOVAL,
2946                        sfc->f_blocks ? SP_VALUE(sfc->f_bfree, sfc->f_blocks, sfc->f_blocks)
2947                                      : 0.0,
2948                        NULL);
2949
2950                 render(isdb, pre, PT_NOFLAG,
2951                        "%s\t%%ufsused",
2952                        NULL,
2953                        cons(sv, DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name, NOVAL),
2954                        NOVAL,
2955                        sfc->f_blocks ? SP_VALUE(sfc->f_bavail, sfc->f_blocks, sfc->f_blocks)
2956                                      : 0.0,
2957                        NULL);
2958
2959                 render(isdb, pre, PT_USEINT,
2960                        "%s\tIfree",
2961                        NULL,
2962                        cons(sv, DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name, NOVAL),
2963                        sfc->f_ffree,
2964                        NOVAL,
2965                        NULL);
2966
2967                 render(isdb, pre, PT_USEINT,
2968                        "%s\tIused",
2969                        NULL,
2970                        cons(sv, DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name, NOVAL),
2971                        sfc->f_files - sfc->f_ffree,
2972                        NOVAL,
2973                        NULL);
2974
2975                 render(isdb, pre,
2976                        (DISPLAY_HORIZONTALLY(flags) ? PT_NOFLAG : PT_NEWLIN),
2977                        "%s\t%%Iused",
2978                        NULL,
2979                        cons(sv, DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name, NOVAL),
2980                        NOVAL,
2981                        sfc->f_files ? SP_VALUE(sfc->f_ffree, sfc->f_files, sfc->f_files)
2982                                     : 0.0,
2983                        NULL);
2984         }
2985 }
2986
2987 /*
2988  ***************************************************************************
2989  * Display Fibre Channel HBA statistics in selected format.
2990  *
2991  * IN:
2992  * @a           Activity structure with statistics.
2993  * @isdb        Flag, true if db printing, false if ppc printing.
2994  * @pre         Prefix string for output entries
2995  * @curr        Index in array for current sample statistics.
2996  * @itv         Interval of time in 1/100th of a second.
2997  ***************************************************************************
2998  */
2999 __print_funct_t render_fchost_stats(struct activity *a, int isdb, char *pre,
3000                                     int curr, unsigned long long itv)
3001 {
3002         int i, j, j0, found;
3003         struct stats_fchost *sfcc, *sfcp, sfczero;
3004
3005         memset(&sfczero, 0, sizeof(struct stats_fchost));
3006
3007         for (i = 0; i < a->nr[curr]; i++) {
3008
3009                 found = FALSE;
3010                 sfcc = (struct stats_fchost *) ((char *) a->buf[curr] + i * a->msize);
3011
3012                 if (a->nr[!curr] > 0) {
3013                         /* Look for corresponding structure in previous iteration */
3014                         j = i;
3015
3016                         if (j >= a->nr[!curr]) {
3017                                 j = a->nr[!curr] - 1;
3018                         }
3019
3020                         j0 = j;
3021
3022                         do {
3023                                 sfcp = (struct stats_fchost *) ((char *) a->buf[!curr] + j * a->msize);
3024                                 if (!strcmp(sfcc->fchost_name, sfcp->fchost_name)) {
3025                                         found = TRUE;
3026                                         break;
3027                                 }
3028                                 if (++j >= a->nr[!curr]) {
3029                                         j = 0;
3030                                 }
3031                         }
3032                         while (j != j0);
3033                 }
3034
3035                 if (!found) {
3036                         /* This is a newly registered host */
3037                         sfcp = &sfczero;
3038                 }
3039
3040                 render(isdb, pre, PT_NOFLAG ,
3041                        "%s\tfch_rxf/s",
3042                        "%s",
3043                        cons(sv, sfcc->fchost_name, NOVAL),
3044                        NOVAL,
3045                        S_VALUE(sfcp->f_rxframes, sfcc->f_rxframes, itv),
3046                        NULL);
3047                 render(isdb, pre, PT_NOFLAG,
3048                        "%s\tfch_txf/s", NULL,
3049                        cons(sv, sfcc->fchost_name, NULL),
3050                        NOVAL,
3051                        S_VALUE(sfcp->f_txframes, sfcc->f_txframes, itv),
3052                        NULL);
3053                 render(isdb, pre, PT_NOFLAG,
3054                        "%s\tfch_rxw/s", NULL,
3055                        cons(sv, sfcc->fchost_name, NULL),
3056                        NOVAL,
3057                        S_VALUE(sfcp->f_rxwords, sfcc->f_rxwords, itv),
3058                        NULL);
3059                 render(isdb, pre,
3060                        (DISPLAY_HORIZONTALLY(flags) ? PT_NOFLAG : PT_NEWLIN),
3061                        "%s\tfch_txw/s", NULL,
3062                        cons(sv, sfcc->fchost_name, NULL),
3063                        NOVAL,
3064                        S_VALUE(sfcp->f_txwords, sfcc->f_txwords, itv),
3065                        NULL);
3066         }
3067 }
3068
3069 /*
3070  ***************************************************************************
3071  * Display softnet statistics in selected format.
3072  *
3073  * IN:
3074  * @a           Activity structure with statistics.
3075  * @isdb        Flag, true if db printing, false if ppc printing.
3076  * @pre         Prefix string for output entries
3077  * @curr        Index in array for current sample statistics.
3078  * @itv         Interval of time in 1/100th of a second.
3079  ***************************************************************************
3080  */
3081 __print_funct_t render_softnet_stats(struct activity *a, int isdb, char *pre,
3082                                      int curr, unsigned long long itv)
3083 {
3084         int i;
3085         struct stats_softnet *ssnc, *ssnp;
3086         unsigned char offline_cpu_bitmap[BITMAP_SIZE(NR_CPUS)] = {0};
3087         int pt_newlin
3088                 = (DISPLAY_HORIZONTALLY(flags) ? PT_NOFLAG : PT_NEWLIN);
3089
3090         /* @nr[curr] cannot normally be greater than @nr_ini */
3091         if (a->nr[curr] > a->nr_ini) {
3092                 a->nr_ini = a->nr[curr];
3093         }
3094
3095         /* Compute statistics for CPU "all" */
3096         get_global_soft_statistics(a, !curr, curr, flags, offline_cpu_bitmap);
3097
3098         for (i = 0; (i < a->nr_ini) && (i < a->bitmap->b_size + 1); i++) {
3099
3100                 /*
3101                  * Note: a->nr is in [1, NR_CPUS + 1].
3102                  * Bitmap size is provided for (NR_CPUS + 1) CPUs.
3103                  * Anyway, NR_CPUS may vary between the version of sysstat
3104                  * used by sadc to create a file, and the version of sysstat
3105                  * used by sar to read it...
3106                  */
3107                 if (!(a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))) ||
3108                     offline_cpu_bitmap[i >> 3] & (1 << (i & 0x07)))
3109                         /* No */
3110                         continue;
3111
3112                 /*
3113                  * The size of a->buf[...] CPU structure may be different from the default
3114                  * sizeof(struct stats_pwr_cpufreq) value if data have been read from a file!
3115                  * That's why we don't use a syntax like:
3116                  * ssnc = (struct stats_softnet *) a->buf[...] + i;
3117                  */
3118                 ssnc = (struct stats_softnet *) ((char *) a->buf[curr]  + i * a->msize);
3119                 ssnp = (struct stats_softnet *) ((char *) a->buf[!curr] + i * a->msize);
3120
3121                 if (!i) {
3122                         /* This is CPU "all" */
3123                         render(isdb, pre, PT_NOFLAG,
3124                                "all\ttotal/s",
3125                                "-1", NULL,
3126                                NOVAL,
3127                                S_VALUE(ssnp->processed, ssnc->processed, itv),
3128                                NULL);
3129
3130                         render(isdb, pre, PT_NOFLAG,
3131                                "all\tdropd/s",
3132                                NULL, NULL,
3133                                NOVAL,
3134                                S_VALUE(ssnp->dropped, ssnc->dropped, itv),
3135                                NULL);
3136
3137                         render(isdb, pre, PT_NOFLAG,
3138                                "all\tsqueezd/s",
3139                                NULL, NULL,
3140                                NOVAL,
3141                                S_VALUE(ssnp->time_squeeze, ssnc->time_squeeze, itv),
3142                                NULL);
3143
3144                         render(isdb, pre, PT_NOFLAG,
3145                                "all\trx_rps/s",
3146                                NULL, NULL,
3147                                NOVAL,
3148                                S_VALUE(ssnp->received_rps, ssnc->received_rps, itv),
3149                                NULL);
3150
3151                         render(isdb, pre, pt_newlin,
3152                                "all\tflw_lim/s",
3153                                NULL, NULL,
3154                                NOVAL,
3155                                S_VALUE(ssnp->flow_limit, ssnc->flow_limit, itv),
3156                                NULL);
3157                 }
3158                 else {
3159                         render(isdb, pre, PT_NOFLAG,
3160                                "cpu%d\ttotal/s",
3161                                "%d", cons(iv, i - 1, NOVAL),
3162                                NOVAL,
3163                                S_VALUE(ssnp->processed, ssnc->processed, itv),
3164                                NULL);
3165
3166                         render(isdb, pre, PT_NOFLAG,
3167                                "cpu%d\tdropd/s",
3168                                NULL, cons(iv, i - 1, NOVAL),
3169                                NOVAL,
3170                                S_VALUE(ssnp->dropped, ssnc->dropped, itv),
3171                                NULL);
3172
3173                         render(isdb, pre, PT_NOFLAG,
3174                                "cpu%d\tsqueezd/s",
3175                                NULL, cons(iv, i - 1, NOVAL),
3176                                NOVAL,
3177                                S_VALUE(ssnp->time_squeeze, ssnc->time_squeeze, itv),
3178                                NULL);
3179
3180                         render(isdb, pre, PT_NOFLAG,
3181                                "cpu%d\trx_rps/s",
3182                                NULL, cons(iv, i - 1, NOVAL),
3183                                NOVAL,
3184                                S_VALUE(ssnp->received_rps, ssnc->received_rps, itv),
3185                                NULL);
3186
3187                         render(isdb, pre, pt_newlin,
3188                                "cpu%d\tflw_lim/s",
3189                                NULL, cons(iv, i - 1, NOVAL),
3190                                NOVAL,
3191                                S_VALUE(ssnp->flow_limit, ssnc->flow_limit, itv),
3192                                NULL);
3193                 }
3194         }
3195 }