]> granicus.if.org Git - sysstat/blob - rndr_stats.c
Merge pull request #346 from Kwstubbs/Kwstubbs/add-codeql-workflow
[sysstat] / rndr_stats.c
1 /*
2  * rndr_stats.c: Functions used by sadf to display statistics in selected format.
3  * (C) 1999-2022 by Sebastien GODARD (sysstat <at> orange.fr)
4  *
5  ***************************************************************************
6  * This program is free software; you can redistribute it and/or modify it *
7  * under the terms of the GNU General Public License as published  by  the *
8  * Free Software Foundation; either version 2 of the License, or (at  your *
9  * option) any later version.                                              *
10  *                                                                         *
11  * This program is distributed in the hope that it  will  be  useful,  but *
12  * WITHOUT ANY WARRANTY; without the implied warranty  of  MERCHANTABILITY *
13  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License *
14  * for more details.                                                       *
15  *                                                                         *
16  * You should have received a copy of the GNU General Public License along *
17  * with this program; if not, write to the Free Software Foundation, Inc., *
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA              *
19  ***************************************************************************
20  */
21
22 #include <stdio.h>
23 #include <string.h>
24 #include <stdarg.h>
25
26 #include "sa.h"
27 #include "ioconf.h"
28 #include "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 uint64_t 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 if (rflags & PT_NOFLAG) {
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                 = PT_NOFLAG + (DISPLAY_HORIZONTALLY(flags) ? 0 : 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                 = PT_NOFLAG + (DISPLAY_HORIZONTALLY(flags) ? 0 : 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, c, first;
521         struct stats_irq *stc_cpu_irq, *stp_cpu_irq, *stc_cpuall_irq;
522         unsigned char masked_cpu_bitmap[BITMAP_SIZE(NR_CPUS)] = {0};
523         char cpu_name[32], ppc_txt[512];
524         double dval;
525
526         /* @nr[curr] cannot normally be greater than @nr_ini */
527         if (a->nr[curr] > a->nr_ini) {
528                 a->nr_ini = a->nr[curr];
529         }
530
531         /* Identify offline and unselected CPU, and keep persistent statistics values */
532         get_global_int_statistics(a, !curr, curr, flags, masked_cpu_bitmap);
533
534         for (i = 0; i < a->nr2; i++) {
535
536                 stc_cpuall_irq = (struct stats_irq *) ((char *) a->buf[curr] + i * a->msize);
537
538                 if (a->item_list != NULL) {
539                         /* A list of devices has been entered on the command line */
540                         if (!search_list_item(a->item_list, stc_cpuall_irq->irq_name))
541                                 /* Device not found */
542                                 continue;
543                 }
544
545                 first = TRUE;
546                 for (c = 0; (c < a->nr[curr]) && (c < a->bitmap->b_size + 1); c++) {
547
548                         stc_cpu_irq = (struct stats_irq *) ((char *) a->buf[curr] + c * a->msize * a->nr2
549                                                                                   + i * a->msize);
550                         stp_cpu_irq = (struct stats_irq *) ((char *) a->buf[!curr] + c * a->msize * a->nr2
551                                                                                   + i * a->msize);
552
553                         /* Should current CPU (including CPU "all") be displayed? */
554                         if (masked_cpu_bitmap[c >> 3] & (1 << (c & 0x07)))
555                                 /* No */
556                                 continue;
557
558                         /* Compute value to be displayed */
559                         dval = S_VALUE(stp_cpu_irq->irq_nr, stc_cpu_irq->irq_nr, itv);
560
561                         /* Yes: Display it */
562                         if (!c) {
563                                 strcpy(cpu_name, "all");
564
565                                 /* If number of int has decreased for CPU "all" then display 0.00 */
566                                 if (stc_cpu_irq->irq_nr < stp_cpu_irq->irq_nr) {
567                                         dval = 0.0;
568                                 }
569                         }
570                         else {
571                                 snprintf(cpu_name, sizeof(cpu_name), "cpu%d", c - 1);
572                                 cpu_name[sizeof(cpu_name) - 1] = '\0';
573                         }
574                         snprintf(ppc_txt, sizeof(ppc_txt), "%s\t%s", stc_cpuall_irq->irq_name, cpu_name);
575                         ppc_txt[sizeof(ppc_txt) - 1] = '\0';
576
577                         if (first) {
578                                 render(isdb, pre, PT_NOFLAG,
579                                        "%s", "%s",
580                                        isdb ? cons(sv, stc_cpuall_irq->irq_name, NOVAL)
581                                             : cons(sv, ppc_txt, NOVAL),
582                                        NOVAL,
583                                        dval,
584                                        NULL);
585                                 first = FALSE;
586                         }
587                         else {
588                                 render(isdb, pre, PT_NOFLAG,
589                                        "%s", NULL,
590                                        cons(sv, ppc_txt, NOVAL),
591                                        NOVAL,
592                                        dval,
593                                        NULL);
594                         }
595                 }
596                 if (isdb && !DISPLAY_HORIZONTALLY(flags)) {
597                         /* Print a newline chr and make sure that @pre text will be printed next time */
598                         render(isdb, pre, PT_NEWLIN, NULL, NULL, NULL, NOVAL, NOVAL, NULL);
599                 }
600         }
601 }
602
603 /*
604  ***************************************************************************
605  * Display swapping statistics in selected format.
606  *
607  * IN:
608  * @a           Activity structure with statistics.
609  * @isdb        Flag, true if db printing, false if ppc printing.
610  * @pre         Prefix string for output entries
611  * @curr        Index in array for current sample statistics.
612  * @itv         Interval of time in 1/100th of a second.
613  ***************************************************************************
614  */
615 __print_funct_t render_swap_stats(struct activity *a, int isdb, char *pre,
616                                   int curr, unsigned long long itv)
617 {
618         struct stats_swap
619                 *ssc = (struct stats_swap *) a->buf[curr],
620                 *ssp = (struct stats_swap *) a->buf[!curr];
621         int pt_newlin
622                 = PT_NOFLAG + (DISPLAY_HORIZONTALLY(flags) ? 0 : PT_NEWLIN);
623
624         render(isdb, pre, PT_NOFLAG,
625                "-\tpswpin/s", NULL, NULL,
626                NOVAL,
627                S_VALUE(ssp->pswpin, ssc->pswpin, itv),
628                NULL);
629         render(isdb, pre, pt_newlin,
630                "-\tpswpout/s", NULL, NULL,
631                NOVAL,
632                S_VALUE(ssp->pswpout, ssc->pswpout, itv),
633                NULL);
634 }
635
636 /*
637  ***************************************************************************
638  * Display paging statistics in selected format.
639  *
640  * IN:
641  * @a           Activity structure with statistics.
642  * @isdb        Flag, true if db printing, false if ppc printing.
643  * @pre         Prefix string for output entries
644  * @curr        Index in array for current sample statistics.
645  * @itv         Interval of time in 1/100th of a second.
646  ***************************************************************************
647  */
648 __print_funct_t render_paging_stats(struct activity *a, int isdb, char *pre,
649                                     int curr, unsigned long long itv)
650 {
651         struct stats_paging
652                 *spc = (struct stats_paging *) a->buf[curr],
653                 *spp = (struct stats_paging *) a->buf[!curr];
654         int pt_newlin
655                 = PT_NOFLAG + (DISPLAY_HORIZONTALLY(flags) ? 0 : PT_NEWLIN);
656
657         render(isdb, pre, PT_NOFLAG,
658                "-\tpgpgin/s", NULL, NULL,
659                NOVAL,
660                S_VALUE(spp->pgpgin, spc->pgpgin, itv),
661                NULL);
662
663         render(isdb, pre, PT_NOFLAG,
664                "-\tpgpgout/s", NULL, NULL,
665                NOVAL,
666                S_VALUE(spp->pgpgout, spc->pgpgout, itv),
667                NULL);
668
669         render(isdb, pre, PT_NOFLAG,
670                "-\tfault/s", NULL, NULL,
671                NOVAL,
672                S_VALUE(spp->pgfault, spc->pgfault, itv),
673                NULL);
674
675         render(isdb, pre, PT_NOFLAG,
676                "-\tmajflt/s", NULL, NULL,
677                NOVAL,
678                S_VALUE(spp->pgmajfault, spc->pgmajfault, itv),
679                NULL);
680
681         render(isdb, pre, PT_NOFLAG,
682                "-\tpgfree/s", NULL, NULL,
683                NOVAL,
684                S_VALUE(spp->pgfree, spc->pgfree, itv),
685                NULL);
686
687         render(isdb, pre, PT_NOFLAG,
688                "-\tpgscank/s", NULL, NULL,
689                NOVAL,
690                S_VALUE(spp->pgscan_kswapd, spc->pgscan_kswapd, itv),
691                NULL);
692
693         render(isdb, pre, PT_NOFLAG,
694                "-\tpgscand/s", NULL, NULL,
695                NOVAL,
696                S_VALUE(spp->pgscan_direct, spc->pgscan_direct, itv),
697                NULL);
698
699         render(isdb, pre, PT_NOFLAG,
700                "-\tpgsteal/s", NULL, NULL,
701                NOVAL,
702                S_VALUE(spp->pgsteal, spc->pgsteal, itv),
703                NULL);
704
705         render(isdb, pre, pt_newlin,
706                "-\t%vmeff", NULL, NULL,
707                NOVAL,
708                (spc->pgscan_kswapd + spc->pgscan_direct -
709                 spp->pgscan_kswapd - spp->pgscan_direct) ?
710                SP_VALUE(spp->pgsteal, spc->pgsteal,
711                         spc->pgscan_kswapd + spc->pgscan_direct -
712                         spp->pgscan_kswapd - spp->pgscan_direct) : 0.0,
713                NULL);
714 }
715
716 /*
717  ***************************************************************************
718  * Display I/O and transfer rate statistics in selected format.
719  *
720  * IN:
721  * @a           Activity structure with statistics.
722  * @isdb        Flag, true if db printing, false if ppc printing.
723  * @pre         Prefix string for output entries
724  * @curr        Index in array for current sample statistics.
725  * @itv         Interval of time in 1/100th of a second.
726  ***************************************************************************
727  */
728 __print_funct_t render_io_stats(struct activity *a, int isdb, char *pre,
729                                 int curr, unsigned long long itv)
730 {
731         struct stats_io
732                 *sic = (struct stats_io *) a->buf[curr],
733                 *sip = (struct stats_io *) a->buf[!curr];
734         int pt_newlin
735                 = PT_NOFLAG + (DISPLAY_HORIZONTALLY(flags) ? 0 : PT_NEWLIN);
736
737         /*
738          * If we get negative values, this is probably because
739          * one or more devices/filesystems have been unmounted.
740          * We display 0.0 in this case though we should rather tell
741          * the user that the value cannot be calculated here.
742          */
743         render(isdb, pre, PT_NOFLAG,
744                "-\ttps", NULL, NULL,
745                NOVAL,
746                sic->dk_drive < sip->dk_drive ? 0.0 :
747                S_VALUE(sip->dk_drive, sic->dk_drive, itv),
748                NULL);
749
750         render(isdb, pre, PT_NOFLAG,
751                "-\trtps", NULL, NULL,
752                NOVAL,
753                sic->dk_drive_rio < sip->dk_drive_rio ? 0.0 :
754                S_VALUE(sip->dk_drive_rio, sic->dk_drive_rio, itv),
755                NULL);
756
757         render(isdb, pre, PT_NOFLAG,
758                "-\twtps", NULL, NULL,
759                NOVAL,
760                sic->dk_drive_wio < sip->dk_drive_wio ? 0.0 :
761                S_VALUE(sip->dk_drive_wio, sic->dk_drive_wio, itv),
762                NULL);
763
764         render(isdb, pre, PT_NOFLAG,
765                "-\tdtps", NULL, NULL,
766                NOVAL,
767                sic->dk_drive_dio < sip->dk_drive_dio ? 0.0 :
768                S_VALUE(sip->dk_drive_dio, sic->dk_drive_dio, itv),
769                NULL);
770
771         render(isdb, pre, PT_NOFLAG,
772                "-\tbread/s", NULL, NULL,
773                NOVAL,
774                sic->dk_drive_rblk < sip->dk_drive_rblk ? 0.0 :
775                S_VALUE(sip->dk_drive_rblk, sic->dk_drive_rblk, itv),
776                NULL);
777
778         render(isdb, pre, PT_NOFLAG,
779                "-\tbwrtn/s", NULL, NULL,
780                NOVAL,
781                sic->dk_drive_wblk < sip->dk_drive_wblk ? 0.0 :
782                S_VALUE(sip->dk_drive_wblk, sic->dk_drive_wblk, itv),
783                NULL);
784
785         render(isdb, pre, pt_newlin,
786                "-\tbdscd/s", NULL, NULL,
787                NOVAL,
788                sic->dk_drive_dblk < sip->dk_drive_dblk ? 0.0 :
789                S_VALUE(sip->dk_drive_dblk, sic->dk_drive_dblk, itv),
790                NULL);
791 }
792
793 /*
794  ***************************************************************************
795  * Display memory and swap statistics in selected format.
796  *
797  * IN:
798  * @a           Activity structure with statistics.
799  * @isdb        Flag, true if db printing, false if ppc printing.
800  * @pre         Prefix string for output entries
801  * @curr        Index in array for current sample statistics.
802  * @itv         Interval of time in 1/100th of a second.
803  ***************************************************************************
804  */
805 __print_funct_t render_memory_stats(struct activity *a, int isdb, char *pre,
806                                     int curr, unsigned long long itv)
807 {
808         struct stats_memory
809                 *smc = (struct stats_memory *) a->buf[curr];
810         int pt_newlin
811                 = PT_NOFLAG + (DISPLAY_HORIZONTALLY(flags) ? 0 : PT_NEWLIN);
812         int ptn;
813         unsigned long long nousedmem;
814
815         if (DISPLAY_MEMORY(a->opt_flags)) {
816
817                 nousedmem = smc->frmkb + smc->bufkb + smc->camkb + smc->slabkb;
818                 if (nousedmem > smc->tlmkb) {
819                         nousedmem = smc->tlmkb;
820                 }
821
822                 render(isdb, pre, PT_USEINT,
823                        "-\tkbmemfree", NULL, NULL,
824                        smc->frmkb, DNOVAL, NULL);
825
826                 render(isdb, pre, PT_USEINT,
827                        "-\tkbavail", NULL, NULL,
828                        smc->availablekb, DNOVAL, NULL);
829
830                 render(isdb, pre, PT_USEINT,
831                        "-\tkbmemused", NULL, NULL,
832                        smc->tlmkb - nousedmem, DNOVAL, NULL);
833
834                 render(isdb, pre, PT_NOFLAG,
835                        "-\t%memused", NULL, NULL, NOVAL,
836                        smc->tlmkb ?
837                        SP_VALUE(nousedmem, smc->tlmkb, smc->tlmkb) :
838                        0.0, NULL);
839
840                 render(isdb, pre, PT_USEINT,
841                        "-\tkbbuffers", NULL, NULL,
842                        smc->bufkb, DNOVAL, NULL);
843
844                 render(isdb, pre, PT_USEINT,
845                        "-\tkbcached", NULL, NULL,
846                        smc->camkb, DNOVAL, NULL);
847
848                 render(isdb, pre, PT_USEINT,
849                        "-\tkbcommit", NULL, NULL,
850                        smc->comkb, DNOVAL, NULL);
851
852                 render(isdb, pre, PT_NOFLAG,
853                        "-\t%commit", NULL, NULL, NOVAL,
854                        (smc->tlmkb + smc->tlskb) ?
855                        SP_VALUE(0, smc->comkb, smc->tlmkb + smc->tlskb) :
856                        0.0, NULL);
857
858                 render(isdb, pre, PT_USEINT,
859                        "-\tkbactive", NULL, NULL,
860                        smc->activekb, DNOVAL, NULL);
861
862                 render(isdb, pre, PT_USEINT,
863                        "-\tkbinact", NULL, NULL,
864                        smc->inactkb, DNOVAL, NULL);
865
866                 ptn = DISPLAY_MEM_ALL(a->opt_flags) ? 0 : pt_newlin;
867                 render(isdb, pre, PT_USEINT | ptn,
868                        "-\tkbdirty", NULL, NULL,
869                        smc->dirtykb, DNOVAL, NULL);
870
871                 if (DISPLAY_MEM_ALL(a->opt_flags)) {
872                         render(isdb, pre, PT_USEINT,
873                                "-\tkbanonpg", NULL, NULL,
874                                smc->anonpgkb, DNOVAL, NULL);
875
876                         render(isdb, pre, PT_USEINT,
877                                "-\tkbslab", NULL, NULL,
878                                smc->slabkb, DNOVAL, NULL);
879
880                         render(isdb, pre, PT_USEINT,
881                                "-\tkbkstack", NULL, NULL,
882                                smc->kstackkb, DNOVAL, NULL);
883
884                         render(isdb, pre, PT_USEINT,
885                                "-\tkbpgtbl", NULL, NULL,
886                                smc->pgtblkb, DNOVAL, NULL);
887
888                         render(isdb, pre, PT_USEINT | pt_newlin,
889                                "-\tkbvmused", NULL, NULL,
890                                smc->vmusedkb, DNOVAL, NULL);
891                 }
892         }
893
894         if (DISPLAY_SWAP(a->opt_flags)) {
895
896                 render(isdb, pre, PT_USEINT,
897                        "-\tkbswpfree", NULL, NULL,
898                        smc->frskb, DNOVAL, NULL);
899
900                 render(isdb, pre, PT_USEINT,
901                        "-\tkbswpused", NULL, NULL,
902                        smc->tlskb - smc->frskb, DNOVAL, NULL);
903
904                 render(isdb, pre, PT_NOFLAG,
905                        "-\t%swpused", NULL, NULL, NOVAL,
906                        smc->tlskb ?
907                        SP_VALUE(smc->frskb, smc->tlskb, smc->tlskb) :
908                        0.0, NULL);
909
910                 render(isdb, pre, PT_USEINT,
911                        "-\tkbswpcad", NULL, NULL,
912                        smc->caskb, DNOVAL, NULL);
913
914                 render(isdb, pre, pt_newlin,
915                        "-\t%swpcad", NULL, NULL, NOVAL,
916                        (smc->tlskb - smc->frskb) ?
917                        SP_VALUE(0, smc->caskb, smc->tlskb - smc->frskb) :
918                        0.0, NULL);
919         }
920 }
921
922 /*
923  ***************************************************************************
924  * Display kernel tables statistics in selected format.
925  *
926  * IN:
927  * @a           Activity structure with statistics.
928  * @isdb        Flag, true if db printing, false if ppc printing.
929  * @pre         Prefix string for output entries
930  * @curr        Index in array for current sample statistics.
931  * @itv         Interval of time in 1/100th of a second.
932  ***************************************************************************
933  */
934 __print_funct_t render_ktables_stats(struct activity *a, int isdb, char *pre,
935                                      int curr, unsigned long long itv)
936 {
937         struct stats_ktables
938                 *skc = (struct stats_ktables *) a->buf[curr];
939         int pt_newlin
940                 = PT_NOFLAG + (DISPLAY_HORIZONTALLY(flags) ? 0 : PT_NEWLIN);
941
942         render(isdb, pre, PT_USEINT,
943                "-\tdentunusd", NULL, NULL,
944                skc->dentry_stat, DNOVAL, NULL);
945
946         render(isdb, pre, PT_USEINT,
947                "-\tfile-nr", NULL, NULL,
948                skc->file_used, DNOVAL, NULL);
949
950         render(isdb, pre, PT_USEINT,
951                "-\tinode-nr", NULL, NULL,
952                skc->inode_used, DNOVAL, NULL);
953
954         render(isdb, pre, PT_USEINT | pt_newlin,
955                "-\tpty-nr", NULL, NULL,
956                skc->pty_nr, DNOVAL, NULL);
957 }
958
959 /*
960  ***************************************************************************
961  * Display queue and load statistics in selected format.
962  *
963  * IN:
964  * @a           Activity structure with statistics.
965  * @isdb        Flag, true if db printing, false if ppc printing.
966  * @pre         Prefix string for output entries
967  * @curr        Index in array for current sample statistics.
968  * @itv         Interval of time in 1/100th of a second.
969  ***************************************************************************
970  */
971 __print_funct_t render_queue_stats(struct activity *a, int isdb, char *pre,
972                                    int curr, unsigned long long itv)
973 {
974         struct stats_queue
975                 *sqc = (struct stats_queue *) a->buf[curr];
976         int pt_newlin
977                 = PT_NOFLAG + (DISPLAY_HORIZONTALLY(flags) ? 0 : PT_NEWLIN);
978
979         render(isdb, pre, PT_USEINT,
980                "-\trunq-sz", NULL, NULL,
981                sqc->nr_running, DNOVAL, NULL);
982
983         render(isdb, pre, PT_USEINT,
984                "-\tplist-sz", NULL, NULL,
985                sqc->nr_threads, DNOVAL, NULL);
986
987         render(isdb, pre, PT_NOFLAG,
988                "-\tldavg-1", NULL, NULL,
989                NOVAL,
990                (double) sqc->load_avg_1 / 100,
991                NULL);
992
993         render(isdb, pre, PT_NOFLAG,
994                "-\tldavg-5", NULL, NULL,
995                NOVAL,
996                (double) sqc->load_avg_5 / 100,
997                NULL);
998
999         render(isdb, pre, PT_NOFLAG,
1000                "-\tldavg-15", NULL, NULL,
1001                NOVAL,
1002                (double) sqc->load_avg_15 / 100,
1003                NULL);
1004
1005         render(isdb, pre, PT_USEINT | pt_newlin,
1006                "-\tblocked", NULL, NULL,
1007                sqc->procs_blocked, DNOVAL, NULL);
1008 }
1009
1010 /*
1011  ***************************************************************************
1012  * Display serial lines statistics in selected format.
1013  *
1014  * IN:
1015  * @a           Activity structure with statistics.
1016  * @isdb        Flag, true if db printing, false if ppc printing.
1017  * @pre         Prefix string for output entries
1018  * @curr        Index in array for current sample statistics.
1019  * @itv         Interval of time in 1/100th of a second.
1020  ***************************************************************************
1021  */
1022 __print_funct_t render_serial_stats(struct activity *a, int isdb, char *pre,
1023                                     int curr, unsigned long long itv)
1024 {
1025         int i, j, j0, found;
1026         struct stats_serial *ssc, *ssp;
1027         int pt_newlin
1028                 = PT_NOFLAG + (DISPLAY_HORIZONTALLY(flags) ? 0 : PT_NEWLIN);
1029
1030         for (i = 0; i < a->nr[curr]; i++) {
1031
1032                 found = FALSE;
1033
1034                 if (a->nr[!curr] > 0) {
1035                         ssc = (struct stats_serial *) ((char *) a->buf[curr]  + i * a->msize);
1036
1037                         /* Look for corresponding serial line in previous iteration */
1038                         j = i;
1039
1040                         if (j >= a->nr[!curr]) {
1041                                 j = a->nr[!curr] - 1;
1042                         }
1043
1044                         j0 = j;
1045
1046                         do {
1047                                 ssp = (struct stats_serial *) ((char *) a->buf[!curr] + j * a->msize);
1048                                 if (ssc->line == ssp->line) {
1049                                         found = TRUE;
1050                                         break;
1051                                 }
1052                                 if (++j >= a->nr[!curr]) {
1053                                         j = 0;
1054                                 }
1055                         }
1056                         while (j != j0);
1057                 }
1058
1059                 if (!found)
1060                         continue;
1061
1062                 render(isdb, pre, PT_NOFLAG,
1063                        "ttyS%d\trcvin/s", "%d",
1064                        cons(iv, ssc->line, NOVAL),
1065                        NOVAL,
1066                        S_VALUE(ssp->rx, ssc->rx, itv),
1067                        NULL);
1068
1069                 render(isdb, pre, PT_NOFLAG,
1070                        "ttyS%d\txmtin/s", NULL,
1071                        cons(iv, ssc->line, NOVAL),
1072                        NOVAL,
1073                        S_VALUE(ssp->tx, ssc->tx, itv),
1074                        NULL);
1075
1076                 render(isdb, pre, PT_NOFLAG,
1077                        "ttyS%d\tframerr/s", NULL,
1078                        cons(iv, ssc->line, NOVAL),
1079                        NOVAL,
1080                        S_VALUE(ssp->frame, ssc->frame, itv),
1081                        NULL);
1082
1083                 render(isdb, pre, PT_NOFLAG,
1084                        "ttyS%d\tprtyerr/s", NULL,
1085                        cons(iv, ssc->line, NOVAL),
1086                        NOVAL,
1087                        S_VALUE(ssp->parity, ssc->parity, itv),
1088                        NULL);
1089
1090                 render(isdb, pre, PT_NOFLAG,
1091                        "ttyS%d\tbrk/s", NULL,
1092                        cons(iv, ssc->line, NOVAL),
1093                        NOVAL,
1094                        S_VALUE(ssp->brk, ssc->brk, itv),
1095                        NULL);
1096
1097                 render(isdb, pre, pt_newlin,
1098                        "ttyS%d\tovrun/s", NULL,
1099                        cons(iv, ssc->line, NOVAL),
1100                        NOVAL,
1101                        S_VALUE(ssp->overrun, ssc->overrun, itv),
1102                        NULL);
1103         }
1104 }
1105
1106 /*
1107  ***************************************************************************
1108  * Display disks statistics in selected format.
1109  *
1110  * IN:
1111  * @a           Activity structure with statistics.
1112  * @isdb        Flag, true if db printing, false if ppc printing.
1113  * @pre         Prefix string for output entries
1114  * @curr        Index in array for current sample statistics.
1115  * @itv         Interval of time in 1/100th of a second.
1116  ***************************************************************************
1117  */
1118 __print_funct_t render_disk_stats(struct activity *a, int isdb, char *pre,
1119                                   int curr, unsigned long long itv)
1120 {
1121         int i, j;
1122         struct stats_disk *sdc, *sdp, sdpzero;
1123         struct ext_disk_stats xds;
1124         char *dev_name;
1125         int pt_newlin
1126                 = PT_NOFLAG + (DISPLAY_HORIZONTALLY(flags) ? 0 : PT_NEWLIN);
1127
1128         memset(&sdpzero, 0, STATS_DISK_SIZE);
1129
1130         for (i = 0; i < a->nr[curr]; i++) {
1131
1132                 sdc = (struct stats_disk *) ((char *) a->buf[curr] + i * a->msize);
1133
1134                 j = check_disk_reg(a, curr, !curr, i);
1135                 if (j < 0) {
1136                         /* This is a newly registered interface. Previous stats are zero */
1137                         sdp = &sdpzero;
1138                 }
1139                 else {
1140                         sdp = (struct stats_disk *) ((char *) a->buf[!curr] + j * a->msize);
1141                 }
1142
1143                 /* Get device name */
1144                 dev_name = get_device_name(sdc->major, sdc->minor, sdc->wwn, sdc->part_nr,
1145                                            DISPLAY_PRETTY(flags), DISPLAY_PERSIST_NAME_S(flags),
1146                                            USE_STABLE_ID(flags), NULL);
1147
1148                 if (a->item_list != NULL) {
1149                         /* A list of devices has been entered on the command line */
1150                         if (!search_list_item(a->item_list, dev_name))
1151                                 /* Device not found */
1152                                 continue;
1153                 }
1154
1155                 /* Compute extended stats (service time, etc.) */
1156                 compute_ext_disk_stats(sdc, sdp, itv, &xds);
1157
1158                 render(isdb, pre, PT_NOFLAG,
1159                        "%s\ttps", "%s",
1160                        cons(sv, dev_name, NOVAL),
1161                        NOVAL,
1162                        S_VALUE(sdp->nr_ios, sdc->nr_ios, itv),
1163                        NULL);
1164
1165                 render(isdb, pre, PT_NOFLAG,
1166                        "%s\trkB/s", NULL,
1167                        cons(sv, dev_name, NOVAL),
1168                        NOVAL,
1169                        S_VALUE(sdp->rd_sect, sdc->rd_sect, itv) / 2,
1170                        NULL);
1171
1172                 render(isdb, pre, PT_NOFLAG,
1173                        "%s\twkB/s", NULL,
1174                        cons(sv, dev_name, NOVAL),
1175                        NOVAL,
1176                        S_VALUE(sdp->wr_sect, sdc->wr_sect, itv) / 2,
1177                        NULL);
1178
1179                 render(isdb, pre, PT_NOFLAG,
1180                        "%s\tdkB/s", NULL,
1181                        cons(sv, dev_name, NOVAL),
1182                        NOVAL,
1183                        S_VALUE(sdp->dc_sect, sdc->dc_sect, itv) / 2,
1184                        NULL);
1185
1186                 render(isdb, pre, PT_NOFLAG,
1187                        "%s\tareq-sz", NULL,
1188                        cons(sv, dev_name, NOVAL),
1189                        NOVAL,
1190                        xds.arqsz / 2,
1191                        NULL);
1192
1193                 render(isdb, pre, PT_NOFLAG,
1194                        "%s\taqu-sz", NULL,
1195                        cons(sv, dev_name, NOVAL),
1196                        NOVAL,
1197                        S_VALUE(sdp->rq_ticks, sdc->rq_ticks, itv) / 1000.0,
1198                        NULL);
1199
1200                 render(isdb, pre, PT_NOFLAG,
1201                        "%s\tawait", NULL,
1202                        cons(sv, dev_name, NOVAL),
1203                        NOVAL,
1204                        xds.await,
1205                        NULL);
1206
1207                 render(isdb, pre, pt_newlin,
1208                        "%s\t%%util", NULL,
1209                        cons(sv, dev_name, NOVAL),
1210                        NOVAL,
1211                        xds.util / 10.0,
1212                        NULL);
1213         }
1214 }
1215
1216 /*
1217  ***************************************************************************
1218  * Display network interfaces statistics in selected format.
1219  *
1220  * IN:
1221  * @a           Activity structure with statistics.
1222  * @isdb        Flag, true if db printing, false if ppc printing.
1223  * @pre         Prefix string for output entries
1224  * @curr        Index in array for current sample statistics.
1225  * @itv         Interval of time in 1/100th of a second.
1226  ***************************************************************************
1227  */
1228 __print_funct_t render_net_dev_stats(struct activity *a, int isdb, char *pre,
1229                                      int curr, unsigned long long itv)
1230 {
1231         int i, j;
1232         struct stats_net_dev *sndc, *sndp, sndzero;
1233         double rxkb, txkb, ifutil;
1234         int pt_newlin
1235                 = PT_NOFLAG + (DISPLAY_HORIZONTALLY(flags) ? 0 : PT_NEWLIN);
1236
1237         memset(&sndzero, 0, STATS_NET_DEV_SIZE);
1238
1239         for (i = 0; i < a->nr[curr]; i++) {
1240
1241                 sndc = (struct stats_net_dev *) ((char *) a->buf[curr] + i * a->msize);
1242
1243                 if (a->item_list != NULL) {
1244                         /* A list of devices has been entered on the command line */
1245                         if (!search_list_item(a->item_list, sndc->interface))
1246                                 /* Device not found */
1247                                 continue;
1248                 }
1249
1250                 j = check_net_dev_reg(a, curr, !curr, i);
1251                 if (j < 0) {
1252                         /* This is a newly registered interface. Previous stats are zero */
1253                         sndp = &sndzero;
1254                 }
1255                 else {
1256                         sndp = (struct stats_net_dev *) ((char *) a->buf[!curr] + j * a->msize);
1257                 }
1258
1259                 render(isdb, pre, PT_NOFLAG,
1260                        "%s\trxpck/s", "%s",
1261                        cons(sv, sndc->interface, NOVAL), /* What if the format args are strings? */
1262                        NOVAL,
1263                        S_VALUE(sndp->rx_packets, sndc->rx_packets, itv),
1264                        NULL);
1265
1266                 render(isdb, pre, PT_NOFLAG,
1267                        "%s\ttxpck/s", NULL,
1268                        cons(sv, sndc->interface, NOVAL),
1269                        NOVAL,
1270                        S_VALUE(sndp->tx_packets, sndc->tx_packets, itv),
1271                        NULL);
1272
1273                 rxkb = S_VALUE(sndp->rx_bytes, sndc->rx_bytes, itv);
1274                 render(isdb, pre, PT_NOFLAG,
1275                        "%s\trxkB/s", NULL,
1276                        cons(sv, sndc->interface, NOVAL),
1277                        NOVAL,
1278                        rxkb / 1024,
1279                        NULL);
1280
1281                 txkb = S_VALUE(sndp->tx_bytes, sndc->tx_bytes, itv);
1282                 render(isdb, pre, PT_NOFLAG,
1283                        "%s\ttxkB/s", NULL,
1284                        cons(sv, sndc->interface, NOVAL),
1285                        NOVAL,
1286                        txkb / 1024,
1287                        NULL);
1288
1289                 render(isdb, pre, PT_NOFLAG,
1290                        "%s\trxcmp/s", NULL,
1291                        cons(sv, sndc->interface, NOVAL),
1292                        NOVAL,
1293                        S_VALUE(sndp->rx_compressed, sndc->rx_compressed, itv),
1294                        NULL);
1295
1296                 render(isdb, pre, PT_NOFLAG,
1297                        "%s\ttxcmp/s", NULL,
1298                        cons(sv, sndc->interface, NOVAL),
1299                        NOVAL,
1300                        S_VALUE(sndp->tx_compressed, sndc->tx_compressed, itv),
1301                        NULL);
1302
1303                 render(isdb, pre, PT_NOFLAG,
1304                        "%s\trxmcst/s", NULL,
1305                        cons(sv, sndc->interface, NOVAL),
1306                        NOVAL,
1307                        S_VALUE(sndp->multicast, sndc->multicast, itv),
1308                        NULL);
1309
1310                 ifutil = compute_ifutil(sndc, rxkb, txkb);
1311                 render(isdb, pre, pt_newlin,
1312                        "%s\t%%ifutil", NULL,
1313                        cons(sv, sndc->interface, NOVAL),
1314                        NOVAL,
1315                        ifutil,
1316                        NULL);
1317         }
1318 }
1319
1320 /*
1321  ***************************************************************************
1322  * Display network interface errors statistics in selected format.
1323  *
1324  * IN:
1325  * @a           Activity structure with statistics.
1326  * @isdb        Flag, true if db printing, false if ppc printing.
1327  * @pre         Prefix string for output entries
1328  * @curr        Index in array for current sample statistics.
1329  * @itv         Interval of time in 1/100th of a second.
1330  ***************************************************************************
1331  */
1332 __print_funct_t render_net_edev_stats(struct activity *a, int isdb, char *pre,
1333                                       int curr, unsigned long long itv)
1334 {
1335         int i, j;
1336         struct stats_net_edev *snedc, *snedp, snedzero;
1337         int pt_newlin
1338                 = PT_NOFLAG + (DISPLAY_HORIZONTALLY(flags) ? 0 : PT_NEWLIN);
1339
1340         memset(&snedzero, 0, STATS_NET_EDEV_SIZE);
1341
1342         for (i = 0; i < a->nr[curr]; i++) {
1343
1344                 snedc = (struct stats_net_edev *) ((char *) a->buf[curr] + i * a->msize);
1345
1346                 if (a->item_list != NULL) {
1347                         /* A list of devices has been entered on the command line */
1348                         if (!search_list_item(a->item_list, snedc->interface))
1349                                 /* Device not found */
1350                                 continue;
1351                 }
1352
1353                 j = check_net_edev_reg(a, curr, !curr, i);
1354                 if (j < 0) {
1355                         /* This is a newly registered interface. Previous stats are zero */
1356                         snedp = &snedzero;
1357                 }
1358                 else {
1359                         snedp = (struct stats_net_edev *) ((char *) a->buf[!curr] + j * a->msize);
1360                 }
1361
1362                 render(isdb, pre, PT_NOFLAG,
1363                        "%s\trxerr/s", "%s",
1364                        cons(sv, snedc->interface, NOVAL),
1365                        NOVAL,
1366                        S_VALUE(snedp->rx_errors, snedc->rx_errors, itv),
1367                        NULL);
1368
1369                 render(isdb, pre, PT_NOFLAG,
1370                        "%s\ttxerr/s", NULL,
1371                        cons(sv, snedc->interface, NOVAL),
1372                        NOVAL,
1373                        S_VALUE(snedp->tx_errors, snedc->tx_errors, itv),
1374                        NULL);
1375
1376                 render(isdb, pre, PT_NOFLAG,
1377                        "%s\tcoll/s", NULL,
1378                        cons(sv, snedc->interface, NOVAL),
1379                        NOVAL,
1380                        S_VALUE(snedp->collisions, snedc->collisions, itv),
1381                        NULL);
1382
1383                 render(isdb, pre, PT_NOFLAG,
1384                        "%s\trxdrop/s", NULL,
1385                        cons(sv, snedc->interface, NOVAL),
1386                        NOVAL,
1387                        S_VALUE(snedp->rx_dropped, snedc->rx_dropped, itv),
1388                        NULL);
1389
1390                 render(isdb, pre, PT_NOFLAG,
1391                        "%s\ttxdrop/s", NULL,
1392                        cons(sv, snedc->interface, NOVAL),
1393                        NOVAL,
1394                        S_VALUE(snedp->tx_dropped, snedc->tx_dropped, itv),
1395                        NULL);
1396
1397                 render(isdb, pre, PT_NOFLAG,
1398                        "%s\ttxcarr/s", NULL,
1399                        cons(sv, snedc->interface, NOVAL),
1400                        NOVAL,
1401                        S_VALUE(snedp->tx_carrier_errors, snedc->tx_carrier_errors, itv),
1402                        NULL);
1403
1404                 render(isdb, pre, PT_NOFLAG,
1405                        "%s\trxfram/s", NULL,
1406                        cons(sv, snedc->interface, NOVAL),
1407                        NOVAL,
1408                        S_VALUE(snedp->rx_frame_errors, snedc->rx_frame_errors, itv),
1409                        NULL);
1410
1411                 render(isdb, pre, PT_NOFLAG,
1412                        "%s\trxfifo/s", NULL,
1413                        cons(sv, snedc->interface, NOVAL),
1414                        NOVAL,
1415                        S_VALUE(snedp->rx_fifo_errors, snedc->rx_fifo_errors, itv),
1416                        NULL);
1417
1418                 render(isdb, pre, pt_newlin,
1419                        "%s\ttxfifo/s", NULL,
1420                        cons(sv, snedc->interface, NOVAL),
1421                        NOVAL,
1422                        S_VALUE(snedp->tx_fifo_errors, snedc->tx_fifo_errors, itv),
1423                        NULL);
1424         }
1425 }
1426
1427 /*
1428  ***************************************************************************
1429  * Display NFS client statistics in selected format.
1430  *
1431  * IN:
1432  * @a           Activity structure with statistics.
1433  * @isdb        Flag, true if db printing, false if ppc printing.
1434  * @pre         Prefix string for output entries
1435  * @curr        Index in array for current sample statistics.
1436  * @itv         Interval of time in 1/100th of a second.
1437  ***************************************************************************
1438  */
1439 __print_funct_t render_net_nfs_stats(struct activity *a, int isdb, char *pre,
1440                                      int curr, unsigned long long itv)
1441 {
1442         struct stats_net_nfs
1443                 *snnc = (struct stats_net_nfs *) a->buf[curr],
1444                 *snnp = (struct stats_net_nfs *) a->buf[!curr];
1445         int pt_newlin
1446                 = PT_NOFLAG + (DISPLAY_HORIZONTALLY(flags) ? 0 : PT_NEWLIN);
1447
1448         render(isdb, pre, PT_NOFLAG,
1449                "-\tcall/s", NULL, NULL,
1450                NOVAL,
1451                S_VALUE(snnp->nfs_rpccnt, snnc->nfs_rpccnt, itv),
1452                NULL);
1453
1454         render(isdb, pre, PT_NOFLAG,
1455                "-\tretrans/s", NULL, NULL,
1456                NOVAL,
1457                S_VALUE(snnp->nfs_rpcretrans, snnc->nfs_rpcretrans, itv),
1458                NULL);
1459
1460         render(isdb, pre, PT_NOFLAG,
1461                "-\tread/s", NULL, NULL,
1462                NOVAL,
1463                S_VALUE(snnp->nfs_readcnt, snnc->nfs_readcnt, itv),
1464                NULL);
1465
1466         render(isdb, pre, PT_NOFLAG,
1467                "-\twrite/s", NULL, NULL,
1468                NOVAL,
1469                S_VALUE(snnp->nfs_writecnt, snnc->nfs_writecnt, itv),
1470                NULL);
1471
1472         render(isdb, pre, PT_NOFLAG,
1473                "-\taccess/s", NULL, NULL,
1474                NOVAL,
1475                S_VALUE(snnp->nfs_accesscnt, snnc->nfs_accesscnt, itv),
1476                NULL);
1477
1478         render(isdb, pre, pt_newlin,
1479                "-\tgetatt/s", NULL, NULL,
1480                NOVAL,
1481                S_VALUE(snnp->nfs_getattcnt, snnc->nfs_getattcnt, itv),
1482                NULL);
1483 }
1484
1485 /*
1486  ***************************************************************************
1487  * Display NFS server statistics in selected format.
1488  *
1489  * IN:
1490  * @a           Activity structure with statistics.
1491  * @isdb        Flag, true if db printing, false if ppc printing.
1492  * @pre         Prefix string for output entries
1493  * @curr        Index in array for current sample statistics.
1494  * @itv         Interval of time in 1/100th of a second.
1495  ***************************************************************************
1496  */
1497 __print_funct_t render_net_nfsd_stats(struct activity *a, int isdb, char *pre,
1498                                       int curr, unsigned long long itv)
1499 {
1500         struct stats_net_nfsd
1501                 *snndc = (struct stats_net_nfsd *) a->buf[curr],
1502                 *snndp = (struct stats_net_nfsd *) a->buf[!curr];
1503         int pt_newlin
1504                 = PT_NOFLAG + (DISPLAY_HORIZONTALLY(flags) ? 0 : PT_NEWLIN);
1505
1506         render(isdb, pre, PT_NOFLAG,
1507                "-\tscall/s", NULL, NULL,
1508                NOVAL,
1509                S_VALUE(snndp->nfsd_rpccnt, snndc->nfsd_rpccnt, itv),
1510                NULL);
1511
1512         render(isdb, pre, PT_NOFLAG,
1513                "-\tbadcall/s", NULL, NULL,
1514                NOVAL,
1515                S_VALUE(snndp->nfsd_rpcbad, snndc->nfsd_rpcbad, itv),
1516                NULL);
1517
1518         render(isdb, pre, PT_NOFLAG,
1519                "-\tpacket/s", NULL, NULL,
1520                NOVAL,
1521                S_VALUE(snndp->nfsd_netcnt, snndc->nfsd_netcnt, itv),
1522                NULL);
1523
1524         render(isdb, pre, PT_NOFLAG,
1525                "-\tudp/s", NULL, NULL,
1526                NOVAL,
1527                S_VALUE(snndp->nfsd_netudpcnt, snndc->nfsd_netudpcnt, itv),
1528                NULL);
1529
1530         render(isdb, pre, PT_NOFLAG,
1531                "-\ttcp/s", NULL, NULL,
1532                NOVAL,
1533                S_VALUE(snndp->nfsd_nettcpcnt, snndc->nfsd_nettcpcnt, itv),
1534                NULL);
1535
1536         render(isdb, pre, PT_NOFLAG,
1537                "-\thit/s", NULL, NULL,
1538                NOVAL,
1539                S_VALUE(snndp->nfsd_rchits, snndc->nfsd_rchits, itv),
1540                NULL);
1541
1542         render(isdb, pre, PT_NOFLAG,
1543                "-\tmiss/s", NULL, NULL,
1544                NOVAL,
1545                S_VALUE(snndp->nfsd_rcmisses, snndc->nfsd_rcmisses, itv),
1546                NULL);
1547
1548         render(isdb, pre, PT_NOFLAG,
1549                "-\tsread/s", NULL, NULL,
1550                NOVAL,
1551                S_VALUE(snndp->nfsd_readcnt, snndc->nfsd_readcnt, itv),
1552                NULL);
1553
1554         render(isdb, pre, PT_NOFLAG,
1555                "-\tswrite/s", NULL, NULL,
1556                NOVAL,
1557                S_VALUE(snndp->nfsd_writecnt, snndc->nfsd_writecnt, itv),
1558                NULL);
1559
1560         render(isdb, pre, PT_NOFLAG,
1561                "-\tsaccess/s", NULL, NULL,
1562                NOVAL,
1563                S_VALUE(snndp->nfsd_accesscnt, snndc->nfsd_accesscnt, itv),
1564                NULL);
1565
1566         render(isdb, pre, pt_newlin,
1567                "-\tsgetatt/s", NULL, NULL,
1568                NOVAL,
1569                S_VALUE(snndp->nfsd_getattcnt, snndc->nfsd_getattcnt, itv),
1570                NULL);
1571 }
1572
1573 /*
1574  ***************************************************************************
1575  * Display network sockets statistics in selected format.
1576  *
1577  * IN:
1578  * @a           Activity structure with statistics.
1579  * @isdb        Flag, true if db printing, false if ppc printing.
1580  * @pre         Prefix string for output entries
1581  * @curr        Index in array for current sample statistics.
1582  * @itv         Interval of time in 1/100th of a second.
1583  ***************************************************************************
1584  */
1585 __print_funct_t render_net_sock_stats(struct activity *a, int isdb, char *pre,
1586                                       int curr, unsigned long long itv)
1587 {
1588         struct stats_net_sock
1589                 *snsc = (struct stats_net_sock *) a->buf[curr];
1590         int pt_newlin
1591                 = PT_NOFLAG + (DISPLAY_HORIZONTALLY(flags) ? 0 : PT_NEWLIN);
1592
1593         render(isdb, pre, PT_USEINT,
1594                "-\ttotsck", NULL, NULL,
1595                (unsigned long long) snsc->sock_inuse, DNOVAL, NULL);
1596
1597         render(isdb, pre, PT_USEINT,
1598                "-\ttcpsck", NULL, NULL,
1599                (unsigned long long) snsc->tcp_inuse, DNOVAL, NULL);
1600
1601         render(isdb, pre, PT_USEINT,
1602                "-\tudpsck",  NULL, NULL,
1603                (unsigned long long) snsc->udp_inuse, DNOVAL, NULL);
1604
1605         render(isdb, pre, PT_USEINT,
1606                "-\trawsck", NULL, NULL,
1607                (unsigned long long) snsc->raw_inuse, DNOVAL, NULL);
1608
1609         render(isdb, pre, PT_USEINT,
1610                "-\tip-frag", NULL, NULL,
1611                (unsigned long long) snsc->frag_inuse, DNOVAL, NULL);
1612
1613         render(isdb, pre, PT_USEINT | pt_newlin,
1614                "-\ttcp-tw", NULL, NULL,
1615                (unsigned long long) snsc->tcp_tw, DNOVAL, NULL);
1616 }
1617
1618 /*
1619  ***************************************************************************
1620  * Display IP network statistics in selected format.
1621  *
1622  * IN:
1623  * @a           Activity structure with statistics.
1624  * @isdb        Flag, true if db printing, false if ppc printing.
1625  * @pre         Prefix string for output entries
1626  * @curr        Index in array for current sample statistics.
1627  * @itv         Interval of time in 1/100th of a second.
1628  ***************************************************************************
1629  */
1630 __print_funct_t render_net_ip_stats(struct activity *a, int isdb, char *pre,
1631                                     int curr, unsigned long long itv)
1632 {
1633         struct stats_net_ip
1634                 *snic = (struct stats_net_ip *) a->buf[curr],
1635                 *snip = (struct stats_net_ip *) a->buf[!curr];
1636         int pt_newlin
1637                 = PT_NOFLAG + (DISPLAY_HORIZONTALLY(flags) ? 0 : PT_NEWLIN);
1638
1639         render(isdb, pre, PT_NOFLAG,
1640                "-\tirec/s", NULL, NULL,
1641                NOVAL,
1642                S_VALUE(snip->InReceives, snic->InReceives, itv),
1643                NULL);
1644
1645         render(isdb, pre, PT_NOFLAG,
1646                "-\tfwddgm/s", NULL, NULL,
1647                NOVAL,
1648                S_VALUE(snip->ForwDatagrams, snic->ForwDatagrams, itv),
1649                NULL);
1650
1651         render(isdb, pre, PT_NOFLAG,
1652                "-\tidel/s", NULL, NULL,
1653                NOVAL,
1654                S_VALUE(snip->InDelivers, snic->InDelivers, itv),
1655                NULL);
1656
1657         render(isdb, pre, PT_NOFLAG,
1658                "-\torq/s", NULL, NULL,
1659                NOVAL,
1660                S_VALUE(snip->OutRequests, snic->OutRequests, itv),
1661                NULL);
1662
1663         render(isdb, pre, PT_NOFLAG,
1664                "-\tasmrq/s", NULL, NULL,
1665                NOVAL,
1666                S_VALUE(snip->ReasmReqds, snic->ReasmReqds, itv),
1667                NULL);
1668
1669         render(isdb, pre, PT_NOFLAG,
1670                "-\tasmok/s", NULL, NULL,
1671                NOVAL,
1672                S_VALUE(snip->ReasmOKs, snic->ReasmOKs, itv),
1673                NULL);
1674
1675         render(isdb, pre, PT_NOFLAG,
1676                "-\tfragok/s", NULL, NULL,
1677                NOVAL,
1678                S_VALUE(snip->FragOKs, snic->FragOKs, itv),
1679                NULL);
1680
1681         render(isdb, pre, pt_newlin,
1682                "-\tfragcrt/s", NULL, NULL,
1683                NOVAL,
1684                S_VALUE(snip->FragCreates, snic->FragCreates, itv),
1685                NULL);
1686 }
1687
1688 /*
1689  ***************************************************************************
1690  * Display IP network errors statistics in selected format.
1691  *
1692  * IN:
1693  * @a           Activity structure with statistics.
1694  * @isdb        Flag, true if db printing, false if ppc printing.
1695  * @pre         Prefix string for output entries
1696  * @curr        Index in array for current sample statistics.
1697  * @itv         Interval of time in 1/100th of a second.
1698  ***************************************************************************
1699  */
1700 __print_funct_t render_net_eip_stats(struct activity *a, int isdb, char *pre,
1701                                      int curr, unsigned long long itv)
1702 {
1703         struct stats_net_eip
1704                 *sneic = (struct stats_net_eip *) a->buf[curr],
1705                 *sneip = (struct stats_net_eip *) a->buf[!curr];
1706         int pt_newlin
1707                 = PT_NOFLAG + (DISPLAY_HORIZONTALLY(flags) ? 0 : PT_NEWLIN);
1708
1709         render(isdb, pre, PT_NOFLAG,
1710                "-\tihdrerr/s", NULL, NULL,
1711                NOVAL,
1712                S_VALUE(sneip->InHdrErrors, sneic->InHdrErrors, itv),
1713                NULL);
1714
1715         render(isdb, pre, PT_NOFLAG,
1716                "-\tiadrerr/s", NULL, NULL,
1717                NOVAL,
1718                S_VALUE(sneip->InAddrErrors, sneic->InAddrErrors, itv),
1719                NULL);
1720
1721         render(isdb, pre, PT_NOFLAG,
1722                "-\tiukwnpr/s", NULL, NULL,
1723                NOVAL,
1724                S_VALUE(sneip->InUnknownProtos, sneic->InUnknownProtos, itv),
1725                NULL);
1726
1727         render(isdb, pre, PT_NOFLAG,
1728                "-\tidisc/s", NULL, NULL,
1729                NOVAL,
1730                S_VALUE(sneip->InDiscards, sneic->InDiscards, itv),
1731                NULL);
1732
1733         render(isdb, pre, PT_NOFLAG,
1734                "-\todisc/s", NULL, NULL,
1735                NOVAL,
1736                S_VALUE(sneip->OutDiscards, sneic->OutDiscards, itv),
1737                NULL);
1738
1739         render(isdb, pre, PT_NOFLAG,
1740                "-\tonort/s", NULL, NULL,
1741                NOVAL,
1742                S_VALUE(sneip->OutNoRoutes, sneic->OutNoRoutes, itv),
1743                NULL);
1744
1745         render(isdb, pre, PT_NOFLAG,
1746                "-\tasmf/s", NULL, NULL,
1747                NOVAL,
1748                S_VALUE(sneip->ReasmFails, sneic->ReasmFails, itv),
1749                NULL);
1750
1751         render(isdb, pre, pt_newlin,
1752                "-\tfragf/s", NULL, NULL,
1753                NOVAL,
1754                S_VALUE(sneip->FragFails, sneic->FragFails, itv),
1755                NULL);
1756 }
1757
1758 /*
1759  ***************************************************************************
1760  * Display ICMP network statistics in selected format.
1761  *
1762  * IN:
1763  * @a           Activity structure with statistics.
1764  * @isdb        Flag, true if db printing, false if ppc printing.
1765  * @pre         Prefix string for output entries
1766  * @curr        Index in array for current sample statistics.
1767  * @itv         Interval of time in 1/100th of a second.
1768  ***************************************************************************
1769  */
1770 __print_funct_t render_net_icmp_stats(struct activity *a, int isdb, char *pre,
1771                                       int curr, unsigned long long itv)
1772 {
1773         struct stats_net_icmp
1774                 *snic = (struct stats_net_icmp *) a->buf[curr],
1775                 *snip = (struct stats_net_icmp *) a->buf[!curr];
1776         int pt_newlin
1777                 = PT_NOFLAG + (DISPLAY_HORIZONTALLY(flags) ? 0 : PT_NEWLIN);
1778
1779         render(isdb, pre, PT_NOFLAG,
1780                "-\timsg/s", NULL, NULL,
1781                NOVAL,
1782                S_VALUE(snip->InMsgs, snic->InMsgs, itv),
1783                NULL);
1784
1785         render(isdb, pre, PT_NOFLAG,
1786                "-\tomsg/s", NULL, NULL,
1787                NOVAL,
1788                S_VALUE(snip->OutMsgs, snic->OutMsgs, itv),
1789                NULL);
1790
1791         render(isdb, pre, PT_NOFLAG,
1792                "-\tiech/s", NULL, NULL,
1793                NOVAL,
1794                S_VALUE(snip->InEchos, snic->InEchos, itv),
1795                NULL);
1796
1797         render(isdb, pre, PT_NOFLAG,
1798                "-\tiechr/s", NULL, NULL,
1799                NOVAL,
1800                S_VALUE(snip->InEchoReps, snic->InEchoReps, itv),
1801                NULL);
1802
1803         render(isdb, pre, PT_NOFLAG,
1804                "-\toech/s", NULL, NULL,
1805                NOVAL,
1806                S_VALUE(snip->OutEchos, snic->OutEchos, itv),
1807                NULL);
1808
1809         render(isdb, pre, PT_NOFLAG,
1810                "-\toechr/s", NULL, NULL,
1811                NOVAL,
1812                S_VALUE(snip->OutEchoReps, snic->OutEchoReps, itv),
1813                NULL);
1814
1815         render(isdb, pre, PT_NOFLAG,
1816                "-\titm/s", NULL, NULL,
1817                NOVAL,
1818                S_VALUE(snip->InTimestamps, snic->InTimestamps, itv),
1819                NULL);
1820
1821         render(isdb, pre, PT_NOFLAG,
1822                "-\titmr/s", NULL, NULL,
1823                NOVAL,
1824                S_VALUE(snip->InTimestampReps, snic->InTimestampReps, itv),
1825                NULL);
1826
1827         render(isdb, pre, PT_NOFLAG,
1828                "-\totm/s", NULL, NULL,
1829                NOVAL,
1830                S_VALUE(snip->OutTimestamps, snic->OutTimestamps, itv),
1831                NULL);
1832
1833         render(isdb, pre, PT_NOFLAG,
1834                "-\totmr/s", NULL, NULL,
1835                NOVAL,
1836                S_VALUE(snip->OutTimestampReps, snic->OutTimestampReps, itv),
1837                NULL);
1838
1839         render(isdb, pre, PT_NOFLAG,
1840                "-\tiadrmk/s", NULL, NULL,
1841                NOVAL,
1842                S_VALUE(snip->InAddrMasks, snic->InAddrMasks, itv),
1843                NULL);
1844
1845         render(isdb, pre, PT_NOFLAG,
1846                "-\tiadrmkr/s", NULL, NULL,
1847                NOVAL,
1848                S_VALUE(snip->InAddrMaskReps, snic->InAddrMaskReps, itv),
1849                NULL);
1850
1851         render(isdb, pre, PT_NOFLAG,
1852                "-\toadrmk/s", NULL, NULL,
1853                NOVAL,
1854                S_VALUE(snip->OutAddrMasks, snic->OutAddrMasks, itv),
1855                NULL);
1856
1857         render(isdb, pre, pt_newlin,
1858                "-\toadrmkr/s", NULL, NULL,
1859                NOVAL,
1860                S_VALUE(snip->OutAddrMaskReps, snic->OutAddrMaskReps, itv),
1861                NULL);
1862 }
1863
1864 /*
1865  ***************************************************************************
1866  * Display ICMP error messages statistics in selected format.
1867  *
1868  * IN:
1869  * @a           Activity structure with statistics.
1870  * @isdb        Flag, true if db printing, false if ppc printing.
1871  * @pre         Prefix string for output entries
1872  * @curr        Index in array for current sample statistics.
1873  * @itv         Interval of time in 1/100th of a second.
1874  ***************************************************************************
1875  */
1876 __print_funct_t render_net_eicmp_stats(struct activity *a, int isdb, char *pre,
1877                                        int curr, unsigned long long itv)
1878 {
1879         struct stats_net_eicmp
1880                 *sneic = (struct stats_net_eicmp *) a->buf[curr],
1881                 *sneip = (struct stats_net_eicmp *) a->buf[!curr];
1882         int pt_newlin
1883                 = PT_NOFLAG + (DISPLAY_HORIZONTALLY(flags) ? 0 : PT_NEWLIN);
1884
1885         render(isdb, pre, PT_NOFLAG,
1886                "-\tierr/s", NULL, NULL,
1887                NOVAL,
1888                S_VALUE(sneip->InErrors, sneic->InErrors, itv),
1889                NULL);
1890
1891         render(isdb, pre, PT_NOFLAG,
1892                "-\toerr/s", NULL, NULL,
1893                NOVAL,
1894                S_VALUE(sneip->OutErrors, sneic->OutErrors, itv),
1895                NULL);
1896
1897         render(isdb, pre, PT_NOFLAG,
1898                "-\tidstunr/s", NULL, NULL,
1899                NOVAL,
1900                S_VALUE(sneip->InDestUnreachs, sneic->InDestUnreachs, itv),
1901                NULL);
1902
1903         render(isdb, pre, PT_NOFLAG,
1904                "-\todstunr/s", NULL, NULL,
1905                NOVAL,
1906                S_VALUE(sneip->OutDestUnreachs, sneic->OutDestUnreachs, itv),
1907                NULL);
1908
1909         render(isdb, pre, PT_NOFLAG,
1910                "-\titmex/s", NULL, NULL,
1911                NOVAL,
1912                S_VALUE(sneip->InTimeExcds, sneic->InTimeExcds, itv),
1913                NULL);
1914
1915         render(isdb, pre, PT_NOFLAG,
1916                "-\totmex/s", NULL, NULL,
1917                NOVAL,
1918                S_VALUE(sneip->OutTimeExcds, sneic->OutTimeExcds, itv),
1919                NULL);
1920
1921         render(isdb, pre, PT_NOFLAG,
1922                "-\tiparmpb/s", NULL, NULL,
1923                NOVAL,
1924                S_VALUE(sneip->InParmProbs, sneic->InParmProbs, itv),
1925                NULL);
1926
1927         render(isdb, pre, PT_NOFLAG,
1928                "-\toparmpb/s", NULL, NULL,
1929                NOVAL,
1930                S_VALUE(sneip->OutParmProbs, sneic->OutParmProbs, itv),
1931                NULL);
1932
1933         render(isdb, pre, PT_NOFLAG,
1934                "-\tisrcq/s", NULL, NULL,
1935                NOVAL,
1936                S_VALUE(sneip->InSrcQuenchs, sneic->InSrcQuenchs, itv),
1937                NULL);
1938
1939         render(isdb, pre, PT_NOFLAG,
1940                "-\tosrcq/s", NULL, NULL,
1941                NOVAL,
1942                S_VALUE(sneip->OutSrcQuenchs, sneic->OutSrcQuenchs, itv),
1943                NULL);
1944
1945         render(isdb, pre, PT_NOFLAG,
1946                "-\tiredir/s", NULL, NULL,
1947                NOVAL,
1948                S_VALUE(sneip->InRedirects, sneic->InRedirects, itv),
1949                NULL);
1950
1951         render(isdb, pre, pt_newlin,
1952                "-\toredir/s", NULL, NULL,
1953                NOVAL,
1954                S_VALUE(sneip->OutRedirects, sneic->OutRedirects, itv),
1955                NULL);
1956 }
1957
1958 /*
1959  ***************************************************************************
1960  * Display TCP network statistics in selected format.
1961  *
1962  * IN:
1963  * @a           Activity structure with statistics.
1964  * @isdb        Flag, true if db printing, false if ppc printing.
1965  * @pre         Prefix string for output entries
1966  * @curr        Index in array for current sample statistics.
1967  * @itv         Interval of time in 1/100th of a second.
1968  ***************************************************************************
1969  */
1970 __print_funct_t render_net_tcp_stats(struct activity *a, int isdb, char *pre,
1971                                      int curr, unsigned long long itv)
1972 {
1973         struct stats_net_tcp
1974                 *sntc = (struct stats_net_tcp *) a->buf[curr],
1975                 *sntp = (struct stats_net_tcp *) a->buf[!curr];
1976         int pt_newlin
1977                 = PT_NOFLAG + (DISPLAY_HORIZONTALLY(flags) ? 0 : PT_NEWLIN);
1978
1979         render(isdb, pre, PT_NOFLAG,
1980                "-\tactive/s", NULL, NULL,
1981                NOVAL,
1982                S_VALUE(sntp->ActiveOpens, sntc->ActiveOpens, itv),
1983                NULL);
1984
1985         render(isdb, pre, PT_NOFLAG,
1986                "-\tpassive/s", NULL, NULL,
1987                NOVAL,
1988                S_VALUE(sntp->PassiveOpens, sntc->PassiveOpens, itv),
1989                NULL);
1990
1991         render(isdb, pre, PT_NOFLAG,
1992                "-\tiseg/s", NULL, NULL,
1993                NOVAL,
1994                S_VALUE(sntp->InSegs, sntc->InSegs, itv),
1995                NULL);
1996
1997         render(isdb, pre, pt_newlin,
1998                "-\toseg/s", NULL, NULL,
1999                NOVAL,
2000                S_VALUE(sntp->OutSegs, sntc->OutSegs, itv),
2001                NULL);
2002 }
2003
2004 /*
2005  ***************************************************************************
2006  * Display TCP network errors statistics in selected format.
2007  *
2008  * IN:
2009  * @a           Activity structure with statistics.
2010  * @isdb        Flag, true if db printing, false if ppc printing.
2011  * @pre         Prefix string for output entries
2012  * @curr        Index in array for current sample statistics.
2013  * @itv         Interval of time in 1/100th of a second.
2014  ***************************************************************************
2015  */
2016 __print_funct_t render_net_etcp_stats(struct activity *a, int isdb, char *pre,
2017                                       int curr, unsigned long long itv)
2018 {
2019         struct stats_net_etcp
2020                 *snetc = (struct stats_net_etcp *) a->buf[curr],
2021                 *snetp = (struct stats_net_etcp *) a->buf[!curr];
2022         int pt_newlin
2023                 = PT_NOFLAG + (DISPLAY_HORIZONTALLY(flags) ? 0 : PT_NEWLIN);
2024
2025         render(isdb, pre, PT_NOFLAG,
2026                "-\tatmptf/s", NULL, NULL,
2027                NOVAL,
2028                S_VALUE(snetp->AttemptFails, snetc->AttemptFails, itv),
2029                NULL);
2030
2031         render(isdb, pre, PT_NOFLAG,
2032                "-\testres/s", NULL, NULL,
2033                NOVAL,
2034                S_VALUE(snetp->EstabResets, snetc->EstabResets, itv),
2035                NULL);
2036
2037         render(isdb, pre, PT_NOFLAG,
2038                "-\tretrans/s", NULL, NULL,
2039                NOVAL,
2040                S_VALUE(snetp->RetransSegs, snetc->RetransSegs, itv),
2041                NULL);
2042
2043         render(isdb, pre, PT_NOFLAG,
2044                "-\tisegerr/s", NULL, NULL,
2045                NOVAL,
2046                S_VALUE(snetp->InErrs, snetc->InErrs, itv),
2047                NULL);
2048
2049         render(isdb, pre, pt_newlin,
2050                "-\torsts/s", NULL, NULL,
2051                NOVAL,
2052                S_VALUE(snetp->OutRsts, snetc->OutRsts, itv),
2053                NULL);
2054 }
2055
2056 /*
2057  ***************************************************************************
2058  * Display UDP network statistics in selected format.
2059  *
2060  * IN:
2061  * @a           Activity structure with statistics.
2062  * @isdb        Flag, true if db printing, false if ppc printing.
2063  * @pre         Prefix string for output entries
2064  * @curr        Index in array for current sample statistics.
2065  * @itv         Interval of time in 1/100th of a second.
2066  ***************************************************************************
2067  */
2068 __print_funct_t render_net_udp_stats(struct activity *a, int isdb, char *pre,
2069                                      int curr, unsigned long long itv)
2070 {
2071         struct stats_net_udp
2072                 *snuc = (struct stats_net_udp *) a->buf[curr],
2073                 *snup = (struct stats_net_udp *) a->buf[!curr];
2074         int pt_newlin
2075                 = PT_NOFLAG + (DISPLAY_HORIZONTALLY(flags) ? 0 : PT_NEWLIN);
2076
2077         render(isdb, pre, PT_NOFLAG,
2078                "-\tidgm/s", NULL, NULL,
2079                NOVAL,
2080                S_VALUE(snup->InDatagrams, snuc->InDatagrams, itv),
2081                NULL);
2082
2083         render(isdb, pre, PT_NOFLAG,
2084                "-\todgm/s", NULL, NULL,
2085                NOVAL,
2086                S_VALUE(snup->OutDatagrams, snuc->OutDatagrams, itv),
2087                NULL);
2088
2089         render(isdb, pre, PT_NOFLAG,
2090                "-\tnoport/s", NULL, NULL,
2091                NOVAL,
2092                S_VALUE(snup->NoPorts, snuc->NoPorts, itv),
2093                NULL);
2094
2095         render(isdb, pre, pt_newlin,
2096                "-\tidgmerr/s", NULL, NULL,
2097                NOVAL,
2098                S_VALUE(snup->InErrors, snuc->InErrors, itv),
2099                NULL);
2100 }
2101
2102 /*
2103  ***************************************************************************
2104  * Display IPv6 network sockets statistics in selected format.
2105  *
2106  * IN:
2107  * @a           Activity structure with statistics.
2108  * @isdb        Flag, true if db printing, false if ppc printing.
2109  * @pre         Prefix string for output entries
2110  * @curr        Index in array for current sample statistics.
2111  * @itv         Interval of time in 1/100th of a second.
2112  ***************************************************************************
2113  */
2114 __print_funct_t render_net_sock6_stats(struct activity *a, int isdb, char *pre,
2115                                        int curr, unsigned long long itv)
2116 {
2117         struct stats_net_sock6
2118                 *snsc = (struct stats_net_sock6 *) a->buf[curr];
2119         int pt_newlin
2120                 = PT_NOFLAG + (DISPLAY_HORIZONTALLY(flags) ? 0 : PT_NEWLIN);
2121
2122         render(isdb, pre, PT_USEINT,
2123                "-\ttcp6sck", NULL, NULL,
2124                (unsigned long long) snsc->tcp6_inuse, DNOVAL, NULL);
2125
2126         render(isdb, pre, PT_USEINT,
2127                "-\tudp6sck",  NULL, NULL,
2128                (unsigned long long) snsc->udp6_inuse, DNOVAL, NULL);
2129
2130         render(isdb, pre, PT_USEINT,
2131                "-\traw6sck", NULL, NULL,
2132                (unsigned long long) snsc->raw6_inuse, DNOVAL, NULL);
2133
2134         render(isdb, pre, PT_USEINT | pt_newlin,
2135                "-\tip6-frag", NULL, NULL,
2136                (unsigned long long) snsc->frag6_inuse, DNOVAL, NULL);
2137 }
2138
2139 /*
2140  ***************************************************************************
2141  * Display IPv6 network statistics in selected format.
2142  *
2143  * IN:
2144  * @a           Activity structure with statistics.
2145  * @isdb        Flag, true if db printing, false if ppc printing.
2146  * @pre         Prefix string for output entries
2147  * @curr        Index in array for current sample statistics.
2148  * @itv         Interval of time in 1/100th of a second.
2149  ***************************************************************************
2150  */
2151 __print_funct_t render_net_ip6_stats(struct activity *a, int isdb, char *pre,
2152                                      int curr, unsigned long long itv)
2153 {
2154         struct stats_net_ip6
2155                 *snic = (struct stats_net_ip6 *) a->buf[curr],
2156                 *snip = (struct stats_net_ip6 *) a->buf[!curr];
2157         int pt_newlin
2158                 = PT_NOFLAG + (DISPLAY_HORIZONTALLY(flags) ? 0 : PT_NEWLIN);
2159
2160         render(isdb, pre, PT_NOFLAG,
2161                "-\tirec6/s", NULL, NULL,
2162                NOVAL,
2163                S_VALUE(snip->InReceives6, snic->InReceives6, itv),
2164                NULL);
2165
2166         render(isdb, pre, PT_NOFLAG,
2167                "-\tfwddgm6/s", NULL, NULL,
2168                NOVAL,
2169                S_VALUE(snip->OutForwDatagrams6, snic->OutForwDatagrams6, itv),
2170                NULL);
2171
2172         render(isdb, pre, PT_NOFLAG,
2173                "-\tidel6/s", NULL, NULL,
2174                NOVAL,
2175                S_VALUE(snip->InDelivers6, snic->InDelivers6, itv),
2176                NULL);
2177
2178         render(isdb, pre, PT_NOFLAG,
2179                "-\torq6/s", NULL, NULL,
2180                NOVAL,
2181                S_VALUE(snip->OutRequests6, snic->OutRequests6, itv),
2182                NULL);
2183
2184         render(isdb, pre, PT_NOFLAG,
2185                "-\tasmrq6/s", NULL, NULL,
2186                NOVAL,
2187                S_VALUE(snip->ReasmReqds6, snic->ReasmReqds6, itv),
2188                NULL);
2189
2190         render(isdb, pre, PT_NOFLAG,
2191                "-\tasmok6/s", NULL, NULL,
2192                NOVAL,
2193                S_VALUE(snip->ReasmOKs6, snic->ReasmOKs6, itv),
2194                NULL);
2195
2196         render(isdb, pre, PT_NOFLAG,
2197                "-\timcpck6/s", NULL, NULL,
2198                NOVAL,
2199                S_VALUE(snip->InMcastPkts6, snic->InMcastPkts6, itv),
2200                NULL);
2201
2202         render(isdb, pre, PT_NOFLAG,
2203                "-\tomcpck6/s", NULL, NULL,
2204                NOVAL,
2205                S_VALUE(snip->OutMcastPkts6, snic->OutMcastPkts6, itv),
2206                NULL);
2207
2208         render(isdb, pre, PT_NOFLAG,
2209                "-\tfragok6/s", NULL, NULL,
2210                NOVAL,
2211                S_VALUE(snip->FragOKs6, snic->FragOKs6, itv),
2212                NULL);
2213
2214         render(isdb, pre, pt_newlin,
2215                "-\tfragcr6/s", NULL, NULL,
2216                NOVAL,
2217                S_VALUE(snip->FragCreates6, snic->FragCreates6, itv),
2218                NULL);
2219 }
2220
2221 /*
2222  ***************************************************************************
2223  * Display IPv6 network errors statistics in selected format.
2224  *
2225  * IN:
2226  * @a           Activity structure with statistics.
2227  * @isdb        Flag, true if db printing, false if ppc printing.
2228  * @pre         Prefix string for output entries
2229  * @curr        Index in array for current sample statistics.
2230  * @itv         Interval of time in 1/100th of a second.
2231  ***************************************************************************
2232  */
2233 __print_funct_t render_net_eip6_stats(struct activity *a, int isdb, char *pre,
2234                                       int curr, unsigned long long itv)
2235 {
2236         struct stats_net_eip6
2237                 *sneic = (struct stats_net_eip6 *) a->buf[curr],
2238                 *sneip = (struct stats_net_eip6 *) a->buf[!curr];
2239         int pt_newlin
2240                 = PT_NOFLAG + (DISPLAY_HORIZONTALLY(flags) ? 0 : PT_NEWLIN);
2241
2242         render(isdb, pre, PT_NOFLAG,
2243                "-\tihdrer6/s", NULL, NULL,
2244                NOVAL,
2245                S_VALUE(sneip->InHdrErrors6, sneic->InHdrErrors6, itv),
2246                NULL);
2247
2248         render(isdb, pre, PT_NOFLAG,
2249                "-\tiadrer6/s", NULL, NULL,
2250                NOVAL,
2251                S_VALUE(sneip->InAddrErrors6, sneic->InAddrErrors6, itv),
2252                NULL);
2253
2254         render(isdb, pre, PT_NOFLAG,
2255                "-\tiukwnp6/s", NULL, NULL,
2256                NOVAL,
2257                S_VALUE(sneip->InUnknownProtos6, sneic->InUnknownProtos6, itv),
2258                NULL);
2259
2260         render(isdb, pre, PT_NOFLAG,
2261                "-\ti2big6/s", NULL, NULL,
2262                NOVAL,
2263                S_VALUE(sneip->InTooBigErrors6, sneic->InTooBigErrors6, itv),
2264                NULL);
2265
2266         render(isdb, pre, PT_NOFLAG,
2267                "-\tidisc6/s", NULL, NULL,
2268                NOVAL,
2269                S_VALUE(sneip->InDiscards6, sneic->InDiscards6, itv),
2270                NULL);
2271
2272         render(isdb, pre, PT_NOFLAG,
2273                "-\todisc6/s", NULL, NULL,
2274                NOVAL,
2275                S_VALUE(sneip->OutDiscards6, sneic->OutDiscards6, itv),
2276                NULL);
2277
2278         render(isdb, pre, PT_NOFLAG,
2279                "-\tinort6/s", NULL, NULL,
2280                NOVAL,
2281                S_VALUE(sneip->InNoRoutes6, sneic->InNoRoutes6, itv),
2282                NULL);
2283
2284         render(isdb, pre, PT_NOFLAG,
2285                "-\tonort6/s", NULL, NULL,
2286                NOVAL,
2287                S_VALUE(sneip->OutNoRoutes6, sneic->OutNoRoutes6, itv),
2288                NULL);
2289
2290         render(isdb, pre, PT_NOFLAG,
2291                "-\tasmf6/s", NULL, NULL,
2292                NOVAL,
2293                S_VALUE(sneip->ReasmFails6, sneic->ReasmFails6, itv),
2294                NULL);
2295
2296         render(isdb, pre, PT_NOFLAG,
2297                "-\tfragf6/s", NULL, NULL,
2298                NOVAL,
2299                S_VALUE(sneip->FragFails6, sneic->FragFails6, itv),
2300                NULL);
2301
2302         render(isdb, pre, pt_newlin,
2303                "-\titrpck6/s", NULL, NULL,
2304                NOVAL,
2305                S_VALUE(sneip->InTruncatedPkts6, sneic->InTruncatedPkts6, itv),
2306                NULL);
2307 }
2308
2309 /*
2310  ***************************************************************************
2311  * Display ICMPv6 network statistics in selected format.
2312  *
2313  * IN:
2314  * @a           Activity structure with statistics.
2315  * @isdb        Flag, true if db printing, false if ppc printing.
2316  * @pre         Prefix string for output entries
2317  * @curr        Index in array for current sample statistics.
2318  * @itv         Interval of time in 1/100th of a second.
2319  ***************************************************************************
2320  */
2321 __print_funct_t render_net_icmp6_stats(struct activity *a, int isdb, char *pre,
2322                                        int curr, unsigned long long itv)
2323 {
2324         struct stats_net_icmp6
2325                 *snic = (struct stats_net_icmp6 *) a->buf[curr],
2326                 *snip = (struct stats_net_icmp6 *) a->buf[!curr];
2327         int pt_newlin
2328                 = PT_NOFLAG + (DISPLAY_HORIZONTALLY(flags) ? 0 : PT_NEWLIN);
2329
2330         render(isdb, pre, PT_NOFLAG,
2331                "-\timsg6/s", NULL, NULL,
2332                NOVAL,
2333                S_VALUE(snip->InMsgs6, snic->InMsgs6, itv),
2334                NULL);
2335
2336         render(isdb, pre, PT_NOFLAG,
2337                "-\tomsg6/s", NULL, NULL,
2338                NOVAL,
2339                S_VALUE(snip->OutMsgs6, snic->OutMsgs6, itv),
2340                NULL);
2341
2342         render(isdb, pre, PT_NOFLAG,
2343                "-\tiech6/s", NULL, NULL,
2344                NOVAL,
2345                S_VALUE(snip->InEchos6, snic->InEchos6, itv),
2346                NULL);
2347
2348         render(isdb, pre, PT_NOFLAG,
2349                "-\tiechr6/s", NULL, NULL,
2350                NOVAL,
2351                S_VALUE(snip->InEchoReplies6, snic->InEchoReplies6, itv),
2352                NULL);
2353
2354         render(isdb, pre, PT_NOFLAG,
2355                "-\toechr6/s", NULL, NULL,
2356                NOVAL,
2357                S_VALUE(snip->OutEchoReplies6, snic->OutEchoReplies6, itv),
2358                NULL);
2359
2360         render(isdb, pre, PT_NOFLAG,
2361                "-\tigmbq6/s", NULL, NULL,
2362                NOVAL,
2363                S_VALUE(snip->InGroupMembQueries6, snic->InGroupMembQueries6, itv),
2364                NULL);
2365
2366         render(isdb, pre, PT_NOFLAG,
2367                "-\tigmbr6/s", NULL, NULL,
2368                NOVAL,
2369                S_VALUE(snip->InGroupMembResponses6, snic->InGroupMembResponses6, itv),
2370                NULL);
2371
2372         render(isdb, pre, PT_NOFLAG,
2373                "-\togmbr6/s", NULL, NULL,
2374                NOVAL,
2375                S_VALUE(snip->OutGroupMembResponses6, snic->OutGroupMembResponses6, itv),
2376                NULL);
2377
2378         render(isdb, pre, PT_NOFLAG,
2379                "-\tigmbrd6/s", NULL, NULL,
2380                NOVAL,
2381                S_VALUE(snip->InGroupMembReductions6, snic->InGroupMembReductions6, itv),
2382                NULL);
2383
2384         render(isdb, pre, PT_NOFLAG,
2385                "-\togmbrd6/s", NULL, NULL,
2386                NOVAL,
2387                S_VALUE(snip->OutGroupMembReductions6, snic->OutGroupMembReductions6, itv),
2388                NULL);
2389
2390         render(isdb, pre, PT_NOFLAG,
2391                "-\tirtsol6/s", NULL, NULL,
2392                NOVAL,
2393                S_VALUE(snip->InRouterSolicits6, snic->InRouterSolicits6, itv),
2394                NULL);
2395
2396         render(isdb, pre, PT_NOFLAG,
2397                "-\tortsol6/s", NULL, NULL,
2398                NOVAL,
2399                S_VALUE(snip->OutRouterSolicits6, snic->OutRouterSolicits6, itv),
2400                NULL);
2401
2402         render(isdb, pre, PT_NOFLAG,
2403                "-\tirtad6/s", NULL, NULL,
2404                NOVAL,
2405                S_VALUE(snip->InRouterAdvertisements6, snic->InRouterAdvertisements6, itv),
2406                NULL);
2407
2408         render(isdb, pre, PT_NOFLAG,
2409                "-\tinbsol6/s", NULL, NULL,
2410                NOVAL,
2411                S_VALUE(snip->InNeighborSolicits6, snic->InNeighborSolicits6, itv),
2412                NULL);
2413
2414         render(isdb, pre, PT_NOFLAG,
2415                "-\tonbsol6/s", NULL, NULL,
2416                NOVAL,
2417                S_VALUE(snip->OutNeighborSolicits6, snic->OutNeighborSolicits6, itv),
2418                NULL);
2419
2420         render(isdb, pre, PT_NOFLAG,
2421                "-\tinbad6/s", NULL, NULL,
2422                NOVAL,
2423                S_VALUE(snip->InNeighborAdvertisements6, snic->InNeighborAdvertisements6, itv),
2424                NULL);
2425
2426         render(isdb, pre, pt_newlin,
2427                "-\tonbad6/s", NULL, NULL,
2428                NOVAL,
2429                S_VALUE(snip->OutNeighborAdvertisements6, snic->OutNeighborAdvertisements6, itv),
2430                NULL);
2431 }
2432
2433 /*
2434  ***************************************************************************
2435  * Display ICMPv6 error messages statistics in selected format.
2436  *
2437  * IN:
2438  * @a           Activity structure with statistics.
2439  * @isdb        Flag, true if db printing, false if ppc printing.
2440  * @pre         Prefix string for output entries
2441  * @curr        Index in array for current sample statistics.
2442  * @itv         Interval of time in 1/100th of a second.
2443  ***************************************************************************
2444  */
2445 __print_funct_t render_net_eicmp6_stats(struct activity *a, int isdb, char *pre,
2446                                         int curr, unsigned long long itv)
2447 {
2448         struct stats_net_eicmp6
2449                 *sneic = (struct stats_net_eicmp6 *) a->buf[curr],
2450                 *sneip = (struct stats_net_eicmp6 *) a->buf[!curr];
2451         int pt_newlin
2452                 = PT_NOFLAG + (DISPLAY_HORIZONTALLY(flags) ? 0 : PT_NEWLIN);
2453
2454         render(isdb, pre, PT_NOFLAG,
2455                "-\tierr6/s", NULL, NULL,
2456                NOVAL,
2457                S_VALUE(sneip->InErrors6, sneic->InErrors6, itv),
2458                NULL);
2459
2460         render(isdb, pre, PT_NOFLAG,
2461                "-\tidtunr6/s", NULL, NULL,
2462                NOVAL,
2463                S_VALUE(sneip->InDestUnreachs6, sneic->InDestUnreachs6, itv),
2464                NULL);
2465
2466         render(isdb, pre, PT_NOFLAG,
2467                "-\todtunr6/s", NULL, NULL,
2468                NOVAL,
2469                S_VALUE(sneip->OutDestUnreachs6, sneic->OutDestUnreachs6, itv),
2470                NULL);
2471
2472         render(isdb, pre, PT_NOFLAG,
2473                "-\titmex6/s", NULL, NULL,
2474                NOVAL,
2475                S_VALUE(sneip->InTimeExcds6, sneic->InTimeExcds6, itv),
2476                NULL);
2477
2478         render(isdb, pre, PT_NOFLAG,
2479                "-\totmex6/s", NULL, NULL,
2480                NOVAL,
2481                S_VALUE(sneip->OutTimeExcds6, sneic->OutTimeExcds6, itv),
2482                NULL);
2483
2484         render(isdb, pre, PT_NOFLAG,
2485                "-\tiprmpb6/s", NULL, NULL,
2486                NOVAL,
2487                S_VALUE(sneip->InParmProblems6, sneic->InParmProblems6, itv),
2488                NULL);
2489
2490         render(isdb, pre, PT_NOFLAG,
2491                "-\toprmpb6/s", NULL, NULL,
2492                NOVAL,
2493                S_VALUE(sneip->OutParmProblems6, sneic->OutParmProblems6, itv),
2494                NULL);
2495
2496         render(isdb, pre, PT_NOFLAG,
2497                "-\tiredir6/s", NULL, NULL,
2498                NOVAL,
2499                S_VALUE(sneip->InRedirects6, sneic->InRedirects6, itv),
2500                NULL);
2501
2502         render(isdb, pre, PT_NOFLAG,
2503                "-\toredir6/s", NULL, NULL,
2504                NOVAL,
2505                S_VALUE(sneip->OutRedirects6, sneic->OutRedirects6, itv),
2506                NULL);
2507
2508         render(isdb, pre, PT_NOFLAG,
2509                "-\tipck2b6/s", NULL, NULL,
2510                NOVAL,
2511                S_VALUE(sneip->InPktTooBigs6, sneic->InPktTooBigs6, itv),
2512                NULL);
2513
2514         render(isdb, pre, pt_newlin,
2515                "-\topck2b6/s", NULL, NULL,
2516                NOVAL,
2517                S_VALUE(sneip->OutPktTooBigs6, sneic->OutPktTooBigs6, itv),
2518                NULL);
2519 }
2520
2521 /*
2522  ***************************************************************************
2523  * Display UDP6 network statistics in selected format.
2524  *
2525  * IN:
2526  * @a           Activity structure with statistics.
2527  * @isdb        Flag, true if db printing, false if ppc printing.
2528  * @pre         Prefix string for output entries
2529  * @curr        Index in array for current sample statistics.
2530  * @itv         Interval of time in 1/100th of a second.
2531  ***************************************************************************
2532  */
2533 __print_funct_t render_net_udp6_stats(struct activity *a, int isdb, char *pre,
2534                                       int curr, unsigned long long itv)
2535 {
2536         struct stats_net_udp6
2537                 *snuc = (struct stats_net_udp6 *) a->buf[curr],
2538                 *snup = (struct stats_net_udp6 *) a->buf[!curr];
2539         int pt_newlin
2540                 = PT_NOFLAG + (DISPLAY_HORIZONTALLY(flags) ? 0 : PT_NEWLIN);
2541
2542         render(isdb, pre, PT_NOFLAG,
2543                "-\tidgm6/s", NULL, NULL,
2544                NOVAL,
2545                S_VALUE(snup->InDatagrams6, snuc->InDatagrams6, itv),
2546                NULL);
2547
2548         render(isdb, pre, PT_NOFLAG,
2549                "-\todgm6/s", NULL, NULL,
2550                NOVAL,
2551                S_VALUE(snup->OutDatagrams6, snuc->OutDatagrams6, itv),
2552                NULL);
2553
2554         render(isdb, pre, PT_NOFLAG,
2555                "-\tnoport6/s", NULL, NULL,
2556                NOVAL,
2557                S_VALUE(snup->NoPorts6, snuc->NoPorts6, itv),
2558                NULL);
2559
2560         render(isdb, pre, pt_newlin,
2561                "-\tidgmer6/s", NULL, NULL,
2562                NOVAL,
2563                S_VALUE(snup->InErrors6, snuc->InErrors6, itv),
2564                NULL);
2565 }
2566
2567 /*
2568  ***************************************************************************
2569  * Display CPU frequency statistics in selected format.
2570  *
2571  * IN:
2572  * @a           Activity structure with statistics.
2573  * @isdb        Flag, true if db printing, false if ppc printing.
2574  * @pre         Prefix string for output entries
2575  * @curr        Index in array for current sample statistics.
2576  * @itv         Interval of time in 1/100th of a second.
2577  ***************************************************************************
2578  */
2579 __print_funct_t render_pwr_cpufreq_stats(struct activity *a, int isdb, char *pre,
2580                                          int curr, unsigned long long itv)
2581 {
2582         int i;
2583         struct stats_pwr_cpufreq *spc;
2584         int pt_newlin
2585                 = PT_NOFLAG + (DISPLAY_HORIZONTALLY(flags) ? 0 : PT_NEWLIN);
2586
2587         for (i = 0; (i < a->nr[curr]) && (i < a->bitmap->b_size + 1); i++) {
2588
2589                 spc = (struct stats_pwr_cpufreq *) ((char *) a->buf[curr] + i * a->msize);
2590
2591                 if (!spc->cpufreq)
2592                         /* This CPU is offline: Don't display it */
2593                         continue;
2594
2595                 /* Should current CPU (including CPU "all") be displayed? */
2596                 if (!(a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))))
2597                         /* No */
2598                         continue;
2599
2600                 if (!i) {
2601                         /* This is CPU "all" */
2602                         render(isdb, pre, pt_newlin,
2603                                "all\tMHz",
2604                                "-1", NULL,
2605                                NOVAL,
2606                                ((double) spc->cpufreq) / 100,
2607                                NULL);
2608                 }
2609                 else {
2610                         render(isdb, pre, pt_newlin,
2611                                "cpu%d\tMHz",
2612                                "%d", cons(iv, i - 1, NOVAL),
2613                                NOVAL,
2614                                ((double) spc->cpufreq) / 100,
2615                                NULL);
2616                 }
2617         }
2618 }
2619
2620 /*
2621  ***************************************************************************
2622  * Display fan statistics in selected format.
2623  *
2624  * IN:
2625  * @a           Activity structure with statistics.
2626  * @isdb        Flag, true if db printing, false if ppc printing.
2627  * @pre         Prefix string for output entries
2628  * @curr        Index in array for current sample statistics.
2629  * @itv         Interval of time in 1/100th of a second.
2630  ***************************************************************************
2631  */
2632 __print_funct_t render_pwr_fan_stats(struct activity *a, int isdb, char *pre,
2633                                      int curr, unsigned long long itv)
2634 {
2635         int i;
2636         struct stats_pwr_fan *spc;
2637         int pt_newlin
2638                 = PT_NOFLAG + (DISPLAY_HORIZONTALLY(flags) ? 0 : PT_NEWLIN);
2639
2640         for (i = 0; i < a->nr[curr]; i++) {
2641                 spc = (struct stats_pwr_fan *) ((char *) a->buf[curr] + i * a->msize);
2642
2643                 render(isdb, pre, PT_USESTR,
2644                        "fan%d\tDEVICE",
2645                        "%d",
2646                        cons(iv, i + 1, NOVAL),
2647                        NOVAL,
2648                        NOVAL,
2649                        spc->device);
2650
2651                 render(isdb, pre, PT_NOFLAG,
2652                        "fan%d\trpm",
2653                        NULL,
2654                        cons(iv, i + 1, NOVAL),
2655                        NOVAL,
2656                        spc->rpm,
2657                        NULL);
2658
2659                 render(isdb, pre, pt_newlin,
2660                        "fan%d\tdrpm",
2661                        NULL,
2662                        cons(iv, i + 1, NOVAL),
2663                        NOVAL,
2664                        spc->rpm - spc->rpm_min,
2665                        NULL);
2666         }
2667 }
2668
2669 /*
2670  ***************************************************************************
2671  * Display temperature 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_temp_stats(struct activity *a, int isdb, char *pre,
2682                                       int curr, unsigned long long itv)
2683 {
2684         int i;
2685         struct stats_pwr_temp *spc;
2686         int pt_newlin
2687                 = PT_NOFLAG + (DISPLAY_HORIZONTALLY(flags) ? 0 : PT_NEWLIN);
2688
2689         for (i = 0; i < a->nr[curr]; i++) {
2690                 spc = (struct stats_pwr_temp *) ((char *) a->buf[curr] + i * a->msize);
2691
2692                 render(isdb, pre, PT_USESTR,
2693                        "temp%d\tDEVICE",
2694                        "%d",
2695                        cons(iv, i + 1, NOVAL),
2696                        NOVAL,
2697                        NOVAL,
2698                        spc->device);
2699
2700                 render(isdb, pre, PT_NOFLAG,
2701                        "temp%d\tdegC",
2702                        NULL,
2703                        cons(iv, i + 1, NOVAL),
2704                        NOVAL,
2705                        spc->temp,
2706                        NULL);
2707
2708                 render(isdb, pre, pt_newlin,
2709                        "temp%d\t%%temp",
2710                        NULL,
2711                        cons(iv, i + 1, NOVAL),
2712                        NOVAL,
2713                        (spc->temp_max - spc->temp_min) ?
2714                        (spc->temp - spc->temp_min) / (spc->temp_max - spc->temp_min) * 100 :
2715                        0.0,
2716                        NULL);
2717         }
2718 }
2719
2720 /*
2721  ***************************************************************************
2722  * Display voltage inputs 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_pwr_in_stats(struct activity *a, int isdb, char *pre,
2733                                     int curr, unsigned long long itv)
2734 {
2735         int i;
2736         struct stats_pwr_in *spc;
2737         int pt_newlin
2738                 = PT_NOFLAG + (DISPLAY_HORIZONTALLY(flags) ? 0 : PT_NEWLIN);
2739
2740         for (i = 0; i < a->nr[curr]; i++) {
2741                 spc = (struct stats_pwr_in *) ((char *) a->buf[curr] + i * a->msize);
2742
2743                 render(isdb, pre, PT_USESTR,
2744                        "in%d\tDEVICE",
2745                        "%d",
2746                        cons(iv, i, NOVAL),
2747                        NOVAL,
2748                        NOVAL,
2749                        spc->device);
2750
2751                 render(isdb, pre, PT_NOFLAG,
2752                        "in%d\tinV",
2753                        NULL,
2754                        cons(iv, i, NOVAL),
2755                        NOVAL,
2756                        spc->in,
2757                        NULL);
2758
2759                 render(isdb, pre, pt_newlin,
2760                        "in%d\t%%in",
2761                        NULL,
2762                        cons(iv, i, NOVAL),
2763                        NOVAL,
2764                        (spc->in_max - spc->in_min) ?
2765                        (spc->in - spc->in_min) / (spc->in_max - spc->in_min) * 100 :
2766                        0.0,
2767                        NULL);
2768         }
2769 }
2770
2771 /*
2772  ***************************************************************************
2773  * Display huge pages statistics in selected format.
2774  *
2775  * IN:
2776  * @a           Activity structure with statistics.
2777  * @isdb        Flag, true if db printing, false if ppc printing.
2778  * @pre         Prefix string for output entries
2779  * @curr        Index in array for current sample statistics.
2780  * @itv         Interval of time in 1/100th of a second.
2781  ***************************************************************************
2782  */
2783 __print_funct_t render_huge_stats(struct activity *a, int isdb, char *pre,
2784                                   int curr, unsigned long long itv)
2785 {
2786         struct stats_huge
2787                 *smc = (struct stats_huge *) a->buf[curr];
2788         int pt_newlin
2789                 = PT_NOFLAG + (DISPLAY_HORIZONTALLY(flags) ? 0 : PT_NEWLIN);
2790
2791         render(isdb, pre, PT_USEINT,
2792                "-\tkbhugfree", NULL, NULL,
2793                smc->frhkb, DNOVAL, NULL);
2794
2795         render(isdb, pre, PT_USEINT,
2796                "-\tkbhugused", NULL, NULL,
2797                smc->tlhkb - smc->frhkb, DNOVAL, NULL);
2798
2799         render(isdb, pre, PT_NOFLAG,
2800                "-\t%hugused", NULL, NULL, NOVAL,
2801                smc->tlhkb ?
2802                SP_VALUE(smc->frhkb, smc->tlhkb, smc->tlhkb) :
2803                0.0, NULL);
2804
2805         render(isdb, pre, PT_USEINT,
2806                "-\tkbhugrsvd", NULL, NULL,
2807                smc->rsvdhkb, DNOVAL, NULL);
2808
2809         render(isdb, pre, PT_USEINT | pt_newlin,
2810                "-\tkbhugsurp", NULL, NULL,
2811                smc->surphkb, DNOVAL, NULL);
2812 }
2813
2814 /*
2815  ***************************************************************************
2816  * Display weighted CPU frequency statistics in selected format.
2817  *
2818  * IN:
2819  * @a           Activity structure with statistics.
2820  * @isdb        Flag, true if db printing, false if ppc printing.
2821  * @pre         Prefix string for output entries
2822  * @curr        Index in array for current sample statistics.
2823  * @itv         Interval of time in 1/100th of a second.
2824  ***************************************************************************
2825  */
2826 __print_funct_t render_pwr_wghfreq_stats(struct activity *a, int isdb, char *pre,
2827                                          int curr, unsigned long long itv)
2828 {
2829         int i, k;
2830         struct stats_pwr_wghfreq *spc, *spp, *spc_k, *spp_k;
2831         unsigned long long tis, tisfreq;
2832         int pt_newlin
2833                 = PT_NOFLAG + (DISPLAY_HORIZONTALLY(flags) ? 0 : PT_NEWLIN);
2834
2835         for (i = 0; (i < a->nr[curr]) && (i < a->bitmap->b_size + 1); i++) {
2836
2837                 spc = (struct stats_pwr_wghfreq *) ((char *) a->buf[curr]  + i * a->msize * a->nr2);
2838                 spp = (struct stats_pwr_wghfreq *) ((char *) a->buf[!curr] + i * a->msize * a->nr2);
2839
2840                 /* Should current CPU (including CPU "all") be displayed? */
2841                 if (!(a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))))
2842                         /* No */
2843                         continue;
2844
2845                 tisfreq = 0;
2846                 tis = 0;
2847
2848                 for (k = 0; k < a->nr2; k++) {
2849
2850                         spc_k = (struct stats_pwr_wghfreq *) ((char *) spc + k * a->msize);
2851                         if (!spc_k->freq)
2852                                 break;
2853                         spp_k = (struct stats_pwr_wghfreq *) ((char *) spp + k * a->msize);
2854
2855                         tisfreq += (spc_k->freq / 1000) *
2856                                    (spc_k->time_in_state - spp_k->time_in_state);
2857                         tis     += (spc_k->time_in_state - spp_k->time_in_state);
2858                 }
2859
2860                 if (!i) {
2861                         /* This is CPU "all" */
2862                         render(isdb, pre, pt_newlin,
2863                                "all\twghMHz",
2864                                "-1", NULL,
2865                                NOVAL,
2866                                tis ? ((double) tisfreq) / tis : 0.0,
2867                                NULL);
2868                 }
2869                 else {
2870                         render(isdb, pre, pt_newlin,
2871                                "cpu%d\twghMHz",
2872                                "%d", cons(iv, i - 1, NOVAL),
2873                                NOVAL,
2874                                tis ? ((double) tisfreq) / tis : 0.0,
2875                                NULL);
2876                 }
2877         }
2878 }
2879
2880 /*
2881  ***************************************************************************
2882  * Display USB devices statistics in selected format.
2883  *
2884  * IN:
2885  * @a           Activity structure with statistics.
2886  * @isdb        Flag, true if db printing, false if ppc printing.
2887  * @pre         Prefix string for output entries
2888  * @curr        Index in array for current sample statistics.
2889  * @itv         Interval of time in 1/100th of a second.
2890  ***************************************************************************
2891  */
2892 __print_funct_t render_pwr_usb_stats(struct activity *a, int isdb, char *pre,
2893                                      int curr, unsigned long long itv)
2894 {
2895         int i;
2896         struct stats_pwr_usb *suc;
2897         char id[9];
2898
2899         for (i = 0; i < a->nr[curr]; i++) {
2900                 suc = (struct stats_pwr_usb *) ((char *) a->buf[curr] + i * a->msize);
2901
2902                 sprintf(id, "%x", suc->vendor_id);
2903                 render(isdb, pre, PT_USESTR,
2904                        "bus%d\tidvendor",
2905                        "%d",
2906                        cons(iv, suc->bus_nr, NOVAL),
2907                        NOVAL,
2908                        NOVAL,
2909                        id);
2910
2911                 sprintf(id, "%x", suc->product_id);
2912                 render(isdb, pre, PT_USESTR,
2913                        "bus%d\tidprod",
2914                        NULL,
2915                        cons(iv, suc->bus_nr, NOVAL),
2916                        NOVAL,
2917                        NOVAL,
2918                        id);
2919
2920                 render(isdb, pre, PT_USEINT,
2921                        "bus%d\tmaxpower",
2922                        NULL,
2923                        cons(iv, suc->bus_nr, NOVAL),
2924                        (unsigned long long) (suc->bmaxpower << 1),
2925                        NOVAL,
2926                        NULL);
2927
2928                 render(isdb, pre, PT_USESTR,
2929                        "bus%d\tmanufact",
2930                        NULL,
2931                        cons(iv, suc->bus_nr, NOVAL),
2932                        NOVAL,
2933                        NOVAL,
2934                        suc->manufacturer);
2935
2936                 render(isdb, pre,
2937                        (DISPLAY_HORIZONTALLY(flags) ? PT_USESTR : PT_USESTR | PT_NEWLIN),
2938                        "bus%d\tproduct",
2939                        NULL,
2940                        cons(iv, suc->bus_nr, NOVAL),
2941                        NOVAL,
2942                        NOVAL,
2943                        suc->product);
2944         }
2945 }
2946
2947 /*
2948  ***************************************************************************
2949  * Display filesystems statistics in selected format.
2950  *
2951  * IN:
2952  * @a           Activity structure with statistics.
2953  * @isdb        Flag, true if db printing, false if ppc printing.
2954  * @pre         Prefix string for output entries
2955  * @curr        Index in array for current sample statistics.
2956  * @itv         Interval of time in 1/100th of a second.
2957  ***************************************************************************
2958  */
2959 __print_funct_t render_filesystem_stats(struct activity *a, int isdb, char *pre,
2960                                         int curr, unsigned long long itv)
2961 {
2962         int i;
2963         struct stats_filesystem *sfc;
2964         char *dev_name;
2965         int pt_newlin
2966                 = PT_NOFLAG + (DISPLAY_HORIZONTALLY(flags) ? 0 : PT_NEWLIN);
2967
2968         for (i = 0; i < a->nr[curr]; i++) {
2969                 sfc = (struct stats_filesystem *) ((char *) a->buf[curr] + i * a->msize);
2970
2971                 /* Get name to display (persistent or standard fs name, or mount point) */
2972                 dev_name = get_fs_name_to_display(a, flags, sfc);
2973
2974                 if (a->item_list != NULL) {
2975                         /* A list of devices has been entered on the command line */
2976                         if (!search_list_item(a->item_list, dev_name))
2977                                 /* Device not found */
2978                                 continue;
2979                 }
2980
2981                 render(isdb, pre, PT_USERND,
2982                        "%s\tMBfsfree",
2983                        "%s",
2984                        cons(sv, dev_name, NOVAL),
2985                        NOVAL,
2986                        (double) sfc->f_bfree / 1024 / 1024,
2987                        NULL);
2988
2989                 render(isdb, pre, PT_USERND,
2990                        "%s\tMBfsused",
2991                        NULL,
2992                        cons(sv, dev_name, NOVAL),
2993                        NOVAL,
2994                        (double) (sfc->f_blocks - sfc->f_bfree) / 1024 / 1024,
2995                        NULL);
2996
2997                 render(isdb, pre, PT_NOFLAG,
2998                        "%s\t%%fsused",
2999                        NULL,
3000                        cons(sv, dev_name, NOVAL),
3001                        NOVAL,
3002                        sfc->f_blocks ? SP_VALUE(sfc->f_bfree, sfc->f_blocks, sfc->f_blocks)
3003                                      : 0.0,
3004                        NULL);
3005
3006                 render(isdb, pre, PT_NOFLAG,
3007                        "%s\t%%ufsused",
3008                        NULL,
3009                        cons(sv, dev_name, NOVAL),
3010                        NOVAL,
3011                        sfc->f_blocks ? SP_VALUE(sfc->f_bavail, sfc->f_blocks, sfc->f_blocks)
3012                                      : 0.0,
3013                        NULL);
3014
3015                 render(isdb, pre, PT_USEINT,
3016                        "%s\tIfree",
3017                        NULL,
3018                        cons(sv, dev_name, NOVAL),
3019                        sfc->f_ffree,
3020                        NOVAL,
3021                        NULL);
3022
3023                 render(isdb, pre, PT_USEINT,
3024                        "%s\tIused",
3025                        NULL,
3026                        cons(sv, dev_name, NOVAL),
3027                        sfc->f_files - sfc->f_ffree,
3028                        NOVAL,
3029                        NULL);
3030
3031                 render(isdb, pre, pt_newlin,
3032                        "%s\t%%Iused",
3033                        NULL,
3034                        cons(sv, dev_name, NOVAL),
3035                        NOVAL,
3036                        sfc->f_files ? SP_VALUE(sfc->f_ffree, sfc->f_files, sfc->f_files)
3037                                     : 0.0,
3038                        NULL);
3039         }
3040 }
3041
3042 /*
3043  ***************************************************************************
3044  * Display Fibre Channel HBA statistics in selected format.
3045  *
3046  * IN:
3047  * @a           Activity structure with statistics.
3048  * @isdb        Flag, true if db printing, false if ppc printing.
3049  * @pre         Prefix string for output entries
3050  * @curr        Index in array for current sample statistics.
3051  * @itv         Interval of time in 1/100th of a second.
3052  ***************************************************************************
3053  */
3054 __print_funct_t render_fchost_stats(struct activity *a, int isdb, char *pre,
3055                                     int curr, unsigned long long itv)
3056 {
3057         int i, j, j0, found;
3058         struct stats_fchost *sfcc, *sfcp, sfczero;
3059         int pt_newlin
3060                 = PT_NOFLAG + (DISPLAY_HORIZONTALLY(flags) ? 0 : PT_NEWLIN);
3061
3062         memset(&sfczero, 0, sizeof(struct stats_fchost));
3063
3064         for (i = 0; i < a->nr[curr]; i++) {
3065
3066                 found = FALSE;
3067                 sfcc = (struct stats_fchost *) ((char *) a->buf[curr] + i * a->msize);
3068
3069                 if (a->nr[!curr] > 0) {
3070                         /* Look for corresponding structure in previous iteration */
3071                         j = i;
3072
3073                         if (j >= a->nr[!curr]) {
3074                                 j = a->nr[!curr] - 1;
3075                         }
3076
3077                         j0 = j;
3078
3079                         do {
3080                                 sfcp = (struct stats_fchost *) ((char *) a->buf[!curr] + j * a->msize);
3081                                 if (!strcmp(sfcc->fchost_name, sfcp->fchost_name)) {
3082                                         found = TRUE;
3083                                         break;
3084                                 }
3085                                 if (++j >= a->nr[!curr]) {
3086                                         j = 0;
3087                                 }
3088                         }
3089                         while (j != j0);
3090                 }
3091
3092                 if (!found) {
3093                         /* This is a newly registered host */
3094                         sfcp = &sfczero;
3095                 }
3096
3097                 render(isdb, pre, PT_NOFLAG ,
3098                        "%s\tfch_rxf/s",
3099                        "%s",
3100                        cons(sv, sfcc->fchost_name, NOVAL),
3101                        NOVAL,
3102                        S_VALUE(sfcp->f_rxframes, sfcc->f_rxframes, itv),
3103                        NULL);
3104                 render(isdb, pre, PT_NOFLAG,
3105                        "%s\tfch_txf/s", NULL,
3106                        cons(sv, sfcc->fchost_name, NOVAL),
3107                        NOVAL,
3108                        S_VALUE(sfcp->f_txframes, sfcc->f_txframes, itv),
3109                        NULL);
3110                 render(isdb, pre, PT_NOFLAG,
3111                        "%s\tfch_rxw/s", NULL,
3112                        cons(sv, sfcc->fchost_name, NOVAL),
3113                        NOVAL,
3114                        S_VALUE(sfcp->f_rxwords, sfcc->f_rxwords, itv),
3115                        NULL);
3116                 render(isdb, pre, pt_newlin,
3117                        "%s\tfch_txw/s", NULL,
3118                        cons(sv, sfcc->fchost_name, NOVAL),
3119                        NOVAL,
3120                        S_VALUE(sfcp->f_txwords, sfcc->f_txwords, itv),
3121                        NULL);
3122         }
3123 }
3124
3125 /*
3126  ***************************************************************************
3127  * Display softnet statistics in selected format.
3128  *
3129  * IN:
3130  * @a           Activity structure with statistics.
3131  * @isdb        Flag, true if db printing, false if ppc printing.
3132  * @pre         Prefix string for output entries
3133  * @curr        Index in array for current sample statistics.
3134  * @itv         Interval of time in 1/100th of a second.
3135  ***************************************************************************
3136  */
3137 __print_funct_t render_softnet_stats(struct activity *a, int isdb, char *pre,
3138                                      int curr, unsigned long long itv)
3139 {
3140         int i;
3141         struct stats_softnet *ssnc, *ssnp;
3142         unsigned char offline_cpu_bitmap[BITMAP_SIZE(NR_CPUS)] = {0};
3143         int pt_newlin
3144                 = PT_NOFLAG + (DISPLAY_HORIZONTALLY(flags) ? 0 : PT_NEWLIN);
3145
3146         /* @nr[curr] cannot normally be greater than @nr_ini */
3147         if (a->nr[curr] > a->nr_ini) {
3148                 a->nr_ini = a->nr[curr];
3149         }
3150
3151         /* Compute statistics for CPU "all" */
3152         get_global_soft_statistics(a, !curr, curr, flags, offline_cpu_bitmap);
3153
3154         for (i = 0; (i < a->nr_ini) && (i < a->bitmap->b_size + 1); i++) {
3155
3156                 /*
3157                  * Note: a->nr is in [1, NR_CPUS + 1].
3158                  * Bitmap size is provided for (NR_CPUS + 1) CPUs.
3159                  * Anyway, NR_CPUS may vary between the version of sysstat
3160                  * used by sadc to create a file, and the version of sysstat
3161                  * used by sar to read it...
3162                  */
3163                 if (!(a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))) ||
3164                     offline_cpu_bitmap[i >> 3] & (1 << (i & 0x07)))
3165                         /* No */
3166                         continue;
3167
3168                 /*
3169                  * The size of a->buf[...] CPU structure may be different from the default
3170                  * sizeof(struct stats_pwr_cpufreq) value if data have been read from a file!
3171                  * That's why we don't use a syntax like:
3172                  * ssnc = (struct stats_softnet *) a->buf[...] + i;
3173                  */
3174                 ssnc = (struct stats_softnet *) ((char *) a->buf[curr]  + i * a->msize);
3175                 ssnp = (struct stats_softnet *) ((char *) a->buf[!curr] + i * a->msize);
3176
3177                 if (!i) {
3178                         /* This is CPU "all" */
3179                         render(isdb, pre, PT_NOFLAG,
3180                                "all\ttotal/s",
3181                                "-1", NULL,
3182                                NOVAL,
3183                                S_VALUE(ssnp->processed, ssnc->processed, itv),
3184                                NULL);
3185
3186                         render(isdb, pre, PT_NOFLAG,
3187                                "all\tdropd/s",
3188                                NULL, NULL,
3189                                NOVAL,
3190                                S_VALUE(ssnp->dropped, ssnc->dropped, itv),
3191                                NULL);
3192
3193                         render(isdb, pre, PT_NOFLAG,
3194                                "all\tsqueezd/s",
3195                                NULL, NULL,
3196                                NOVAL,
3197                                S_VALUE(ssnp->time_squeeze, ssnc->time_squeeze, itv),
3198                                NULL);
3199
3200                         render(isdb, pre, PT_NOFLAG,
3201                                "all\trx_rps/s",
3202                                NULL, NULL,
3203                                NOVAL,
3204                                S_VALUE(ssnp->received_rps, ssnc->received_rps, itv),
3205                                NULL);
3206
3207                         render(isdb, pre, PT_NOFLAG,
3208                                "all\tflw_lim/s",
3209                                NULL, NULL,
3210                                NOVAL,
3211                                S_VALUE(ssnp->flow_limit, ssnc->flow_limit, itv),
3212                                NULL);
3213
3214                         render(isdb, pre, PT_USEINT | pt_newlin,
3215                                "all\tblg_len",
3216                                NULL, NULL,
3217                                ssnc->backlog_len,
3218                                DNOVAL,
3219                                NULL);
3220                 }
3221                 else {
3222                         render(isdb, pre, PT_NOFLAG,
3223                                "cpu%d\ttotal/s",
3224                                "%d", cons(iv, i - 1, NOVAL),
3225                                NOVAL,
3226                                S_VALUE(ssnp->processed, ssnc->processed, itv),
3227                                NULL);
3228
3229                         render(isdb, pre, PT_NOFLAG,
3230                                "cpu%d\tdropd/s",
3231                                NULL, cons(iv, i - 1, NOVAL),
3232                                NOVAL,
3233                                S_VALUE(ssnp->dropped, ssnc->dropped, itv),
3234                                NULL);
3235
3236                         render(isdb, pre, PT_NOFLAG,
3237                                "cpu%d\tsqueezd/s",
3238                                NULL, cons(iv, i - 1, NOVAL),
3239                                NOVAL,
3240                                S_VALUE(ssnp->time_squeeze, ssnc->time_squeeze, itv),
3241                                NULL);
3242
3243                         render(isdb, pre, PT_NOFLAG,
3244                                "cpu%d\trx_rps/s",
3245                                NULL, cons(iv, i - 1, NOVAL),
3246                                NOVAL,
3247                                S_VALUE(ssnp->received_rps, ssnc->received_rps, itv),
3248                                NULL);
3249
3250                         render(isdb, pre, PT_NOFLAG,
3251                                "cpu%d\tflw_lim/s",
3252                                NULL, cons(iv, i - 1, NOVAL),
3253                                NOVAL,
3254                                S_VALUE(ssnp->flow_limit, ssnc->flow_limit, itv),
3255                                NULL);
3256
3257                         render(isdb, pre, PT_USEINT | pt_newlin,
3258                                "cpu%d\tblg_len",
3259                                NULL, cons(iv, i - 1, NOVAL),
3260                                ssnc->backlog_len,
3261                                DNOVAL,
3262                                NULL);
3263                 }
3264         }
3265 }
3266
3267 /*
3268  ***************************************************************************
3269  * Display pressure-stall CPU statistics in selected format.
3270  *
3271  * IN:
3272  * @a           Activity structure with statistics.
3273  * @isdb        Flag, true if db printing, false if ppc printing.
3274  * @pre         Prefix string for output entries
3275  * @curr        Index in array for current sample statistics.
3276  * @itv         Interval of time in 1/100th of a second.
3277  ***************************************************************************
3278  */
3279 __print_funct_t render_psicpu_stats(struct activity *a, int isdb, char *pre,
3280                                     int curr, unsigned long long itv)
3281 {
3282         struct stats_psi_cpu
3283                 *psic = (struct stats_psi_cpu *) a->buf[curr],
3284                 *psip = (struct stats_psi_cpu *) a->buf[!curr];
3285         int pt_newlin
3286                 = PT_NOFLAG + (DISPLAY_HORIZONTALLY(flags) ? 0 : PT_NEWLIN);
3287
3288         render(isdb, pre, PT_NOFLAG,
3289                "-\t%scpu-10", NULL, NULL,
3290                NOVAL,
3291                (double) psic->some_acpu_10 / 100,
3292                NULL);
3293
3294         render(isdb, pre, PT_NOFLAG,
3295                "-\t%scpu-60", NULL, NULL,
3296                NOVAL,
3297                (double) psic->some_acpu_60 / 100,
3298                NULL);
3299
3300         render(isdb, pre, PT_NOFLAG,
3301                "-\t%scpu-300", NULL, NULL,
3302                NOVAL,
3303                (double) psic->some_acpu_300 / 100,
3304                NULL);
3305
3306         render(isdb, pre, pt_newlin,
3307                "-\t%scpu", NULL, NULL,
3308                NOVAL,
3309                ((double) psic->some_cpu_total - psip->some_cpu_total) / (100 * itv),
3310                NULL);
3311 }
3312
3313 /*
3314  ***************************************************************************
3315  * Display pressure-stall I/O statistics in selected format.
3316  *
3317  * IN:
3318  * @a           Activity structure with statistics.
3319  * @isdb        Flag, true if db printing, false if ppc printing.
3320  * @pre         Prefix string for output entries
3321  * @curr        Index in array for current sample statistics.
3322  * @itv         Interval of time in 1/100th of a second.
3323  ***************************************************************************
3324  */
3325 __print_funct_t render_psiio_stats(struct activity *a, int isdb, char *pre,
3326                                    int curr, unsigned long long itv)
3327 {
3328         struct stats_psi_io
3329                 *psic = (struct stats_psi_io *) a->buf[curr],
3330                 *psip = (struct stats_psi_io *) a->buf[!curr];
3331         int pt_newlin
3332                 = PT_NOFLAG + (DISPLAY_HORIZONTALLY(flags) ? 0 : PT_NEWLIN);
3333
3334         render(isdb, pre, PT_NOFLAG,
3335                "-\t%sio-10", NULL, NULL,
3336                NOVAL,
3337                (double) psic->some_aio_10 / 100,
3338                NULL);
3339
3340         render(isdb, pre, PT_NOFLAG,
3341                "-\t%sio-60", NULL, NULL,
3342                NOVAL,
3343                (double) psic->some_aio_60 / 100,
3344                NULL);
3345
3346         render(isdb, pre, PT_NOFLAG,
3347                "-\t%sio-300", NULL, NULL,
3348                NOVAL,
3349                (double) psic->some_aio_300 / 100,
3350                NULL);
3351
3352         render(isdb, pre, PT_NOFLAG,
3353                "-\t%sio", NULL, NULL,
3354                NOVAL,
3355                ((double) psic->some_io_total - psip->some_io_total) / (100 * itv),
3356                NULL);
3357
3358         render(isdb, pre, PT_NOFLAG,
3359                "-\t%fio-10", NULL, NULL,
3360                NOVAL,
3361                (double) psic->full_aio_10 / 100,
3362                NULL);
3363
3364         render(isdb, pre, PT_NOFLAG,
3365                "-\t%fio-60", NULL, NULL,
3366                NOVAL,
3367                (double) psic->full_aio_60 / 100,
3368                NULL);
3369
3370         render(isdb, pre, PT_NOFLAG,
3371                "-\t%fio-300", NULL, NULL,
3372                NOVAL,
3373                (double) psic->full_aio_300 / 100,
3374                NULL);
3375
3376         render(isdb, pre, pt_newlin,
3377                "-\t%fio", NULL, NULL,
3378                NOVAL,
3379                ((double) psic->full_io_total - psip->full_io_total) / (100 * itv),
3380                NULL);
3381 }
3382
3383 /*
3384  ***************************************************************************
3385  * Display pressure-stall memory statistics in selected format.
3386  *
3387  * IN:
3388  * @a           Activity structure with statistics.
3389  * @isdb        Flag, true if db printing, false if ppc printing.
3390  * @pre         Prefix string for output entries
3391  * @curr        Index in array for current sample statistics.
3392  * @itv         Interval of time in 1/100th of a second.
3393  ***************************************************************************
3394  */
3395 __print_funct_t render_psimem_stats(struct activity *a, int isdb, char *pre,
3396                                     int curr, unsigned long long itv)
3397 {
3398         struct stats_psi_mem
3399                 *psic = (struct stats_psi_mem *) a->buf[curr],
3400                 *psip = (struct stats_psi_mem *) a->buf[!curr];
3401         int pt_newlin
3402                 = PT_NOFLAG + (DISPLAY_HORIZONTALLY(flags) ? 0 : PT_NEWLIN);
3403
3404         render(isdb, pre, PT_NOFLAG,
3405                "-\t%smem-10", NULL, NULL,
3406                NOVAL,
3407                (double) psic->some_amem_10 / 100,
3408                NULL);
3409
3410         render(isdb, pre, PT_NOFLAG,
3411                "-\t%smem-60", NULL, NULL,
3412                NOVAL,
3413                (double) psic->some_amem_60 / 100,
3414                NULL);
3415
3416         render(isdb, pre, PT_NOFLAG,
3417                "-\t%smem-300", NULL, NULL,
3418                NOVAL,
3419                (double) psic->some_amem_300 / 100,
3420                NULL);
3421
3422         render(isdb, pre, PT_NOFLAG,
3423                "-\t%smem", NULL, NULL,
3424                NOVAL,
3425                ((double) psic->some_mem_total - psip->some_mem_total) / (100 * itv),
3426                NULL);
3427
3428         render(isdb, pre, PT_NOFLAG,
3429                "-\t%fmem-10", NULL, NULL,
3430                NOVAL,
3431                (double) psic->full_amem_10 / 100,
3432                NULL);
3433
3434         render(isdb, pre, PT_NOFLAG,
3435                "-\t%fmem-60", NULL, NULL,
3436                NOVAL,
3437                (double) psic->full_amem_60 / 100,
3438                NULL);
3439
3440         render(isdb, pre, PT_NOFLAG,
3441                "-\t%fmem-300", NULL, NULL,
3442                NOVAL,
3443                (double) psic->full_amem_300 / 100,
3444                NULL);
3445
3446         render(isdb, pre, pt_newlin,
3447                "-\t%fmem", NULL, NULL,
3448                NOVAL,
3449                ((double) psic->full_mem_total - psip->full_mem_total) / (100 * itv),
3450                NULL);
3451 }