]> granicus.if.org Git - sysstat/blob - raw_stats.c
Cosmetic fixes
[sysstat] / raw_stats.c
1 /*
2  * raw_stats.c: Functions used by sar to display statistics in raw format.
3  * (C) 1999-2019 by Sebastien GODARD (sysstat <at> orange.fr)
4  *
5  ***************************************************************************
6  * This program is free software; you can redistribute it and/or modify it *
7  * under the terms of the GNU General Public License as published  by  the *
8  * Free Software Foundation; either version 2 of the License, or (at  your *
9  * option) any later version.                                              *
10  *                                                                         *
11  * This program is distributed in the hope that it  will  be  useful,  but *
12  * WITHOUT ANY WARRANTY; without the implied warranty  of  MERCHANTABILITY *
13  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License *
14  * for more details.                                                       *
15  *                                                                         *
16  * You should have received a copy of the GNU General Public License along *
17  * with this program; if not, write to the Free Software Foundation, Inc., *
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA              *
19  ***************************************************************************
20  */
21
22 #include <stdio.h>
23 #include <string.h>
24 #include <stdarg.h>
25 #include <stdlib.h>
26
27 #include "sa.h"
28 #include "ioconf.h"
29 #include "raw_stats.h"
30
31 extern unsigned int flags;
32
33 /*
34  ***************************************************************************
35  * Display current field name.
36  *
37  * IN:
38  * @hdr_line    On the first call, complete header line, containing all the
39  *              metric names. In each subsequent call, must be NULL.
40  * @pos         Index in @hdr_line string, 0 being the first one (headers
41  *              are delimited by the '|' character).
42  *
43  * RETURNS:
44  * Pointer on string containing field name.
45  ***************************************************************************
46  */
47 char *pfield(char *hdr_line, int pos)
48 {
49         char hline[HEADER_LINE_LEN] = "";
50         static char field[HEADER_LINE_LEN] = "";
51         static int idx = 0;
52         char *hl;
53         int i, j = 0;
54
55         if (hdr_line) {
56                 strncpy(hline, hdr_line, sizeof(hline) - 1);
57                 hline[sizeof(hline) - 1] = '\0';
58                 idx = 0;
59
60                 for (hl = strtok(hline, "|"); hl && (pos > 0); hl = strtok(NULL, "|"), pos--);
61                 if (!hl) {
62                         /* Bad @pos arg given to function */
63                         strcpy(field, "");
64                         return field;
65                 }
66                 if (strchr(hl, '&')) {
67                         j = strcspn(hl, "&");
68                         *(hl + j) = ';';
69                 }
70                 strncpy(field, hl, sizeof(field));
71                 field[sizeof(field) - 1] = '\0';
72         }
73
74         /* Display current field */
75         if (strchr(field + idx, ';')) {
76                 j = strcspn(field + idx, ";");
77                 *(field + idx + j) = '\0';
78         }
79         i = idx;
80         idx += j + 1;
81
82         return field + i;
83 }
84
85 /*
86  ***************************************************************************
87  * Display field values.
88  *
89  * IN:
90  * @valp        Field's value from previous statistics sample.
91  * @valc        Field's value from current statistics sample.
92  ***************************************************************************
93  */
94 void pval(unsigned long long valp, unsigned long long valc)
95 {
96         if (DISPLAY_DEBUG_MODE(flags)) {
97                 if (valc < valp) {
98                         /* Field's value has decreased */
99                         printf(" [DEC]");
100                 }
101         }
102         printf("; %llu; %llu;", valp, valc);
103 }
104
105 /*
106  ***************************************************************************
107  * Display CPU statistics in raw format.
108  * Note: Values displayed for CPU "all" may slightly differ from those you
109  * would get if you were displaying them in pr_stats.c:print_cpu_stats().
110  * This is because values for CPU "all" are recalculated there as the sum of
111  * all individual CPU values (done by a call to get_global_cpu_statistics()
112  * function).
113  *
114  * IN:
115  * @a           Activity structure with statistics.
116  * @timestr     Time for current statistics sample.
117  * @curr        Index in array for current statistics sample.
118  ***************************************************************************
119  */
120 __print_funct_t raw_print_cpu_stats(struct activity *a, char *timestr, int curr)
121 {
122         int i;
123         struct stats_cpu *scc, *scp;
124
125         /* @nr[curr] cannot normally be greater than @nr_ini */
126         if (a->nr[curr] > a->nr_ini) {
127                 a->nr_ini = a->nr[curr];
128         }
129
130         for (i = 0; (i < a->nr_ini) && (i < a->bitmap->b_size + 1); i++) {
131
132                 /*
133                  * The size of a->buf[...] CPU structure may be different from the default
134                  * sizeof(struct stats_cpu) value if data have been read from a file!
135                  * That's why we don't use a syntax like:
136                  * scc = (struct stats_cpu *) a->buf[...] + i;
137                  */
138                 scc = (struct stats_cpu *) ((char *) a->buf[curr] + i * a->msize);
139                 scp = (struct stats_cpu *) ((char *) a->buf[!curr] + i * a->msize);
140
141                 /* Should current CPU (including CPU "all") be displayed? */
142                 if (!(a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))))
143                         /* No */
144                         continue;
145
146                 /* Yes: Display it */
147                 printf("%s; %s", timestr, pfield(a->hdr_line, DISPLAY_CPU_ALL(a->opt_flags)));
148                 if (DISPLAY_DEBUG_MODE(flags) && i) {
149                         if ((scc->cpu_user + scc->cpu_nice + scc->cpu_sys +
150                              scc->cpu_iowait + scc->cpu_idle + scc->cpu_steal +
151                              scc->cpu_hardirq + scc->cpu_softirq) == 0) {
152                                 /* CPU is offline */
153                                 printf(" [OFF]");
154                         }
155                         else {
156                                 if (!get_per_cpu_interval(scc, scp)) {
157                                         /* CPU is tickless */
158                                         printf(" [TLS]");
159                                 }
160                         }
161                 }
162                 printf("; %d;", i - 1);
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[curr]) && (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_dio, sic->dk_drive_dio);
343         printf(" %s", pfield(NULL, 0));
344         pval(sip->dk_drive_rblk, sic->dk_drive_rblk);
345         printf(" %s", pfield(NULL, 0));
346         pval(sip->dk_drive_wblk, sic->dk_drive_wblk);
347         printf(" %s", pfield(NULL, 0));
348         pval(sip->dk_drive_dblk, sic->dk_drive_dblk);
349         printf("\n");
350 }
351
352 /*
353  ***************************************************************************
354  * Display memory statistics in raw format.
355  *
356  * IN:
357  * @a           Activity structure with statistics.
358  * @timestr     Time for current statistics sample.
359  * @curr        Index in array for current sample statistics.
360  ***************************************************************************
361  */
362 __print_funct_t raw_print_memory_stats(struct activity *a, char *timestr, int curr)
363 {
364         struct stats_memory
365                 *smc = (struct stats_memory *) a->buf[curr];
366
367         if (DISPLAY_MEMORY(a->opt_flags)) {
368                 printf("%s; %s; %llu;", timestr, pfield(a->hdr_line, FIRST), smc->frmkb);
369                 printf(" %s; %llu;", pfield(NULL, 0), smc->availablekb);
370                 printf(" kbttlmem; %llu;", smc->tlmkb);
371                 pfield(NULL, 0); /* Skip kbmemused */
372                 pfield(NULL, 0); /* Skip %memused */
373                 printf(" %s; %llu;", pfield(NULL, 0), smc->bufkb);
374                 printf(" %s; %llu;", pfield(NULL, 0), smc->camkb);
375                 printf(" %s; %llu;", pfield(NULL, 0), smc->comkb);
376                 pfield(NULL, 0); /* Skip %commit */
377                 printf(" %s; %llu;", pfield(NULL, 0), smc->activekb);
378                 printf(" %s; %llu;", pfield(NULL, 0), smc->inactkb);
379                 printf(" %s; %llu;", pfield(NULL, 0), smc->dirtykb);
380
381                 if (DISPLAY_MEM_ALL(a->opt_flags)) {
382                         printf(" %s; %llu;", pfield(NULL, 0), smc->anonpgkb);
383                         printf(" %s; %llu;", pfield(NULL, 0), smc->slabkb);
384                         printf(" %s; %llu;", pfield(NULL, 0), smc->kstackkb);
385                         printf(" %s; %llu;", pfield(NULL, 0), smc->pgtblkb);
386                         printf(" %s; %llu;", pfield(NULL, 0), smc->vmusedkb);
387                 }
388                 printf("\n");
389         }
390
391         if (DISPLAY_SWAP(a->opt_flags)) {
392                 printf("%s; %s; %llu;", timestr, pfield(a->hdr_line, SECOND), smc->frskb);
393                 printf(" kbttlswp; %llu;", smc->tlskb);
394                 pfield(NULL, 0); /* Skip kbswpused */
395                 pfield(NULL, 0); /* Skip %swpused */
396                 printf(" %s; %llu;", pfield(NULL, 0), smc->caskb);
397                 printf("\n");
398         }
399 }
400
401 /*
402  ***************************************************************************
403  * Display kernel tables statistics in raw format.
404  *
405  * IN:
406  * @a           Activity structure with statistics.
407  * @timestr     Time for current statistics sample.
408  * @curr        Index in array for current sample statistics.
409  ***************************************************************************
410  */
411 __print_funct_t raw_print_ktables_stats(struct activity *a, char *timestr, int curr)
412 {
413         struct stats_ktables
414                 *skc = (struct stats_ktables *) a->buf[curr];
415
416         printf("%s; %s; %llu;", timestr, pfield(a->hdr_line, FIRST), skc->dentry_stat);
417         printf(" %s; %llu;", pfield(NULL, 0), skc->file_used);
418         printf(" %s; %llu;", pfield(NULL, 0), skc->inode_used);
419         printf(" %s; %llu;", pfield(NULL, 0), skc->pty_nr);
420         printf("\n");
421 }
422
423 /*
424  ***************************************************************************
425  * Display queue and load statistics in raw format.
426  *
427  * IN:
428  * @a           Activity structure with statistics.
429  * @timestr     Time for current statistics sample.
430  * @curr        Index in array for current sample statistics.
431  ***************************************************************************
432  */
433 __print_funct_t raw_print_queue_stats(struct activity *a, char *timestr, int curr)
434 {
435         struct stats_queue
436                 *sqc = (struct stats_queue *) a->buf[curr];
437
438         printf("%s; %s; %llu;", timestr, pfield(a->hdr_line, FIRST), sqc->nr_running);
439         printf(" %s; %llu;", pfield(NULL, 0), sqc->nr_threads);
440         printf(" %s; %u;", pfield(NULL, 0), sqc->load_avg_1);
441         printf(" %s; %u;", pfield(NULL, 0), sqc->load_avg_5);
442         printf(" %s; %u;", pfield(NULL, 0), sqc->load_avg_15);
443         printf(" %s; %llu;", pfield(NULL, 0), sqc->procs_blocked);
444         printf("\n");
445 }
446
447 /*
448  ***************************************************************************
449  * Display serial lines statistics in raw format.
450  *
451  * IN:
452  * @a           Activity structure with statistics.
453  * @timestr     Time for current statistics sample.
454  * @curr        Index in array for current sample statistics.
455  ***************************************************************************
456  */
457 __print_funct_t raw_print_serial_stats(struct activity *a, char *timestr, int curr)
458 {
459         int i, j, j0, found;
460         struct stats_serial *ssc, *ssp;
461
462         for (i = 0; i < a->nr[curr]; i++) {
463
464                 found = FALSE;
465                 ssc = (struct stats_serial *) ((char *) a->buf[curr]  + i * a->msize);
466
467                 if (a->nr[!curr] > 0) {
468
469                         /* Look for corresponding serial line in previous iteration */
470                         j = i;
471
472                         if (j >= a->nr[!curr]) {
473                                 j = a->nr[!curr] - 1;
474                         }
475
476                         j0 = j;
477
478                         do {
479                                 ssp = (struct stats_serial *) ((char *) a->buf[!curr] + j * a->msize);
480                                 if (ssc->line == ssp->line) {
481                                         found = TRUE;
482                                         break;
483                                 }
484                                 if (++j >= a->nr[!curr]) {
485                                         j = 0;
486                                 }
487                         }
488                         while (j != j0);
489                 }
490
491                 printf("%s; %s", timestr, pfield(a->hdr_line, FIRST));
492                 if (!found && DISPLAY_DEBUG_MODE(flags)) {
493                         printf(" [NEW]");
494                 }
495                 printf("; %u;", ssc->line);
496                 if (!found) {
497                         printf("\n");
498                         continue;
499                 }
500
501                 printf(" %s", pfield(NULL, 0));
502                 pval((unsigned long long) ssp->rx, (unsigned long long)ssc->rx);
503                 printf(" %s", pfield(NULL, 0));
504                 pval((unsigned long long) ssp->tx, (unsigned long long) ssc->tx);
505                 printf(" %s", pfield(NULL, 0));
506                 pval((unsigned long long) ssp->frame, (unsigned long long) ssc->frame);
507                 printf(" %s", pfield(NULL, 0));
508                 pval((unsigned long long) ssp->parity, (unsigned long long) ssc->parity);
509                 printf(" %s", pfield(NULL, 0));
510                 pval((unsigned long long) ssp->brk, (unsigned long long) ssc->brk);
511                 printf(" %s", pfield(NULL, 0));
512                 pval((unsigned long long) ssp->overrun, (unsigned long long) ssc->overrun);
513                 printf("\n");
514         }
515 }
516
517 /*
518  ***************************************************************************
519  * Display disks statistics in raw format.
520  *
521  * IN:
522  * @a           Activity structure with statistics.
523  * @timestr     Time for current statistics sample.
524  * @curr        Index in array for current sample statistics.
525  ***************************************************************************
526  */
527 __print_funct_t raw_print_disk_stats(struct activity *a, char *timestr, int curr)
528 {
529         int i, j;
530         struct stats_disk *sdc, *sdp, sdpzero;
531         char *dev_name;
532
533         memset(&sdpzero, 0, STATS_DISK_SIZE);
534
535         for (i = 0; i < a->nr[curr]; i++) {
536
537                 sdc = (struct stats_disk *) ((char *) a->buf[curr] + i * a->msize);
538
539                 /* Get device name */
540                 dev_name = get_sa_devname(sdc->major, sdc->minor,
541                                           sdc->wwn, sdc->part_nr, flags);
542
543                 if (a->item_list != NULL) {
544                         /* A list of devices has been entered on the command line */
545                         if (!search_list_item(a->item_list, dev_name))
546                                 /* Device not found */
547                                 continue;
548                 }
549
550                 printf("%s; major; %u; minor; %u; %s",
551                        timestr, sdc->major, sdc->minor, pfield(a->hdr_line, FIRST));
552
553                 j = check_disk_reg(a, curr, !curr, i);
554                 if (j < 0) {
555                         /* This is a newly registered interface. Previous stats are zero */
556                         sdp = &sdpzero;
557                         if (DISPLAY_DEBUG_MODE(flags)) {
558                                 printf(" [%s]", j == -1 ? "NEW" : "BCK");
559                         }
560                 }
561                 else {
562                         sdp = (struct stats_disk *) ((char *) a->buf[!curr] + j * a->msize);
563                 }
564
565                 printf("; %s;", dev_name);
566                 printf(" %s", pfield(NULL, 0));
567                 pval(sdp->nr_ios, sdc->nr_ios);
568                 printf(" %s", pfield(NULL, 0));
569                 pval((unsigned long long) sdp->rd_sect, (unsigned long long) sdc->rd_sect);
570                 printf(" %s", pfield(NULL, 0));
571                 pval((unsigned long long) sdp->wr_sect, (unsigned long long) sdc->wr_sect);
572                 printf(" %s", pfield(NULL, 0));
573                 pval((unsigned long long) sdp->dc_sect, (unsigned long long) sdc->dc_sect);
574                 printf(" rd_ticks");
575                 pval((unsigned long long) sdp->rd_ticks, (unsigned long long) sdc->rd_ticks);
576                 printf(" wr_ticks");
577                 pval((unsigned long long) sdp->wr_ticks, (unsigned long long) sdc->wr_ticks);
578                 printf(" dc_ticks");
579                 pval((unsigned long long) sdp->dc_ticks, (unsigned long long) sdc->dc_ticks);
580                 printf(" tot_ticks");
581                 pval((unsigned long long) sdp->tot_ticks, (unsigned long long) sdc->tot_ticks);
582                 pfield(NULL, 0); /* Skip areq-sz */
583                 printf(" %s", pfield(NULL, 0));
584                 pval((unsigned long long) sdp->rq_ticks, (unsigned long long) sdc->rq_ticks);
585                 printf("\n");
586         }
587 }
588
589 /*
590  ***************************************************************************
591  * Display network interfaces statistics in raw format.
592  *
593  * IN:
594  * @a           Activity structure with statistics.
595  * @timestr     Time for current statistics sample.
596  * @curr        Index in array for current sample statistics.
597  ***************************************************************************
598  */
599 __print_funct_t raw_print_net_dev_stats(struct activity *a, char *timestr, int curr)
600 {
601         int i, j;
602         struct stats_net_dev *sndc, *sndp, sndzero;
603
604         memset(&sndzero, 0, STATS_NET_DEV_SIZE);
605
606         for (i = 0; i < a->nr[curr]; i++) {
607
608                 sndc = (struct stats_net_dev *) ((char *) a->buf[curr] + i * a->msize);
609
610                 if (a->item_list != NULL) {
611                         /* A list of devices has been entered on the command line */
612                         if (!search_list_item(a->item_list, sndc->interface))
613                                 /* Device not found */
614                                 continue;
615                 }
616
617                 printf("%s; %s", timestr, pfield(a->hdr_line, FIRST));
618                 j = check_net_dev_reg(a, curr, !curr, i);
619                 if (j < 0) {
620                         /* This is a newly registered interface. Previous stats are zero */
621                         sndp = &sndzero;
622                         if (DISPLAY_DEBUG_MODE(flags)) {
623                                 printf(" [%s]", j == -1 ? "NEW" : "BCK");
624                         }
625                 }
626                 else {
627                         sndp = (struct stats_net_dev *) ((char *) a->buf[!curr] + j * a->msize);
628                 }
629                 printf("; %s;", sndc->interface);
630
631                 printf(" %s", pfield(NULL, 0));
632                 pval(sndp->rx_packets, sndc->rx_packets);
633                 printf(" %s", pfield(NULL, 0));
634                 pval(sndp->tx_packets, sndc->tx_packets);
635                 printf(" %s", pfield(NULL, 0));
636                 pval(sndp->rx_bytes, sndc->rx_bytes);
637                 printf(" %s", pfield(NULL, 0));
638                 pval(sndp->tx_bytes, sndc->tx_bytes);
639                 printf(" %s", pfield(NULL, 0));
640                 pval(sndp->rx_compressed, sndc->rx_compressed);
641                 printf(" %s", pfield(NULL, 0));
642                 pval(sndp->tx_compressed, sndc->tx_compressed);
643                 printf(" %s", pfield(NULL, 0));
644                 pval(sndp->multicast, sndc->multicast);
645                 printf(" speed; %u; duplex; %u;\n", sndc->speed, sndc->duplex);
646         }
647 }
648
649 /*
650  ***************************************************************************
651  * Display network interfaces errors statistics in raw format.
652  *
653  * IN:
654  * @a           Activity structure with statistics.
655  * @timestr     Time for current statistics sample.
656  * @curr        Index in array for current sample statistics.
657  ***************************************************************************
658  */
659 __print_funct_t raw_print_net_edev_stats(struct activity *a, char *timestr, int curr)
660 {
661         int i, j;
662         struct stats_net_edev *snedc, *snedp, snedzero;
663
664         memset(&snedzero, 0, STATS_NET_EDEV_SIZE);
665
666         for (i = 0; i < a->nr[curr]; i++) {
667
668                 snedc = (struct stats_net_edev *) ((char *) a->buf[curr] + i * a->msize);
669
670                 if (a->item_list != NULL) {
671                         /* A list of devices has been entered on the command line */
672                         if (!search_list_item(a->item_list, snedc->interface))
673                                 /* Device not found */
674                                 continue;
675                 }
676
677                 printf("%s; %s", timestr, pfield(a->hdr_line, FIRST));
678                 j = check_net_edev_reg(a, curr, !curr, i);
679                 if (j < 0) {
680                         /* This is a newly registered interface. Previous stats are zero */
681                         snedp = &snedzero;
682                         if (DISPLAY_DEBUG_MODE(flags)) {
683                                 printf(" [%s]", j == -1 ? "NEW" : "BCK");
684                         }
685                 }
686                 else {
687                         snedp = (struct stats_net_edev *) ((char *) a->buf[!curr] + j * a->msize);
688                 }
689                 printf("; %s;", snedc->interface);
690
691                 printf(" %s", pfield(NULL, 0));
692                 pval(snedp->rx_errors, snedc->rx_errors);
693                 printf(" %s", pfield(NULL, 0));
694                 pval(snedp->tx_errors, snedc->tx_errors);
695                 printf(" %s", pfield(NULL, 0));
696                 pval(snedp->collisions, snedc->collisions);
697                 printf(" %s", pfield(NULL, 0));
698                 pval(snedp->rx_dropped, snedc->rx_dropped);
699                 printf(" %s", pfield(NULL, 0));
700                 pval(snedp->tx_dropped, snedc->tx_dropped);
701                 printf(" %s", pfield(NULL, 0));
702                 pval(snedp->tx_carrier_errors, snedc->tx_carrier_errors);
703                 printf(" %s", pfield(NULL, 0));
704                 pval(snedp->rx_frame_errors, snedc->rx_frame_errors);
705                 printf(" %s", pfield(NULL, 0));
706                 pval(snedp->rx_fifo_errors, snedc->rx_fifo_errors);
707                 printf(" %s", pfield(NULL, 0));
708                 pval(snedp->tx_fifo_errors, snedc->tx_fifo_errors);
709                 printf("\n");
710         }
711 }
712
713 /*
714  ***************************************************************************
715  * Display NFS client statistics in raw format.
716  *
717  * IN:
718  * @a           Activity structure with statistics.
719  * @timestr     Time for current statistics sample.
720  * @curr        Index in array for current sample statistics.
721  ***************************************************************************
722  */
723 __print_funct_t raw_print_net_nfs_stats(struct activity *a, char *timestr, int curr)
724 {
725         struct stats_net_nfs
726                 *snnc = (struct stats_net_nfs *) a->buf[curr],
727                 *snnp = (struct stats_net_nfs *) a->buf[!curr];
728
729         printf("%s; %s", timestr, pfield(a->hdr_line, FIRST));
730         pval((unsigned long long) snnp->nfs_rpccnt, (unsigned long long) snnc->nfs_rpccnt);
731         printf(" %s", pfield(NULL, 0));
732         pval((unsigned long long) snnp->nfs_rpcretrans, (unsigned long long) snnc->nfs_rpcretrans);
733         printf(" %s", pfield(NULL, 0));
734         pval((unsigned long long) snnp->nfs_readcnt, (unsigned long long) snnc->nfs_readcnt);
735         printf(" %s", pfield(NULL, 0));
736         pval((unsigned long long) snnp->nfs_writecnt, (unsigned long long) snnc->nfs_writecnt);
737         printf(" %s", pfield(NULL, 0));
738         pval((unsigned long long) snnp->nfs_accesscnt, (unsigned long long) snnc->nfs_accesscnt);
739         printf(" %s", pfield(NULL, 0));
740         pval((unsigned long long) snnp->nfs_getattcnt, (unsigned long long) snnc->nfs_getattcnt);
741         printf("\n");
742 }
743
744 /*
745  ***************************************************************************
746  * Display NFS server statistics in raw format.
747  *
748  * IN:
749  * @a           Activity structure with statistics.
750  * @timestr     Time for current statistics sample.
751  * @curr        Index in array for current sample statistics.
752  ***************************************************************************
753  */
754 __print_funct_t raw_print_net_nfsd_stats(struct activity *a, char *timestr, int curr)
755 {
756         struct stats_net_nfsd
757                 *snndc = (struct stats_net_nfsd *) a->buf[curr],
758                 *snndp = (struct stats_net_nfsd *) a->buf[!curr];
759
760         printf("%s; %s", timestr, pfield(a->hdr_line, FIRST));
761         pval((unsigned long long) snndp->nfsd_rpccnt, (unsigned long long) snndc->nfsd_rpccnt);
762         printf(" %s", pfield(NULL, 0));
763         pval((unsigned long long) snndp->nfsd_rpcbad, (unsigned long long) snndc->nfsd_rpcbad);
764         printf(" %s", pfield(NULL, 0));
765         pval((unsigned long long) snndp->nfsd_netcnt, (unsigned long long) snndc->nfsd_netcnt);
766         printf(" %s", pfield(NULL, 0));
767         pval((unsigned long long) snndp->nfsd_netudpcnt, (unsigned long long) snndc->nfsd_netudpcnt);
768         printf(" %s", pfield(NULL, 0));
769         pval((unsigned long long) snndp->nfsd_nettcpcnt, (unsigned long long) snndc->nfsd_nettcpcnt);
770         printf(" %s", pfield(NULL, 0));
771         pval((unsigned long long) snndp->nfsd_rchits, (unsigned long long) snndc->nfsd_rchits);
772         printf(" %s", pfield(NULL, 0));
773         pval((unsigned long long) snndp->nfsd_rcmisses, (unsigned long long) snndc->nfsd_rcmisses);
774         printf(" %s", pfield(NULL, 0));
775         pval((unsigned long long) snndp->nfsd_readcnt, (unsigned long long) snndc->nfsd_readcnt);
776         printf(" %s", pfield(NULL, 0));
777         pval((unsigned long long) snndp->nfsd_writecnt, (unsigned long long) snndc->nfsd_writecnt);
778         printf(" %s", pfield(NULL, 0));
779         pval((unsigned long long) snndp->nfsd_accesscnt, (unsigned long long) snndc->nfsd_accesscnt);
780         printf(" %s", pfield(NULL, 0));
781         pval((unsigned long long) snndp->nfsd_getattcnt, (unsigned long long) snndc->nfsd_getattcnt);
782         printf("\n");
783 }
784
785 /*
786  ***************************************************************************
787  * Display network socket statistics in raw format.
788  *
789  * IN:
790  * @a           Activity structure with statistics.
791  * @timestr     Time for current statistics sample.
792  * @curr        Index in array for current sample statistics.
793  ***************************************************************************
794  */
795 __print_funct_t raw_print_net_sock_stats(struct activity *a, char *timestr, int curr)
796 {
797         struct stats_net_sock
798                 *snsc = (struct stats_net_sock *) a->buf[curr];
799
800         printf("%s; %s; %u;", timestr, pfield(a->hdr_line, FIRST), snsc->sock_inuse);
801         printf(" %s; %u;", pfield(NULL, 0), snsc->tcp_inuse);
802         printf(" %s; %u;", pfield(NULL, 0), snsc->udp_inuse);
803         printf(" %s; %u;", pfield(NULL, 0), snsc->raw_inuse);
804         printf(" %s; %u;", pfield(NULL, 0), snsc->frag_inuse);
805         printf(" %s; %u;", pfield(NULL, 0), snsc->tcp_tw);
806         printf("\n");
807 }
808
809 /*
810  ***************************************************************************
811  * Display IP network statistics in raw format.
812  *
813  * IN:
814  * @a           Activity structure with statistics.
815  * @timestr     Time for current statistics sample.
816  * @curr        Index in array for current sample statistics.
817  ***************************************************************************
818  */
819 __print_funct_t raw_print_net_ip_stats(struct activity *a, char *timestr, int curr)
820 {
821         struct stats_net_ip
822                 *snic = (struct stats_net_ip *) a->buf[curr],
823                 *snip = (struct stats_net_ip *) a->buf[!curr];
824
825         printf("%s; %s", timestr, pfield(a->hdr_line, FIRST));
826         pval(snip->InReceives, snic->InReceives);
827         printf(" %s", pfield(NULL, 0));
828         pval(snip->ForwDatagrams, snic->ForwDatagrams);
829         printf(" %s", pfield(NULL, 0));
830         pval(snip->InDelivers, snic->InDelivers);
831         printf(" %s", pfield(NULL, 0));
832         pval(snip->OutRequests, snic->OutRequests);
833         printf(" %s", pfield(NULL, 0));
834         pval(snip->ReasmReqds, snic->ReasmReqds);
835         printf(" %s", pfield(NULL, 0));
836         pval(snip->ReasmOKs, snic->ReasmOKs);
837         printf(" %s", pfield(NULL, 0));
838         pval(snip->FragOKs, snic->FragOKs);
839         printf(" %s", pfield(NULL, 0));
840         pval(snip->FragCreates, snic->FragCreates);
841         printf("\n");
842 }
843
844 /*
845  ***************************************************************************
846  * Display IP network errors statistics in raw format.
847  *
848  * IN:
849  * @a           Activity structure with statistics.
850  * @timestr     Time for current statistics sample.
851  * @curr        Index in array for current sample statistics.
852  ***************************************************************************
853  */
854 __print_funct_t raw_print_net_eip_stats(struct activity *a, char *timestr, int curr)
855 {
856         struct stats_net_eip
857                 *sneic = (struct stats_net_eip *) a->buf[curr],
858                 *sneip = (struct stats_net_eip *) a->buf[!curr];
859
860         printf("%s; %s", timestr, pfield(a->hdr_line, FIRST));
861         pval(sneip->InHdrErrors, sneic->InHdrErrors);
862         printf(" %s", pfield(NULL, 0));
863         pval(sneip->InAddrErrors, sneic->InAddrErrors);
864         printf(" %s", pfield(NULL, 0));
865         pval(sneip->InUnknownProtos, sneic->InUnknownProtos);
866         printf(" %s", pfield(NULL, 0));
867         pval(sneip->InDiscards, sneic->InDiscards);
868         printf(" %s", pfield(NULL, 0));
869         pval(sneip->OutDiscards, sneic->OutDiscards);
870         printf(" %s", pfield(NULL, 0));
871         pval(sneip->OutNoRoutes, sneic->OutNoRoutes);
872         printf(" %s", pfield(NULL, 0));
873         pval(sneip->ReasmFails, sneic->ReasmFails);
874         printf(" %s", pfield(NULL, 0));
875         pval(sneip->FragFails, sneic->FragFails);
876         printf("\n");
877 }
878
879 /*
880  ***************************************************************************
881  * Display ICMP network statistics in raw format.
882  *
883  * IN:
884  * @a           Activity structure with statistics.
885  * @timestr     Time for current statistics sample.
886  * @curr        Index in array for current sample statistics.
887  ***************************************************************************
888  */
889 __print_funct_t raw_print_net_icmp_stats(struct activity *a, char *timestr, int curr)
890 {
891         struct stats_net_icmp
892                 *snic = (struct stats_net_icmp *) a->buf[curr],
893                 *snip = (struct stats_net_icmp *) a->buf[!curr];
894
895         printf("%s; %s", timestr, pfield(a->hdr_line, FIRST));
896         pval((unsigned long long) snip->InMsgs, (unsigned long long) snic->InMsgs);
897         printf(" %s", pfield(NULL, 0));
898         pval((unsigned long long) snip->OutMsgs, (unsigned long long) snic->OutMsgs);
899         printf(" %s", pfield(NULL, 0));
900         pval((unsigned long long) snip->InEchos, (unsigned long long) snic->InEchos);
901         printf(" %s", pfield(NULL, 0));
902         pval((unsigned long long) snip->InEchoReps, (unsigned long long) snic->InEchoReps);
903         printf(" %s", pfield(NULL, 0));
904         pval((unsigned long long) snip->OutEchos, (unsigned long long) snic->OutEchos);
905         printf(" %s", pfield(NULL, 0));
906         pval((unsigned long long) snip->OutEchoReps, (unsigned long long) snic->OutEchoReps);
907         printf(" %s", pfield(NULL, 0));
908         pval((unsigned long long) snip->InTimestamps, (unsigned long long) snic->InTimestamps);
909         printf(" %s", pfield(NULL, 0));
910         pval((unsigned long long) snip->InTimestampReps, (unsigned long long) snic->InTimestampReps);
911         printf(" %s", pfield(NULL, 0));
912         pval((unsigned long long) snip->OutTimestamps, (unsigned long long) snic->OutTimestamps);
913         printf(" %s", pfield(NULL, 0));
914         pval((unsigned long long) snip->OutTimestampReps, (unsigned long long) snic->OutTimestampReps);
915         printf(" %s", pfield(NULL, 0));
916         pval((unsigned long long) snip->InAddrMasks, (unsigned long long) snic->InAddrMasks);
917         printf(" %s", pfield(NULL, 0));
918         pval((unsigned long long) snip->InAddrMaskReps, (unsigned long long) snic->InAddrMaskReps);
919         printf(" %s", pfield(NULL, 0));
920         pval((unsigned long long) snip->OutAddrMasks, (unsigned long long) snic->OutAddrMasks);
921         printf(" %s", pfield(NULL, 0));
922         pval((unsigned long long) snip->OutAddrMaskReps, (unsigned long long) snic->OutAddrMaskReps);
923         printf("\n");
924 }
925
926 /*
927  ***************************************************************************
928  * Display ICMP errors message statistics in raw format.
929  *
930  * IN:
931  * @a           Activity structure with statistics.
932  * @timestr     Time for current statistics sample.
933  * @curr        Index in array for current sample statistics.
934  ***************************************************************************
935  */
936 __print_funct_t raw_print_net_eicmp_stats(struct activity *a, char *timestr, int curr)
937 {
938         struct stats_net_eicmp
939                 *sneic = (struct stats_net_eicmp *) a->buf[curr],
940                 *sneip = (struct stats_net_eicmp *) a->buf[!curr];
941
942         printf("%s; %s", timestr, pfield(a->hdr_line, FIRST));
943         pval((unsigned long long) sneip->InErrors, (unsigned long long) sneic->InErrors);
944         printf(" %s", pfield(NULL, 0));
945         pval((unsigned long long) sneip->OutErrors, (unsigned long long) sneic->OutErrors);
946         printf(" %s", pfield(NULL, 0));
947         pval((unsigned long long) sneip->InDestUnreachs, (unsigned long long) sneic->InDestUnreachs);
948         printf(" %s", pfield(NULL, 0));
949         pval((unsigned long long) sneip->OutDestUnreachs, (unsigned long long) sneic->OutDestUnreachs);
950         printf(" %s", pfield(NULL, 0));
951         pval((unsigned long long) sneip->InTimeExcds, (unsigned long long) sneic->InTimeExcds);
952         printf(" %s", pfield(NULL, 0));
953         pval((unsigned long long) sneip->OutTimeExcds, (unsigned long long) sneic->OutTimeExcds);
954         printf(" %s", pfield(NULL, 0));
955         pval((unsigned long long) sneip->InParmProbs, (unsigned long long) sneic->InParmProbs);
956         printf(" %s", pfield(NULL, 0));
957         pval((unsigned long long) sneip->OutParmProbs, (unsigned long long) sneic->OutParmProbs);
958         printf(" %s", pfield(NULL, 0));
959         pval((unsigned long long) sneip->InSrcQuenchs, (unsigned long long) sneic->InSrcQuenchs);
960         printf(" %s", pfield(NULL, 0));
961         pval((unsigned long long) sneip->OutSrcQuenchs, (unsigned long long) sneic->OutSrcQuenchs);
962         printf(" %s", pfield(NULL, 0));
963         pval((unsigned long long) sneip->InRedirects, (unsigned long long) sneic->InRedirects);
964         printf(" %s", pfield(NULL, 0));
965         pval((unsigned long long) sneip->OutRedirects, (unsigned long long) sneic->OutRedirects);
966         printf("\n");
967 }
968
969 /*
970  ***************************************************************************
971  * Display TCP network statistics in raw format.
972  *
973  * IN:
974  * @a           Activity structure with statistics.
975  * @timestr     Time for current statistics sample.
976  * @curr        Index in array for current sample statistics.
977  ***************************************************************************
978  */
979 __print_funct_t raw_print_net_tcp_stats(struct activity *a, char *timestr, int curr)
980 {
981         struct stats_net_tcp
982                 *sntc = (struct stats_net_tcp *) a->buf[curr],
983                 *sntp = (struct stats_net_tcp *) a->buf[!curr];
984
985         printf("%s; %s", timestr, pfield(a->hdr_line, FIRST));
986         pval((unsigned long long) sntp->ActiveOpens, (unsigned long long) sntc->ActiveOpens);
987         printf(" %s", pfield(NULL, 0));
988         pval((unsigned long long) sntp->PassiveOpens, (unsigned long long) sntc->PassiveOpens);
989         printf(" %s", pfield(NULL, 0));
990         pval((unsigned long long) sntp->InSegs, (unsigned long long) sntc->InSegs);
991         printf(" %s", pfield(NULL, 0));
992         pval((unsigned long long) sntp->OutSegs, (unsigned long long) sntc->OutSegs);
993         printf("\n");
994 }
995
996 /*
997  ***************************************************************************
998  * Display TCP network errors statistics in raw format.
999  *
1000  * IN:
1001  * @a           Activity structure with statistics.
1002  * @timestr     Time for current statistics sample.
1003  * @curr        Index in array for current sample statistics.
1004  ***************************************************************************
1005  */
1006 __print_funct_t raw_print_net_etcp_stats(struct activity *a, char *timestr, int curr)
1007 {
1008         struct stats_net_etcp
1009                 *snetc = (struct stats_net_etcp *) a->buf[curr],
1010                 *snetp = (struct stats_net_etcp *) a->buf[!curr];
1011
1012         printf("%s; %s", timestr, pfield(a->hdr_line, FIRST));
1013         pval((unsigned long long) snetp->AttemptFails, (unsigned long long) snetc->AttemptFails);
1014         printf(" %s", pfield(NULL, 0));
1015         pval((unsigned long long) snetp->EstabResets, (unsigned long long) snetc->EstabResets);
1016         printf(" %s", pfield(NULL, 0));
1017         pval((unsigned long long) snetp->RetransSegs, (unsigned long long) snetc->RetransSegs);
1018         printf(" %s", pfield(NULL, 0));
1019         pval((unsigned long long) snetp->InErrs, (unsigned long long) snetc->InErrs);
1020         printf(" %s", pfield(NULL, 0));
1021         pval((unsigned long long) snetp->OutRsts, (unsigned long long) snetc->OutRsts);
1022         printf("\n");
1023 }
1024
1025 /*
1026  ***************************************************************************
1027  * Display UDP network statistics in raw format.
1028  *
1029  * IN:
1030  * @a           Activity structure with statistics.
1031  * @timestr     Time for current statistics sample.
1032  * @curr        Index in array for current sample statistics.
1033  ***************************************************************************
1034  */
1035 __print_funct_t raw_print_net_udp_stats(struct activity *a, char *timestr, int curr)
1036 {
1037         struct stats_net_udp
1038                 *snuc = (struct stats_net_udp *) a->buf[curr],
1039                 *snup = (struct stats_net_udp *) a->buf[!curr];
1040
1041         printf("%s; %s", timestr, pfield(a->hdr_line, FIRST));
1042         pval((unsigned long long) snup->InDatagrams, (unsigned long long) snuc->InDatagrams);
1043         printf(" %s", pfield(NULL, 0));
1044         pval((unsigned long long) snup->OutDatagrams, (unsigned long long) snuc->OutDatagrams);
1045         printf(" %s", pfield(NULL, 0));
1046         pval((unsigned long long) snup->NoPorts, (unsigned long long) snuc->NoPorts);
1047         printf(" %s", pfield(NULL, 0));
1048         pval((unsigned long long) snup->InErrors, (unsigned long long) snuc->InErrors);
1049         printf("\n");
1050 }
1051
1052 /*
1053  ***************************************************************************
1054  * Display IPv6 network socket statistics in raw format.
1055  *
1056  * IN:
1057  * @a           Activity structure with statistics.
1058  * @timestr     Time for current statistics sample.
1059  * @curr        Index in array for current sample statistics.
1060  ***************************************************************************
1061  */
1062 __print_funct_t raw_print_net_sock6_stats(struct activity *a, char *timestr, int curr)
1063 {
1064         struct stats_net_sock6
1065                 *snsc = (struct stats_net_sock6 *) a->buf[curr];
1066
1067         printf("%s; %s; %u;", timestr, pfield(a->hdr_line, FIRST), snsc->tcp6_inuse);
1068         printf(" %s; %u;", pfield(NULL, 0), snsc->udp6_inuse);
1069         printf(" %s; %u;", pfield(NULL, 0), snsc->raw6_inuse);
1070         printf(" %s; %u;", pfield(NULL, 0), snsc->frag6_inuse);
1071         printf("\n");
1072 }
1073
1074 /*
1075  ***************************************************************************
1076  * Display IPv6 network statistics in raw format.
1077  *
1078  * IN:
1079  * @a           Activity structure with statistics.
1080  * @timestr     Time for current statistics sample.
1081  * @curr        Index in array for current sample statistics.
1082  ***************************************************************************
1083  */
1084 __print_funct_t raw_print_net_ip6_stats(struct activity *a, char *timestr, int curr)
1085 {
1086         struct stats_net_ip6
1087                 *snic = (struct stats_net_ip6 *) a->buf[curr],
1088                 *snip = (struct stats_net_ip6 *) a->buf[!curr];
1089
1090         printf("%s; %s", timestr, pfield(a->hdr_line, FIRST));
1091         pval(snip->InReceives6, snic->InReceives6);
1092         printf(" %s", pfield(NULL, 0));
1093         pval(snip->OutForwDatagrams6, snic->OutForwDatagrams6);
1094         printf(" %s", pfield(NULL, 0));
1095         pval(snip->InDelivers6, snic->InDelivers6);
1096         printf(" %s", pfield(NULL, 0));
1097         pval(snip->OutRequests6, snic->OutRequests6);
1098         printf(" %s", pfield(NULL, 0));
1099         pval(snip->ReasmReqds6, snic->ReasmReqds6);
1100         printf(" %s", pfield(NULL, 0));
1101         pval(snip->ReasmOKs6, snic->ReasmOKs6);
1102         printf(" %s", pfield(NULL, 0));
1103         pval(snip->InMcastPkts6, snic->InMcastPkts6);
1104         printf(" %s", pfield(NULL, 0));
1105         pval(snip->OutMcastPkts6, snic->OutMcastPkts6);
1106         printf(" %s", pfield(NULL, 0));
1107         pval(snip->FragOKs6, snic->FragOKs6);
1108         printf(" %s", pfield(NULL, 0));
1109         pval(snip->FragCreates6, snic->FragCreates6);
1110         printf("\n");
1111 }
1112
1113 /*
1114  ***************************************************************************
1115  * Display IPv6 network errors statistics in raw format.
1116  *
1117  * IN:
1118  * @a           Activity structure with statistics.
1119  * @timestr     Time for current statistics sample.
1120  * @curr        Index in array for current sample statistics.
1121  ***************************************************************************
1122  */
1123 __print_funct_t raw_print_net_eip6_stats(struct activity *a, char *timestr, int curr)
1124 {
1125         struct stats_net_eip6
1126                 *sneic = (struct stats_net_eip6 *) a->buf[curr],
1127                 *sneip = (struct stats_net_eip6 *) a->buf[!curr];
1128
1129         printf("%s; %s", timestr, pfield(a->hdr_line, FIRST));
1130         pval(sneip->InHdrErrors6, sneic->InHdrErrors6);
1131         printf(" %s", pfield(NULL, 0));
1132         pval(sneip->InAddrErrors6, sneic->InAddrErrors6);
1133         printf(" %s", pfield(NULL, 0));
1134         pval(sneip->InUnknownProtos6, sneic->InUnknownProtos6);
1135         printf(" %s", pfield(NULL, 0));
1136         pval(sneip->InTooBigErrors6, sneic->InTooBigErrors6);
1137         printf(" %s", pfield(NULL, 0));
1138         pval(sneip->InDiscards6, sneic->InDiscards6);
1139         printf(" %s", pfield(NULL, 0));
1140         pval(sneip->OutDiscards6, sneic->OutDiscards6);
1141         printf(" %s", pfield(NULL, 0));
1142         pval(sneip->InNoRoutes6, sneic->InNoRoutes6);
1143         printf(" %s", pfield(NULL, 0));
1144         pval(sneip->OutNoRoutes6, sneic->OutNoRoutes6);
1145         printf(" %s", pfield(NULL, 0));
1146         pval(sneip->ReasmFails6, sneic->ReasmFails6);
1147         printf(" %s", pfield(NULL, 0));
1148         pval(sneip->FragFails6, sneic->FragFails6);
1149         printf(" %s", pfield(NULL, 0));
1150         pval(sneip->InTruncatedPkts6, sneic->InTruncatedPkts6);
1151         printf("\n");
1152 }
1153
1154 /*
1155  ***************************************************************************
1156  * Display ICMPv6 network statistics in raw format.
1157  *
1158  * IN:
1159  * @a           Activity structure with statistics.
1160  * @timestr     Time for current statistics sample.
1161  * @curr        Index in array for current sample statistics.
1162  ***************************************************************************
1163  */
1164 __print_funct_t raw_print_net_icmp6_stats(struct activity *a, char *timestr, int curr)
1165 {
1166         struct stats_net_icmp6
1167                 *snic = (struct stats_net_icmp6 *) a->buf[curr],
1168                 *snip = (struct stats_net_icmp6 *) a->buf[!curr];
1169
1170         printf("%s; %s", timestr, pfield(a->hdr_line, FIRST));
1171         pval((unsigned long long) snip->InMsgs6,
1172              (unsigned long long) snic->InMsgs6);
1173         printf(" %s", pfield(NULL, 0));
1174         pval((unsigned long long) snip->OutMsgs6,
1175              (unsigned long long) snic->OutMsgs6);
1176         printf(" %s", pfield(NULL, 0));
1177         pval((unsigned long long) snip->InEchos6,
1178              (unsigned long long) snic->InEchos6);
1179         printf(" %s", pfield(NULL, 0));
1180         pval((unsigned long long) snip->InEchoReplies6,
1181              (unsigned long long) snic->InEchoReplies6);
1182         printf(" %s", pfield(NULL, 0));
1183         pval((unsigned long long) snip->OutEchoReplies6,
1184              (unsigned long long) snic->OutEchoReplies6);
1185         printf(" %s", pfield(NULL, 0));
1186         pval((unsigned long long) snip->InGroupMembQueries6,
1187              (unsigned long long) snic->InGroupMembQueries6);
1188         printf(" %s", pfield(NULL, 0));
1189         pval((unsigned long long) snip->InGroupMembResponses6,
1190              (unsigned long long) snic->InGroupMembResponses6);
1191         printf(" %s", pfield(NULL, 0));
1192         pval((unsigned long long) snip->OutGroupMembResponses6,
1193              (unsigned long long) snic->OutGroupMembResponses6);
1194         printf(" %s", pfield(NULL, 0));
1195         pval((unsigned long long) snip->InGroupMembReductions6,
1196              (unsigned long long) snic->InGroupMembReductions6);
1197         printf(" %s", pfield(NULL, 0));
1198         pval((unsigned long long) snip->OutGroupMembReductions6,
1199              (unsigned long long) snic->OutGroupMembReductions6);
1200         printf(" %s", pfield(NULL, 0));
1201         pval((unsigned long long) snip->InRouterSolicits6,
1202              (unsigned long long) snic->InRouterSolicits6);
1203         printf(" %s", pfield(NULL, 0));
1204         pval((unsigned long long) snip->OutRouterSolicits6,
1205              (unsigned long long) snic->OutRouterSolicits6);
1206         printf(" %s", pfield(NULL, 0));
1207         pval((unsigned long long) snip->InRouterAdvertisements6,
1208              (unsigned long long) snic->InRouterAdvertisements6);
1209         printf(" %s", pfield(NULL, 0));
1210         pval((unsigned long long) snip->InNeighborSolicits6,
1211              (unsigned long long) snic->InNeighborSolicits6);
1212         printf(" %s", pfield(NULL, 0));
1213         pval((unsigned long long) snip->OutNeighborSolicits6,
1214              (unsigned long long) snic->OutNeighborSolicits6);
1215         printf(" %s", pfield(NULL, 0));
1216         pval((unsigned long long) snip->InNeighborAdvertisements6,
1217              (unsigned long long) snic->InNeighborAdvertisements6);
1218         printf(" %s", pfield(NULL, 0));
1219         pval((unsigned long long) snip->OutNeighborAdvertisements6,
1220              (unsigned long long) snic->OutNeighborAdvertisements6);
1221         printf("\n");
1222 }
1223
1224 /*
1225  ***************************************************************************
1226  * Display ICMPv6 error messages statistics in rw format.
1227  *
1228  * IN:
1229  * @a           Activity structure with statistics.
1230  * @timestr     Time for current statistics sample.
1231  * @curr        Index in array for current sample statistics.
1232  ***************************************************************************
1233  */
1234 __print_funct_t raw_print_net_eicmp6_stats(struct activity *a, char *timestr, int curr)
1235 {
1236         struct stats_net_eicmp6
1237                 *sneic = (struct stats_net_eicmp6 *) a->buf[curr],
1238                 *sneip = (struct stats_net_eicmp6 *) a->buf[!curr];
1239
1240         printf("%s; %s", timestr, pfield(a->hdr_line, FIRST));
1241         pval((unsigned long long) sneip->InErrors6, (unsigned long long) sneic->InErrors6);
1242         printf(" %s", pfield(NULL, 0));
1243         pval((unsigned long long) sneip->InDestUnreachs6, (unsigned long long) sneic->InDestUnreachs6);
1244         printf(" %s", pfield(NULL, 0));
1245         pval((unsigned long long) sneip->OutDestUnreachs6, (unsigned long long) sneic->OutDestUnreachs6);
1246         printf(" %s", pfield(NULL, 0));
1247         pval((unsigned long long) sneip->InTimeExcds6, (unsigned long long) sneic->InTimeExcds6);
1248         printf(" %s", pfield(NULL, 0));
1249         pval((unsigned long long) sneip->OutTimeExcds6, (unsigned long long) sneic->OutTimeExcds6);
1250         printf(" %s", pfield(NULL, 0));
1251         pval((unsigned long long) sneip->InParmProblems6, (unsigned long long) sneic->InParmProblems6);
1252         printf(" %s", pfield(NULL, 0));
1253         pval((unsigned long long) sneip->OutParmProblems6, (unsigned long long) sneic->OutParmProblems6);
1254         printf(" %s", pfield(NULL, 0));
1255         pval((unsigned long long) sneip->InRedirects6, (unsigned long long) sneic->InRedirects6);
1256         printf(" %s", pfield(NULL, 0));
1257         pval((unsigned long long) sneip->OutRedirects6, (unsigned long long) sneic->OutRedirects6);
1258         printf(" %s", pfield(NULL, 0));
1259         pval((unsigned long long) sneip->InPktTooBigs6, (unsigned long long) sneic->InPktTooBigs6);
1260         printf(" %s", pfield(NULL, 0));
1261         pval((unsigned long long) sneip->OutPktTooBigs6, (unsigned long long) sneic->OutPktTooBigs6);
1262         printf("\n");
1263 }
1264
1265 /*
1266  ***************************************************************************
1267  * Display UDPv6 network statistics in raw format.
1268  *
1269  * IN:
1270  * @a           Activity structure with statistics.
1271  * @timestr     Time for current statistics sample.
1272  * @curr        Index in array for current sample statistics.
1273  ***************************************************************************
1274  */
1275 __print_funct_t raw_print_net_udp6_stats(struct activity *a, char *timestr, int curr)
1276 {
1277         struct stats_net_udp6
1278                 *snuc = (struct stats_net_udp6 *) a->buf[curr],
1279                 *snup = (struct stats_net_udp6 *) a->buf[!curr];
1280
1281         printf("%s; %s", timestr, pfield(a->hdr_line, FIRST));
1282         pval((unsigned long long) snup->InDatagrams6, (unsigned long long) snuc->InDatagrams6);
1283         printf(" %s", pfield(NULL, 0));
1284         pval((unsigned long long) snup->OutDatagrams6, (unsigned long long) snuc->OutDatagrams6);
1285         printf(" %s", pfield(NULL, 0));
1286         pval((unsigned long long) snup->NoPorts6, (unsigned long long) snuc->NoPorts6);
1287         printf(" %s", pfield(NULL, 0));
1288         pval((unsigned long long) snup->InErrors6, (unsigned long long) snuc->InErrors6);
1289         printf("\n");
1290 }
1291
1292 /*
1293  ***************************************************************************
1294  * Display CPU frequency statistics in raw format.
1295  *
1296  * IN:
1297  * @a           Activity structure with statistics.
1298  * @timestr     Time for current statistics sample.
1299  * @curr        Index in array for current sample statistics.
1300  ***************************************************************************
1301  */
1302 __print_funct_t raw_print_pwr_cpufreq_stats(struct activity *a, char *timestr, int curr)
1303 {
1304         int i;
1305         struct stats_pwr_cpufreq *spc;
1306
1307         for (i = 0; (i < a->nr[curr]) && (i < a->bitmap->b_size + 1); i++) {
1308
1309                 spc = (struct stats_pwr_cpufreq *) ((char *) a->buf[curr] + i * a->msize);
1310
1311                 /* Should current CPU (including CPU "all") be displayed? */
1312                 if (a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))) {
1313                         /* Yes: Display it */
1314                         printf("%s; %s; %d;", timestr, pfield(a->hdr_line, FIRST), i - 1);
1315                         printf(" %s; %lu;\n", pfield(NULL, 0), spc->cpufreq);
1316                 }
1317         }
1318 }
1319
1320 /*
1321  ***************************************************************************
1322  * Display fan statistics in raw format.
1323  *
1324  * IN:
1325  * @a           Activity structure with statistics.
1326  * @timestr     Time for current statistics sample.
1327  * @curr        Index in array for current sample statistics.
1328  ***************************************************************************
1329  */
1330 __print_funct_t raw_print_pwr_fan_stats(struct activity *a, char *timestr, int curr)
1331 {
1332         int i;
1333         struct stats_pwr_fan *spc;
1334
1335         for (i = 0; i < a->nr[curr]; i++) {
1336                 spc = (struct stats_pwr_fan *) ((char *) a->buf[curr] + i * a->msize);
1337
1338                 printf("%s; %s; %d;", timestr, pfield(a->hdr_line, FIRST), i + 1);
1339                 printf(" %s; %s;", pfield(NULL, 0), spc->device);
1340                 printf(" %s; %f;", pfield(NULL, 0), spc->rpm);
1341                 printf(" rpm_min; %f;\n", spc->rpm_min);
1342         }
1343 }
1344
1345 /*
1346  ***************************************************************************
1347  * Display temperature statistics in raw format.
1348  *
1349  * IN:
1350  * @a           Activity structure with statistics.
1351  * @timestr     Time for current statistics sample.
1352  * @curr        Index in array for current sample statistics.
1353  ***************************************************************************
1354  */
1355 __print_funct_t raw_print_pwr_temp_stats(struct activity *a, char *timestr, int curr)
1356 {
1357         int i;
1358         struct stats_pwr_temp *spc;
1359
1360         for (i = 0; i < a->nr[curr]; i++) {
1361                 spc = (struct stats_pwr_temp *) ((char *) a->buf[curr] + i * a->msize);
1362
1363                 printf("%s; %s; %d;", timestr, pfield(a->hdr_line, FIRST), i + 1);
1364                 printf(" %s; %s;", pfield(NULL, 0), spc->device);
1365                 printf(" %s; %f;", pfield(NULL, 0), spc->temp);
1366                 printf(" temp_min; %f;", spc->temp_min);
1367                 printf(" temp_max; %f;\n", spc->temp_max);
1368         }
1369 }
1370
1371 /*
1372  ***************************************************************************
1373  * Display voltage inputs statistics in raw format.
1374  *
1375  * IN:
1376  * @a           Activity structure with statistics.
1377  * @timestr     Time for current statistics sample.
1378  * @curr        Index in array for current sample statistics.
1379  ***************************************************************************
1380  */
1381 __print_funct_t raw_print_pwr_in_stats(struct activity *a, char *timestr, int curr)
1382 {
1383         int i;
1384         struct stats_pwr_in *spc;
1385
1386         for (i = 0; i < a->nr[curr]; i++) {
1387                 spc = (struct stats_pwr_in *) ((char *) a->buf[curr] + i * a->msize);
1388
1389                 printf("%s; %s; %d;", timestr, pfield(a->hdr_line, FIRST), i);
1390                 printf(" %s; %s;", pfield(NULL, 0), spc->device);
1391                 printf(" %s; %f;", pfield(NULL, 0), spc->in);
1392                 printf(" in_min; %f;", spc->in_min);
1393                 printf(" in_max; %f;\n", spc->in_max);
1394         }
1395 }
1396
1397 /*
1398  ***************************************************************************
1399  * Display huge pages statistics in raw format.
1400  *
1401  * IN:
1402  * @a           Activity structure with statistics.
1403  * @timestr     Time for current statistics sample.
1404  * @curr        Index in array for current sample statistics.
1405  ***************************************************************************
1406  */
1407 __print_funct_t raw_print_huge_stats(struct activity *a, char *timestr, int curr)
1408 {
1409         struct stats_huge
1410                 *smc = (struct stats_huge *) a->buf[curr];
1411
1412         printf("%s; %s; %llu;", timestr, pfield(a->hdr_line, FIRST), smc->frhkb);
1413         printf(" hugtotal; %llu;", smc->tlhkb);
1414         pfield(NULL, 0); /* Skip kbhugused */
1415         pfield(NULL, 0); /* Skip %hugused */
1416         printf(" %s; %llu;", pfield(NULL, 0), smc->rsvdhkb);
1417         printf(" %s; %llu;\n", pfield(NULL, 0), smc->surphkb);
1418 }
1419
1420 /*
1421  ***************************************************************************
1422  * Display weighted CPU frequency statistics in raw format.
1423  *
1424  * IN:
1425  * @a           Activity structure with statistics.
1426  * @timestr     Time for current statistics sample.
1427  * @curr        Index in array for current sample statistics.
1428  ***************************************************************************
1429  */
1430 __print_funct_t raw_print_pwr_wghfreq_stats(struct activity *a, char *timestr, int curr)
1431 {
1432         int i, k;
1433         struct stats_pwr_wghfreq *spc, *spp, *spc_k, *spp_k;
1434
1435         for (i = 0; (i < a->nr[curr]) && (i < a->bitmap->b_size + 1); i++) {
1436
1437                 spc = (struct stats_pwr_wghfreq *) ((char *) a->buf[curr]  + i * a->msize * a->nr2);
1438                 spp = (struct stats_pwr_wghfreq *) ((char *) a->buf[!curr] + i * a->msize * a->nr2);
1439
1440                 /* Should current CPU (including CPU "all") be displayed? */
1441                 if (!(a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))))
1442                         /* No */
1443                         continue;
1444
1445                 printf("%s; %s; %d;", timestr, pfield(a->hdr_line, FIRST), i - 1);
1446
1447                 for (k = 0; k < a->nr2; k++) {
1448
1449                         spc_k = (struct stats_pwr_wghfreq *) ((char *) spc + k * a->msize);
1450                         if (!spc_k->freq)
1451                                 break;
1452                         spp_k = (struct stats_pwr_wghfreq *) ((char *) spp + k * a->msize);
1453
1454                         printf(" freq; %lu;", spc_k->freq);
1455                         printf(" tminst");
1456                         pval(spp_k->time_in_state, spc_k->time_in_state);
1457                 }
1458                 printf("\n");
1459         }
1460 }
1461
1462 /*
1463  ***************************************************************************
1464  * Display USB devices statistics in raw format.
1465  *
1466  * IN:
1467  * @a           Activity structure with statistics.
1468  * @timestr     Time for current statistics sample.
1469  * @curr        Index in array for current sample statistics.
1470  ***************************************************************************
1471  */
1472 __print_funct_t raw_print_pwr_usb_stats(struct activity *a, char *timestr, int curr)
1473 {
1474         int i;
1475         struct stats_pwr_usb *suc;
1476
1477         for (i = 0; i < a->nr[curr]; i++) {
1478                 suc = (struct stats_pwr_usb *) ((char *) a->buf[curr] + i * a->msize);
1479
1480                 printf("%s; %s; \"%s\";", timestr, pfield(a->hdr_line, FIRST), suc->manufacturer);
1481                 printf(" %s; \"%s\";", pfield(NULL, 0), suc->product);
1482                 printf(" %s; %d;", pfield(NULL, 0), suc->bus_nr);
1483                 printf(" %s; %x;", pfield(NULL, 0), suc->vendor_id);
1484                 printf(" %s; %x;", pfield(NULL, 0), suc->product_id);
1485                 printf(" %s; %u;\n", pfield(NULL, 0), suc->bmaxpower);
1486         }
1487 }
1488
1489 /*
1490  ***************************************************************************
1491  * Display filesystems statistics in raw format.
1492  *
1493  * IN:
1494  * @a           Activity structure with statistics.
1495  * @timestr     Time for current statistics sample.
1496  * @curr        Index in array for current sample statistics.
1497  ***************************************************************************
1498  */
1499 __print_funct_t raw_print_filesystem_stats(struct activity *a, char *timestr, int curr)
1500 {
1501         int i;
1502         struct stats_filesystem *sfc;
1503
1504         for (i = 0; i < a->nr[curr]; i++) {
1505                 sfc = (struct stats_filesystem *) ((char *) a->buf[curr] + i * a->msize);
1506
1507                 if (a->item_list != NULL) {
1508                         /* A list of devices has been entered on the command line */
1509                         if (!search_list_item(a->item_list,
1510                                               DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name))
1511                                 /* Device not found */
1512                                 continue;
1513                 }
1514
1515                 printf("%s; %s; \"%s\";", timestr, pfield(a->hdr_line, FIRST + DISPLAY_MOUNT(a->opt_flags)),
1516                        DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name);
1517                 printf(" f_bfree; %llu;", sfc->f_bfree);
1518                 printf(" f_blocks; %llu;", sfc->f_blocks);
1519                 printf(" f_bavail; %llu;", sfc->f_bavail);
1520                 pfield(NULL, 0); /* Skip MBfsfree */
1521                 pfield(NULL, 0); /* Skip MBfsused */
1522                 pfield(NULL, 0); /* Skip %fsused */
1523                 pfield(NULL, 0); /* Skip %ufsused */
1524                 printf(" %s; %llu;", pfield(NULL, 0), sfc->f_ffree);
1525                 printf(" f_files; %llu;\n", sfc->f_files);
1526
1527         }
1528 }
1529
1530 /*
1531  ***************************************************************************
1532  * Display Fibre Channel HBA statistics in raw format.
1533  *
1534  * IN:
1535  * @a           Activity structure with statistics.
1536  * @timestr     Time for current statistics sample.
1537  * @curr        Index in array for current sample statistics.
1538  ***************************************************************************
1539  */
1540 __print_funct_t raw_print_fchost_stats(struct activity *a, char *timestr, int curr)
1541 {
1542         int i, j, j0, found;
1543         struct stats_fchost *sfcc, *sfcp, sfczero;
1544
1545         memset(&sfczero, 0, sizeof(struct stats_fchost));
1546
1547         for (i = 0; i < a->nr[curr]; i++) {
1548
1549                 found = FALSE;
1550                 sfcc = (struct stats_fchost *) ((char *) a->buf[curr] + i * a->msize);
1551
1552                 if (a->nr[!curr] > 0) {
1553                         /* Look for corresponding structure in previous iteration */
1554                         j = i;
1555
1556                         if (j >= a->nr[!curr]) {
1557                                 j = a->nr[!curr] - 1;
1558                         }
1559
1560                         j0 = j;
1561
1562                         do {
1563                                 sfcp = (struct stats_fchost *) ((char *) a->buf[!curr] + j * a->msize);
1564                                 if (!strcmp(sfcc->fchost_name, sfcp->fchost_name)) {
1565                                         found = TRUE;
1566                                         break;
1567                                 }
1568                                 if (++j >= a->nr[!curr]) {
1569                                         j = 0;
1570                                 }
1571                         }
1572                         while (j != j0);
1573                 }
1574
1575                 printf("%s; %s", timestr, pfield(a->hdr_line, FIRST));
1576
1577                 if (!found) {
1578                         /* This is a newly registered host. Previous stats are zero */
1579                         sfcp = &sfczero;
1580                         if (DISPLAY_DEBUG_MODE(flags)) {
1581                                 printf(" [NEW]");
1582                         }
1583                 }
1584
1585                 printf("; %s;", sfcc->fchost_name);
1586                 printf(" %s", pfield(NULL, 0));
1587                 pval((unsigned long long) sfcp->f_rxframes, (unsigned long long) sfcc->f_rxframes);
1588                 printf(" %s", pfield(NULL, 0));
1589                 pval((unsigned long long) sfcp->f_txframes, (unsigned long long) sfcc->f_txframes);
1590                 printf(" %s", pfield(NULL, 0));
1591                 pval((unsigned long long) sfcp->f_rxwords, (unsigned long long) sfcc->f_rxwords);
1592                 printf(" %s", pfield(NULL, 0));
1593                 pval((unsigned long long) sfcp->f_txwords, (unsigned long long) sfcc->f_txwords);
1594                 printf("\n");
1595         }
1596 }
1597
1598 /*
1599  ***************************************************************************
1600  * Display softnet statistics in raw format.
1601  *
1602  * IN:
1603  * @a           Activity structure with statistics.
1604  * @timestr     Time for current statistics sample.
1605  * @curr        Index in array for current sample statistics.
1606  ***************************************************************************
1607  */
1608 __print_funct_t raw_print_softnet_stats(struct activity *a, char *timestr, int curr)
1609 {
1610         int i;
1611         struct stats_softnet *ssnc, *ssnp;
1612
1613         /* @nr[curr] cannot normally be greater than @nr_ini */
1614         if (a->nr[curr] > a->nr_ini) {
1615                 a->nr_ini = a->nr[curr];
1616         }
1617
1618         /* Don't display CPU "all" which doesn't exist in file */
1619         for (i = 1; (i < a->nr_ini) && (i < a->bitmap->b_size + 1); i++) {
1620
1621                 /*
1622                  * The size of a->buf[...] CPU structure may be different from the default
1623                  * sizeof(struct stats_pwr_cpufreq) value if data have been read from a file!
1624                  * That's why we don't use a syntax like:
1625                  * ssnc = (struct stats_softnet *) a->buf[...] + i;
1626                  */
1627                 ssnc = (struct stats_softnet *) ((char *) a->buf[curr]  + i * a->msize);
1628                 ssnp = (struct stats_softnet *) ((char *) a->buf[!curr] + i * a->msize);
1629
1630                 /*
1631                  * Note: a->nr is in [1, NR_CPUS + 1].
1632                  * Bitmap size is provided for (NR_CPUS + 1) CPUs.
1633                  * Anyway, NR_CPUS may vary between the version of sysstat
1634                  * used by sadc to create a file, and the version of sysstat
1635                  * used by sar to read it...
1636                  */
1637
1638                 /* Should current CPU (including CPU "all") be displayed? */
1639                 if (!(a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))))
1640                         /* No */
1641                         continue;
1642
1643                 /* Yes: Display current CPU stats */
1644                 printf("%s; %s", timestr, pfield(a->hdr_line, FIRST));
1645                 if (DISPLAY_DEBUG_MODE(flags) && i) {
1646                         if (ssnc->processed + ssnc->dropped + ssnc->time_squeeze +
1647                             ssnc->received_rps + ssnc->flow_limit == 0) {
1648                                 /* CPU is considered offline */
1649                                 printf(" [OFF]");
1650                         }
1651                 }
1652                 printf("; %d;", i - 1);
1653
1654                 printf(" %s", pfield(NULL, 0));
1655                 pval((unsigned long long) ssnp->processed, (unsigned long long) ssnc->processed);
1656                 printf(" %s", pfield(NULL, 0));
1657                 pval((unsigned long long) ssnp->dropped, (unsigned long long) ssnc->dropped);
1658                 printf(" %s", pfield(NULL, 0));
1659                 pval((unsigned long long) ssnp->time_squeeze, (unsigned long long) ssnc->time_squeeze);
1660                 printf(" %s", pfield(NULL, 0));
1661                 pval((unsigned long long) ssnp->received_rps, (unsigned long long) ssnc->received_rps);
1662                 printf(" %s", pfield(NULL, 0));
1663                 pval((unsigned long long) ssnp->flow_limit, (unsigned long long) ssnc->flow_limit);
1664                 printf("\n");
1665         }
1666 }
1667
1668 /*
1669  ***************************************************************************
1670  * Display pressure-stall CPU statistics in raw format.
1671  *
1672  * IN:
1673  * @a           Activity structure with statistics.
1674  * @timestr     Time for current statistics sample.
1675  * @curr        Index in array for current sample statistics.
1676  ***************************************************************************
1677  */
1678 __print_funct_t raw_print_psicpu_stats(struct activity *a, char *timestr, int curr)
1679 {
1680         struct stats_psi_cpu
1681                 *psic = (struct stats_psi_cpu *) a->buf[curr],
1682                 *psip = (struct stats_psi_cpu *) a->buf[!curr];
1683
1684         printf("%s; %s; %lu;", timestr, pfield(a->hdr_line, FIRST), psic->some_acpu_10);
1685         printf(" %s; %lu;", pfield(NULL, 0), psic->some_acpu_60);
1686         printf(" %s; %lu;", pfield(NULL, 0), psic->some_acpu_300);
1687         printf(" %s", pfield(NULL, 0));
1688         pval((unsigned long long) psip->some_cpu_total, (unsigned long long) psic->some_cpu_total);
1689         printf("\n");
1690 }
1691
1692 /*
1693  ***************************************************************************
1694  * Display pressure-stall I/O statistics in raw format.
1695  *
1696  * IN:
1697  * @a           Activity structure with statistics.
1698  * @timestr     Time for current statistics sample.
1699  * @curr        Index in array for current sample statistics.
1700  ***************************************************************************
1701  */
1702 __print_funct_t raw_print_psiio_stats(struct activity *a, char *timestr, int curr)
1703 {
1704         struct stats_psi_io
1705                 *psic = (struct stats_psi_io *) a->buf[curr],
1706                 *psip = (struct stats_psi_io *) a->buf[!curr];
1707
1708         printf("%s; %s; %lu;", timestr, pfield(a->hdr_line, FIRST), psic->some_aio_10);
1709         printf(" %s; %lu;", pfield(NULL, 0), psic->some_aio_60);
1710         printf(" %s; %lu;", pfield(NULL, 0), psic->some_aio_300);
1711         printf(" %s", pfield(NULL, 0));
1712         pval((unsigned long long) psip->some_io_total, (unsigned long long) psic->some_io_total);
1713
1714         printf(" %s; %lu;", pfield(NULL, 0), psic->full_aio_10);
1715         printf(" %s; %lu;", pfield(NULL, 0), psic->full_aio_60);
1716         printf(" %s; %lu;", pfield(NULL, 0), psic->full_aio_300);
1717         printf(" %s", pfield(NULL, 0));
1718         pval((unsigned long long) psip->full_io_total, (unsigned long long) psic->full_io_total);
1719         printf("\n");
1720 }
1721
1722 /*
1723  ***************************************************************************
1724  * Display pressure-stall mem statistics in raw format.
1725  *
1726  * IN:
1727  * @a           Activity structure with statistics.
1728  * @timestr     Time for current statistics sample.
1729  * @curr        Index in array for current sample statistics.
1730  ***************************************************************************
1731  */
1732 __print_funct_t raw_print_psimem_stats(struct activity *a, char *timestr, int curr)
1733 {
1734         struct stats_psi_mem
1735                 *psic = (struct stats_psi_mem *) a->buf[curr],
1736                 *psip = (struct stats_psi_mem *) a->buf[!curr];
1737
1738         printf("%s; %s; %lu;", timestr, pfield(a->hdr_line, FIRST), psic->some_amem_10);
1739         printf(" %s; %lu;", pfield(NULL, 0), psic->some_amem_60);
1740         printf(" %s; %lu;", pfield(NULL, 0), psic->some_amem_300);
1741         printf(" %s", pfield(NULL, 0));
1742         pval((unsigned long long) psip->some_mem_total, (unsigned long long) psic->some_mem_total);
1743
1744         printf(" %s; %lu;", pfield(NULL, 0), psic->full_amem_10);
1745         printf(" %s; %lu;", pfield(NULL, 0), psic->full_amem_60);
1746         printf(" %s; %lu;", pfield(NULL, 0), psic->full_amem_300);
1747         printf(" %s", pfield(NULL, 0));
1748         pval((unsigned long long) psip->full_mem_total, (unsigned long long) psic->full_mem_total);
1749         printf("\n");
1750 }