]> granicus.if.org Git - sysstat/blob - raw_stats.c
sar/sadf: Test values returned by functions
[sysstat] / raw_stats.c
1 /*
2  * raw_stats.c: Functions used by sar to display statistics in raw format.
3  * (C) 1999-2020 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 uint64_t 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_device_name(sdc->major, sdc->minor, sdc->wwn, sdc->part_nr,
541                                            DISPLAY_PRETTY(flags), DISPLAY_PERSIST_NAME_S(flags),
542                                            USE_STABLE_ID(flags), NULL);
543
544                 if (a->item_list != NULL) {
545                         /* A list of devices has been entered on the command line */
546                         if (!search_list_item(a->item_list, dev_name))
547                                 /* Device not found */
548                                 continue;
549                 }
550
551                 printf("%s; major; %u; minor; %u; %s",
552                        timestr, sdc->major, sdc->minor, pfield(a->hdr_line, FIRST));
553
554                 j = check_disk_reg(a, curr, !curr, i);
555                 if (j < 0) {
556                         /* This is a newly registered interface. Previous stats are zero */
557                         sdp = &sdpzero;
558                         if (DISPLAY_DEBUG_MODE(flags)) {
559                                 printf(" [%s]", j == -1 ? "NEW" : "BCK");
560                         }
561                 }
562                 else {
563                         sdp = (struct stats_disk *) ((char *) a->buf[!curr] + j * a->msize);
564                 }
565
566                 printf("; %s;", dev_name);
567                 printf(" %s", pfield(NULL, 0));
568                 pval(sdp->nr_ios, sdc->nr_ios);
569                 printf(" %s", pfield(NULL, 0));
570                 pval((unsigned long long) sdp->rd_sect, (unsigned long long) sdc->rd_sect);
571                 printf(" %s", pfield(NULL, 0));
572                 pval((unsigned long long) sdp->wr_sect, (unsigned long long) sdc->wr_sect);
573                 printf(" %s", pfield(NULL, 0));
574                 pval((unsigned long long) sdp->dc_sect, (unsigned long long) sdc->dc_sect);
575                 printf(" rd_ticks");
576                 pval((unsigned long long) sdp->rd_ticks, (unsigned long long) sdc->rd_ticks);
577                 printf(" wr_ticks");
578                 pval((unsigned long long) sdp->wr_ticks, (unsigned long long) sdc->wr_ticks);
579                 printf(" dc_ticks");
580                 pval((unsigned long long) sdp->dc_ticks, (unsigned long long) sdc->dc_ticks);
581                 printf(" tot_ticks");
582                 pval((unsigned long long) sdp->tot_ticks, (unsigned long long) sdc->tot_ticks);
583                 pfield(NULL, 0); /* Skip areq-sz */
584                 printf(" %s", pfield(NULL, 0));
585                 pval((unsigned long long) sdp->rq_ticks, (unsigned long long) sdc->rq_ticks);
586                 printf("\n");
587         }
588 }
589
590 /*
591  ***************************************************************************
592  * Display network interfaces statistics in raw format.
593  *
594  * IN:
595  * @a           Activity structure with statistics.
596  * @timestr     Time for current statistics sample.
597  * @curr        Index in array for current sample statistics.
598  ***************************************************************************
599  */
600 __print_funct_t raw_print_net_dev_stats(struct activity *a, char *timestr, int curr)
601 {
602         int i, j;
603         struct stats_net_dev *sndc, *sndp, sndzero;
604
605         memset(&sndzero, 0, STATS_NET_DEV_SIZE);
606
607         for (i = 0; i < a->nr[curr]; i++) {
608
609                 sndc = (struct stats_net_dev *) ((char *) a->buf[curr] + i * a->msize);
610
611                 if (a->item_list != NULL) {
612                         /* A list of devices has been entered on the command line */
613                         if (!search_list_item(a->item_list, sndc->interface))
614                                 /* Device not found */
615                                 continue;
616                 }
617
618                 printf("%s; %s", timestr, pfield(a->hdr_line, FIRST));
619                 j = check_net_dev_reg(a, curr, !curr, i);
620                 if (j < 0) {
621                         /* This is a newly registered interface. Previous stats are zero */
622                         sndp = &sndzero;
623                         if (DISPLAY_DEBUG_MODE(flags)) {
624                                 printf(" [%s]", j == -1 ? "NEW" : "BCK");
625                         }
626                 }
627                 else {
628                         sndp = (struct stats_net_dev *) ((char *) a->buf[!curr] + j * a->msize);
629                 }
630                 printf("; %s;", sndc->interface);
631
632                 printf(" %s", pfield(NULL, 0));
633                 pval(sndp->rx_packets, sndc->rx_packets);
634                 printf(" %s", pfield(NULL, 0));
635                 pval(sndp->tx_packets, sndc->tx_packets);
636                 printf(" %s", pfield(NULL, 0));
637                 pval(sndp->rx_bytes, sndc->rx_bytes);
638                 printf(" %s", pfield(NULL, 0));
639                 pval(sndp->tx_bytes, sndc->tx_bytes);
640                 printf(" %s", pfield(NULL, 0));
641                 pval(sndp->rx_compressed, sndc->rx_compressed);
642                 printf(" %s", pfield(NULL, 0));
643                 pval(sndp->tx_compressed, sndc->tx_compressed);
644                 printf(" %s", pfield(NULL, 0));
645                 pval(sndp->multicast, sndc->multicast);
646                 printf(" speed; %u; duplex; %u;\n", sndc->speed, sndc->duplex);
647         }
648 }
649
650 /*
651  ***************************************************************************
652  * Display network interfaces errors statistics in raw format.
653  *
654  * IN:
655  * @a           Activity structure with statistics.
656  * @timestr     Time for current statistics sample.
657  * @curr        Index in array for current sample statistics.
658  ***************************************************************************
659  */
660 __print_funct_t raw_print_net_edev_stats(struct activity *a, char *timestr, int curr)
661 {
662         int i, j;
663         struct stats_net_edev *snedc, *snedp, snedzero;
664
665         memset(&snedzero, 0, STATS_NET_EDEV_SIZE);
666
667         for (i = 0; i < a->nr[curr]; i++) {
668
669                 snedc = (struct stats_net_edev *) ((char *) a->buf[curr] + i * a->msize);
670
671                 if (a->item_list != NULL) {
672                         /* A list of devices has been entered on the command line */
673                         if (!search_list_item(a->item_list, snedc->interface))
674                                 /* Device not found */
675                                 continue;
676                 }
677
678                 printf("%s; %s", timestr, pfield(a->hdr_line, FIRST));
679                 j = check_net_edev_reg(a, curr, !curr, i);
680                 if (j < 0) {
681                         /* This is a newly registered interface. Previous stats are zero */
682                         snedp = &snedzero;
683                         if (DISPLAY_DEBUG_MODE(flags)) {
684                                 printf(" [%s]", j == -1 ? "NEW" : "BCK");
685                         }
686                 }
687                 else {
688                         snedp = (struct stats_net_edev *) ((char *) a->buf[!curr] + j * a->msize);
689                 }
690                 printf("; %s;", snedc->interface);
691
692                 printf(" %s", pfield(NULL, 0));
693                 pval(snedp->rx_errors, snedc->rx_errors);
694                 printf(" %s", pfield(NULL, 0));
695                 pval(snedp->tx_errors, snedc->tx_errors);
696                 printf(" %s", pfield(NULL, 0));
697                 pval(snedp->collisions, snedc->collisions);
698                 printf(" %s", pfield(NULL, 0));
699                 pval(snedp->rx_dropped, snedc->rx_dropped);
700                 printf(" %s", pfield(NULL, 0));
701                 pval(snedp->tx_dropped, snedc->tx_dropped);
702                 printf(" %s", pfield(NULL, 0));
703                 pval(snedp->tx_carrier_errors, snedc->tx_carrier_errors);
704                 printf(" %s", pfield(NULL, 0));
705                 pval(snedp->rx_frame_errors, snedc->rx_frame_errors);
706                 printf(" %s", pfield(NULL, 0));
707                 pval(snedp->rx_fifo_errors, snedc->rx_fifo_errors);
708                 printf(" %s", pfield(NULL, 0));
709                 pval(snedp->tx_fifo_errors, snedc->tx_fifo_errors);
710                 printf("\n");
711         }
712 }
713
714 /*
715  ***************************************************************************
716  * Display NFS client statistics in raw format.
717  *
718  * IN:
719  * @a           Activity structure with statistics.
720  * @timestr     Time for current statistics sample.
721  * @curr        Index in array for current sample statistics.
722  ***************************************************************************
723  */
724 __print_funct_t raw_print_net_nfs_stats(struct activity *a, char *timestr, int curr)
725 {
726         struct stats_net_nfs
727                 *snnc = (struct stats_net_nfs *) a->buf[curr],
728                 *snnp = (struct stats_net_nfs *) a->buf[!curr];
729
730         printf("%s; %s", timestr, pfield(a->hdr_line, FIRST));
731         pval((unsigned long long) snnp->nfs_rpccnt, (unsigned long long) snnc->nfs_rpccnt);
732         printf(" %s", pfield(NULL, 0));
733         pval((unsigned long long) snnp->nfs_rpcretrans, (unsigned long long) snnc->nfs_rpcretrans);
734         printf(" %s", pfield(NULL, 0));
735         pval((unsigned long long) snnp->nfs_readcnt, (unsigned long long) snnc->nfs_readcnt);
736         printf(" %s", pfield(NULL, 0));
737         pval((unsigned long long) snnp->nfs_writecnt, (unsigned long long) snnc->nfs_writecnt);
738         printf(" %s", pfield(NULL, 0));
739         pval((unsigned long long) snnp->nfs_accesscnt, (unsigned long long) snnc->nfs_accesscnt);
740         printf(" %s", pfield(NULL, 0));
741         pval((unsigned long long) snnp->nfs_getattcnt, (unsigned long long) snnc->nfs_getattcnt);
742         printf("\n");
743 }
744
745 /*
746  ***************************************************************************
747  * Display NFS server statistics in raw format.
748  *
749  * IN:
750  * @a           Activity structure with statistics.
751  * @timestr     Time for current statistics sample.
752  * @curr        Index in array for current sample statistics.
753  ***************************************************************************
754  */
755 __print_funct_t raw_print_net_nfsd_stats(struct activity *a, char *timestr, int curr)
756 {
757         struct stats_net_nfsd
758                 *snndc = (struct stats_net_nfsd *) a->buf[curr],
759                 *snndp = (struct stats_net_nfsd *) a->buf[!curr];
760
761         printf("%s; %s", timestr, pfield(a->hdr_line, FIRST));
762         pval((unsigned long long) snndp->nfsd_rpccnt, (unsigned long long) snndc->nfsd_rpccnt);
763         printf(" %s", pfield(NULL, 0));
764         pval((unsigned long long) snndp->nfsd_rpcbad, (unsigned long long) snndc->nfsd_rpcbad);
765         printf(" %s", pfield(NULL, 0));
766         pval((unsigned long long) snndp->nfsd_netcnt, (unsigned long long) snndc->nfsd_netcnt);
767         printf(" %s", pfield(NULL, 0));
768         pval((unsigned long long) snndp->nfsd_netudpcnt, (unsigned long long) snndc->nfsd_netudpcnt);
769         printf(" %s", pfield(NULL, 0));
770         pval((unsigned long long) snndp->nfsd_nettcpcnt, (unsigned long long) snndc->nfsd_nettcpcnt);
771         printf(" %s", pfield(NULL, 0));
772         pval((unsigned long long) snndp->nfsd_rchits, (unsigned long long) snndc->nfsd_rchits);
773         printf(" %s", pfield(NULL, 0));
774         pval((unsigned long long) snndp->nfsd_rcmisses, (unsigned long long) snndc->nfsd_rcmisses);
775         printf(" %s", pfield(NULL, 0));
776         pval((unsigned long long) snndp->nfsd_readcnt, (unsigned long long) snndc->nfsd_readcnt);
777         printf(" %s", pfield(NULL, 0));
778         pval((unsigned long long) snndp->nfsd_writecnt, (unsigned long long) snndc->nfsd_writecnt);
779         printf(" %s", pfield(NULL, 0));
780         pval((unsigned long long) snndp->nfsd_accesscnt, (unsigned long long) snndc->nfsd_accesscnt);
781         printf(" %s", pfield(NULL, 0));
782         pval((unsigned long long) snndp->nfsd_getattcnt, (unsigned long long) snndc->nfsd_getattcnt);
783         printf("\n");
784 }
785
786 /*
787  ***************************************************************************
788  * Display network socket statistics in raw format.
789  *
790  * IN:
791  * @a           Activity structure with statistics.
792  * @timestr     Time for current statistics sample.
793  * @curr        Index in array for current sample statistics.
794  ***************************************************************************
795  */
796 __print_funct_t raw_print_net_sock_stats(struct activity *a, char *timestr, int curr)
797 {
798         struct stats_net_sock
799                 *snsc = (struct stats_net_sock *) a->buf[curr];
800
801         printf("%s; %s; %u;", timestr, pfield(a->hdr_line, FIRST), snsc->sock_inuse);
802         printf(" %s; %u;", pfield(NULL, 0), snsc->tcp_inuse);
803         printf(" %s; %u;", pfield(NULL, 0), snsc->udp_inuse);
804         printf(" %s; %u;", pfield(NULL, 0), snsc->raw_inuse);
805         printf(" %s; %u;", pfield(NULL, 0), snsc->frag_inuse);
806         printf(" %s; %u;", pfield(NULL, 0), snsc->tcp_tw);
807         printf("\n");
808 }
809
810 /*
811  ***************************************************************************
812  * Display IP network statistics in raw format.
813  *
814  * IN:
815  * @a           Activity structure with statistics.
816  * @timestr     Time for current statistics sample.
817  * @curr        Index in array for current sample statistics.
818  ***************************************************************************
819  */
820 __print_funct_t raw_print_net_ip_stats(struct activity *a, char *timestr, int curr)
821 {
822         struct stats_net_ip
823                 *snic = (struct stats_net_ip *) a->buf[curr],
824                 *snip = (struct stats_net_ip *) a->buf[!curr];
825
826         printf("%s; %s", timestr, pfield(a->hdr_line, FIRST));
827         pval(snip->InReceives, snic->InReceives);
828         printf(" %s", pfield(NULL, 0));
829         pval(snip->ForwDatagrams, snic->ForwDatagrams);
830         printf(" %s", pfield(NULL, 0));
831         pval(snip->InDelivers, snic->InDelivers);
832         printf(" %s", pfield(NULL, 0));
833         pval(snip->OutRequests, snic->OutRequests);
834         printf(" %s", pfield(NULL, 0));
835         pval(snip->ReasmReqds, snic->ReasmReqds);
836         printf(" %s", pfield(NULL, 0));
837         pval(snip->ReasmOKs, snic->ReasmOKs);
838         printf(" %s", pfield(NULL, 0));
839         pval(snip->FragOKs, snic->FragOKs);
840         printf(" %s", pfield(NULL, 0));
841         pval(snip->FragCreates, snic->FragCreates);
842         printf("\n");
843 }
844
845 /*
846  ***************************************************************************
847  * Display IP network errors statistics in raw format.
848  *
849  * IN:
850  * @a           Activity structure with statistics.
851  * @timestr     Time for current statistics sample.
852  * @curr        Index in array for current sample statistics.
853  ***************************************************************************
854  */
855 __print_funct_t raw_print_net_eip_stats(struct activity *a, char *timestr, int curr)
856 {
857         struct stats_net_eip
858                 *sneic = (struct stats_net_eip *) a->buf[curr],
859                 *sneip = (struct stats_net_eip *) a->buf[!curr];
860
861         printf("%s; %s", timestr, pfield(a->hdr_line, FIRST));
862         pval(sneip->InHdrErrors, sneic->InHdrErrors);
863         printf(" %s", pfield(NULL, 0));
864         pval(sneip->InAddrErrors, sneic->InAddrErrors);
865         printf(" %s", pfield(NULL, 0));
866         pval(sneip->InUnknownProtos, sneic->InUnknownProtos);
867         printf(" %s", pfield(NULL, 0));
868         pval(sneip->InDiscards, sneic->InDiscards);
869         printf(" %s", pfield(NULL, 0));
870         pval(sneip->OutDiscards, sneic->OutDiscards);
871         printf(" %s", pfield(NULL, 0));
872         pval(sneip->OutNoRoutes, sneic->OutNoRoutes);
873         printf(" %s", pfield(NULL, 0));
874         pval(sneip->ReasmFails, sneic->ReasmFails);
875         printf(" %s", pfield(NULL, 0));
876         pval(sneip->FragFails, sneic->FragFails);
877         printf("\n");
878 }
879
880 /*
881  ***************************************************************************
882  * Display ICMP network statistics in raw format.
883  *
884  * IN:
885  * @a           Activity structure with statistics.
886  * @timestr     Time for current statistics sample.
887  * @curr        Index in array for current sample statistics.
888  ***************************************************************************
889  */
890 __print_funct_t raw_print_net_icmp_stats(struct activity *a, char *timestr, int curr)
891 {
892         struct stats_net_icmp
893                 *snic = (struct stats_net_icmp *) a->buf[curr],
894                 *snip = (struct stats_net_icmp *) a->buf[!curr];
895
896         printf("%s; %s", timestr, pfield(a->hdr_line, FIRST));
897         pval((unsigned long long) snip->InMsgs, (unsigned long long) snic->InMsgs);
898         printf(" %s", pfield(NULL, 0));
899         pval((unsigned long long) snip->OutMsgs, (unsigned long long) snic->OutMsgs);
900         printf(" %s", pfield(NULL, 0));
901         pval((unsigned long long) snip->InEchos, (unsigned long long) snic->InEchos);
902         printf(" %s", pfield(NULL, 0));
903         pval((unsigned long long) snip->InEchoReps, (unsigned long long) snic->InEchoReps);
904         printf(" %s", pfield(NULL, 0));
905         pval((unsigned long long) snip->OutEchos, (unsigned long long) snic->OutEchos);
906         printf(" %s", pfield(NULL, 0));
907         pval((unsigned long long) snip->OutEchoReps, (unsigned long long) snic->OutEchoReps);
908         printf(" %s", pfield(NULL, 0));
909         pval((unsigned long long) snip->InTimestamps, (unsigned long long) snic->InTimestamps);
910         printf(" %s", pfield(NULL, 0));
911         pval((unsigned long long) snip->InTimestampReps, (unsigned long long) snic->InTimestampReps);
912         printf(" %s", pfield(NULL, 0));
913         pval((unsigned long long) snip->OutTimestamps, (unsigned long long) snic->OutTimestamps);
914         printf(" %s", pfield(NULL, 0));
915         pval((unsigned long long) snip->OutTimestampReps, (unsigned long long) snic->OutTimestampReps);
916         printf(" %s", pfield(NULL, 0));
917         pval((unsigned long long) snip->InAddrMasks, (unsigned long long) snic->InAddrMasks);
918         printf(" %s", pfield(NULL, 0));
919         pval((unsigned long long) snip->InAddrMaskReps, (unsigned long long) snic->InAddrMaskReps);
920         printf(" %s", pfield(NULL, 0));
921         pval((unsigned long long) snip->OutAddrMasks, (unsigned long long) snic->OutAddrMasks);
922         printf(" %s", pfield(NULL, 0));
923         pval((unsigned long long) snip->OutAddrMaskReps, (unsigned long long) snic->OutAddrMaskReps);
924         printf("\n");
925 }
926
927 /*
928  ***************************************************************************
929  * Display ICMP errors message statistics in raw format.
930  *
931  * IN:
932  * @a           Activity structure with statistics.
933  * @timestr     Time for current statistics sample.
934  * @curr        Index in array for current sample statistics.
935  ***************************************************************************
936  */
937 __print_funct_t raw_print_net_eicmp_stats(struct activity *a, char *timestr, int curr)
938 {
939         struct stats_net_eicmp
940                 *sneic = (struct stats_net_eicmp *) a->buf[curr],
941                 *sneip = (struct stats_net_eicmp *) a->buf[!curr];
942
943         printf("%s; %s", timestr, pfield(a->hdr_line, FIRST));
944         pval((unsigned long long) sneip->InErrors, (unsigned long long) sneic->InErrors);
945         printf(" %s", pfield(NULL, 0));
946         pval((unsigned long long) sneip->OutErrors, (unsigned long long) sneic->OutErrors);
947         printf(" %s", pfield(NULL, 0));
948         pval((unsigned long long) sneip->InDestUnreachs, (unsigned long long) sneic->InDestUnreachs);
949         printf(" %s", pfield(NULL, 0));
950         pval((unsigned long long) sneip->OutDestUnreachs, (unsigned long long) sneic->OutDestUnreachs);
951         printf(" %s", pfield(NULL, 0));
952         pval((unsigned long long) sneip->InTimeExcds, (unsigned long long) sneic->InTimeExcds);
953         printf(" %s", pfield(NULL, 0));
954         pval((unsigned long long) sneip->OutTimeExcds, (unsigned long long) sneic->OutTimeExcds);
955         printf(" %s", pfield(NULL, 0));
956         pval((unsigned long long) sneip->InParmProbs, (unsigned long long) sneic->InParmProbs);
957         printf(" %s", pfield(NULL, 0));
958         pval((unsigned long long) sneip->OutParmProbs, (unsigned long long) sneic->OutParmProbs);
959         printf(" %s", pfield(NULL, 0));
960         pval((unsigned long long) sneip->InSrcQuenchs, (unsigned long long) sneic->InSrcQuenchs);
961         printf(" %s", pfield(NULL, 0));
962         pval((unsigned long long) sneip->OutSrcQuenchs, (unsigned long long) sneic->OutSrcQuenchs);
963         printf(" %s", pfield(NULL, 0));
964         pval((unsigned long long) sneip->InRedirects, (unsigned long long) sneic->InRedirects);
965         printf(" %s", pfield(NULL, 0));
966         pval((unsigned long long) sneip->OutRedirects, (unsigned long long) sneic->OutRedirects);
967         printf("\n");
968 }
969
970 /*
971  ***************************************************************************
972  * Display TCP network statistics in raw format.
973  *
974  * IN:
975  * @a           Activity structure with statistics.
976  * @timestr     Time for current statistics sample.
977  * @curr        Index in array for current sample statistics.
978  ***************************************************************************
979  */
980 __print_funct_t raw_print_net_tcp_stats(struct activity *a, char *timestr, int curr)
981 {
982         struct stats_net_tcp
983                 *sntc = (struct stats_net_tcp *) a->buf[curr],
984                 *sntp = (struct stats_net_tcp *) a->buf[!curr];
985
986         printf("%s; %s", timestr, pfield(a->hdr_line, FIRST));
987         pval((unsigned long long) sntp->ActiveOpens, (unsigned long long) sntc->ActiveOpens);
988         printf(" %s", pfield(NULL, 0));
989         pval((unsigned long long) sntp->PassiveOpens, (unsigned long long) sntc->PassiveOpens);
990         printf(" %s", pfield(NULL, 0));
991         pval((unsigned long long) sntp->InSegs, (unsigned long long) sntc->InSegs);
992         printf(" %s", pfield(NULL, 0));
993         pval((unsigned long long) sntp->OutSegs, (unsigned long long) sntc->OutSegs);
994         printf("\n");
995 }
996
997 /*
998  ***************************************************************************
999  * Display TCP network errors statistics in raw format.
1000  *
1001  * IN:
1002  * @a           Activity structure with statistics.
1003  * @timestr     Time for current statistics sample.
1004  * @curr        Index in array for current sample statistics.
1005  ***************************************************************************
1006  */
1007 __print_funct_t raw_print_net_etcp_stats(struct activity *a, char *timestr, int curr)
1008 {
1009         struct stats_net_etcp
1010                 *snetc = (struct stats_net_etcp *) a->buf[curr],
1011                 *snetp = (struct stats_net_etcp *) a->buf[!curr];
1012
1013         printf("%s; %s", timestr, pfield(a->hdr_line, FIRST));
1014         pval((unsigned long long) snetp->AttemptFails, (unsigned long long) snetc->AttemptFails);
1015         printf(" %s", pfield(NULL, 0));
1016         pval((unsigned long long) snetp->EstabResets, (unsigned long long) snetc->EstabResets);
1017         printf(" %s", pfield(NULL, 0));
1018         pval((unsigned long long) snetp->RetransSegs, (unsigned long long) snetc->RetransSegs);
1019         printf(" %s", pfield(NULL, 0));
1020         pval((unsigned long long) snetp->InErrs, (unsigned long long) snetc->InErrs);
1021         printf(" %s", pfield(NULL, 0));
1022         pval((unsigned long long) snetp->OutRsts, (unsigned long long) snetc->OutRsts);
1023         printf("\n");
1024 }
1025
1026 /*
1027  ***************************************************************************
1028  * Display UDP network statistics in raw format.
1029  *
1030  * IN:
1031  * @a           Activity structure with statistics.
1032  * @timestr     Time for current statistics sample.
1033  * @curr        Index in array for current sample statistics.
1034  ***************************************************************************
1035  */
1036 __print_funct_t raw_print_net_udp_stats(struct activity *a, char *timestr, int curr)
1037 {
1038         struct stats_net_udp
1039                 *snuc = (struct stats_net_udp *) a->buf[curr],
1040                 *snup = (struct stats_net_udp *) a->buf[!curr];
1041
1042         printf("%s; %s", timestr, pfield(a->hdr_line, FIRST));
1043         pval((unsigned long long) snup->InDatagrams, (unsigned long long) snuc->InDatagrams);
1044         printf(" %s", pfield(NULL, 0));
1045         pval((unsigned long long) snup->OutDatagrams, (unsigned long long) snuc->OutDatagrams);
1046         printf(" %s", pfield(NULL, 0));
1047         pval((unsigned long long) snup->NoPorts, (unsigned long long) snuc->NoPorts);
1048         printf(" %s", pfield(NULL, 0));
1049         pval((unsigned long long) snup->InErrors, (unsigned long long) snuc->InErrors);
1050         printf("\n");
1051 }
1052
1053 /*
1054  ***************************************************************************
1055  * Display IPv6 network socket statistics in raw format.
1056  *
1057  * IN:
1058  * @a           Activity structure with statistics.
1059  * @timestr     Time for current statistics sample.
1060  * @curr        Index in array for current sample statistics.
1061  ***************************************************************************
1062  */
1063 __print_funct_t raw_print_net_sock6_stats(struct activity *a, char *timestr, int curr)
1064 {
1065         struct stats_net_sock6
1066                 *snsc = (struct stats_net_sock6 *) a->buf[curr];
1067
1068         printf("%s; %s; %u;", timestr, pfield(a->hdr_line, FIRST), snsc->tcp6_inuse);
1069         printf(" %s; %u;", pfield(NULL, 0), snsc->udp6_inuse);
1070         printf(" %s; %u;", pfield(NULL, 0), snsc->raw6_inuse);
1071         printf(" %s; %u;", pfield(NULL, 0), snsc->frag6_inuse);
1072         printf("\n");
1073 }
1074
1075 /*
1076  ***************************************************************************
1077  * Display IPv6 network statistics in raw format.
1078  *
1079  * IN:
1080  * @a           Activity structure with statistics.
1081  * @timestr     Time for current statistics sample.
1082  * @curr        Index in array for current sample statistics.
1083  ***************************************************************************
1084  */
1085 __print_funct_t raw_print_net_ip6_stats(struct activity *a, char *timestr, int curr)
1086 {
1087         struct stats_net_ip6
1088                 *snic = (struct stats_net_ip6 *) a->buf[curr],
1089                 *snip = (struct stats_net_ip6 *) a->buf[!curr];
1090
1091         printf("%s; %s", timestr, pfield(a->hdr_line, FIRST));
1092         pval(snip->InReceives6, snic->InReceives6);
1093         printf(" %s", pfield(NULL, 0));
1094         pval(snip->OutForwDatagrams6, snic->OutForwDatagrams6);
1095         printf(" %s", pfield(NULL, 0));
1096         pval(snip->InDelivers6, snic->InDelivers6);
1097         printf(" %s", pfield(NULL, 0));
1098         pval(snip->OutRequests6, snic->OutRequests6);
1099         printf(" %s", pfield(NULL, 0));
1100         pval(snip->ReasmReqds6, snic->ReasmReqds6);
1101         printf(" %s", pfield(NULL, 0));
1102         pval(snip->ReasmOKs6, snic->ReasmOKs6);
1103         printf(" %s", pfield(NULL, 0));
1104         pval(snip->InMcastPkts6, snic->InMcastPkts6);
1105         printf(" %s", pfield(NULL, 0));
1106         pval(snip->OutMcastPkts6, snic->OutMcastPkts6);
1107         printf(" %s", pfield(NULL, 0));
1108         pval(snip->FragOKs6, snic->FragOKs6);
1109         printf(" %s", pfield(NULL, 0));
1110         pval(snip->FragCreates6, snic->FragCreates6);
1111         printf("\n");
1112 }
1113
1114 /*
1115  ***************************************************************************
1116  * Display IPv6 network errors statistics in raw format.
1117  *
1118  * IN:
1119  * @a           Activity structure with statistics.
1120  * @timestr     Time for current statistics sample.
1121  * @curr        Index in array for current sample statistics.
1122  ***************************************************************************
1123  */
1124 __print_funct_t raw_print_net_eip6_stats(struct activity *a, char *timestr, int curr)
1125 {
1126         struct stats_net_eip6
1127                 *sneic = (struct stats_net_eip6 *) a->buf[curr],
1128                 *sneip = (struct stats_net_eip6 *) a->buf[!curr];
1129
1130         printf("%s; %s", timestr, pfield(a->hdr_line, FIRST));
1131         pval(sneip->InHdrErrors6, sneic->InHdrErrors6);
1132         printf(" %s", pfield(NULL, 0));
1133         pval(sneip->InAddrErrors6, sneic->InAddrErrors6);
1134         printf(" %s", pfield(NULL, 0));
1135         pval(sneip->InUnknownProtos6, sneic->InUnknownProtos6);
1136         printf(" %s", pfield(NULL, 0));
1137         pval(sneip->InTooBigErrors6, sneic->InTooBigErrors6);
1138         printf(" %s", pfield(NULL, 0));
1139         pval(sneip->InDiscards6, sneic->InDiscards6);
1140         printf(" %s", pfield(NULL, 0));
1141         pval(sneip->OutDiscards6, sneic->OutDiscards6);
1142         printf(" %s", pfield(NULL, 0));
1143         pval(sneip->InNoRoutes6, sneic->InNoRoutes6);
1144         printf(" %s", pfield(NULL, 0));
1145         pval(sneip->OutNoRoutes6, sneic->OutNoRoutes6);
1146         printf(" %s", pfield(NULL, 0));
1147         pval(sneip->ReasmFails6, sneic->ReasmFails6);
1148         printf(" %s", pfield(NULL, 0));
1149         pval(sneip->FragFails6, sneic->FragFails6);
1150         printf(" %s", pfield(NULL, 0));
1151         pval(sneip->InTruncatedPkts6, sneic->InTruncatedPkts6);
1152         printf("\n");
1153 }
1154
1155 /*
1156  ***************************************************************************
1157  * Display ICMPv6 network statistics in raw format.
1158  *
1159  * IN:
1160  * @a           Activity structure with statistics.
1161  * @timestr     Time for current statistics sample.
1162  * @curr        Index in array for current sample statistics.
1163  ***************************************************************************
1164  */
1165 __print_funct_t raw_print_net_icmp6_stats(struct activity *a, char *timestr, int curr)
1166 {
1167         struct stats_net_icmp6
1168                 *snic = (struct stats_net_icmp6 *) a->buf[curr],
1169                 *snip = (struct stats_net_icmp6 *) a->buf[!curr];
1170
1171         printf("%s; %s", timestr, pfield(a->hdr_line, FIRST));
1172         pval((unsigned long long) snip->InMsgs6,
1173              (unsigned long long) snic->InMsgs6);
1174         printf(" %s", pfield(NULL, 0));
1175         pval((unsigned long long) snip->OutMsgs6,
1176              (unsigned long long) snic->OutMsgs6);
1177         printf(" %s", pfield(NULL, 0));
1178         pval((unsigned long long) snip->InEchos6,
1179              (unsigned long long) snic->InEchos6);
1180         printf(" %s", pfield(NULL, 0));
1181         pval((unsigned long long) snip->InEchoReplies6,
1182              (unsigned long long) snic->InEchoReplies6);
1183         printf(" %s", pfield(NULL, 0));
1184         pval((unsigned long long) snip->OutEchoReplies6,
1185              (unsigned long long) snic->OutEchoReplies6);
1186         printf(" %s", pfield(NULL, 0));
1187         pval((unsigned long long) snip->InGroupMembQueries6,
1188              (unsigned long long) snic->InGroupMembQueries6);
1189         printf(" %s", pfield(NULL, 0));
1190         pval((unsigned long long) snip->InGroupMembResponses6,
1191              (unsigned long long) snic->InGroupMembResponses6);
1192         printf(" %s", pfield(NULL, 0));
1193         pval((unsigned long long) snip->OutGroupMembResponses6,
1194              (unsigned long long) snic->OutGroupMembResponses6);
1195         printf(" %s", pfield(NULL, 0));
1196         pval((unsigned long long) snip->InGroupMembReductions6,
1197              (unsigned long long) snic->InGroupMembReductions6);
1198         printf(" %s", pfield(NULL, 0));
1199         pval((unsigned long long) snip->OutGroupMembReductions6,
1200              (unsigned long long) snic->OutGroupMembReductions6);
1201         printf(" %s", pfield(NULL, 0));
1202         pval((unsigned long long) snip->InRouterSolicits6,
1203              (unsigned long long) snic->InRouterSolicits6);
1204         printf(" %s", pfield(NULL, 0));
1205         pval((unsigned long long) snip->OutRouterSolicits6,
1206              (unsigned long long) snic->OutRouterSolicits6);
1207         printf(" %s", pfield(NULL, 0));
1208         pval((unsigned long long) snip->InRouterAdvertisements6,
1209              (unsigned long long) snic->InRouterAdvertisements6);
1210         printf(" %s", pfield(NULL, 0));
1211         pval((unsigned long long) snip->InNeighborSolicits6,
1212              (unsigned long long) snic->InNeighborSolicits6);
1213         printf(" %s", pfield(NULL, 0));
1214         pval((unsigned long long) snip->OutNeighborSolicits6,
1215              (unsigned long long) snic->OutNeighborSolicits6);
1216         printf(" %s", pfield(NULL, 0));
1217         pval((unsigned long long) snip->InNeighborAdvertisements6,
1218              (unsigned long long) snic->InNeighborAdvertisements6);
1219         printf(" %s", pfield(NULL, 0));
1220         pval((unsigned long long) snip->OutNeighborAdvertisements6,
1221              (unsigned long long) snic->OutNeighborAdvertisements6);
1222         printf("\n");
1223 }
1224
1225 /*
1226  ***************************************************************************
1227  * Display ICMPv6 error messages statistics in rw format.
1228  *
1229  * IN:
1230  * @a           Activity structure with statistics.
1231  * @timestr     Time for current statistics sample.
1232  * @curr        Index in array for current sample statistics.
1233  ***************************************************************************
1234  */
1235 __print_funct_t raw_print_net_eicmp6_stats(struct activity *a, char *timestr, int curr)
1236 {
1237         struct stats_net_eicmp6
1238                 *sneic = (struct stats_net_eicmp6 *) a->buf[curr],
1239                 *sneip = (struct stats_net_eicmp6 *) a->buf[!curr];
1240
1241         printf("%s; %s", timestr, pfield(a->hdr_line, FIRST));
1242         pval((unsigned long long) sneip->InErrors6, (unsigned long long) sneic->InErrors6);
1243         printf(" %s", pfield(NULL, 0));
1244         pval((unsigned long long) sneip->InDestUnreachs6, (unsigned long long) sneic->InDestUnreachs6);
1245         printf(" %s", pfield(NULL, 0));
1246         pval((unsigned long long) sneip->OutDestUnreachs6, (unsigned long long) sneic->OutDestUnreachs6);
1247         printf(" %s", pfield(NULL, 0));
1248         pval((unsigned long long) sneip->InTimeExcds6, (unsigned long long) sneic->InTimeExcds6);
1249         printf(" %s", pfield(NULL, 0));
1250         pval((unsigned long long) sneip->OutTimeExcds6, (unsigned long long) sneic->OutTimeExcds6);
1251         printf(" %s", pfield(NULL, 0));
1252         pval((unsigned long long) sneip->InParmProblems6, (unsigned long long) sneic->InParmProblems6);
1253         printf(" %s", pfield(NULL, 0));
1254         pval((unsigned long long) sneip->OutParmProblems6, (unsigned long long) sneic->OutParmProblems6);
1255         printf(" %s", pfield(NULL, 0));
1256         pval((unsigned long long) sneip->InRedirects6, (unsigned long long) sneic->InRedirects6);
1257         printf(" %s", pfield(NULL, 0));
1258         pval((unsigned long long) sneip->OutRedirects6, (unsigned long long) sneic->OutRedirects6);
1259         printf(" %s", pfield(NULL, 0));
1260         pval((unsigned long long) sneip->InPktTooBigs6, (unsigned long long) sneic->InPktTooBigs6);
1261         printf(" %s", pfield(NULL, 0));
1262         pval((unsigned long long) sneip->OutPktTooBigs6, (unsigned long long) sneic->OutPktTooBigs6);
1263         printf("\n");
1264 }
1265
1266 /*
1267  ***************************************************************************
1268  * Display UDPv6 network statistics in raw format.
1269  *
1270  * IN:
1271  * @a           Activity structure with statistics.
1272  * @timestr     Time for current statistics sample.
1273  * @curr        Index in array for current sample statistics.
1274  ***************************************************************************
1275  */
1276 __print_funct_t raw_print_net_udp6_stats(struct activity *a, char *timestr, int curr)
1277 {
1278         struct stats_net_udp6
1279                 *snuc = (struct stats_net_udp6 *) a->buf[curr],
1280                 *snup = (struct stats_net_udp6 *) a->buf[!curr];
1281
1282         printf("%s; %s", timestr, pfield(a->hdr_line, FIRST));
1283         pval((unsigned long long) snup->InDatagrams6, (unsigned long long) snuc->InDatagrams6);
1284         printf(" %s", pfield(NULL, 0));
1285         pval((unsigned long long) snup->OutDatagrams6, (unsigned long long) snuc->OutDatagrams6);
1286         printf(" %s", pfield(NULL, 0));
1287         pval((unsigned long long) snup->NoPorts6, (unsigned long long) snuc->NoPorts6);
1288         printf(" %s", pfield(NULL, 0));
1289         pval((unsigned long long) snup->InErrors6, (unsigned long long) snuc->InErrors6);
1290         printf("\n");
1291 }
1292
1293 /*
1294  ***************************************************************************
1295  * Display CPU frequency statistics in raw format.
1296  *
1297  * IN:
1298  * @a           Activity structure with statistics.
1299  * @timestr     Time for current statistics sample.
1300  * @curr        Index in array for current sample statistics.
1301  ***************************************************************************
1302  */
1303 __print_funct_t raw_print_pwr_cpufreq_stats(struct activity *a, char *timestr, int curr)
1304 {
1305         int i;
1306         struct stats_pwr_cpufreq *spc;
1307
1308         for (i = 0; (i < a->nr[curr]) && (i < a->bitmap->b_size + 1); i++) {
1309
1310                 spc = (struct stats_pwr_cpufreq *) ((char *) a->buf[curr] + i * a->msize);
1311
1312                 /* Should current CPU (including CPU "all") be displayed? */
1313                 if (a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))) {
1314                         /* Yes: Display it */
1315                         printf("%s; %s; %d;", timestr, pfield(a->hdr_line, FIRST), i - 1);
1316                         printf(" %s; %lu;\n", pfield(NULL, 0), spc->cpufreq);
1317                 }
1318         }
1319 }
1320
1321 /*
1322  ***************************************************************************
1323  * Display fan statistics in raw format.
1324  *
1325  * IN:
1326  * @a           Activity structure with statistics.
1327  * @timestr     Time for current statistics sample.
1328  * @curr        Index in array for current sample statistics.
1329  ***************************************************************************
1330  */
1331 __print_funct_t raw_print_pwr_fan_stats(struct activity *a, char *timestr, int curr)
1332 {
1333         int i;
1334         struct stats_pwr_fan *spc;
1335
1336         for (i = 0; i < a->nr[curr]; i++) {
1337                 spc = (struct stats_pwr_fan *) ((char *) a->buf[curr] + i * a->msize);
1338
1339                 printf("%s; %s; %d;", timestr, pfield(a->hdr_line, FIRST), i + 1);
1340                 printf(" %s; %s;", pfield(NULL, 0), spc->device);
1341                 printf(" %s; %f;", pfield(NULL, 0), spc->rpm);
1342                 printf(" rpm_min; %f;\n", spc->rpm_min);
1343         }
1344 }
1345
1346 /*
1347  ***************************************************************************
1348  * Display temperature statistics in raw format.
1349  *
1350  * IN:
1351  * @a           Activity structure with statistics.
1352  * @timestr     Time for current statistics sample.
1353  * @curr        Index in array for current sample statistics.
1354  ***************************************************************************
1355  */
1356 __print_funct_t raw_print_pwr_temp_stats(struct activity *a, char *timestr, int curr)
1357 {
1358         int i;
1359         struct stats_pwr_temp *spc;
1360
1361         for (i = 0; i < a->nr[curr]; i++) {
1362                 spc = (struct stats_pwr_temp *) ((char *) a->buf[curr] + i * a->msize);
1363
1364                 printf("%s; %s; %d;", timestr, pfield(a->hdr_line, FIRST), i + 1);
1365                 printf(" %s; %s;", pfield(NULL, 0), spc->device);
1366                 printf(" %s; %f;", pfield(NULL, 0), spc->temp);
1367                 printf(" temp_min; %f;", spc->temp_min);
1368                 printf(" temp_max; %f;\n", spc->temp_max);
1369         }
1370 }
1371
1372 /*
1373  ***************************************************************************
1374  * Display voltage inputs statistics in raw format.
1375  *
1376  * IN:
1377  * @a           Activity structure with statistics.
1378  * @timestr     Time for current statistics sample.
1379  * @curr        Index in array for current sample statistics.
1380  ***************************************************************************
1381  */
1382 __print_funct_t raw_print_pwr_in_stats(struct activity *a, char *timestr, int curr)
1383 {
1384         int i;
1385         struct stats_pwr_in *spc;
1386
1387         for (i = 0; i < a->nr[curr]; i++) {
1388                 spc = (struct stats_pwr_in *) ((char *) a->buf[curr] + i * a->msize);
1389
1390                 printf("%s; %s; %d;", timestr, pfield(a->hdr_line, FIRST), i);
1391                 printf(" %s; %s;", pfield(NULL, 0), spc->device);
1392                 printf(" %s; %f;", pfield(NULL, 0), spc->in);
1393                 printf(" in_min; %f;", spc->in_min);
1394                 printf(" in_max; %f;\n", spc->in_max);
1395         }
1396 }
1397
1398 /*
1399  ***************************************************************************
1400  * Display huge pages statistics in raw format.
1401  *
1402  * IN:
1403  * @a           Activity structure with statistics.
1404  * @timestr     Time for current statistics sample.
1405  * @curr        Index in array for current sample statistics.
1406  ***************************************************************************
1407  */
1408 __print_funct_t raw_print_huge_stats(struct activity *a, char *timestr, int curr)
1409 {
1410         struct stats_huge
1411                 *smc = (struct stats_huge *) a->buf[curr];
1412
1413         printf("%s; %s; %llu;", timestr, pfield(a->hdr_line, FIRST), smc->frhkb);
1414         printf(" hugtotal; %llu;", smc->tlhkb);
1415         pfield(NULL, 0); /* Skip kbhugused */
1416         pfield(NULL, 0); /* Skip %hugused */
1417         printf(" %s; %llu;", pfield(NULL, 0), smc->rsvdhkb);
1418         printf(" %s; %llu;\n", pfield(NULL, 0), smc->surphkb);
1419 }
1420
1421 /*
1422  ***************************************************************************
1423  * Display weighted CPU frequency statistics in raw format.
1424  *
1425  * IN:
1426  * @a           Activity structure with statistics.
1427  * @timestr     Time for current statistics sample.
1428  * @curr        Index in array for current sample statistics.
1429  ***************************************************************************
1430  */
1431 __print_funct_t raw_print_pwr_wghfreq_stats(struct activity *a, char *timestr, int curr)
1432 {
1433         int i, k;
1434         struct stats_pwr_wghfreq *spc, *spp, *spc_k, *spp_k;
1435
1436         for (i = 0; (i < a->nr[curr]) && (i < a->bitmap->b_size + 1); i++) {
1437
1438                 spc = (struct stats_pwr_wghfreq *) ((char *) a->buf[curr]  + i * a->msize * a->nr2);
1439                 spp = (struct stats_pwr_wghfreq *) ((char *) a->buf[!curr] + i * a->msize * a->nr2);
1440
1441                 /* Should current CPU (including CPU "all") be displayed? */
1442                 if (!(a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))))
1443                         /* No */
1444                         continue;
1445
1446                 printf("%s; %s; %d;", timestr, pfield(a->hdr_line, FIRST), i - 1);
1447
1448                 for (k = 0; k < a->nr2; k++) {
1449
1450                         spc_k = (struct stats_pwr_wghfreq *) ((char *) spc + k * a->msize);
1451                         if (!spc_k->freq)
1452                                 break;
1453                         spp_k = (struct stats_pwr_wghfreq *) ((char *) spp + k * a->msize);
1454
1455                         printf(" freq; %lu;", spc_k->freq);
1456                         printf(" tminst");
1457                         pval(spp_k->time_in_state, spc_k->time_in_state);
1458                 }
1459                 printf("\n");
1460         }
1461 }
1462
1463 /*
1464  ***************************************************************************
1465  * Display USB devices statistics in raw format.
1466  *
1467  * IN:
1468  * @a           Activity structure with statistics.
1469  * @timestr     Time for current statistics sample.
1470  * @curr        Index in array for current sample statistics.
1471  ***************************************************************************
1472  */
1473 __print_funct_t raw_print_pwr_usb_stats(struct activity *a, char *timestr, int curr)
1474 {
1475         int i;
1476         struct stats_pwr_usb *suc;
1477
1478         for (i = 0; i < a->nr[curr]; i++) {
1479                 suc = (struct stats_pwr_usb *) ((char *) a->buf[curr] + i * a->msize);
1480
1481                 printf("%s; %s; \"%s\";", timestr, pfield(a->hdr_line, FIRST), suc->manufacturer);
1482                 printf(" %s; \"%s\";", pfield(NULL, 0), suc->product);
1483                 printf(" %s; %d;", pfield(NULL, 0), suc->bus_nr);
1484                 printf(" %s; %x;", pfield(NULL, 0), suc->vendor_id);
1485                 printf(" %s; %x;", pfield(NULL, 0), suc->product_id);
1486                 printf(" %s; %u;\n", pfield(NULL, 0), suc->bmaxpower);
1487         }
1488 }
1489
1490 /*
1491  ***************************************************************************
1492  * Display filesystems statistics in raw format.
1493  *
1494  * IN:
1495  * @a           Activity structure with statistics.
1496  * @timestr     Time for current statistics sample.
1497  * @curr        Index in array for current sample statistics.
1498  ***************************************************************************
1499  */
1500 __print_funct_t raw_print_filesystem_stats(struct activity *a, char *timestr, int curr)
1501 {
1502         int i;
1503         struct stats_filesystem *sfc;
1504         char *dev_name;
1505
1506         for (i = 0; i < a->nr[curr]; i++) {
1507                 sfc = (struct stats_filesystem *) ((char *) a->buf[curr] + i * a->msize);
1508
1509                 /* Get name to display (persistent or standard fs name, or mount point) */
1510                 dev_name = get_fs_name_to_display(a, flags, sfc);
1511
1512                 if (a->item_list != NULL) {
1513                         /* A list of devices has been entered on the command line */
1514                         if (!search_list_item(a->item_list, dev_name))
1515                                 /* Device not found */
1516                                 continue;
1517                 }
1518
1519                 printf("%s; %s; \"%s\";", timestr, pfield(a->hdr_line, FIRST + DISPLAY_MOUNT(a->opt_flags)),
1520                        dev_name);
1521                 printf(" f_bfree; %llu;", sfc->f_bfree);
1522                 printf(" f_blocks; %llu;", sfc->f_blocks);
1523                 printf(" f_bavail; %llu;", sfc->f_bavail);
1524                 pfield(NULL, 0); /* Skip MBfsfree */
1525                 pfield(NULL, 0); /* Skip MBfsused */
1526                 pfield(NULL, 0); /* Skip %fsused */
1527                 pfield(NULL, 0); /* Skip %ufsused */
1528                 printf(" %s; %llu;", pfield(NULL, 0), sfc->f_ffree);
1529                 printf(" f_files; %llu;\n", sfc->f_files);
1530
1531         }
1532 }
1533
1534 /*
1535  ***************************************************************************
1536  * Display Fibre Channel HBA statistics in raw format.
1537  *
1538  * IN:
1539  * @a           Activity structure with statistics.
1540  * @timestr     Time for current statistics sample.
1541  * @curr        Index in array for current sample statistics.
1542  ***************************************************************************
1543  */
1544 __print_funct_t raw_print_fchost_stats(struct activity *a, char *timestr, int curr)
1545 {
1546         int i, j, j0, found;
1547         struct stats_fchost *sfcc, *sfcp, sfczero;
1548
1549         memset(&sfczero, 0, sizeof(struct stats_fchost));
1550
1551         for (i = 0; i < a->nr[curr]; i++) {
1552
1553                 found = FALSE;
1554                 sfcc = (struct stats_fchost *) ((char *) a->buf[curr] + i * a->msize);
1555
1556                 if (a->nr[!curr] > 0) {
1557                         /* Look for corresponding structure in previous iteration */
1558                         j = i;
1559
1560                         if (j >= a->nr[!curr]) {
1561                                 j = a->nr[!curr] - 1;
1562                         }
1563
1564                         j0 = j;
1565
1566                         do {
1567                                 sfcp = (struct stats_fchost *) ((char *) a->buf[!curr] + j * a->msize);
1568                                 if (!strcmp(sfcc->fchost_name, sfcp->fchost_name)) {
1569                                         found = TRUE;
1570                                         break;
1571                                 }
1572                                 if (++j >= a->nr[!curr]) {
1573                                         j = 0;
1574                                 }
1575                         }
1576                         while (j != j0);
1577                 }
1578
1579                 printf("%s; %s", timestr, pfield(a->hdr_line, FIRST));
1580
1581                 if (!found) {
1582                         /* This is a newly registered host. Previous stats are zero */
1583                         sfcp = &sfczero;
1584                         if (DISPLAY_DEBUG_MODE(flags)) {
1585                                 printf(" [NEW]");
1586                         }
1587                 }
1588
1589                 printf("; %s;", sfcc->fchost_name);
1590                 printf(" %s", pfield(NULL, 0));
1591                 pval((unsigned long long) sfcp->f_rxframes, (unsigned long long) sfcc->f_rxframes);
1592                 printf(" %s", pfield(NULL, 0));
1593                 pval((unsigned long long) sfcp->f_txframes, (unsigned long long) sfcc->f_txframes);
1594                 printf(" %s", pfield(NULL, 0));
1595                 pval((unsigned long long) sfcp->f_rxwords, (unsigned long long) sfcc->f_rxwords);
1596                 printf(" %s", pfield(NULL, 0));
1597                 pval((unsigned long long) sfcp->f_txwords, (unsigned long long) sfcc->f_txwords);
1598                 printf("\n");
1599         }
1600 }
1601
1602 /*
1603  ***************************************************************************
1604  * Display softnet statistics in raw format.
1605  *
1606  * IN:
1607  * @a           Activity structure with statistics.
1608  * @timestr     Time for current statistics sample.
1609  * @curr        Index in array for current sample statistics.
1610  ***************************************************************************
1611  */
1612 __print_funct_t raw_print_softnet_stats(struct activity *a, char *timestr, int curr)
1613 {
1614         int i;
1615         struct stats_softnet *ssnc, *ssnp;
1616
1617         /* @nr[curr] cannot normally be greater than @nr_ini */
1618         if (a->nr[curr] > a->nr_ini) {
1619                 a->nr_ini = a->nr[curr];
1620         }
1621
1622         /* Don't display CPU "all" which doesn't exist in file */
1623         for (i = 1; (i < a->nr_ini) && (i < a->bitmap->b_size + 1); i++) {
1624
1625                 /*
1626                  * The size of a->buf[...] CPU structure may be different from the default
1627                  * sizeof(struct stats_pwr_cpufreq) value if data have been read from a file!
1628                  * That's why we don't use a syntax like:
1629                  * ssnc = (struct stats_softnet *) a->buf[...] + i;
1630                  */
1631                 ssnc = (struct stats_softnet *) ((char *) a->buf[curr]  + i * a->msize);
1632                 ssnp = (struct stats_softnet *) ((char *) a->buf[!curr] + i * a->msize);
1633
1634                 /*
1635                  * Note: a->nr is in [1, NR_CPUS + 1].
1636                  * Bitmap size is provided for (NR_CPUS + 1) CPUs.
1637                  * Anyway, NR_CPUS may vary between the version of sysstat
1638                  * used by sadc to create a file, and the version of sysstat
1639                  * used by sar to read it...
1640                  */
1641
1642                 /* Should current CPU (including CPU "all") be displayed? */
1643                 if (!(a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))))
1644                         /* No */
1645                         continue;
1646
1647                 /* Yes: Display current CPU stats */
1648                 printf("%s; %s", timestr, pfield(a->hdr_line, FIRST));
1649                 if (DISPLAY_DEBUG_MODE(flags) && i) {
1650                         if (ssnc->processed + ssnc->dropped + ssnc->time_squeeze +
1651                             ssnc->received_rps + ssnc->flow_limit == 0) {
1652                                 /* CPU is considered offline */
1653                                 printf(" [OFF]");
1654                         }
1655                 }
1656                 printf("; %d;", i - 1);
1657
1658                 printf(" %s", pfield(NULL, 0));
1659                 pval((unsigned long long) ssnp->processed, (unsigned long long) ssnc->processed);
1660                 printf(" %s", pfield(NULL, 0));
1661                 pval((unsigned long long) ssnp->dropped, (unsigned long long) ssnc->dropped);
1662                 printf(" %s", pfield(NULL, 0));
1663                 pval((unsigned long long) ssnp->time_squeeze, (unsigned long long) ssnc->time_squeeze);
1664                 printf(" %s", pfield(NULL, 0));
1665                 pval((unsigned long long) ssnp->received_rps, (unsigned long long) ssnc->received_rps);
1666                 printf(" %s", pfield(NULL, 0));
1667                 pval((unsigned long long) ssnp->flow_limit, (unsigned long long) ssnc->flow_limit);
1668                 printf("\n");
1669         }
1670 }
1671
1672 /*
1673  ***************************************************************************
1674  * Display pressure-stall CPU statistics in raw format.
1675  *
1676  * IN:
1677  * @a           Activity structure with statistics.
1678  * @timestr     Time for current statistics sample.
1679  * @curr        Index in array for current sample statistics.
1680  ***************************************************************************
1681  */
1682 __print_funct_t raw_print_psicpu_stats(struct activity *a, char *timestr, int curr)
1683 {
1684         struct stats_psi_cpu
1685                 *psic = (struct stats_psi_cpu *) a->buf[curr],
1686                 *psip = (struct stats_psi_cpu *) a->buf[!curr];
1687
1688         printf("%s; %s; %lu;", timestr, pfield(a->hdr_line, FIRST), psic->some_acpu_10);
1689         printf(" %s; %lu;", pfield(NULL, 0), psic->some_acpu_60);
1690         printf(" %s; %lu;", pfield(NULL, 0), psic->some_acpu_300);
1691         printf(" %s", pfield(NULL, 0));
1692         pval((unsigned long long) psip->some_cpu_total, (unsigned long long) psic->some_cpu_total);
1693         printf("\n");
1694 }
1695
1696 /*
1697  ***************************************************************************
1698  * Display pressure-stall I/O statistics in raw format.
1699  *
1700  * IN:
1701  * @a           Activity structure with statistics.
1702  * @timestr     Time for current statistics sample.
1703  * @curr        Index in array for current sample statistics.
1704  ***************************************************************************
1705  */
1706 __print_funct_t raw_print_psiio_stats(struct activity *a, char *timestr, int curr)
1707 {
1708         struct stats_psi_io
1709                 *psic = (struct stats_psi_io *) a->buf[curr],
1710                 *psip = (struct stats_psi_io *) a->buf[!curr];
1711
1712         printf("%s; %s; %lu;", timestr, pfield(a->hdr_line, FIRST), psic->some_aio_10);
1713         printf(" %s; %lu;", pfield(NULL, 0), psic->some_aio_60);
1714         printf(" %s; %lu;", pfield(NULL, 0), psic->some_aio_300);
1715         printf(" %s", pfield(NULL, 0));
1716         pval((unsigned long long) psip->some_io_total, (unsigned long long) psic->some_io_total);
1717
1718         printf(" %s; %lu;", pfield(NULL, 0), psic->full_aio_10);
1719         printf(" %s; %lu;", pfield(NULL, 0), psic->full_aio_60);
1720         printf(" %s; %lu;", pfield(NULL, 0), psic->full_aio_300);
1721         printf(" %s", pfield(NULL, 0));
1722         pval((unsigned long long) psip->full_io_total, (unsigned long long) psic->full_io_total);
1723         printf("\n");
1724 }
1725
1726 /*
1727  ***************************************************************************
1728  * Display pressure-stall mem statistics in raw format.
1729  *
1730  * IN:
1731  * @a           Activity structure with statistics.
1732  * @timestr     Time for current statistics sample.
1733  * @curr        Index in array for current sample statistics.
1734  ***************************************************************************
1735  */
1736 __print_funct_t raw_print_psimem_stats(struct activity *a, char *timestr, int curr)
1737 {
1738         struct stats_psi_mem
1739                 *psic = (struct stats_psi_mem *) a->buf[curr],
1740                 *psip = (struct stats_psi_mem *) a->buf[!curr];
1741
1742         printf("%s; %s; %lu;", timestr, pfield(a->hdr_line, FIRST), psic->some_amem_10);
1743         printf(" %s; %lu;", pfield(NULL, 0), psic->some_amem_60);
1744         printf(" %s; %lu;", pfield(NULL, 0), psic->some_amem_300);
1745         printf(" %s", pfield(NULL, 0));
1746         pval((unsigned long long) psip->some_mem_total, (unsigned long long) psic->some_mem_total);
1747
1748         printf(" %s; %lu;", pfield(NULL, 0), psic->full_amem_10);
1749         printf(" %s; %lu;", pfield(NULL, 0), psic->full_amem_60);
1750         printf(" %s; %lu;", pfield(NULL, 0), psic->full_amem_300);
1751         printf(" %s", pfield(NULL, 0));
1752         pval((unsigned long long) psip->full_mem_total, (unsigned long long) psic->full_mem_total);
1753         printf("\n");
1754 }