]> granicus.if.org Git - sysstat/blob - raw_stats.c
Apply "sar -d" changes to sadf
[sysstat] / raw_stats.c
1 /*
2  * raw_stats.c: Functions used by sar to display statistics in raw format.
3  * (C) 1999-2017 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 #include <stdlib.h>
26
27 #include "sa.h"
28 #include "ioconf.h"
29 #include "raw_stats.h"
30
31 extern unsigned int flags;
32 extern unsigned int dm_major;
33
34 /*
35  ***************************************************************************
36  * Display current field name.
37  *
38  * IN:
39  * @hdr_line    On the first call, complete header line, containing all the
40  *              metric names. In each subsequent call, must be NULL.
41  * @pos         Index in @hdr_line string, 0 being the first one (headers
42  *              are delimited by the '|' character).
43  *
44  * RETURNS:
45  * Pointer on string containing field name.
46  ***************************************************************************
47  */
48 char *pfield(char *hdr_line, int pos)
49 {
50         char hline[HEADER_LINE_LEN] = "";
51         static char field[HEADER_LINE_LEN] = "";
52         static int idx = 0;
53         char *hl;
54         int i, j = 0;
55
56         if (hdr_line) {
57                 strncpy(hline, hdr_line, HEADER_LINE_LEN - 1);
58                 hline[HEADER_LINE_LEN - 1] = '\0';
59                 idx = 0;
60
61                 for (hl = strtok(hline, "|"); hl && (pos > 0); hl = strtok(NULL, "|"), pos--);
62                 if (!hl) {
63                         /* Bad @pos arg given to function */
64                         strcpy(field, "");
65                         return field;
66                 }
67                 if (strchr(hl, '&')) {
68                         j = strcspn(hl, "&");
69                         *(hl + j) = ';';
70                 }
71                 strncpy(field, hl, HEADER_LINE_LEN);
72                 field[HEADER_LINE_LEN - 1] = '\0';
73         }
74
75         /* Display current field */
76         if (strchr(field + idx, ';')) {
77                 j = strcspn(field + idx, ";");
78                 *(field + idx + j) = '\0';
79         }
80         i = idx;
81         idx += j + 1;
82
83         return field + i;
84 }
85
86 /*
87  ***************************************************************************
88  * Display field values.
89  *
90  * IN:
91  * @valp        Field's value from previous statistics sample.
92  * @valc        Field's value from current statistics sample.
93  ***************************************************************************
94  */
95 void pval(unsigned long long valp, unsigned long long valc)
96 {
97         printf("%llu>%llu", valp, valc);
98         if (DISPLAY_HINTS(flags)) {
99                 if (valc < valp) {
100                         /* Field's value has decreased */
101                         printf(" [DEC]");
102                 }
103         }
104 }
105
106 /*
107  ***************************************************************************
108  * Display CPU statistics in raw format.
109  *
110  * IN:
111  * @a           Activity structure with statistics.
112  * @timestr     Time for current statistics sample.
113  * @curr        Index in array for current statistics sample.
114  ***************************************************************************
115  */
116 __print_funct_t raw_print_cpu_stats(struct activity *a, char *timestr, int curr)
117 {
118         int i;
119         struct stats_cpu *scc, *scp;
120
121         for (i = 0; (i < a->nr) && (i < a->bitmap->b_size + 1); i++) {
122
123                 /*
124                  * The size of a->buf[...] CPU structure may be different from the default
125                  * sizeof(struct stats_cpu) value if data have been read from a file!
126                  * That's why we don't use a syntax like:
127                  * scc = (struct stats_cpu *) a->buf[...] + i;
128                  */
129                 scc = (struct stats_cpu *) ((char *) a->buf[curr] + i * a->msize);
130                 scp = (struct stats_cpu *) ((char *) a->buf[!curr] + i * a->msize);
131
132                 /*
133                  * Note: a->nr is in [1, NR_CPUS + 1].
134                  * Bitmap size is provided for (NR_CPUS + 1) CPUs.
135                  * Anyway, NR_CPUS may vary between the version of sysstat
136                  * used by sadc to create a file, and the version of sysstat
137                  * used by sar to read it...
138                  */
139
140                 /* Should current CPU (including CPU "all") be displayed? */
141                 if (!(a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))))
142                         /* No */
143                         continue;
144
145                 /* Yes: Display it */
146                 printf("%s %s:%d", timestr,
147                        pfield(a->hdr_line, DISPLAY_CPU_ALL(a->opt_flags)), i - 1);
148
149                 if (DISPLAY_HINTS(flags) && i) {
150                         if ((scc->cpu_user + scc->cpu_nice + scc->cpu_sys +
151                              scc->cpu_iowait + scc->cpu_idle + scc->cpu_steal +
152                              scc->cpu_hardirq + scc->cpu_softirq) == 0) {
153                                 /* CPU is offline */
154                                 printf(" [OFF]");
155                         }
156                         else {
157                                 if (!get_per_cpu_interval(scc, scp)) {
158                                         /* CPU is tickless */
159                                         printf(" [TLS]");
160                                 }
161                         }
162                 }
163
164                 if (DISPLAY_CPU_DEF(a->opt_flags)) {
165                         printf(" %s:", pfield(NULL, 0));
166                         pval(scp->cpu_user, scc->cpu_user);
167                         printf(" %s:", pfield(NULL, 0));
168                         pval(scp->cpu_nice, scc->cpu_nice);
169                         printf(" %s:", pfield(NULL, 0));
170                         pval(scp->cpu_sys + scp->cpu_hardirq + scp->cpu_softirq,
171                              scc->cpu_sys + scc->cpu_hardirq + scc->cpu_softirq);
172                         printf(" %s:", pfield(NULL, 0));
173                         pval(scp->cpu_iowait, scc->cpu_iowait);
174                         printf(" %s:", pfield(NULL, 0));
175                         pval(scp->cpu_steal, scc->cpu_steal);
176                         printf(" %s:", pfield(NULL, 0));
177                         pval(scp->cpu_idle, scc->cpu_idle);
178                 }
179                 else if (DISPLAY_CPU_ALL(a->opt_flags)) {
180                         printf(" %s:", pfield(NULL, 0));
181                         pval(scp->cpu_user - scp->cpu_guest, scc->cpu_user - scc->cpu_guest);
182                         printf(" %s:", pfield(NULL, 0));
183                         pval(scp->cpu_nice - scp->cpu_guest_nice, scc->cpu_nice - scc->cpu_guest_nice);
184                         printf(" %s:", pfield(NULL, 0));
185                         pval(scp->cpu_sys, scc->cpu_sys);
186                         printf(" %s:", pfield(NULL, 0));
187                         pval(scp->cpu_iowait, scc->cpu_iowait);
188                         printf(" %s:", pfield(NULL, 0));
189                         pval(scp->cpu_steal, scc->cpu_steal);
190                         printf(" %s:", pfield(NULL, 0));
191                         pval(scp->cpu_hardirq, scc->cpu_hardirq);
192                         printf(" %s:", pfield(NULL, 0));
193                         pval(scp->cpu_softirq, scc->cpu_softirq);
194                         printf(" %s:", pfield(NULL, 0));
195                         pval(scp->cpu_guest, scc->cpu_guest);
196                         printf(" %s:", pfield(NULL, 0));
197                         pval(scp->cpu_guest_nice, scc->cpu_guest_nice);
198                         printf(" %s:", pfield(NULL, 0));
199                         pval(scp->cpu_idle, scc->cpu_idle);
200                 }
201                 printf("\n");
202         }
203 }
204
205 /*
206  ***************************************************************************
207  * Display tasks creation and context switches statistics in raw format.
208  *
209  * IN:
210  * @a           Activity structure with statistics.
211  * @timestr     Time for current statistics sample.
212  * @curr        Index in array for current sample statistics.
213  ***************************************************************************
214  */
215 __print_funct_t raw_print_pcsw_stats(struct activity *a, char *timestr, int curr)
216 {
217         struct stats_pcsw
218                 *spc = (struct stats_pcsw *) a->buf[curr],
219                 *spp = (struct stats_pcsw *) a->buf[!curr];
220
221         printf("%s %s:", timestr, pfield(a->hdr_line, FIRST));
222         pval((unsigned long long) spp->processes, (unsigned long long) spc->processes);
223         printf(" %s:", pfield(NULL, 0));
224         pval(spp->context_switch, spc->context_switch);
225         printf("\n");
226 }
227
228 /*
229  ***************************************************************************
230  * Display interrupts statistics in raw format.
231  *
232  * IN:
233  * @a           Activity structure with statistics.
234  * @timestr     Time for current statistics sample.
235  * @curr        Index in array for current sample statistics.
236  ***************************************************************************
237  */
238 __print_funct_t raw_print_irq_stats(struct activity *a, char *timestr, int curr)
239 {
240         int i;
241         struct stats_irq *sic, *sip;
242
243         for (i = 0; (i < a->nr) && (i < a->bitmap->b_size + 1); i++) {
244
245                 sic = (struct stats_irq *) ((char *) a->buf[curr]  + i * a->msize);
246                 sip = (struct stats_irq *) ((char *) a->buf[!curr] + i * a->msize);
247
248                 /* Should current interrupt (including int "sum") be displayed? */
249                 if (a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))) {
250
251                         /* Yes: Display it */
252                         printf("%s %s:%d", timestr,
253                                pfield(a->hdr_line, FIRST), i - 1);
254                         printf(" %s:", pfield(NULL, 0));
255                         pval(sip->irq_nr, sic->irq_nr);
256                         printf("\n");
257                 }
258         }
259 }
260
261 /*
262  ***************************************************************************
263  * Display swapping statistics in raw format.
264  *
265  * IN:
266  * @a           Activity structure with statistics.
267  * @timestr     Time for current statistics sample.
268  * @curr        Index in array for current sample statistics.
269  ***************************************************************************
270  */
271 __print_funct_t raw_print_swap_stats(struct activity *a, char *timestr, int curr)
272 {
273         struct stats_swap
274                 *ssc = (struct stats_swap *) a->buf[curr],
275                 *ssp = (struct stats_swap *) a->buf[!curr];
276
277         printf("%s %s:", timestr, pfield(a->hdr_line, FIRST));
278         pval((unsigned long long) ssp->pswpin, (unsigned long long) ssc->pswpin);
279         printf(" %s:", pfield(NULL, 0));
280         pval((unsigned long long) ssp->pswpout, (unsigned long long) ssc->pswpout);
281         printf("\n");
282 }
283
284 /*
285  ***************************************************************************
286  * Display paging statistics in raw format.
287  *
288  * IN:
289  * @a           Activity structure with statistics.
290  * @timestr     Time for current statistics sample.
291  * @curr        Index in array for current sample statistics.
292  ***************************************************************************
293  */
294 __print_funct_t raw_print_paging_stats(struct activity *a, char *timestr, int curr)
295 {
296         struct stats_paging
297                 *spc = (struct stats_paging *) a->buf[curr],
298                 *spp = (struct stats_paging *) a->buf[!curr];
299
300         printf("%s %s:", timestr, pfield(a->hdr_line, FIRST));
301         pval((unsigned long long) spp->pgpgin, (unsigned long long) spc->pgpgin);
302         printf(" %s:", pfield(NULL, 0));
303         pval((unsigned long long) spp->pgpgout, (unsigned long long) spc->pgpgout);
304         printf(" %s:", pfield(NULL, 0));
305         pval((unsigned long long) spp->pgfault, (unsigned long long) spc->pgfault);
306         printf(" %s:", pfield(NULL, 0));
307         pval((unsigned long long) spp->pgmajfault, (unsigned long long) spc->pgmajfault);
308         printf(" %s:", pfield(NULL, 0));
309         pval((unsigned long long) spp->pgfree, (unsigned long long) spc->pgfree);
310         printf(" %s:", pfield(NULL, 0));
311         pval((unsigned long long) spp->pgscan_kswapd, (unsigned long long) spc->pgscan_kswapd);
312         printf(" %s:", pfield(NULL, 0));
313         pval((unsigned long long) spp->pgscan_direct, (unsigned long long) spc->pgscan_direct);
314         printf(" %s:", pfield(NULL, 0));
315         pval((unsigned long long) spp->pgsteal, (unsigned long long) spc->pgsteal);
316         printf("\n");
317 }
318
319 /*
320  ***************************************************************************
321  * Display I/O and transfer rate statistics in raw format.
322  *
323  * IN:
324  * @a           Activity structure with statistics.
325  * @timestr     Time for current statistics sample.
326  * @curr        Index in array for current sample statistics.
327  ***************************************************************************
328  */
329 __print_funct_t raw_print_io_stats(struct activity *a, char *timestr, int curr)
330 {
331         struct stats_io
332                 *sic = (struct stats_io *) a->buf[curr],
333                 *sip = (struct stats_io *) a->buf[!curr];
334
335         printf("%s %s:", timestr, pfield(a->hdr_line, FIRST));
336         pval(sip->dk_drive, sic->dk_drive);
337         printf(" %s:", pfield(NULL, 0));
338         pval(sip->dk_drive_rio, sic->dk_drive_rio);
339         printf(" %s:", pfield(NULL, 0));
340         pval(sip->dk_drive_wio, sic->dk_drive_wio);
341         printf(" %s:", pfield(NULL, 0));
342         pval(sip->dk_drive_rblk, sic->dk_drive_rblk);
343         printf(" %s:", pfield(NULL, 0));
344         pval(sip->dk_drive_wblk, sic->dk_drive_wblk);
345         printf("\n");
346 }
347
348 /*
349  ***************************************************************************
350  * Display memory statistics in raw format.
351  *
352  * IN:
353  * @a           Activity structure with statistics.
354  * @timestr     Time for current statistics sample.
355  * @curr        Index in array for current sample statistics.
356  ***************************************************************************
357  */
358 __print_funct_t raw_print_memory_stats(struct activity *a, char *timestr, int curr)
359 {
360         struct stats_memory
361                 *smc = (struct stats_memory *) a->buf[curr];
362
363         if (DISPLAY_MEMORY(a->opt_flags)) {
364                 printf("%s %s:%lu", timestr, pfield(a->hdr_line, FIRST), smc->frmkb);
365                 printf(" %s:%lu", pfield(NULL, 0), smc->availablekb);
366                 printf(" kbttlmem:%lu", smc->tlmkb);
367                 pfield(NULL, 0); /* Skip kbmemused */
368                 pfield(NULL, 0); /* Skip %memused */
369                 printf(" %s:%lu", pfield(NULL, 0), smc->bufkb);
370                 printf(" %s:%lu", pfield(NULL, 0), smc->camkb);
371                 printf(" %s:%lu", pfield(NULL, 0), smc->comkb);
372                 pfield(NULL, 0); /* Skip %commit */
373                 printf(" %s:%lu", pfield(NULL, 0), smc->activekb);
374                 printf(" %s:%lu", pfield(NULL, 0), smc->inactkb);
375                 printf(" %s:%lu", pfield(NULL, 0), smc->dirtykb);
376
377                 if (DISPLAY_MEM_ALL(a->opt_flags)) {
378                         printf(" %s:%lu", pfield(NULL, 0), smc->anonpgkb);
379                         printf(" %s:%lu", pfield(NULL, 0), smc->slabkb);
380                         printf(" %s:%lu", pfield(NULL, 0), smc->kstackkb);
381                         printf(" %s:%lu", pfield(NULL, 0), smc->pgtblkb);
382                         printf(" %s:%lu", pfield(NULL, 0), smc->vmusedkb);
383                 }
384                 printf("\n");
385         }
386
387         if (DISPLAY_SWAP(a->opt_flags)) {
388                 printf("%s %s:%lu", timestr, pfield(a->hdr_line, SECOND), smc->frskb);
389                 printf(" kbttlswp:%lu", smc->tlskb);
390                 pfield(NULL, 0); /* Skip kbswpused */
391                 pfield(NULL, 0); /* Skip %swpused */
392                 printf(" %s:%lu", pfield(NULL, 0), smc->caskb);
393                 printf("\n");
394         }
395 }
396
397 /*
398  ***************************************************************************
399  * Display kernel tables statistics in raw format.
400  *
401  * IN:
402  * @a           Activity structure with statistics.
403  * @timestr     Time for current statistics sample.
404  * @curr        Index in array for current sample statistics.
405  ***************************************************************************
406  */
407 __print_funct_t raw_print_ktables_stats(struct activity *a, char *timestr, int curr)
408 {
409         struct stats_ktables
410                 *skc = (struct stats_ktables *) a->buf[curr];
411
412         printf("%s %s:%u", timestr, pfield(a->hdr_line, FIRST), skc->dentry_stat);
413         printf(" %s:%u", pfield(NULL, 0), skc->file_used);
414         printf(" %s:%u", pfield(NULL, 0), skc->inode_used);
415         printf(" %s:%u", pfield(NULL, 0), skc->pty_nr);
416         printf("\n");
417 }
418
419 /*
420  ***************************************************************************
421  * Display queue and load statistics in raw format.
422  *
423  * IN:
424  * @a           Activity structure with statistics.
425  * @timestr     Time for current statistics sample.
426  * @curr        Index in array for current sample statistics.
427  ***************************************************************************
428  */
429 __print_funct_t raw_print_queue_stats(struct activity *a, char *timestr, int curr)
430 {
431         struct stats_queue
432                 *sqc = (struct stats_queue *) a->buf[curr];
433
434         printf("%s %s:%lu", timestr, pfield(a->hdr_line, FIRST), sqc->nr_running);
435         printf(" %s:%u", pfield(NULL, 0), sqc->nr_threads);
436         printf(" %s:%u", pfield(NULL, 0), sqc->load_avg_1);
437         printf(" %s:%u", pfield(NULL, 0), sqc->load_avg_5);
438         printf(" %s:%u", pfield(NULL, 0), sqc->load_avg_15);
439         printf(" %s:%lu", pfield(NULL, 0), sqc->procs_blocked);
440         printf("\n");
441 }
442
443 /*
444  ***************************************************************************
445  * Display serial lines statistics in raw format.
446  *
447  * IN:
448  * @a           Activity structure with statistics.
449  * @timestr     Time for current statistics sample.
450  * @curr        Index in array for current sample statistics.
451  ***************************************************************************
452  */
453 __print_funct_t raw_print_serial_stats(struct activity *a, char *timestr, int curr)
454 {
455         int i;
456         struct stats_serial *ssc, *ssp;
457
458         for (i = 0; i < a->nr; i++) {
459
460                 ssc = (struct stats_serial *) ((char *) a->buf[curr]  + i * a->msize);
461                 ssp = (struct stats_serial *) ((char *) a->buf[!curr] + i * a->msize);
462
463                 printf("%s %s:", timestr, pfield(a->hdr_line, FIRST));
464                 pval((unsigned long long) ssp->line, (unsigned long long) ssc->line);
465
466                 if (ssc->line == 0) {
467                         if (DISPLAY_HINTS(flags)) {
468                                 printf(" [SKP]");
469                         }
470                         printf("\n");
471                         continue;
472                 }
473
474                 if (ssc->line == ssp->line) {
475                         printf(" %s:", pfield(NULL, 0));
476                         pval((unsigned long long) ssp->rx, (unsigned long long)ssc->rx);
477                         printf(" %s:", pfield(NULL, 0));
478                         pval((unsigned long long) ssp->tx, (unsigned long long) ssc->tx);
479                         printf(" %s:", pfield(NULL, 0));
480                         pval((unsigned long long) ssp->frame, (unsigned long long) ssc->frame);
481                         printf(" %s:", pfield(NULL, 0));
482                         pval((unsigned long long) ssp->parity, (unsigned long long) ssc->parity);
483                         printf(" %s:", pfield(NULL, 0));
484                         pval((unsigned long long) ssp->brk, (unsigned long long) ssc->brk);
485                         printf(" %s:", pfield(NULL, 0));
486                         pval((unsigned long long) ssp->overrun, (unsigned long long) ssc->overrun);
487                 }
488                 else if (DISPLAY_HINTS(flags)) {
489                         printf(" [NEW]");
490                 }
491
492                 printf("\n");
493         }
494 }
495
496 /*
497  ***************************************************************************
498  * Display disks statistics in raw format.
499  *
500  * IN:
501  * @a           Activity structure with statistics.
502  * @timestr     Time for current statistics sample.
503  * @curr        Index in array for current sample statistics.
504  ***************************************************************************
505  */
506 __print_funct_t raw_print_disk_stats(struct activity *a, char *timestr, int curr)
507 {
508         int i, j;
509         struct stats_disk *sdc, *sdp, sdpzero;
510         char *dev_name, *persist_dev_name;
511
512         memset(&sdpzero, 0, STATS_DISK_SIZE);
513
514         for (i = 0; i < a->nr; i++) {
515
516                 sdc = (struct stats_disk *) ((char *) a->buf[curr] + i * a->msize);
517
518                 printf("%s major:%u minor:%u", timestr, sdc->major, sdc->minor);
519
520                 if (!(sdc->major + sdc->minor)) {
521                         if (DISPLAY_HINTS(flags)) {
522                                 printf(" [SKP]");
523                         }
524                         printf("\n");
525                         continue;
526                 }
527
528                 j = check_disk_reg(a, curr, !curr, i);
529                 if (j < 0) {
530                         /* This is a newly registered interface. Previous stats are zero */
531                         sdp = &sdpzero;
532                         if (DISPLAY_HINTS(flags)) {
533                                 printf(" [NEW]");
534                         }
535                 }
536                 else {
537                         sdp = (struct stats_disk *) ((char *) a->buf[!curr] + j * a->msize);
538                 }
539
540                 dev_name = NULL;
541                 persist_dev_name = NULL;
542
543                 if (DISPLAY_PERSIST_NAME_S(flags)) {
544                         persist_dev_name = get_persistent_name_from_pretty(get_devname(sdc->major, sdc->minor, TRUE));
545                 }
546
547                 if (persist_dev_name) {
548                         dev_name = persist_dev_name;
549                 }
550                 else {
551                         /* Always use pretty option (-p) */
552                         if (sdc->major == dm_major) {
553                                 dev_name = transform_devmapname(sdc->major, sdc->minor);
554                         }
555
556                         if (!dev_name) {
557                                 dev_name = get_devname(sdc->major, sdc->minor, TRUE);
558                         }
559                 }
560
561                 printf(" %s:%s", pfield(a->hdr_line, FIRST), dev_name);
562                 printf(" %s:", pfield(NULL, 0));
563                 pval(sdp->nr_ios, sdc->nr_ios);
564                 printf(" %s:", pfield(NULL, 0));
565                 pval((unsigned long long) sdp->rd_sect, (unsigned long long) sdc->rd_sect);
566                 printf(" %s:", pfield(NULL, 0));
567                 pval((unsigned long long) sdp->wr_sect, (unsigned long long) sdc->wr_sect);
568                 printf(" tot_ticks:");
569                 pval((unsigned long long) sdp->tot_ticks, (unsigned long long) sdc->tot_ticks);
570                 pfield(NULL, 0); /* Skip areq-sz */
571                 printf(" %s:", pfield(NULL, 0));
572                 pval((unsigned long long) sdp->rq_ticks, (unsigned long long) sdc->rq_ticks);
573                 printf("\n");
574         }
575 }
576
577 /*
578  ***************************************************************************
579  * Display network interfaces statistics in raw format.
580  *
581  * IN:
582  * @a           Activity structure with statistics.
583  * @timestr     Time for current statistics sample.
584  * @curr        Index in array for current sample statistics.
585  ***************************************************************************
586  */
587 __print_funct_t raw_print_net_dev_stats(struct activity *a, char *timestr, int curr)
588 {
589         int i, j;
590         struct stats_net_dev *sndc, *sndp, sndzero;
591
592         memset(&sndzero, 0, STATS_NET_DEV_SIZE);
593
594         for (i = 0; i < a->nr; i++) {
595
596                 sndc = (struct stats_net_dev *) ((char *) a->buf[curr] + i * a->msize);
597
598                 if (!strcmp(sndc->interface, ""))
599                         break;
600
601                 printf("%s %s:%s", timestr, pfield(a->hdr_line, FIRST), sndc->interface);
602
603                 j = check_net_dev_reg(a, curr, !curr, i);
604                 if (j < 0) {
605                         /* This is a newly registered interface. Previous stats are zero */
606                         sndp = &sndzero;
607                         if (DISPLAY_HINTS(flags)) {
608                                 printf(" [NEW]");
609                         }
610                 }
611                 else {
612                         sndp = (struct stats_net_dev *) ((char *) a->buf[!curr] + j * a->msize);
613                 }
614
615                 printf(" %s:", pfield(NULL, 0));
616                 pval(sndp->rx_packets, sndc->rx_packets);
617                 printf(" %s:", pfield(NULL, 0));
618                 pval(sndp->tx_packets, sndc->tx_packets);
619                 printf(" %s:", pfield(NULL, 0));
620                 pval(sndp->rx_bytes, sndc->rx_bytes);
621                 printf(" %s:", pfield(NULL, 0));
622                 pval(sndp->tx_bytes, sndc->tx_bytes);
623                 printf(" %s:", pfield(NULL, 0));
624                 pval(sndp->rx_compressed, sndc->rx_compressed);
625                 printf(" %s:", pfield(NULL, 0));
626                 pval(sndp->tx_compressed, sndc->tx_compressed);
627                 printf(" %s:", pfield(NULL, 0));
628                 pval(sndp->multicast, sndc->multicast);
629                 printf(" speed:%u duplex:%u\n", sndc->speed, sndc->duplex);
630         }
631 }
632
633 /*
634  ***************************************************************************
635  * Display network interfaces errors statistics in raw format.
636  *
637  * IN:
638  * @a           Activity structure with statistics.
639  * @timestr     Time for current statistics sample.
640  * @curr        Index in array for current sample statistics.
641  ***************************************************************************
642  */
643 __print_funct_t raw_print_net_edev_stats(struct activity *a, char *timestr, int curr)
644 {
645         int i, j;
646         struct stats_net_edev *snedc, *snedp, snedzero;
647
648         memset(&snedzero, 0, STATS_NET_EDEV_SIZE);
649
650         for (i = 0; i < a->nr; i++) {
651
652                 snedc = (struct stats_net_edev *) ((char *) a->buf[curr] + i * a->msize);
653
654                 if (!strcmp(snedc->interface, ""))
655                         break;
656
657                 printf("%s %s:%s", timestr, pfield(a->hdr_line, FIRST), snedc->interface);
658
659                 j = check_net_edev_reg(a, curr, !curr, i);
660                 if (j < 0) {
661                         /* This is a newly registered interface. Previous stats are zero */
662                         snedp = &snedzero;
663                         if (DISPLAY_HINTS(flags)) {
664                                 printf(" [NEW]");
665                         }
666                 }
667                 else {
668                         snedp = (struct stats_net_edev *) ((char *) a->buf[!curr] + j * a->msize);
669                 }
670
671                 printf(" %s:", pfield(NULL, 0));
672                 pval(snedp->rx_errors, snedc->rx_errors);
673                 printf(" %s:", pfield(NULL, 0));
674                 pval(snedp->tx_errors, snedc->tx_errors);
675                 printf(" %s:", pfield(NULL, 0));
676                 pval(snedp->collisions, snedc->collisions);
677                 printf(" %s:", pfield(NULL, 0));
678                 pval(snedp->rx_dropped, snedc->rx_dropped);
679                 printf(" %s:", pfield(NULL, 0));
680                 pval(snedp->tx_dropped, snedc->tx_dropped);
681                 printf(" %s:", pfield(NULL, 0));
682                 pval(snedp->tx_carrier_errors, snedc->tx_carrier_errors);
683                 printf(" %s:", pfield(NULL, 0));
684                 pval(snedp->rx_frame_errors, snedc->rx_frame_errors);
685                 printf(" %s:", pfield(NULL, 0));
686                 pval(snedp->rx_fifo_errors, snedc->rx_fifo_errors);
687                 printf(" %s:", pfield(NULL, 0));
688                 pval(snedp->tx_fifo_errors, snedc->tx_fifo_errors);
689                 printf("\n");
690         }
691 }
692
693 /*
694  ***************************************************************************
695  * Display NFS client statistics in raw format.
696  *
697  * IN:
698  * @a           Activity structure with statistics.
699  * @timestr     Time for current statistics sample.
700  * @curr        Index in array for current sample statistics.
701  ***************************************************************************
702  */
703 __print_funct_t raw_print_net_nfs_stats(struct activity *a, char *timestr, int curr)
704 {
705         struct stats_net_nfs
706                 *snnc = (struct stats_net_nfs *) a->buf[curr],
707                 *snnp = (struct stats_net_nfs *) a->buf[!curr];
708
709         printf("%s %s:", timestr, pfield(a->hdr_line, FIRST));
710         pval((unsigned long long) snnp->nfs_rpccnt, (unsigned long long) snnc->nfs_rpccnt);
711         printf(" %s:", pfield(NULL, 0));
712         pval((unsigned long long) snnp->nfs_rpcretrans, (unsigned long long) snnc->nfs_rpcretrans);
713         printf(" %s:", pfield(NULL, 0));
714         pval((unsigned long long) snnp->nfs_readcnt, (unsigned long long) snnc->nfs_readcnt);
715         printf(" %s:", pfield(NULL, 0));
716         pval((unsigned long long) snnp->nfs_writecnt, (unsigned long long) snnc->nfs_writecnt);
717         printf(" %s:", pfield(NULL, 0));
718         pval((unsigned long long) snnp->nfs_accesscnt, (unsigned long long) snnc->nfs_accesscnt);
719         printf(" %s:", pfield(NULL, 0));
720         pval((unsigned long long) snnp->nfs_getattcnt, (unsigned long long) snnc->nfs_getattcnt);
721         printf("\n");
722 }
723
724 /*
725  ***************************************************************************
726  * Display NFS server statistics in raw format.
727  *
728  * IN:
729  * @a           Activity structure with statistics.
730  * @timestr     Time for current statistics sample.
731  * @curr        Index in array for current sample statistics.
732  ***************************************************************************
733  */
734 __print_funct_t raw_print_net_nfsd_stats(struct activity *a, char *timestr, int curr)
735 {
736         struct stats_net_nfsd
737                 *snndc = (struct stats_net_nfsd *) a->buf[curr],
738                 *snndp = (struct stats_net_nfsd *) a->buf[!curr];
739
740         printf("%s %s:", timestr, pfield(a->hdr_line, FIRST));
741         pval((unsigned long long) snndp->nfsd_rpccnt, (unsigned long long) snndc->nfsd_rpccnt);
742         printf(" %s:", pfield(NULL, 0));
743         pval((unsigned long long) snndp->nfsd_rpcbad, (unsigned long long) snndc->nfsd_rpcbad);
744         printf(" %s:", pfield(NULL, 0));
745         pval((unsigned long long) snndp->nfsd_netcnt, (unsigned long long) snndc->nfsd_netcnt);
746         printf(" %s:", pfield(NULL, 0));
747         pval((unsigned long long) snndp->nfsd_netudpcnt, (unsigned long long) snndc->nfsd_netudpcnt);
748         printf(" %s:", pfield(NULL, 0));
749         pval((unsigned long long) snndp->nfsd_nettcpcnt, (unsigned long long) snndc->nfsd_nettcpcnt);
750         printf(" %s:", pfield(NULL, 0));
751         pval((unsigned long long) snndp->nfsd_rchits, (unsigned long long) snndc->nfsd_rchits);
752         printf(" %s:", pfield(NULL, 0));
753         pval((unsigned long long) snndp->nfsd_rcmisses, (unsigned long long) snndc->nfsd_rcmisses);
754         printf(" %s:", pfield(NULL, 0));
755         pval((unsigned long long) snndp->nfsd_readcnt, (unsigned long long) snndc->nfsd_readcnt);
756         printf(" %s:", pfield(NULL, 0));
757         pval((unsigned long long) snndp->nfsd_writecnt, (unsigned long long) snndc->nfsd_writecnt);
758         printf(" %s:", pfield(NULL, 0));
759         pval((unsigned long long) snndp->nfsd_accesscnt, (unsigned long long) snndc->nfsd_accesscnt);
760         printf(" %s:", pfield(NULL, 0));
761         pval((unsigned long long) snndp->nfsd_getattcnt, (unsigned long long) snndc->nfsd_getattcnt);
762         printf("\n");
763 }
764
765 /*
766  ***************************************************************************
767  * Display network socket statistics in raw format.
768  *
769  * IN:
770  * @a           Activity structure with statistics.
771  * @timestr     Time for current statistics sample.
772  * @curr        Index in array for current sample statistics.
773  ***************************************************************************
774  */
775 __print_funct_t raw_print_net_sock_stats(struct activity *a, char *timestr, int curr)
776 {
777         struct stats_net_sock
778                 *snsc = (struct stats_net_sock *) a->buf[curr];
779
780         printf("%s %s:%u", timestr, pfield(a->hdr_line, FIRST), snsc->sock_inuse);
781         printf(" %s:%u", pfield(NULL, 0), snsc->tcp_inuse);
782         printf(" %s:%u", pfield(NULL, 0), snsc->udp_inuse);
783         printf(" %s:%u", pfield(NULL, 0), snsc->raw_inuse);
784         printf(" %s:%u", pfield(NULL, 0), snsc->frag_inuse);
785         printf(" %s:%u", pfield(NULL, 0), snsc->tcp_tw);
786         printf("\n");
787 }
788
789 /*
790  ***************************************************************************
791  * Display IP network statistics in raw format.
792  *
793  * IN:
794  * @a           Activity structure with statistics.
795  * @timestr     Time for current statistics sample.
796  * @curr        Index in array for current sample statistics.
797  ***************************************************************************
798  */
799 __print_funct_t raw_print_net_ip_stats(struct activity *a, char *timestr, int curr)
800 {
801         struct stats_net_ip
802                 *snic = (struct stats_net_ip *) a->buf[curr],
803                 *snip = (struct stats_net_ip *) a->buf[!curr];
804
805         printf("%s %s:", timestr, pfield(a->hdr_line, FIRST));
806         pval(snip->InReceives, snic->InReceives);
807         printf(" %s:", pfield(NULL, 0));
808         pval(snip->ForwDatagrams, snic->ForwDatagrams);
809         printf(" %s:", pfield(NULL, 0));
810         pval(snip->InDelivers, snic->InDelivers);
811         printf(" %s:", pfield(NULL, 0));
812         pval(snip->OutRequests, snic->OutRequests);
813         printf(" %s:", pfield(NULL, 0));
814         pval(snip->ReasmReqds, snic->ReasmReqds);
815         printf(" %s:", pfield(NULL, 0));
816         pval(snip->ReasmOKs, snic->ReasmOKs);
817         printf(" %s:", pfield(NULL, 0));
818         pval(snip->FragOKs, snic->FragOKs);
819         printf(" %s:", pfield(NULL, 0));
820         pval(snip->FragCreates, snic->FragCreates);
821         printf("\n");
822 }
823
824 /*
825  ***************************************************************************
826  * Display IP network errors statistics in raw format.
827  *
828  * IN:
829  * @a           Activity structure with statistics.
830  * @timestr     Time for current statistics sample.
831  * @curr        Index in array for current sample statistics.
832  ***************************************************************************
833  */
834 __print_funct_t raw_print_net_eip_stats(struct activity *a, char *timestr, int curr)
835 {
836         struct stats_net_eip
837                 *sneic = (struct stats_net_eip *) a->buf[curr],
838                 *sneip = (struct stats_net_eip *) a->buf[!curr];
839
840         printf("%s %s:", timestr, pfield(a->hdr_line, FIRST));
841         pval(sneip->InHdrErrors, sneic->InHdrErrors);
842         printf(" %s:", pfield(NULL, 0));
843         pval(sneip->InAddrErrors, sneic->InAddrErrors);
844         printf(" %s:", pfield(NULL, 0));
845         pval(sneip->InUnknownProtos, sneic->InUnknownProtos);
846         printf(" %s:", pfield(NULL, 0));
847         pval(sneip->InDiscards, sneic->InDiscards);
848         printf(" %s:", pfield(NULL, 0));
849         pval(sneip->OutDiscards, sneic->OutDiscards);
850         printf(" %s:", pfield(NULL, 0));
851         pval(sneip->OutNoRoutes, sneic->OutNoRoutes);
852         printf(" %s:", pfield(NULL, 0));
853         pval(sneip->ReasmFails, sneic->ReasmFails);
854         printf(" %s:", pfield(NULL, 0));
855         pval(sneip->FragFails, sneic->FragFails);
856         printf("\n");
857 }
858
859 /*
860  ***************************************************************************
861  * Display ICMP network statistics in raw format.
862  *
863  * IN:
864  * @a           Activity structure with statistics.
865  * @timestr     Time for current statistics sample.
866  * @curr        Index in array for current sample statistics.
867  ***************************************************************************
868  */
869 __print_funct_t raw_print_net_icmp_stats(struct activity *a, char *timestr, int curr)
870 {
871         struct stats_net_icmp
872                 *snic = (struct stats_net_icmp *) a->buf[curr],
873                 *snip = (struct stats_net_icmp *) a->buf[!curr];
874
875         printf("%s %s:", timestr, pfield(a->hdr_line, FIRST));
876         pval((unsigned long long) snip->InMsgs, (unsigned long long) snic->InMsgs);
877         printf(" %s:", pfield(NULL, 0));
878         pval((unsigned long long) snip->OutMsgs, (unsigned long long) snic->OutMsgs);
879         printf(" %s:", pfield(NULL, 0));
880         pval((unsigned long long) snip->InEchos, (unsigned long long) snic->InEchos);
881         printf(" %s:", pfield(NULL, 0));
882         pval((unsigned long long) snip->InEchoReps, (unsigned long long) snic->InEchoReps);
883         printf(" %s:", pfield(NULL, 0));
884         pval((unsigned long long) snip->OutEchos, (unsigned long long) snic->OutEchos);
885         printf(" %s:", pfield(NULL, 0));
886         pval((unsigned long long) snip->OutEchoReps, (unsigned long long) snic->OutEchoReps);
887         printf(" %s:", pfield(NULL, 0));
888         pval((unsigned long long) snip->InTimestamps, (unsigned long long) snic->InTimestamps);
889         printf(" %s:", pfield(NULL, 0));
890         pval((unsigned long long) snip->InTimestampReps, (unsigned long long) snic->InTimestampReps);
891         printf(" %s:", pfield(NULL, 0));
892         pval((unsigned long long) snip->OutTimestamps, (unsigned long long) snic->OutTimestamps);
893         printf(" %s:", pfield(NULL, 0));
894         pval((unsigned long long) snip->OutTimestampReps, (unsigned long long) snic->OutTimestampReps);
895         printf(" %s:", pfield(NULL, 0));
896         pval((unsigned long long) snip->InAddrMasks, (unsigned long long) snic->InAddrMasks);
897         printf(" %s:", pfield(NULL, 0));
898         pval((unsigned long long) snip->InAddrMaskReps, (unsigned long long) snic->InAddrMaskReps);
899         printf(" %s:", pfield(NULL, 0));
900         pval((unsigned long long) snip->OutAddrMasks, (unsigned long long) snic->OutAddrMasks);
901         printf(" %s:", pfield(NULL, 0));
902         pval((unsigned long long) snip->OutAddrMaskReps, (unsigned long long) snic->OutAddrMaskReps);
903         printf("\n");
904 }
905
906 /*
907  ***************************************************************************
908  * Display ICMP errors message statistics in raw format.
909  *
910  * IN:
911  * @a           Activity structure with statistics.
912  * @timestr     Time for current statistics sample.
913  * @curr        Index in array for current sample statistics.
914  ***************************************************************************
915  */
916 __print_funct_t raw_print_net_eicmp_stats(struct activity *a, char *timestr, int curr)
917 {
918         struct stats_net_eicmp
919                 *sneic = (struct stats_net_eicmp *) a->buf[curr],
920                 *sneip = (struct stats_net_eicmp *) a->buf[!curr];
921
922         printf("%s %s:", timestr, pfield(a->hdr_line, FIRST));
923         pval((unsigned long long) sneip->InErrors, (unsigned long long) sneic->InErrors);
924         printf(" %s:", pfield(NULL, 0));
925         pval((unsigned long long) sneip->OutErrors, (unsigned long long) sneic->OutErrors);
926         printf(" %s:", pfield(NULL, 0));
927         pval((unsigned long long) sneip->InDestUnreachs, (unsigned long long) sneic->InDestUnreachs);
928         printf(" %s:", pfield(NULL, 0));
929         pval((unsigned long long) sneip->OutDestUnreachs, (unsigned long long) sneic->OutDestUnreachs);
930         printf(" %s:", pfield(NULL, 0));
931         pval((unsigned long long) sneip->InTimeExcds, (unsigned long long) sneic->InTimeExcds);
932         printf(" %s:", pfield(NULL, 0));
933         pval((unsigned long long) sneip->OutTimeExcds, (unsigned long long) sneic->OutTimeExcds);
934         printf(" %s:", pfield(NULL, 0));
935         pval((unsigned long long) sneip->InParmProbs, (unsigned long long) sneic->InParmProbs);
936         printf(" %s:", pfield(NULL, 0));
937         pval((unsigned long long) sneip->OutParmProbs, (unsigned long long) sneic->OutParmProbs);
938         printf(" %s:", pfield(NULL, 0));
939         pval((unsigned long long) sneip->InSrcQuenchs, (unsigned long long) sneic->InSrcQuenchs);
940         printf(" %s:", pfield(NULL, 0));
941         pval((unsigned long long) sneip->OutSrcQuenchs, (unsigned long long) sneic->OutSrcQuenchs);
942         printf(" %s:", pfield(NULL, 0));
943         pval((unsigned long long) sneip->InRedirects, (unsigned long long) sneic->InRedirects);
944         printf(" %s:", pfield(NULL, 0));
945         pval((unsigned long long) sneip->OutRedirects, (unsigned long long) sneic->OutRedirects);
946         printf("\n");
947 }
948
949 /*
950  ***************************************************************************
951  * Display TCP network statistics in raw format.
952  *
953  * IN:
954  * @a           Activity structure with statistics.
955  * @timestr     Time for current statistics sample.
956  * @curr        Index in array for current sample statistics.
957  ***************************************************************************
958  */
959 __print_funct_t raw_print_net_tcp_stats(struct activity *a, char *timestr, int curr)
960 {
961         struct stats_net_tcp
962                 *sntc = (struct stats_net_tcp *) a->buf[curr],
963                 *sntp = (struct stats_net_tcp *) a->buf[!curr];
964
965         printf("%s %s:", timestr, pfield(a->hdr_line, FIRST));
966         pval((unsigned long long) sntp->ActiveOpens, (unsigned long long) sntc->ActiveOpens);
967         printf(" %s:", pfield(NULL, 0));
968         pval((unsigned long long) sntp->PassiveOpens, (unsigned long long) sntc->PassiveOpens);
969         printf(" %s:", pfield(NULL, 0));
970         pval((unsigned long long) sntp->InSegs, (unsigned long long) sntc->InSegs);
971         printf(" %s:", pfield(NULL, 0));
972         pval((unsigned long long) sntp->OutSegs, (unsigned long long) sntc->OutSegs);
973         printf("\n");
974 }
975
976 /*
977  ***************************************************************************
978  * Display TCP network errors statistics in raw format.
979  *
980  * IN:
981  * @a           Activity structure with statistics.
982  * @timestr     Time for current statistics sample.
983  * @curr        Index in array for current sample statistics.
984  ***************************************************************************
985  */
986 __print_funct_t raw_print_net_etcp_stats(struct activity *a, char *timestr, int curr)
987 {
988         struct stats_net_etcp
989                 *snetc = (struct stats_net_etcp *) a->buf[curr],
990                 *snetp = (struct stats_net_etcp *) a->buf[!curr];
991
992         printf("%s %s:", timestr, pfield(a->hdr_line, FIRST));
993         pval((unsigned long long) snetp->AttemptFails, (unsigned long long) snetc->AttemptFails);
994         printf(" %s:", pfield(NULL, 0));
995         pval((unsigned long long) snetp->EstabResets, (unsigned long long) snetc->EstabResets);
996         printf(" %s:", pfield(NULL, 0));
997         pval((unsigned long long) snetp->RetransSegs, (unsigned long long) snetc->RetransSegs);
998         printf(" %s:", pfield(NULL, 0));
999         pval((unsigned long long) snetp->InErrs, (unsigned long long) snetc->InErrs);
1000         printf(" %s:", pfield(NULL, 0));
1001         pval((unsigned long long) snetp->OutRsts, (unsigned long long) snetc->OutRsts);
1002         printf("\n");
1003 }
1004
1005 /*
1006  ***************************************************************************
1007  * Display UDP network statistics in raw format.
1008  *
1009  * IN:
1010  * @a           Activity structure with statistics.
1011  * @timestr     Time for current statistics sample.
1012  * @curr        Index in array for current sample statistics.
1013  ***************************************************************************
1014  */
1015 __print_funct_t raw_print_net_udp_stats(struct activity *a, char *timestr, int curr)
1016 {
1017         struct stats_net_udp
1018                 *snuc = (struct stats_net_udp *) a->buf[curr],
1019                 *snup = (struct stats_net_udp *) a->buf[!curr];
1020
1021         printf("%s %s:", timestr, pfield(a->hdr_line, FIRST));
1022         pval((unsigned long long) snup->InDatagrams, (unsigned long long) snuc->InDatagrams);
1023         printf(" %s:", pfield(NULL, 0));
1024         pval((unsigned long long) snup->OutDatagrams, (unsigned long long) snuc->OutDatagrams);
1025         printf(" %s:", pfield(NULL, 0));
1026         pval((unsigned long long) snup->NoPorts, (unsigned long long) snuc->NoPorts);
1027         printf(" %s:", pfield(NULL, 0));
1028         pval((unsigned long long) snup->InErrors, (unsigned long long) snuc->InErrors);
1029         printf("\n");
1030 }
1031
1032 /*
1033  ***************************************************************************
1034  * Display IPv6 network socket statistics in raw format.
1035  *
1036  * IN:
1037  * @a           Activity structure with statistics.
1038  * @timestr     Time for current statistics sample.
1039  * @curr        Index in array for current sample statistics.
1040  ***************************************************************************
1041  */
1042 __print_funct_t raw_print_net_sock6_stats(struct activity *a, char *timestr, int curr)
1043 {
1044         struct stats_net_sock6
1045                 *snsc = (struct stats_net_sock6 *) a->buf[curr];
1046
1047         printf("%s %s:%u", timestr, pfield(a->hdr_line, FIRST), snsc->tcp6_inuse);
1048         printf(" %s:%u", pfield(NULL, 0), snsc->udp6_inuse);
1049         printf(" %s:%u", pfield(NULL, 0), snsc->raw6_inuse);
1050         printf(" %s:%u", pfield(NULL, 0), snsc->frag6_inuse);
1051         printf("\n");
1052 }
1053
1054 /*
1055  ***************************************************************************
1056  * Display IPv6 network statistics in raw format.
1057  *
1058  * IN:
1059  * @a           Activity structure with statistics.
1060  * @timestr     Time for current statistics sample.
1061  * @curr        Index in array for current sample statistics.
1062  ***************************************************************************
1063  */
1064 __print_funct_t raw_print_net_ip6_stats(struct activity *a, char *timestr, int curr)
1065 {
1066         struct stats_net_ip6
1067                 *snic = (struct stats_net_ip6 *) a->buf[curr],
1068                 *snip = (struct stats_net_ip6 *) a->buf[!curr];
1069
1070         printf("%s %s:", timestr, pfield(a->hdr_line, FIRST));
1071         pval(snip->InReceives6, snic->InReceives6);
1072         printf(" %s:", pfield(NULL, 0));
1073         pval(snip->OutForwDatagrams6, snic->OutForwDatagrams6);
1074         printf(" %s:", pfield(NULL, 0));
1075         pval(snip->InDelivers6, snic->InDelivers6);
1076         printf(" %s:", pfield(NULL, 0));
1077         pval(snip->OutRequests6, snic->OutRequests6);
1078         printf(" %s:", pfield(NULL, 0));
1079         pval(snip->ReasmReqds6, snic->ReasmReqds6);
1080         printf(" %s:", pfield(NULL, 0));
1081         pval(snip->ReasmOKs6, snic->ReasmOKs6);
1082         printf(" %s:", pfield(NULL, 0));
1083         pval(snip->InMcastPkts6, snic->InMcastPkts6);
1084         printf(" %s:", pfield(NULL, 0));
1085         pval(snip->OutMcastPkts6, snic->OutMcastPkts6);
1086         printf(" %s:", pfield(NULL, 0));
1087         pval(snip->FragOKs6, snic->FragOKs6);
1088         printf(" %s:", pfield(NULL, 0));
1089         pval(snip->FragCreates6, snic->FragCreates6);
1090         printf("\n");
1091 }
1092
1093 /*
1094  ***************************************************************************
1095  * Display IPv6 network errors statistics in raw format.
1096  *
1097  * IN:
1098  * @a           Activity structure with statistics.
1099  * @timestr     Time for current statistics sample.
1100  * @curr        Index in array for current sample statistics.
1101  ***************************************************************************
1102  */
1103 __print_funct_t raw_print_net_eip6_stats(struct activity *a, char *timestr, int curr)
1104 {
1105         struct stats_net_eip6
1106                 *sneic = (struct stats_net_eip6 *) a->buf[curr],
1107                 *sneip = (struct stats_net_eip6 *) a->buf[!curr];
1108
1109         printf("%s %s:", timestr, pfield(a->hdr_line, FIRST));
1110         pval(sneip->InHdrErrors6, sneic->InHdrErrors6);
1111         printf(" %s:", pfield(NULL, 0));
1112         pval(sneip->InAddrErrors6, sneic->InAddrErrors6);
1113         printf(" %s:", pfield(NULL, 0));
1114         pval(sneip->InUnknownProtos6, sneic->InUnknownProtos6);
1115         printf(" %s:", pfield(NULL, 0));
1116         pval(sneip->InTooBigErrors6, sneic->InTooBigErrors6);
1117         printf(" %s:", pfield(NULL, 0));
1118         pval(sneip->InDiscards6, sneic->InDiscards6);
1119         printf(" %s:", pfield(NULL, 0));
1120         pval(sneip->OutDiscards6, sneic->OutDiscards6);
1121         printf(" %s:", pfield(NULL, 0));
1122         pval(sneip->InNoRoutes6, sneic->InNoRoutes6);
1123         printf(" %s:", pfield(NULL, 0));
1124         pval(sneip->OutNoRoutes6, sneic->OutNoRoutes6);
1125         printf(" %s:", pfield(NULL, 0));
1126         pval(sneip->ReasmFails6, sneic->ReasmFails6);
1127         printf(" %s:", pfield(NULL, 0));
1128         pval(sneip->FragFails6, sneic->FragFails6);
1129         printf(" %s:", pfield(NULL, 0));
1130         pval(sneip->InTruncatedPkts6, sneic->InTruncatedPkts6);
1131         printf("\n");
1132 }
1133
1134 /*
1135  ***************************************************************************
1136  * Display ICMPv6 network statistics in raw format.
1137  *
1138  * IN:
1139  * @a           Activity structure with statistics.
1140  * @timestr     Time for current statistics sample.
1141  * @curr        Index in array for current sample statistics.
1142  ***************************************************************************
1143  */
1144 __print_funct_t raw_print_net_icmp6_stats(struct activity *a, char *timestr, int curr)
1145 {
1146         struct stats_net_icmp6
1147                 *snic = (struct stats_net_icmp6 *) a->buf[curr],
1148                 *snip = (struct stats_net_icmp6 *) a->buf[!curr];
1149
1150         printf("%s %s:", timestr, pfield(a->hdr_line, FIRST));
1151         pval((unsigned long long) snip->InMsgs6,
1152              (unsigned long long) snic->InMsgs6);
1153         printf(" %s:", pfield(NULL, 0));
1154         pval((unsigned long long) snip->OutMsgs6,
1155              (unsigned long long) snic->OutMsgs6);
1156         printf(" %s:", pfield(NULL, 0));
1157         pval((unsigned long long) snip->InEchos6,
1158              (unsigned long long) snic->InEchos6);
1159         printf(" %s:", pfield(NULL, 0));
1160         pval((unsigned long long) snip->InEchoReplies6,
1161              (unsigned long long) snic->InEchoReplies6);
1162         printf(" %s:", pfield(NULL, 0));
1163         pval((unsigned long long) snip->OutEchoReplies6,
1164              (unsigned long long) snic->OutEchoReplies6);
1165         printf(" %s:", pfield(NULL, 0));
1166         pval((unsigned long long) snip->InGroupMembQueries6,
1167              (unsigned long long) snic->InGroupMembQueries6);
1168         printf(" %s:", pfield(NULL, 0));
1169         pval((unsigned long long) snip->InGroupMembResponses6,
1170              (unsigned long long) snic->InGroupMembResponses6);
1171         printf(" %s:", pfield(NULL, 0));
1172         pval((unsigned long long) snip->OutGroupMembResponses6,
1173              (unsigned long long) snic->OutGroupMembResponses6);
1174         printf(" %s:", pfield(NULL, 0));
1175         pval((unsigned long long) snip->InGroupMembReductions6,
1176              (unsigned long long) snic->InGroupMembReductions6);
1177         printf(" %s:", pfield(NULL, 0));
1178         pval((unsigned long long) snip->OutGroupMembReductions6,
1179              (unsigned long long) snic->OutGroupMembReductions6);
1180         printf(" %s:", pfield(NULL, 0));
1181         pval((unsigned long long) snip->InRouterSolicits6,
1182              (unsigned long long) snic->InRouterSolicits6);
1183         printf(" %s:", pfield(NULL, 0));
1184         pval((unsigned long long) snip->OutRouterSolicits6,
1185              (unsigned long long) snic->OutRouterSolicits6);
1186         printf(" %s:", pfield(NULL, 0));
1187         pval((unsigned long long) snip->InRouterAdvertisements6,
1188              (unsigned long long) snic->InRouterAdvertisements6);
1189         printf(" %s:", pfield(NULL, 0));
1190         pval((unsigned long long) snip->InNeighborSolicits6,
1191              (unsigned long long) snic->InNeighborSolicits6);
1192         printf(" %s:", pfield(NULL, 0));
1193         pval((unsigned long long) snip->OutNeighborSolicits6,
1194              (unsigned long long) snic->OutNeighborSolicits6);
1195         printf(" %s:", pfield(NULL, 0));
1196         pval((unsigned long long) snip->InNeighborAdvertisements6,
1197              (unsigned long long) snic->InNeighborAdvertisements6);
1198         printf(" %s:", pfield(NULL, 0));
1199         pval((unsigned long long) snip->OutNeighborAdvertisements6,
1200              (unsigned long long) snic->OutNeighborAdvertisements6);
1201         printf("\n");
1202 }
1203
1204 /*
1205  ***************************************************************************
1206  * Display ICMPv6 error messages statistics in rw format.
1207  *
1208  * IN:
1209  * @a           Activity structure with statistics.
1210  * @timestr     Time for current statistics sample.
1211  * @curr        Index in array for current sample statistics.
1212  ***************************************************************************
1213  */
1214 __print_funct_t raw_print_net_eicmp6_stats(struct activity *a, char *timestr, int curr)
1215 {
1216         struct stats_net_eicmp6
1217                 *sneic = (struct stats_net_eicmp6 *) a->buf[curr],
1218                 *sneip = (struct stats_net_eicmp6 *) a->buf[!curr];
1219
1220         printf("%s %s:", timestr, pfield(a->hdr_line, FIRST));
1221         pval((unsigned long long) sneip->InErrors6, (unsigned long long) sneic->InErrors6);
1222         printf(" %s:", pfield(NULL, 0));
1223         pval((unsigned long long) sneip->InDestUnreachs6, (unsigned long long) sneic->InDestUnreachs6);
1224         printf(" %s:", pfield(NULL, 0));
1225         pval((unsigned long long) sneip->OutDestUnreachs6, (unsigned long long) sneic->OutDestUnreachs6);
1226         printf(" %s:", pfield(NULL, 0));
1227         pval((unsigned long long) sneip->InTimeExcds6, (unsigned long long) sneic->InTimeExcds6);
1228         printf(" %s:", pfield(NULL, 0));
1229         pval((unsigned long long) sneip->OutTimeExcds6, (unsigned long long) sneic->OutTimeExcds6);
1230         printf(" %s:", pfield(NULL, 0));
1231         pval((unsigned long long) sneip->InParmProblems6, (unsigned long long) sneic->InParmProblems6);
1232         printf(" %s:", pfield(NULL, 0));
1233         pval((unsigned long long) sneip->OutParmProblems6, (unsigned long long) sneic->OutParmProblems6);
1234         printf(" %s:", pfield(NULL, 0));
1235         pval((unsigned long long) sneip->InRedirects6, (unsigned long long) sneic->InRedirects6);
1236         printf(" %s:", pfield(NULL, 0));
1237         pval((unsigned long long) sneip->OutRedirects6, (unsigned long long) sneic->OutRedirects6);
1238         printf(" %s:", pfield(NULL, 0));
1239         pval((unsigned long long) sneip->InPktTooBigs6, (unsigned long long) sneic->InPktTooBigs6);
1240         printf(" %s:", pfield(NULL, 0));
1241         pval((unsigned long long) sneip->OutPktTooBigs6, (unsigned long long) sneic->OutPktTooBigs6);
1242         printf("\n");
1243 }
1244
1245 /*
1246  ***************************************************************************
1247  * Display UDPv6 network statistics in raw format.
1248  *
1249  * IN:
1250  * @a           Activity structure with statistics.
1251  * @timestr     Time for current statistics sample.
1252  * @curr        Index in array for current sample statistics.
1253  ***************************************************************************
1254  */
1255 __print_funct_t raw_print_net_udp6_stats(struct activity *a, char *timestr, int curr)
1256 {
1257         struct stats_net_udp6
1258                 *snuc = (struct stats_net_udp6 *) a->buf[curr],
1259                 *snup = (struct stats_net_udp6 *) a->buf[!curr];
1260
1261         printf("%s %s:", timestr, pfield(a->hdr_line, FIRST));
1262         pval((unsigned long long) snup->InDatagrams6, (unsigned long long) snuc->InDatagrams6);
1263         printf(" %s:", pfield(NULL, 0));
1264         pval((unsigned long long) snup->OutDatagrams6, (unsigned long long) snuc->OutDatagrams6);
1265         printf(" %s:", pfield(NULL, 0));
1266         pval((unsigned long long) snup->NoPorts6, (unsigned long long) snuc->NoPorts6);
1267         printf(" %s:", pfield(NULL, 0));
1268         pval((unsigned long long) snup->InErrors6, (unsigned long long) snuc->InErrors6);
1269         printf("\n");
1270 }
1271
1272 /*
1273  ***************************************************************************
1274  * Display CPU frequency statistics in raw format.
1275  *
1276  * IN:
1277  * @a           Activity structure with statistics.
1278  * @timestr     Time for current statistics sample.
1279  * @curr        Index in array for current sample statistics.
1280  ***************************************************************************
1281  */
1282 __print_funct_t raw_print_pwr_cpufreq_stats(struct activity *a, char *timestr, int curr)
1283 {
1284         int i;
1285         struct stats_pwr_cpufreq *spc;
1286
1287         for (i = 0; (i < a->nr) && (i < a->bitmap->b_size + 1); i++) {
1288
1289                 spc = (struct stats_pwr_cpufreq *) ((char *) a->buf[curr]  + i * a->msize);
1290
1291                 /* Should current CPU (including CPU "all") be displayed? */
1292                 if (a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))) {
1293                         /* Yes: Display it */
1294                         printf("%s %s:%d", timestr, pfield(a->hdr_line, FIRST), i - 1);
1295                         printf(" %s:%lu\n", pfield(NULL, 0), spc->cpufreq);
1296                 }
1297         }
1298 }
1299
1300 /*
1301  ***************************************************************************
1302  * Display fan statistics in raw format.
1303  *
1304  * IN:
1305  * @a           Activity structure with statistics.
1306  * @timestr     Time for current statistics sample.
1307  * @curr        Index in array for current sample statistics.
1308  ***************************************************************************
1309  */
1310 __print_funct_t raw_print_pwr_fan_stats(struct activity *a, char *timestr, int curr)
1311 {
1312         int i;
1313         struct stats_pwr_fan *spc;
1314
1315         for (i = 0; i < a->nr; i++) {
1316                 spc = (struct stats_pwr_fan *) ((char *) a->buf[curr]  + i * a->msize);
1317
1318                 printf("%s %s:%d", timestr, pfield(a->hdr_line, FIRST), i + 1);
1319                 printf(" %s:%s", pfield(NULL, 0), spc->device);
1320                 printf(" %s:%f", pfield(NULL, 0), spc->rpm);
1321                 printf(" rpm_min:%f\n", spc->rpm_min);
1322         }
1323 }
1324
1325 /*
1326  ***************************************************************************
1327  * Display temperature statistics in raw format.
1328  *
1329  * IN:
1330  * @a           Activity structure with statistics.
1331  * @timestr     Time for current statistics sample.
1332  * @curr        Index in array for current sample statistics.
1333  ***************************************************************************
1334  */
1335 __print_funct_t raw_print_pwr_temp_stats(struct activity *a, char *timestr, int curr)
1336 {
1337         int i;
1338         struct stats_pwr_temp *spc;
1339
1340         for (i = 0; i < a->nr; i++) {
1341                 spc = (struct stats_pwr_temp *) ((char *) a->buf[curr]  + i * a->msize);
1342
1343                 printf("%s %s:%d", timestr, pfield(a->hdr_line, FIRST), i + 1);
1344                 printf(" %s:%s", pfield(NULL, 0), spc->device);
1345                 printf(" %s:%f", pfield(NULL, 0), spc->temp);
1346                 printf(" temp_min:%f", spc->temp_min);
1347                 printf(" temp_max:%f\n", spc->temp_max);
1348         }
1349 }
1350
1351 /*
1352  ***************************************************************************
1353  * Display voltage inputs statistics in raw format.
1354  *
1355  * IN:
1356  * @a           Activity structure with statistics.
1357  * @timestr     Time for current statistics sample.
1358  * @curr        Index in array for current sample statistics.
1359  ***************************************************************************
1360  */
1361 __print_funct_t raw_print_pwr_in_stats(struct activity *a, char *timestr, int curr)
1362 {
1363         int i;
1364         struct stats_pwr_in *spc;
1365
1366         for (i = 0; i < a->nr; i++) {
1367                 spc = (struct stats_pwr_in *) ((char *) a->buf[curr]  + i * a->msize);
1368
1369                 printf("%s %s:%d", timestr, pfield(a->hdr_line, FIRST), i);
1370                 printf(" %s:%s", pfield(NULL, 0), spc->device);
1371                 printf(" %s:%f", pfield(NULL, 0), spc->in);
1372                 printf(" in_min:%f", spc->in_min);
1373                 printf(" in_max:%f\n", spc->in_max);
1374         }
1375 }
1376
1377 /*
1378  ***************************************************************************
1379  * Display huge pages statistics in raw format.
1380  *
1381  * IN:
1382  * @a           Activity structure with statistics.
1383  * @timestr     Time for current statistics sample.
1384  * @curr        Index in array for current sample statistics.
1385  ***************************************************************************
1386  */
1387 __print_funct_t raw_print_huge_stats(struct activity *a, char *timestr, int curr)
1388 {
1389         struct stats_huge
1390                 *smc = (struct stats_huge *) a->buf[curr];
1391
1392         printf("%s %s:%lu", timestr, pfield(a->hdr_line, FIRST), smc->frhkb);
1393         printf(" hugtotal:%lu\n", smc->tlhkb);
1394 }
1395
1396 /*
1397  ***************************************************************************
1398  * Display weighted CPU frequency statistics in raw format.
1399  *
1400  * IN:
1401  * @a           Activity structure with statistics.
1402  * @timestr     Time for current statistics sample.
1403  * @curr        Index in array for current sample statistics.
1404  ***************************************************************************
1405  */
1406 __print_funct_t raw_print_pwr_wghfreq_stats(struct activity *a, char *timestr, int curr)
1407 {
1408         int i, k;
1409         struct stats_pwr_wghfreq *spc, *spp, *spc_k, *spp_k;
1410
1411         for (i = 0; (i < a->nr) && (i < a->bitmap->b_size + 1); i++) {
1412
1413                 spc = (struct stats_pwr_wghfreq *) ((char *) a->buf[curr]  + i * a->msize * a->nr2);
1414                 spp = (struct stats_pwr_wghfreq *) ((char *) a->buf[!curr] + i * a->msize * a->nr2);
1415
1416                 /* Should current CPU (including CPU "all") be displayed? */
1417                 if (a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))) {
1418
1419                         /* Yes... */
1420                         printf("%s %s:%d", timestr, pfield(a->hdr_line, FIRST), i - 1);
1421
1422                         for (k = 0; k < a->nr2; k++) {
1423
1424                                 spc_k = (struct stats_pwr_wghfreq *) ((char *) spc + k * a->msize);
1425                                 if (!spc_k->freq)
1426                                         break;
1427                                 spp_k = (struct stats_pwr_wghfreq *) ((char *) spp + k * a->msize);
1428
1429                                 printf(" freq: %lu", spc_k->freq);
1430                                 printf(" tminst:");
1431                                 pval(spp_k->time_in_state, spc_k->time_in_state);
1432                         }
1433                         printf("\n");
1434                 }
1435         }
1436 }
1437
1438 /*
1439  ***************************************************************************
1440  * Display USB devices statistics in raw format.
1441  *
1442  * IN:
1443  * @a           Activity structure with statistics.
1444  * @timestr     Time for current statistics sample.
1445  * @curr        Index in array for current sample statistics.
1446  ***************************************************************************
1447  */
1448 __print_funct_t raw_print_pwr_usb_stats(struct activity *a, char *timestr, int curr)
1449 {
1450         int i;
1451         struct stats_pwr_usb *suc;
1452
1453         for (i = 0; i < a->nr; i++) {
1454                 suc = (struct stats_pwr_usb *) ((char *) a->buf[curr]  + i * a->msize);
1455
1456                 if (!suc->bus_nr)
1457                         /* Bus#0 doesn't exist: We are at the end of the list */
1458                         break;
1459
1460                 printf("%s %s:\"%s\"", timestr, pfield(a->hdr_line, FIRST), suc->manufacturer);
1461                 printf(" %s:\"%s\"", pfield(NULL, 0), suc->product);
1462                 printf(" %s:%d", pfield(NULL, 0), suc->bus_nr);
1463                 printf(" %s:%x", pfield(NULL, 0), suc->vendor_id);
1464                 printf(" %s:%x", pfield(NULL, 0), suc->product_id);
1465                 printf(" %s:%u\n", pfield(NULL, 0), suc->bmaxpower);
1466         }
1467 }
1468
1469 /*
1470  ***************************************************************************
1471  * Display filesystems statistics in raw format.
1472  *
1473  * IN:
1474  * @a           Activity structure with statistics.
1475  * @timestr     Time for current statistics sample.
1476  * @curr        Index in array for current sample statistics.
1477  ***************************************************************************
1478  */
1479 __print_funct_t raw_print_filesystem_stats(struct activity *a, char *timestr, int curr)
1480 {
1481         int i;
1482         struct stats_filesystem *sfc;
1483
1484
1485         for (i = 0; i < a->nr; i++) {
1486                 sfc = (struct stats_filesystem *) ((char *) a->buf[curr]  + i * a->msize);
1487
1488                 if (!sfc->f_blocks)
1489                         /* Size of filesystem is zero: We are at the end of the list */
1490                         break;
1491
1492                 printf("%s %s:\"%s\"", timestr, pfield(a->hdr_line, FIRST + DISPLAY_MOUNT(a->opt_flags)),
1493                        DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name);
1494                 printf(" f_bfree:%llu", sfc->f_bfree);
1495                 printf(" f_blocks:%llu", sfc->f_blocks);
1496                 printf(" f_bavail:%llu", sfc->f_bavail);
1497                 pfield(NULL, 0); /* Skip MBfsfree */
1498                 pfield(NULL, 0); /* Skip MBfsused */
1499                 pfield(NULL, 0); /* Skip %fsused */
1500                 pfield(NULL, 0); /* Skip %ufsused */
1501                 printf(" %s:%llu", pfield(NULL, 0), sfc->f_ffree);
1502                 printf(" f_files:%llu\n", sfc->f_files);
1503
1504         }
1505 }
1506
1507 /*
1508  ***************************************************************************
1509  * Display Fibre Channel HBA statistics in raw format.
1510  *
1511  * IN:
1512  * @a           Activity structure with statistics.
1513  * @timestr     Time for current statistics sample.
1514  * @curr        Index in array for current sample statistics.
1515  ***************************************************************************
1516  */
1517 __print_funct_t raw_print_fchost_stats(struct activity *a, char *timestr, int curr)
1518 {
1519         int i;
1520         struct stats_fchost *sfcc, *sfcp;
1521
1522         for (i = 0; i < a->nr; i++) {
1523                 sfcc = (struct stats_fchost *) ((char *) a->buf[curr]  + i * a->msize);
1524                 sfcp = (struct stats_fchost *) ((char *) a->buf[!curr]  + i * a->msize);
1525
1526                 if (!sfcc->fchost_name[0])
1527                         /* We are at the end of the list */
1528                         break;
1529
1530                 printf(" %s:%s", pfield(a->hdr_line, FIRST), sfcc->fchost_name);
1531                 printf(" %s:", pfield(NULL, 0));
1532                 pval((unsigned long long) sfcp->f_rxframes, (unsigned long long) sfcc->f_rxframes);
1533                 printf(" %s:", pfield(NULL, 0));
1534                 pval((unsigned long long) sfcp->f_txframes, (unsigned long long) sfcc->f_txframes);
1535                 printf(" %s:", pfield(NULL, 0));
1536                 pval((unsigned long long) sfcp->f_rxwords, (unsigned long long) sfcc->f_rxwords);
1537                 printf(" %s:", pfield(NULL, 0));
1538                 pval((unsigned long long) sfcp->f_txwords, (unsigned long long) sfcc->f_txwords);
1539                 printf("\n");
1540         }
1541 }
1542
1543 /*
1544  ***************************************************************************
1545  * Display softnet statistics in raw format.
1546  *
1547  * IN:
1548  * @a           Activity structure with statistics.
1549  * @timestr     Time for current statistics sample.
1550  * @curr        Index in array for current sample statistics.
1551  ***************************************************************************
1552  */
1553 __print_funct_t raw_print_softnet_stats(struct activity *a, char *timestr, int curr)
1554 {
1555         int i;
1556         struct stats_softnet *ssnc, *ssnp;
1557
1558         for (i = 0; (i < a->nr) && (i < a->bitmap->b_size + 1); i++) {
1559
1560                 /*
1561                  * The size of a->buf[...] CPU structure may be different from the default
1562                  * sizeof(struct stats_pwr_cpufreq) value if data have been read from a file!
1563                  * That's why we don't use a syntax like:
1564                  * ssnc = (struct stats_softnet *) a->buf[...] + i;
1565                  */
1566                 ssnc = (struct stats_softnet *) ((char *) a->buf[curr] + i * a->msize);
1567                 ssnp = (struct stats_softnet *) ((char *) a->buf[!curr] + i * a->msize);
1568
1569                 /*
1570                  * Note: a->nr is in [1, NR_CPUS + 1].
1571                  * Bitmap size is provided for (NR_CPUS + 1) CPUs.
1572                  * Anyway, NR_CPUS may vary between the version of sysstat
1573                  * used by sadc to create a file, and the version of sysstat
1574                  * used by sar to read it...
1575                  */
1576
1577                 /* Should current CPU (including CPU "all") be displayed? */
1578                 if (!(a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))))
1579                         /* No */
1580                         continue;
1581
1582                 /* Yes: Display current CPU stats */
1583                 printf("%s %s:%d", timestr, pfield(a->hdr_line, FIRST), i - 1);
1584                 printf(" %s:", pfield(NULL, 0));
1585                 pval((unsigned long long) ssnp->processed, (unsigned long long) ssnc->processed);
1586                 printf(" %s:", pfield(NULL, 0));
1587                 pval((unsigned long long) ssnp->dropped, (unsigned long long) ssnc->dropped);
1588                 printf(" %s:", pfield(NULL, 0));
1589                 pval((unsigned long long) ssnp->time_squeeze, (unsigned long long) ssnc->time_squeeze);
1590                 printf(" %s:", pfield(NULL, 0));
1591                 pval((unsigned long long) ssnp->received_rps, (unsigned long long) ssnc->received_rps);
1592                 printf(" %s:", pfield(NULL, 0));
1593                 pval((unsigned long long) ssnp->flow_limit, (unsigned long long) ssnc->flow_limit);
1594                 printf("\n");
1595         }
1596 }