2 * raw_stats.c: Functions used by sar to display statistics in raw format.
3 * (C) 1999-2018 by Sebastien GODARD (sysstat <at> orange.fr)
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. *
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 *
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 ***************************************************************************
29 #include "raw_stats.h"
31 extern unsigned int flags;
34 ***************************************************************************
35 * Display current field name.
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).
44 * Pointer on string containing field name.
45 ***************************************************************************
47 char *pfield(char *hdr_line, int pos)
49 char hline[HEADER_LINE_LEN] = "";
50 static char field[HEADER_LINE_LEN] = "";
56 strncpy(hline, hdr_line, HEADER_LINE_LEN - 1);
57 hline[HEADER_LINE_LEN - 1] = '\0';
60 for (hl = strtok(hline, "|"); hl && (pos > 0); hl = strtok(NULL, "|"), pos--);
62 /* Bad @pos arg given to function */
66 if (strchr(hl, '&')) {
70 strncpy(field, hl, HEADER_LINE_LEN);
71 field[HEADER_LINE_LEN - 1] = '\0';
74 /* Display current field */
75 if (strchr(field + idx, ';')) {
76 j = strcspn(field + idx, ";");
77 *(field + idx + j) = '\0';
86 ***************************************************************************
87 * Display field values.
90 * @valp Field's value from previous statistics sample.
91 * @valc Field's value from current statistics sample.
92 ***************************************************************************
94 void pval(unsigned long long valp, unsigned long long valc)
96 if (DISPLAY_DEBUG_MODE(flags)) {
98 /* Field's value has decreased */
102 printf("; %llu; %llu;", valp, valc);
106 ***************************************************************************
107 * Display CPU statistics in raw format.
110 * @a Activity structure with statistics.
111 * @timestr Time for current statistics sample.
112 * @curr Index in array for current statistics sample.
113 ***************************************************************************
115 __print_funct_t raw_print_cpu_stats(struct activity *a, char *timestr, int curr)
118 struct stats_cpu *scc, *scp;
120 /* @nr[curr] cannot normally be greater than @nr_ini */
121 if (a->nr[curr] > a->nr_ini) {
122 a->nr_ini = a->nr[curr];
125 for (i = 0; (i < a->nr_ini) && (i < a->bitmap->b_size + 1); i++) {
128 * The size of a->buf[...] CPU structure may be different from the default
129 * sizeof(struct stats_cpu) value if data have been read from a file!
130 * That's why we don't use a syntax like:
131 * scc = (struct stats_cpu *) a->buf[...] + i;
133 scc = (struct stats_cpu *) ((char *) a->buf[curr] + i * a->msize);
134 scp = (struct stats_cpu *) ((char *) a->buf[!curr] + i * a->msize);
136 /* Should current CPU (including CPU "all") be displayed? */
137 if (!(a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))))
141 /* Yes: Display it */
142 printf("%s; %s", timestr, pfield(a->hdr_line, DISPLAY_CPU_ALL(a->opt_flags)));
143 if (DISPLAY_DEBUG_MODE(flags) && i) {
144 if ((scc->cpu_user + scc->cpu_nice + scc->cpu_sys +
145 scc->cpu_iowait + scc->cpu_idle + scc->cpu_steal +
146 scc->cpu_hardirq + scc->cpu_softirq) == 0) {
151 if (!get_per_cpu_interval(scc, scp)) {
152 /* CPU is tickless */
157 printf("; %d;", i - 1);
159 if (DISPLAY_CPU_DEF(a->opt_flags)) {
160 printf(" %s", pfield(NULL, 0));
161 pval(scp->cpu_user, scc->cpu_user);
162 printf(" %s", pfield(NULL, 0));
163 pval(scp->cpu_nice, scc->cpu_nice);
164 printf(" %s", pfield(NULL, 0));
165 pval(scp->cpu_sys + scp->cpu_hardirq + scp->cpu_softirq,
166 scc->cpu_sys + scc->cpu_hardirq + scc->cpu_softirq);
167 printf(" %s", pfield(NULL, 0));
168 pval(scp->cpu_iowait, scc->cpu_iowait);
169 printf(" %s", pfield(NULL, 0));
170 pval(scp->cpu_steal, scc->cpu_steal);
171 printf(" %s", pfield(NULL, 0));
172 pval(scp->cpu_idle, scc->cpu_idle);
174 else if (DISPLAY_CPU_ALL(a->opt_flags)) {
175 printf(" %s", pfield(NULL, 0));
176 pval(scp->cpu_user - scp->cpu_guest, scc->cpu_user - scc->cpu_guest);
177 printf(" %s", pfield(NULL, 0));
178 pval(scp->cpu_nice - scp->cpu_guest_nice, scc->cpu_nice - scc->cpu_guest_nice);
179 printf(" %s", pfield(NULL, 0));
180 pval(scp->cpu_sys, scc->cpu_sys);
181 printf(" %s", pfield(NULL, 0));
182 pval(scp->cpu_iowait, scc->cpu_iowait);
183 printf(" %s", pfield(NULL, 0));
184 pval(scp->cpu_steal, scc->cpu_steal);
185 printf(" %s", pfield(NULL, 0));
186 pval(scp->cpu_hardirq, scc->cpu_hardirq);
187 printf(" %s", pfield(NULL, 0));
188 pval(scp->cpu_softirq, scc->cpu_softirq);
189 printf(" %s", pfield(NULL, 0));
190 pval(scp->cpu_guest, scc->cpu_guest);
191 printf(" %s", pfield(NULL, 0));
192 pval(scp->cpu_guest_nice, scc->cpu_guest_nice);
193 printf(" %s", pfield(NULL, 0));
194 pval(scp->cpu_idle, scc->cpu_idle);
201 ***************************************************************************
202 * Display tasks creation and context switches statistics in raw format.
205 * @a Activity structure with statistics.
206 * @timestr Time for current statistics sample.
207 * @curr Index in array for current sample statistics.
208 ***************************************************************************
210 __print_funct_t raw_print_pcsw_stats(struct activity *a, char *timestr, int curr)
213 *spc = (struct stats_pcsw *) a->buf[curr],
214 *spp = (struct stats_pcsw *) a->buf[!curr];
216 printf("%s; %s", timestr, pfield(a->hdr_line, FIRST));
217 pval((unsigned long long) spp->processes, (unsigned long long) spc->processes);
218 printf(" %s", pfield(NULL, 0));
219 pval(spp->context_switch, spc->context_switch);
224 ***************************************************************************
225 * Display interrupts statistics in raw format.
228 * @a Activity structure with statistics.
229 * @timestr Time for current statistics sample.
230 * @curr Index in array for current sample statistics.
231 ***************************************************************************
233 __print_funct_t raw_print_irq_stats(struct activity *a, char *timestr, int curr)
236 struct stats_irq *sic, *sip;
238 for (i = 0; (i < a->nr[curr]) && (i < a->bitmap->b_size + 1); i++) {
240 sic = (struct stats_irq *) ((char *) a->buf[curr] + i * a->msize);
241 sip = (struct stats_irq *) ((char *) a->buf[!curr] + i * a->msize);
243 /* Should current interrupt (including int "sum") be displayed? */
244 if (a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))) {
246 /* Yes: Display it */
247 printf("%s; %s; %d;", timestr,
248 pfield(a->hdr_line, FIRST), i - 1);
249 printf(" %s", pfield(NULL, 0));
250 pval(sip->irq_nr, sic->irq_nr);
257 ***************************************************************************
258 * Display swapping statistics in raw format.
261 * @a Activity structure with statistics.
262 * @timestr Time for current statistics sample.
263 * @curr Index in array for current sample statistics.
264 ***************************************************************************
266 __print_funct_t raw_print_swap_stats(struct activity *a, char *timestr, int curr)
269 *ssc = (struct stats_swap *) a->buf[curr],
270 *ssp = (struct stats_swap *) a->buf[!curr];
272 printf("%s; %s", timestr, pfield(a->hdr_line, FIRST));
273 pval((unsigned long long) ssp->pswpin, (unsigned long long) ssc->pswpin);
274 printf(" %s", pfield(NULL, 0));
275 pval((unsigned long long) ssp->pswpout, (unsigned long long) ssc->pswpout);
280 ***************************************************************************
281 * Display paging statistics in raw format.
284 * @a Activity structure with statistics.
285 * @timestr Time for current statistics sample.
286 * @curr Index in array for current sample statistics.
287 ***************************************************************************
289 __print_funct_t raw_print_paging_stats(struct activity *a, char *timestr, int curr)
292 *spc = (struct stats_paging *) a->buf[curr],
293 *spp = (struct stats_paging *) a->buf[!curr];
295 printf("%s; %s", timestr, pfield(a->hdr_line, FIRST));
296 pval((unsigned long long) spp->pgpgin, (unsigned long long) spc->pgpgin);
297 printf(" %s", pfield(NULL, 0));
298 pval((unsigned long long) spp->pgpgout, (unsigned long long) spc->pgpgout);
299 printf(" %s", pfield(NULL, 0));
300 pval((unsigned long long) spp->pgfault, (unsigned long long) spc->pgfault);
301 printf(" %s", pfield(NULL, 0));
302 pval((unsigned long long) spp->pgmajfault, (unsigned long long) spc->pgmajfault);
303 printf(" %s", pfield(NULL, 0));
304 pval((unsigned long long) spp->pgfree, (unsigned long long) spc->pgfree);
305 printf(" %s", pfield(NULL, 0));
306 pval((unsigned long long) spp->pgscan_kswapd, (unsigned long long) spc->pgscan_kswapd);
307 printf(" %s", pfield(NULL, 0));
308 pval((unsigned long long) spp->pgscan_direct, (unsigned long long) spc->pgscan_direct);
309 printf(" %s", pfield(NULL, 0));
310 pval((unsigned long long) spp->pgsteal, (unsigned long long) spc->pgsteal);
315 ***************************************************************************
316 * Display I/O and transfer rate statistics in raw format.
319 * @a Activity structure with statistics.
320 * @timestr Time for current statistics sample.
321 * @curr Index in array for current sample statistics.
322 ***************************************************************************
324 __print_funct_t raw_print_io_stats(struct activity *a, char *timestr, int curr)
327 *sic = (struct stats_io *) a->buf[curr],
328 *sip = (struct stats_io *) a->buf[!curr];
330 printf("%s; %s", timestr, pfield(a->hdr_line, FIRST));
331 pval(sip->dk_drive, sic->dk_drive);
332 printf(" %s", pfield(NULL, 0));
333 pval(sip->dk_drive_rio, sic->dk_drive_rio);
334 printf(" %s", pfield(NULL, 0));
335 pval(sip->dk_drive_wio, sic->dk_drive_wio);
336 printf(" %s", pfield(NULL, 0));
337 pval(sip->dk_drive_rblk, sic->dk_drive_rblk);
338 printf(" %s", pfield(NULL, 0));
339 pval(sip->dk_drive_wblk, sic->dk_drive_wblk);
344 ***************************************************************************
345 * Display memory statistics in raw format.
348 * @a Activity structure with statistics.
349 * @timestr Time for current statistics sample.
350 * @curr Index in array for current sample statistics.
351 ***************************************************************************
353 __print_funct_t raw_print_memory_stats(struct activity *a, char *timestr, int curr)
356 *smc = (struct stats_memory *) a->buf[curr];
358 if (DISPLAY_MEMORY(a->opt_flags)) {
359 printf("%s; %s; %llu;", timestr, pfield(a->hdr_line, FIRST), smc->frmkb);
360 printf(" %s; %llu;", pfield(NULL, 0), smc->availablekb);
361 printf(" kbttlmem; %llu;", smc->tlmkb);
362 pfield(NULL, 0); /* Skip kbmemused */
363 pfield(NULL, 0); /* Skip %memused */
364 printf(" %s; %llu;", pfield(NULL, 0), smc->bufkb);
365 printf(" %s; %llu;", pfield(NULL, 0), smc->camkb);
366 printf(" %s; %llu;", pfield(NULL, 0), smc->comkb);
367 pfield(NULL, 0); /* Skip %commit */
368 printf(" %s; %llu;", pfield(NULL, 0), smc->activekb);
369 printf(" %s; %llu;", pfield(NULL, 0), smc->inactkb);
370 printf(" %s; %llu;", pfield(NULL, 0), smc->dirtykb);
372 if (DISPLAY_MEM_ALL(a->opt_flags)) {
373 printf(" %s; %llu;", pfield(NULL, 0), smc->anonpgkb);
374 printf(" %s; %llu;", pfield(NULL, 0), smc->slabkb);
375 printf(" %s; %llu;", pfield(NULL, 0), smc->kstackkb);
376 printf(" %s; %llu;", pfield(NULL, 0), smc->pgtblkb);
377 printf(" %s; %llu;", pfield(NULL, 0), smc->vmusedkb);
382 if (DISPLAY_SWAP(a->opt_flags)) {
383 printf("%s; %s; %llu;", timestr, pfield(a->hdr_line, SECOND), smc->frskb);
384 printf(" kbttlswp; %llu;", smc->tlskb);
385 pfield(NULL, 0); /* Skip kbswpused */
386 pfield(NULL, 0); /* Skip %swpused */
387 printf(" %s; %llu;", pfield(NULL, 0), smc->caskb);
393 ***************************************************************************
394 * Display kernel tables statistics in raw format.
397 * @a Activity structure with statistics.
398 * @timestr Time for current statistics sample.
399 * @curr Index in array for current sample statistics.
400 ***************************************************************************
402 __print_funct_t raw_print_ktables_stats(struct activity *a, char *timestr, int curr)
405 *skc = (struct stats_ktables *) a->buf[curr];
407 printf("%s; %s; %llu;", timestr, pfield(a->hdr_line, FIRST), skc->dentry_stat);
408 printf(" %s; %llu;", pfield(NULL, 0), skc->file_used);
409 printf(" %s; %llu;", pfield(NULL, 0), skc->inode_used);
410 printf(" %s; %llu;", pfield(NULL, 0), skc->pty_nr);
415 ***************************************************************************
416 * Display queue and load statistics in raw format.
419 * @a Activity structure with statistics.
420 * @timestr Time for current statistics sample.
421 * @curr Index in array for current sample statistics.
422 ***************************************************************************
424 __print_funct_t raw_print_queue_stats(struct activity *a, char *timestr, int curr)
427 *sqc = (struct stats_queue *) a->buf[curr];
429 printf("%s; %s; %llu;", timestr, pfield(a->hdr_line, FIRST), sqc->nr_running);
430 printf(" %s; %llu;", pfield(NULL, 0), sqc->nr_threads);
431 printf(" %s; %u;", pfield(NULL, 0), sqc->load_avg_1);
432 printf(" %s; %u;", pfield(NULL, 0), sqc->load_avg_5);
433 printf(" %s; %u;", pfield(NULL, 0), sqc->load_avg_15);
434 printf(" %s; %llu;", pfield(NULL, 0), sqc->procs_blocked);
439 ***************************************************************************
440 * Display serial lines statistics in raw format.
443 * @a Activity structure with statistics.
444 * @timestr Time for current statistics sample.
445 * @curr Index in array for current sample statistics.
446 ***************************************************************************
448 __print_funct_t raw_print_serial_stats(struct activity *a, char *timestr, int curr)
451 struct stats_serial *ssc, *ssp;
453 for (i = 0; i < a->nr[curr]; i++) {
456 ssc = (struct stats_serial *) ((char *) a->buf[curr] + i * a->msize);
458 if (a->nr[!curr] > 0) {
460 /* Look for corresponding serial line in previous iteration */
463 if (j >= a->nr[!curr]) {
464 j = a->nr[!curr] - 1;
470 ssp = (struct stats_serial *) ((char *) a->buf[!curr] + j * a->msize);
471 if (ssc->line == ssp->line) {
475 if (++j >= a->nr[!curr]) {
482 printf("%s; %s", timestr, pfield(a->hdr_line, FIRST));
483 if (!found && DISPLAY_DEBUG_MODE(flags)) {
486 printf("; %u;", ssc->line);
492 printf(" %s", pfield(NULL, 0));
493 pval((unsigned long long) ssp->rx, (unsigned long long)ssc->rx);
494 printf(" %s", pfield(NULL, 0));
495 pval((unsigned long long) ssp->tx, (unsigned long long) ssc->tx);
496 printf(" %s", pfield(NULL, 0));
497 pval((unsigned long long) ssp->frame, (unsigned long long) ssc->frame);
498 printf(" %s", pfield(NULL, 0));
499 pval((unsigned long long) ssp->parity, (unsigned long long) ssc->parity);
500 printf(" %s", pfield(NULL, 0));
501 pval((unsigned long long) ssp->brk, (unsigned long long) ssc->brk);
502 printf(" %s", pfield(NULL, 0));
503 pval((unsigned long long) ssp->overrun, (unsigned long long) ssc->overrun);
509 ***************************************************************************
510 * Display disks statistics in raw format.
513 * @a Activity structure with statistics.
514 * @timestr Time for current statistics sample.
515 * @curr Index in array for current sample statistics.
516 ***************************************************************************
518 __print_funct_t raw_print_disk_stats(struct activity *a, char *timestr, int curr)
521 struct stats_disk *sdc, *sdp, sdpzero;
524 memset(&sdpzero, 0, STATS_DISK_SIZE);
526 for (i = 0; i < a->nr[curr]; i++) {
528 sdc = (struct stats_disk *) ((char *) a->buf[curr] + i * a->msize);
530 /* Get device name */
531 dev_name = get_sa_devname(sdc->major, sdc->minor, flags);
533 if (a->item_list != NULL) {
534 /* A list of devices has been entered on the command line */
535 if (!search_list_item(a->item_list, dev_name))
536 /* Device not found */
540 printf("%s; major; %u; minor; %u; %s",
541 timestr, sdc->major, sdc->minor, pfield(a->hdr_line, FIRST));
543 j = check_disk_reg(a, curr, !curr, i);
545 /* This is a newly registered interface. Previous stats are zero */
547 if (DISPLAY_DEBUG_MODE(flags)) {
548 printf(" [%s]", j == -1 ? "NEW" : "BCK");
552 sdp = (struct stats_disk *) ((char *) a->buf[!curr] + j * a->msize);
555 printf("; %s;", dev_name);
556 printf(" %s", pfield(NULL, 0));
557 pval(sdp->nr_ios, sdc->nr_ios);
558 printf(" %s", pfield(NULL, 0));
559 pval((unsigned long long) sdp->rd_sect, (unsigned long long) sdc->rd_sect);
560 printf(" %s", pfield(NULL, 0));
561 pval((unsigned long long) sdp->wr_sect, (unsigned long long) sdc->wr_sect);
562 printf(" tot_ticks");
563 pval((unsigned long long) sdp->tot_ticks, (unsigned long long) sdc->tot_ticks);
564 pfield(NULL, 0); /* Skip areq-sz */
565 printf(" %s", pfield(NULL, 0));
566 pval((unsigned long long) sdp->rq_ticks, (unsigned long long) sdc->rq_ticks);
572 ***************************************************************************
573 * Display network interfaces statistics in raw format.
576 * @a Activity structure with statistics.
577 * @timestr Time for current statistics sample.
578 * @curr Index in array for current sample statistics.
579 ***************************************************************************
581 __print_funct_t raw_print_net_dev_stats(struct activity *a, char *timestr, int curr)
584 struct stats_net_dev *sndc, *sndp, sndzero;
586 memset(&sndzero, 0, STATS_NET_DEV_SIZE);
588 for (i = 0; i < a->nr[curr]; i++) {
590 sndc = (struct stats_net_dev *) ((char *) a->buf[curr] + i * a->msize);
592 if (a->item_list != NULL) {
593 /* A list of devices has been entered on the command line */
594 if (!search_list_item(a->item_list, sndc->interface))
595 /* Device not found */
599 printf("%s; %s", timestr, pfield(a->hdr_line, FIRST));
600 j = check_net_dev_reg(a, curr, !curr, i);
602 /* This is a newly registered interface. Previous stats are zero */
604 if (DISPLAY_DEBUG_MODE(flags)) {
605 printf(" [%s]", j == -1 ? "NEW" : "BCK");
609 sndp = (struct stats_net_dev *) ((char *) a->buf[!curr] + j * a->msize);
611 printf("; %s;", sndc->interface);
613 printf(" %s", pfield(NULL, 0));
614 pval(sndp->rx_packets, sndc->rx_packets);
615 printf(" %s", pfield(NULL, 0));
616 pval(sndp->tx_packets, sndc->tx_packets);
617 printf(" %s", pfield(NULL, 0));
618 pval(sndp->rx_bytes, sndc->rx_bytes);
619 printf(" %s", pfield(NULL, 0));
620 pval(sndp->tx_bytes, sndc->tx_bytes);
621 printf(" %s", pfield(NULL, 0));
622 pval(sndp->rx_compressed, sndc->rx_compressed);
623 printf(" %s", pfield(NULL, 0));
624 pval(sndp->tx_compressed, sndc->tx_compressed);
625 printf(" %s", pfield(NULL, 0));
626 pval(sndp->multicast, sndc->multicast);
627 printf(" speed; %u; duplex; %u;\n", sndc->speed, sndc->duplex);
632 ***************************************************************************
633 * Display network interfaces errors statistics in raw format.
636 * @a Activity structure with statistics.
637 * @timestr Time for current statistics sample.
638 * @curr Index in array for current sample statistics.
639 ***************************************************************************
641 __print_funct_t raw_print_net_edev_stats(struct activity *a, char *timestr, int curr)
644 struct stats_net_edev *snedc, *snedp, snedzero;
646 memset(&snedzero, 0, STATS_NET_EDEV_SIZE);
648 for (i = 0; i < a->nr[curr]; i++) {
650 snedc = (struct stats_net_edev *) ((char *) a->buf[curr] + i * a->msize);
652 if (a->item_list != NULL) {
653 /* A list of devices has been entered on the command line */
654 if (!search_list_item(a->item_list, snedc->interface))
655 /* Device not found */
659 printf("%s; %s", timestr, pfield(a->hdr_line, FIRST));
660 j = check_net_edev_reg(a, curr, !curr, i);
662 /* This is a newly registered interface. Previous stats are zero */
664 if (DISPLAY_DEBUG_MODE(flags)) {
665 printf(" [%s]", j == -1 ? "NEW" : "BCK");
669 snedp = (struct stats_net_edev *) ((char *) a->buf[!curr] + j * a->msize);
671 printf("; %s;", snedc->interface);
673 printf(" %s", pfield(NULL, 0));
674 pval(snedp->rx_errors, snedc->rx_errors);
675 printf(" %s", pfield(NULL, 0));
676 pval(snedp->tx_errors, snedc->tx_errors);
677 printf(" %s", pfield(NULL, 0));
678 pval(snedp->collisions, snedc->collisions);
679 printf(" %s", pfield(NULL, 0));
680 pval(snedp->rx_dropped, snedc->rx_dropped);
681 printf(" %s", pfield(NULL, 0));
682 pval(snedp->tx_dropped, snedc->tx_dropped);
683 printf(" %s", pfield(NULL, 0));
684 pval(snedp->tx_carrier_errors, snedc->tx_carrier_errors);
685 printf(" %s", pfield(NULL, 0));
686 pval(snedp->rx_frame_errors, snedc->rx_frame_errors);
687 printf(" %s", pfield(NULL, 0));
688 pval(snedp->rx_fifo_errors, snedc->rx_fifo_errors);
689 printf(" %s", pfield(NULL, 0));
690 pval(snedp->tx_fifo_errors, snedc->tx_fifo_errors);
696 ***************************************************************************
697 * Display NFS client statistics in raw format.
700 * @a Activity structure with statistics.
701 * @timestr Time for current statistics sample.
702 * @curr Index in array for current sample statistics.
703 ***************************************************************************
705 __print_funct_t raw_print_net_nfs_stats(struct activity *a, char *timestr, int curr)
708 *snnc = (struct stats_net_nfs *) a->buf[curr],
709 *snnp = (struct stats_net_nfs *) a->buf[!curr];
711 printf("%s; %s", timestr, pfield(a->hdr_line, FIRST));
712 pval((unsigned long long) snnp->nfs_rpccnt, (unsigned long long) snnc->nfs_rpccnt);
713 printf(" %s", pfield(NULL, 0));
714 pval((unsigned long long) snnp->nfs_rpcretrans, (unsigned long long) snnc->nfs_rpcretrans);
715 printf(" %s", pfield(NULL, 0));
716 pval((unsigned long long) snnp->nfs_readcnt, (unsigned long long) snnc->nfs_readcnt);
717 printf(" %s", pfield(NULL, 0));
718 pval((unsigned long long) snnp->nfs_writecnt, (unsigned long long) snnc->nfs_writecnt);
719 printf(" %s", pfield(NULL, 0));
720 pval((unsigned long long) snnp->nfs_accesscnt, (unsigned long long) snnc->nfs_accesscnt);
721 printf(" %s", pfield(NULL, 0));
722 pval((unsigned long long) snnp->nfs_getattcnt, (unsigned long long) snnc->nfs_getattcnt);
727 ***************************************************************************
728 * Display NFS server statistics in raw format.
731 * @a Activity structure with statistics.
732 * @timestr Time for current statistics sample.
733 * @curr Index in array for current sample statistics.
734 ***************************************************************************
736 __print_funct_t raw_print_net_nfsd_stats(struct activity *a, char *timestr, int curr)
738 struct stats_net_nfsd
739 *snndc = (struct stats_net_nfsd *) a->buf[curr],
740 *snndp = (struct stats_net_nfsd *) a->buf[!curr];
742 printf("%s; %s", timestr, pfield(a->hdr_line, FIRST));
743 pval((unsigned long long) snndp->nfsd_rpccnt, (unsigned long long) snndc->nfsd_rpccnt);
744 printf(" %s", pfield(NULL, 0));
745 pval((unsigned long long) snndp->nfsd_rpcbad, (unsigned long long) snndc->nfsd_rpcbad);
746 printf(" %s", pfield(NULL, 0));
747 pval((unsigned long long) snndp->nfsd_netcnt, (unsigned long long) snndc->nfsd_netcnt);
748 printf(" %s", pfield(NULL, 0));
749 pval((unsigned long long) snndp->nfsd_netudpcnt, (unsigned long long) snndc->nfsd_netudpcnt);
750 printf(" %s", pfield(NULL, 0));
751 pval((unsigned long long) snndp->nfsd_nettcpcnt, (unsigned long long) snndc->nfsd_nettcpcnt);
752 printf(" %s", pfield(NULL, 0));
753 pval((unsigned long long) snndp->nfsd_rchits, (unsigned long long) snndc->nfsd_rchits);
754 printf(" %s", pfield(NULL, 0));
755 pval((unsigned long long) snndp->nfsd_rcmisses, (unsigned long long) snndc->nfsd_rcmisses);
756 printf(" %s", pfield(NULL, 0));
757 pval((unsigned long long) snndp->nfsd_readcnt, (unsigned long long) snndc->nfsd_readcnt);
758 printf(" %s", pfield(NULL, 0));
759 pval((unsigned long long) snndp->nfsd_writecnt, (unsigned long long) snndc->nfsd_writecnt);
760 printf(" %s", pfield(NULL, 0));
761 pval((unsigned long long) snndp->nfsd_accesscnt, (unsigned long long) snndc->nfsd_accesscnt);
762 printf(" %s", pfield(NULL, 0));
763 pval((unsigned long long) snndp->nfsd_getattcnt, (unsigned long long) snndc->nfsd_getattcnt);
768 ***************************************************************************
769 * Display network socket statistics in raw format.
772 * @a Activity structure with statistics.
773 * @timestr Time for current statistics sample.
774 * @curr Index in array for current sample statistics.
775 ***************************************************************************
777 __print_funct_t raw_print_net_sock_stats(struct activity *a, char *timestr, int curr)
779 struct stats_net_sock
780 *snsc = (struct stats_net_sock *) a->buf[curr];
782 printf("%s; %s; %u;", timestr, pfield(a->hdr_line, FIRST), snsc->sock_inuse);
783 printf(" %s; %u;", pfield(NULL, 0), snsc->tcp_inuse);
784 printf(" %s; %u;", pfield(NULL, 0), snsc->udp_inuse);
785 printf(" %s; %u;", pfield(NULL, 0), snsc->raw_inuse);
786 printf(" %s; %u;", pfield(NULL, 0), snsc->frag_inuse);
787 printf(" %s; %u;", pfield(NULL, 0), snsc->tcp_tw);
792 ***************************************************************************
793 * Display IP network statistics in raw format.
796 * @a Activity structure with statistics.
797 * @timestr Time for current statistics sample.
798 * @curr Index in array for current sample statistics.
799 ***************************************************************************
801 __print_funct_t raw_print_net_ip_stats(struct activity *a, char *timestr, int curr)
804 *snic = (struct stats_net_ip *) a->buf[curr],
805 *snip = (struct stats_net_ip *) a->buf[!curr];
807 printf("%s; %s", timestr, pfield(a->hdr_line, FIRST));
808 pval(snip->InReceives, snic->InReceives);
809 printf(" %s", pfield(NULL, 0));
810 pval(snip->ForwDatagrams, snic->ForwDatagrams);
811 printf(" %s", pfield(NULL, 0));
812 pval(snip->InDelivers, snic->InDelivers);
813 printf(" %s", pfield(NULL, 0));
814 pval(snip->OutRequests, snic->OutRequests);
815 printf(" %s", pfield(NULL, 0));
816 pval(snip->ReasmReqds, snic->ReasmReqds);
817 printf(" %s", pfield(NULL, 0));
818 pval(snip->ReasmOKs, snic->ReasmOKs);
819 printf(" %s", pfield(NULL, 0));
820 pval(snip->FragOKs, snic->FragOKs);
821 printf(" %s", pfield(NULL, 0));
822 pval(snip->FragCreates, snic->FragCreates);
827 ***************************************************************************
828 * Display IP network errors statistics in raw format.
831 * @a Activity structure with statistics.
832 * @timestr Time for current statistics sample.
833 * @curr Index in array for current sample statistics.
834 ***************************************************************************
836 __print_funct_t raw_print_net_eip_stats(struct activity *a, char *timestr, int curr)
839 *sneic = (struct stats_net_eip *) a->buf[curr],
840 *sneip = (struct stats_net_eip *) a->buf[!curr];
842 printf("%s; %s", timestr, pfield(a->hdr_line, FIRST));
843 pval(sneip->InHdrErrors, sneic->InHdrErrors);
844 printf(" %s", pfield(NULL, 0));
845 pval(sneip->InAddrErrors, sneic->InAddrErrors);
846 printf(" %s", pfield(NULL, 0));
847 pval(sneip->InUnknownProtos, sneic->InUnknownProtos);
848 printf(" %s", pfield(NULL, 0));
849 pval(sneip->InDiscards, sneic->InDiscards);
850 printf(" %s", pfield(NULL, 0));
851 pval(sneip->OutDiscards, sneic->OutDiscards);
852 printf(" %s", pfield(NULL, 0));
853 pval(sneip->OutNoRoutes, sneic->OutNoRoutes);
854 printf(" %s", pfield(NULL, 0));
855 pval(sneip->ReasmFails, sneic->ReasmFails);
856 printf(" %s", pfield(NULL, 0));
857 pval(sneip->FragFails, sneic->FragFails);
862 ***************************************************************************
863 * Display ICMP network statistics in raw format.
866 * @a Activity structure with statistics.
867 * @timestr Time for current statistics sample.
868 * @curr Index in array for current sample statistics.
869 ***************************************************************************
871 __print_funct_t raw_print_net_icmp_stats(struct activity *a, char *timestr, int curr)
873 struct stats_net_icmp
874 *snic = (struct stats_net_icmp *) a->buf[curr],
875 *snip = (struct stats_net_icmp *) a->buf[!curr];
877 printf("%s; %s", timestr, pfield(a->hdr_line, FIRST));
878 pval((unsigned long long) snip->InMsgs, (unsigned long long) snic->InMsgs);
879 printf(" %s", pfield(NULL, 0));
880 pval((unsigned long long) snip->OutMsgs, (unsigned long long) snic->OutMsgs);
881 printf(" %s", pfield(NULL, 0));
882 pval((unsigned long long) snip->InEchos, (unsigned long long) snic->InEchos);
883 printf(" %s", pfield(NULL, 0));
884 pval((unsigned long long) snip->InEchoReps, (unsigned long long) snic->InEchoReps);
885 printf(" %s", pfield(NULL, 0));
886 pval((unsigned long long) snip->OutEchos, (unsigned long long) snic->OutEchos);
887 printf(" %s", pfield(NULL, 0));
888 pval((unsigned long long) snip->OutEchoReps, (unsigned long long) snic->OutEchoReps);
889 printf(" %s", pfield(NULL, 0));
890 pval((unsigned long long) snip->InTimestamps, (unsigned long long) snic->InTimestamps);
891 printf(" %s", pfield(NULL, 0));
892 pval((unsigned long long) snip->InTimestampReps, (unsigned long long) snic->InTimestampReps);
893 printf(" %s", pfield(NULL, 0));
894 pval((unsigned long long) snip->OutTimestamps, (unsigned long long) snic->OutTimestamps);
895 printf(" %s", pfield(NULL, 0));
896 pval((unsigned long long) snip->OutTimestampReps, (unsigned long long) snic->OutTimestampReps);
897 printf(" %s", pfield(NULL, 0));
898 pval((unsigned long long) snip->InAddrMasks, (unsigned long long) snic->InAddrMasks);
899 printf(" %s", pfield(NULL, 0));
900 pval((unsigned long long) snip->InAddrMaskReps, (unsigned long long) snic->InAddrMaskReps);
901 printf(" %s", pfield(NULL, 0));
902 pval((unsigned long long) snip->OutAddrMasks, (unsigned long long) snic->OutAddrMasks);
903 printf(" %s", pfield(NULL, 0));
904 pval((unsigned long long) snip->OutAddrMaskReps, (unsigned long long) snic->OutAddrMaskReps);
909 ***************************************************************************
910 * Display ICMP errors message statistics in raw format.
913 * @a Activity structure with statistics.
914 * @timestr Time for current statistics sample.
915 * @curr Index in array for current sample statistics.
916 ***************************************************************************
918 __print_funct_t raw_print_net_eicmp_stats(struct activity *a, char *timestr, int curr)
920 struct stats_net_eicmp
921 *sneic = (struct stats_net_eicmp *) a->buf[curr],
922 *sneip = (struct stats_net_eicmp *) a->buf[!curr];
924 printf("%s; %s", timestr, pfield(a->hdr_line, FIRST));
925 pval((unsigned long long) sneip->InErrors, (unsigned long long) sneic->InErrors);
926 printf(" %s", pfield(NULL, 0));
927 pval((unsigned long long) sneip->OutErrors, (unsigned long long) sneic->OutErrors);
928 printf(" %s", pfield(NULL, 0));
929 pval((unsigned long long) sneip->InDestUnreachs, (unsigned long long) sneic->InDestUnreachs);
930 printf(" %s", pfield(NULL, 0));
931 pval((unsigned long long) sneip->OutDestUnreachs, (unsigned long long) sneic->OutDestUnreachs);
932 printf(" %s", pfield(NULL, 0));
933 pval((unsigned long long) sneip->InTimeExcds, (unsigned long long) sneic->InTimeExcds);
934 printf(" %s", pfield(NULL, 0));
935 pval((unsigned long long) sneip->OutTimeExcds, (unsigned long long) sneic->OutTimeExcds);
936 printf(" %s", pfield(NULL, 0));
937 pval((unsigned long long) sneip->InParmProbs, (unsigned long long) sneic->InParmProbs);
938 printf(" %s", pfield(NULL, 0));
939 pval((unsigned long long) sneip->OutParmProbs, (unsigned long long) sneic->OutParmProbs);
940 printf(" %s", pfield(NULL, 0));
941 pval((unsigned long long) sneip->InSrcQuenchs, (unsigned long long) sneic->InSrcQuenchs);
942 printf(" %s", pfield(NULL, 0));
943 pval((unsigned long long) sneip->OutSrcQuenchs, (unsigned long long) sneic->OutSrcQuenchs);
944 printf(" %s", pfield(NULL, 0));
945 pval((unsigned long long) sneip->InRedirects, (unsigned long long) sneic->InRedirects);
946 printf(" %s", pfield(NULL, 0));
947 pval((unsigned long long) sneip->OutRedirects, (unsigned long long) sneic->OutRedirects);
952 ***************************************************************************
953 * Display TCP network statistics in raw format.
956 * @a Activity structure with statistics.
957 * @timestr Time for current statistics sample.
958 * @curr Index in array for current sample statistics.
959 ***************************************************************************
961 __print_funct_t raw_print_net_tcp_stats(struct activity *a, char *timestr, int curr)
964 *sntc = (struct stats_net_tcp *) a->buf[curr],
965 *sntp = (struct stats_net_tcp *) a->buf[!curr];
967 printf("%s; %s", timestr, pfield(a->hdr_line, FIRST));
968 pval((unsigned long long) sntp->ActiveOpens, (unsigned long long) sntc->ActiveOpens);
969 printf(" %s", pfield(NULL, 0));
970 pval((unsigned long long) sntp->PassiveOpens, (unsigned long long) sntc->PassiveOpens);
971 printf(" %s", pfield(NULL, 0));
972 pval((unsigned long long) sntp->InSegs, (unsigned long long) sntc->InSegs);
973 printf(" %s", pfield(NULL, 0));
974 pval((unsigned long long) sntp->OutSegs, (unsigned long long) sntc->OutSegs);
979 ***************************************************************************
980 * Display TCP network errors statistics in raw format.
983 * @a Activity structure with statistics.
984 * @timestr Time for current statistics sample.
985 * @curr Index in array for current sample statistics.
986 ***************************************************************************
988 __print_funct_t raw_print_net_etcp_stats(struct activity *a, char *timestr, int curr)
990 struct stats_net_etcp
991 *snetc = (struct stats_net_etcp *) a->buf[curr],
992 *snetp = (struct stats_net_etcp *) a->buf[!curr];
994 printf("%s; %s", timestr, pfield(a->hdr_line, FIRST));
995 pval((unsigned long long) snetp->AttemptFails, (unsigned long long) snetc->AttemptFails);
996 printf(" %s", pfield(NULL, 0));
997 pval((unsigned long long) snetp->EstabResets, (unsigned long long) snetc->EstabResets);
998 printf(" %s", pfield(NULL, 0));
999 pval((unsigned long long) snetp->RetransSegs, (unsigned long long) snetc->RetransSegs);
1000 printf(" %s", pfield(NULL, 0));
1001 pval((unsigned long long) snetp->InErrs, (unsigned long long) snetc->InErrs);
1002 printf(" %s", pfield(NULL, 0));
1003 pval((unsigned long long) snetp->OutRsts, (unsigned long long) snetc->OutRsts);
1008 ***************************************************************************
1009 * Display UDP network statistics in raw format.
1012 * @a Activity structure with statistics.
1013 * @timestr Time for current statistics sample.
1014 * @curr Index in array for current sample statistics.
1015 ***************************************************************************
1017 __print_funct_t raw_print_net_udp_stats(struct activity *a, char *timestr, int curr)
1019 struct stats_net_udp
1020 *snuc = (struct stats_net_udp *) a->buf[curr],
1021 *snup = (struct stats_net_udp *) a->buf[!curr];
1023 printf("%s; %s", timestr, pfield(a->hdr_line, FIRST));
1024 pval((unsigned long long) snup->InDatagrams, (unsigned long long) snuc->InDatagrams);
1025 printf(" %s", pfield(NULL, 0));
1026 pval((unsigned long long) snup->OutDatagrams, (unsigned long long) snuc->OutDatagrams);
1027 printf(" %s", pfield(NULL, 0));
1028 pval((unsigned long long) snup->NoPorts, (unsigned long long) snuc->NoPorts);
1029 printf(" %s", pfield(NULL, 0));
1030 pval((unsigned long long) snup->InErrors, (unsigned long long) snuc->InErrors);
1035 ***************************************************************************
1036 * Display IPv6 network socket statistics in raw format.
1039 * @a Activity structure with statistics.
1040 * @timestr Time for current statistics sample.
1041 * @curr Index in array for current sample statistics.
1042 ***************************************************************************
1044 __print_funct_t raw_print_net_sock6_stats(struct activity *a, char *timestr, int curr)
1046 struct stats_net_sock6
1047 *snsc = (struct stats_net_sock6 *) a->buf[curr];
1049 printf("%s; %s; %u;", timestr, pfield(a->hdr_line, FIRST), snsc->tcp6_inuse);
1050 printf(" %s; %u;", pfield(NULL, 0), snsc->udp6_inuse);
1051 printf(" %s; %u;", pfield(NULL, 0), snsc->raw6_inuse);
1052 printf(" %s; %u;", pfield(NULL, 0), snsc->frag6_inuse);
1057 ***************************************************************************
1058 * Display IPv6 network statistics in raw format.
1061 * @a Activity structure with statistics.
1062 * @timestr Time for current statistics sample.
1063 * @curr Index in array for current sample statistics.
1064 ***************************************************************************
1066 __print_funct_t raw_print_net_ip6_stats(struct activity *a, char *timestr, int curr)
1068 struct stats_net_ip6
1069 *snic = (struct stats_net_ip6 *) a->buf[curr],
1070 *snip = (struct stats_net_ip6 *) a->buf[!curr];
1072 printf("%s; %s", timestr, pfield(a->hdr_line, FIRST));
1073 pval(snip->InReceives6, snic->InReceives6);
1074 printf(" %s", pfield(NULL, 0));
1075 pval(snip->OutForwDatagrams6, snic->OutForwDatagrams6);
1076 printf(" %s", pfield(NULL, 0));
1077 pval(snip->InDelivers6, snic->InDelivers6);
1078 printf(" %s", pfield(NULL, 0));
1079 pval(snip->OutRequests6, snic->OutRequests6);
1080 printf(" %s", pfield(NULL, 0));
1081 pval(snip->ReasmReqds6, snic->ReasmReqds6);
1082 printf(" %s", pfield(NULL, 0));
1083 pval(snip->ReasmOKs6, snic->ReasmOKs6);
1084 printf(" %s", pfield(NULL, 0));
1085 pval(snip->InMcastPkts6, snic->InMcastPkts6);
1086 printf(" %s", pfield(NULL, 0));
1087 pval(snip->OutMcastPkts6, snic->OutMcastPkts6);
1088 printf(" %s", pfield(NULL, 0));
1089 pval(snip->FragOKs6, snic->FragOKs6);
1090 printf(" %s", pfield(NULL, 0));
1091 pval(snip->FragCreates6, snic->FragCreates6);
1096 ***************************************************************************
1097 * Display IPv6 network errors statistics in raw format.
1100 * @a Activity structure with statistics.
1101 * @timestr Time for current statistics sample.
1102 * @curr Index in array for current sample statistics.
1103 ***************************************************************************
1105 __print_funct_t raw_print_net_eip6_stats(struct activity *a, char *timestr, int curr)
1107 struct stats_net_eip6
1108 *sneic = (struct stats_net_eip6 *) a->buf[curr],
1109 *sneip = (struct stats_net_eip6 *) a->buf[!curr];
1111 printf("%s; %s", timestr, pfield(a->hdr_line, FIRST));
1112 pval(sneip->InHdrErrors6, sneic->InHdrErrors6);
1113 printf(" %s", pfield(NULL, 0));
1114 pval(sneip->InAddrErrors6, sneic->InAddrErrors6);
1115 printf(" %s", pfield(NULL, 0));
1116 pval(sneip->InUnknownProtos6, sneic->InUnknownProtos6);
1117 printf(" %s", pfield(NULL, 0));
1118 pval(sneip->InTooBigErrors6, sneic->InTooBigErrors6);
1119 printf(" %s", pfield(NULL, 0));
1120 pval(sneip->InDiscards6, sneic->InDiscards6);
1121 printf(" %s", pfield(NULL, 0));
1122 pval(sneip->OutDiscards6, sneic->OutDiscards6);
1123 printf(" %s", pfield(NULL, 0));
1124 pval(sneip->InNoRoutes6, sneic->InNoRoutes6);
1125 printf(" %s", pfield(NULL, 0));
1126 pval(sneip->OutNoRoutes6, sneic->OutNoRoutes6);
1127 printf(" %s", pfield(NULL, 0));
1128 pval(sneip->ReasmFails6, sneic->ReasmFails6);
1129 printf(" %s", pfield(NULL, 0));
1130 pval(sneip->FragFails6, sneic->FragFails6);
1131 printf(" %s", pfield(NULL, 0));
1132 pval(sneip->InTruncatedPkts6, sneic->InTruncatedPkts6);
1137 ***************************************************************************
1138 * Display ICMPv6 network statistics in raw format.
1141 * @a Activity structure with statistics.
1142 * @timestr Time for current statistics sample.
1143 * @curr Index in array for current sample statistics.
1144 ***************************************************************************
1146 __print_funct_t raw_print_net_icmp6_stats(struct activity *a, char *timestr, int curr)
1148 struct stats_net_icmp6
1149 *snic = (struct stats_net_icmp6 *) a->buf[curr],
1150 *snip = (struct stats_net_icmp6 *) a->buf[!curr];
1152 printf("%s; %s", timestr, pfield(a->hdr_line, FIRST));
1153 pval((unsigned long long) snip->InMsgs6,
1154 (unsigned long long) snic->InMsgs6);
1155 printf(" %s", pfield(NULL, 0));
1156 pval((unsigned long long) snip->OutMsgs6,
1157 (unsigned long long) snic->OutMsgs6);
1158 printf(" %s", pfield(NULL, 0));
1159 pval((unsigned long long) snip->InEchos6,
1160 (unsigned long long) snic->InEchos6);
1161 printf(" %s", pfield(NULL, 0));
1162 pval((unsigned long long) snip->InEchoReplies6,
1163 (unsigned long long) snic->InEchoReplies6);
1164 printf(" %s", pfield(NULL, 0));
1165 pval((unsigned long long) snip->OutEchoReplies6,
1166 (unsigned long long) snic->OutEchoReplies6);
1167 printf(" %s", pfield(NULL, 0));
1168 pval((unsigned long long) snip->InGroupMembQueries6,
1169 (unsigned long long) snic->InGroupMembQueries6);
1170 printf(" %s", pfield(NULL, 0));
1171 pval((unsigned long long) snip->InGroupMembResponses6,
1172 (unsigned long long) snic->InGroupMembResponses6);
1173 printf(" %s", pfield(NULL, 0));
1174 pval((unsigned long long) snip->OutGroupMembResponses6,
1175 (unsigned long long) snic->OutGroupMembResponses6);
1176 printf(" %s", pfield(NULL, 0));
1177 pval((unsigned long long) snip->InGroupMembReductions6,
1178 (unsigned long long) snic->InGroupMembReductions6);
1179 printf(" %s", pfield(NULL, 0));
1180 pval((unsigned long long) snip->OutGroupMembReductions6,
1181 (unsigned long long) snic->OutGroupMembReductions6);
1182 printf(" %s", pfield(NULL, 0));
1183 pval((unsigned long long) snip->InRouterSolicits6,
1184 (unsigned long long) snic->InRouterSolicits6);
1185 printf(" %s", pfield(NULL, 0));
1186 pval((unsigned long long) snip->OutRouterSolicits6,
1187 (unsigned long long) snic->OutRouterSolicits6);
1188 printf(" %s", pfield(NULL, 0));
1189 pval((unsigned long long) snip->InRouterAdvertisements6,
1190 (unsigned long long) snic->InRouterAdvertisements6);
1191 printf(" %s", pfield(NULL, 0));
1192 pval((unsigned long long) snip->InNeighborSolicits6,
1193 (unsigned long long) snic->InNeighborSolicits6);
1194 printf(" %s", pfield(NULL, 0));
1195 pval((unsigned long long) snip->OutNeighborSolicits6,
1196 (unsigned long long) snic->OutNeighborSolicits6);
1197 printf(" %s", pfield(NULL, 0));
1198 pval((unsigned long long) snip->InNeighborAdvertisements6,
1199 (unsigned long long) snic->InNeighborAdvertisements6);
1200 printf(" %s", pfield(NULL, 0));
1201 pval((unsigned long long) snip->OutNeighborAdvertisements6,
1202 (unsigned long long) snic->OutNeighborAdvertisements6);
1207 ***************************************************************************
1208 * Display ICMPv6 error messages statistics in rw format.
1211 * @a Activity structure with statistics.
1212 * @timestr Time for current statistics sample.
1213 * @curr Index in array for current sample statistics.
1214 ***************************************************************************
1216 __print_funct_t raw_print_net_eicmp6_stats(struct activity *a, char *timestr, int curr)
1218 struct stats_net_eicmp6
1219 *sneic = (struct stats_net_eicmp6 *) a->buf[curr],
1220 *sneip = (struct stats_net_eicmp6 *) a->buf[!curr];
1222 printf("%s; %s", timestr, pfield(a->hdr_line, FIRST));
1223 pval((unsigned long long) sneip->InErrors6, (unsigned long long) sneic->InErrors6);
1224 printf(" %s", pfield(NULL, 0));
1225 pval((unsigned long long) sneip->InDestUnreachs6, (unsigned long long) sneic->InDestUnreachs6);
1226 printf(" %s", pfield(NULL, 0));
1227 pval((unsigned long long) sneip->OutDestUnreachs6, (unsigned long long) sneic->OutDestUnreachs6);
1228 printf(" %s", pfield(NULL, 0));
1229 pval((unsigned long long) sneip->InTimeExcds6, (unsigned long long) sneic->InTimeExcds6);
1230 printf(" %s", pfield(NULL, 0));
1231 pval((unsigned long long) sneip->OutTimeExcds6, (unsigned long long) sneic->OutTimeExcds6);
1232 printf(" %s", pfield(NULL, 0));
1233 pval((unsigned long long) sneip->InParmProblems6, (unsigned long long) sneic->InParmProblems6);
1234 printf(" %s", pfield(NULL, 0));
1235 pval((unsigned long long) sneip->OutParmProblems6, (unsigned long long) sneic->OutParmProblems6);
1236 printf(" %s", pfield(NULL, 0));
1237 pval((unsigned long long) sneip->InRedirects6, (unsigned long long) sneic->InRedirects6);
1238 printf(" %s", pfield(NULL, 0));
1239 pval((unsigned long long) sneip->OutRedirects6, (unsigned long long) sneic->OutRedirects6);
1240 printf(" %s", pfield(NULL, 0));
1241 pval((unsigned long long) sneip->InPktTooBigs6, (unsigned long long) sneic->InPktTooBigs6);
1242 printf(" %s", pfield(NULL, 0));
1243 pval((unsigned long long) sneip->OutPktTooBigs6, (unsigned long long) sneic->OutPktTooBigs6);
1248 ***************************************************************************
1249 * Display UDPv6 network statistics in raw format.
1252 * @a Activity structure with statistics.
1253 * @timestr Time for current statistics sample.
1254 * @curr Index in array for current sample statistics.
1255 ***************************************************************************
1257 __print_funct_t raw_print_net_udp6_stats(struct activity *a, char *timestr, int curr)
1259 struct stats_net_udp6
1260 *snuc = (struct stats_net_udp6 *) a->buf[curr],
1261 *snup = (struct stats_net_udp6 *) a->buf[!curr];
1263 printf("%s; %s", timestr, pfield(a->hdr_line, FIRST));
1264 pval((unsigned long long) snup->InDatagrams6, (unsigned long long) snuc->InDatagrams6);
1265 printf(" %s", pfield(NULL, 0));
1266 pval((unsigned long long) snup->OutDatagrams6, (unsigned long long) snuc->OutDatagrams6);
1267 printf(" %s", pfield(NULL, 0));
1268 pval((unsigned long long) snup->NoPorts6, (unsigned long long) snuc->NoPorts6);
1269 printf(" %s", pfield(NULL, 0));
1270 pval((unsigned long long) snup->InErrors6, (unsigned long long) snuc->InErrors6);
1275 ***************************************************************************
1276 * Display CPU frequency statistics in raw format.
1279 * @a Activity structure with statistics.
1280 * @timestr Time for current statistics sample.
1281 * @curr Index in array for current sample statistics.
1282 ***************************************************************************
1284 __print_funct_t raw_print_pwr_cpufreq_stats(struct activity *a, char *timestr, int curr)
1287 struct stats_pwr_cpufreq *spc;
1289 for (i = 0; (i < a->nr[curr]) && (i < a->bitmap->b_size + 1); i++) {
1291 spc = (struct stats_pwr_cpufreq *) ((char *) a->buf[curr] + i * a->msize);
1293 /* Should current CPU (including CPU "all") be displayed? */
1294 if (a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))) {
1295 /* Yes: Display it */
1296 printf("%s; %s; %d;", timestr, pfield(a->hdr_line, FIRST), i - 1);
1297 printf(" %s; %lu;\n", pfield(NULL, 0), spc->cpufreq);
1303 ***************************************************************************
1304 * Display fan statistics in raw format.
1307 * @a Activity structure with statistics.
1308 * @timestr Time for current statistics sample.
1309 * @curr Index in array for current sample statistics.
1310 ***************************************************************************
1312 __print_funct_t raw_print_pwr_fan_stats(struct activity *a, char *timestr, int curr)
1315 struct stats_pwr_fan *spc;
1317 for (i = 0; i < a->nr[curr]; i++) {
1318 spc = (struct stats_pwr_fan *) ((char *) a->buf[curr] + i * a->msize);
1320 printf("%s; %s; %d;", timestr, pfield(a->hdr_line, FIRST), i + 1);
1321 printf(" %s; %s;", pfield(NULL, 0), spc->device);
1322 printf(" %s; %f;", pfield(NULL, 0), spc->rpm);
1323 printf(" rpm_min; %f;\n", spc->rpm_min);
1328 ***************************************************************************
1329 * Display temperature statistics in raw format.
1332 * @a Activity structure with statistics.
1333 * @timestr Time for current statistics sample.
1334 * @curr Index in array for current sample statistics.
1335 ***************************************************************************
1337 __print_funct_t raw_print_pwr_temp_stats(struct activity *a, char *timestr, int curr)
1340 struct stats_pwr_temp *spc;
1342 for (i = 0; i < a->nr[curr]; i++) {
1343 spc = (struct stats_pwr_temp *) ((char *) a->buf[curr] + i * a->msize);
1345 printf("%s; %s; %d;", timestr, pfield(a->hdr_line, FIRST), i + 1);
1346 printf(" %s; %s;", pfield(NULL, 0), spc->device);
1347 printf(" %s; %f;", pfield(NULL, 0), spc->temp);
1348 printf(" temp_min; %f;", spc->temp_min);
1349 printf(" temp_max; %f;\n", spc->temp_max);
1354 ***************************************************************************
1355 * Display voltage inputs statistics in raw format.
1358 * @a Activity structure with statistics.
1359 * @timestr Time for current statistics sample.
1360 * @curr Index in array for current sample statistics.
1361 ***************************************************************************
1363 __print_funct_t raw_print_pwr_in_stats(struct activity *a, char *timestr, int curr)
1366 struct stats_pwr_in *spc;
1368 for (i = 0; i < a->nr[curr]; i++) {
1369 spc = (struct stats_pwr_in *) ((char *) a->buf[curr] + i * a->msize);
1371 printf("%s; %s; %d;", timestr, pfield(a->hdr_line, FIRST), i);
1372 printf(" %s; %s;", pfield(NULL, 0), spc->device);
1373 printf(" %s; %f;", pfield(NULL, 0), spc->in);
1374 printf(" in_min; %f;", spc->in_min);
1375 printf(" in_max; %f;\n", spc->in_max);
1380 ***************************************************************************
1381 * Display huge pages statistics in raw format.
1384 * @a Activity structure with statistics.
1385 * @timestr Time for current statistics sample.
1386 * @curr Index in array for current sample statistics.
1387 ***************************************************************************
1389 __print_funct_t raw_print_huge_stats(struct activity *a, char *timestr, int curr)
1392 *smc = (struct stats_huge *) a->buf[curr];
1394 printf("%s; %s; %llu;", timestr, pfield(a->hdr_line, FIRST), smc->frhkb);
1395 printf(" hugtotal; %llu;\n", smc->tlhkb);
1399 ***************************************************************************
1400 * Display weighted CPU frequency statistics in raw format.
1403 * @a Activity structure with statistics.
1404 * @timestr Time for current statistics sample.
1405 * @curr Index in array for current sample statistics.
1406 ***************************************************************************
1408 __print_funct_t raw_print_pwr_wghfreq_stats(struct activity *a, char *timestr, int curr)
1411 struct stats_pwr_wghfreq *spc, *spp, *spc_k, *spp_k;
1413 for (i = 0; (i < a->nr[curr]) && (i < a->bitmap->b_size + 1); i++) {
1415 spc = (struct stats_pwr_wghfreq *) ((char *) a->buf[curr] + i * a->msize * a->nr2);
1416 spp = (struct stats_pwr_wghfreq *) ((char *) a->buf[!curr] + i * a->msize * a->nr2);
1418 /* Should current CPU (including CPU "all") be displayed? */
1419 if (!(a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))))
1423 printf("%s; %s; %d;", timestr, pfield(a->hdr_line, FIRST), i - 1);
1425 for (k = 0; k < a->nr2; k++) {
1427 spc_k = (struct stats_pwr_wghfreq *) ((char *) spc + k * a->msize);
1430 spp_k = (struct stats_pwr_wghfreq *) ((char *) spp + k * a->msize);
1432 printf(" freq; %lu;", spc_k->freq);
1434 pval(spp_k->time_in_state, spc_k->time_in_state);
1441 ***************************************************************************
1442 * Display USB devices statistics in raw format.
1445 * @a Activity structure with statistics.
1446 * @timestr Time for current statistics sample.
1447 * @curr Index in array for current sample statistics.
1448 ***************************************************************************
1450 __print_funct_t raw_print_pwr_usb_stats(struct activity *a, char *timestr, int curr)
1453 struct stats_pwr_usb *suc;
1455 for (i = 0; i < a->nr[curr]; i++) {
1456 suc = (struct stats_pwr_usb *) ((char *) a->buf[curr] + i * a->msize);
1458 printf("%s; %s; \"%s\";", timestr, pfield(a->hdr_line, FIRST), suc->manufacturer);
1459 printf(" %s; \"%s\";", pfield(NULL, 0), suc->product);
1460 printf(" %s; %d;", pfield(NULL, 0), suc->bus_nr);
1461 printf(" %s; %x;", pfield(NULL, 0), suc->vendor_id);
1462 printf(" %s; %x;", pfield(NULL, 0), suc->product_id);
1463 printf(" %s; %u;\n", pfield(NULL, 0), suc->bmaxpower);
1468 ***************************************************************************
1469 * Display filesystems statistics in raw format.
1472 * @a Activity structure with statistics.
1473 * @timestr Time for current statistics sample.
1474 * @curr Index in array for current sample statistics.
1475 ***************************************************************************
1477 __print_funct_t raw_print_filesystem_stats(struct activity *a, char *timestr, int curr)
1480 struct stats_filesystem *sfc;
1482 for (i = 0; i < a->nr[curr]; i++) {
1483 sfc = (struct stats_filesystem *) ((char *) a->buf[curr] + i * a->msize);
1485 if (a->item_list != NULL) {
1486 /* A list of devices has been entered on the command line */
1487 if (!search_list_item(a->item_list,
1488 DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name))
1489 /* Device not found */
1493 printf("%s; %s; \"%s\";", timestr, pfield(a->hdr_line, FIRST + DISPLAY_MOUNT(a->opt_flags)),
1494 DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name);
1495 printf(" f_bfree; %llu;", sfc->f_bfree);
1496 printf(" f_blocks; %llu;", sfc->f_blocks);
1497 printf(" f_bavail; %llu;", sfc->f_bavail);
1498 pfield(NULL, 0); /* Skip MBfsfree */
1499 pfield(NULL, 0); /* Skip MBfsused */
1500 pfield(NULL, 0); /* Skip %fsused */
1501 pfield(NULL, 0); /* Skip %ufsused */
1502 printf(" %s; %llu;", pfield(NULL, 0), sfc->f_ffree);
1503 printf(" f_files; %llu;\n", sfc->f_files);
1509 ***************************************************************************
1510 * Display Fibre Channel HBA statistics in raw format.
1513 * @a Activity structure with statistics.
1514 * @timestr Time for current statistics sample.
1515 * @curr Index in array for current sample statistics.
1516 ***************************************************************************
1518 __print_funct_t raw_print_fchost_stats(struct activity *a, char *timestr, int curr)
1520 int i, j, j0, found;
1521 struct stats_fchost *sfcc, *sfcp;
1523 for (i = 0; i < a->nr[curr]; i++) {
1527 if (a->nr[!curr] > 0) {
1528 sfcc = (struct stats_fchost *) ((char *) a->buf[curr] + i * a->msize);
1530 /* Look for corresponding structure in previous iteration */
1533 if (j >= a->nr[!curr]) {
1534 j = a->nr[!curr] - 1;
1540 sfcp = (struct stats_fchost *) ((char *) a->buf[!curr] + j * a->msize);
1541 if (!strcmp(sfcc->fchost_name, sfcp->fchost_name)) {
1545 if (++j >= a->nr[!curr]) {
1555 printf("%s; %s; %s;", timestr, pfield(a->hdr_line, FIRST), sfcc->fchost_name);
1556 printf(" %s", pfield(NULL, 0));
1557 pval((unsigned long long) sfcp->f_rxframes, (unsigned long long) sfcc->f_rxframes);
1558 printf(" %s", pfield(NULL, 0));
1559 pval((unsigned long long) sfcp->f_txframes, (unsigned long long) sfcc->f_txframes);
1560 printf(" %s", pfield(NULL, 0));
1561 pval((unsigned long long) sfcp->f_rxwords, (unsigned long long) sfcc->f_rxwords);
1562 printf(" %s", pfield(NULL, 0));
1563 pval((unsigned long long) sfcp->f_txwords, (unsigned long long) sfcc->f_txwords);
1569 ***************************************************************************
1570 * Display softnet statistics in raw format.
1573 * @a Activity structure with statistics.
1574 * @timestr Time for current statistics sample.
1575 * @curr Index in array for current sample statistics.
1576 ***************************************************************************
1578 __print_funct_t raw_print_softnet_stats(struct activity *a, char *timestr, int curr)
1581 struct stats_softnet *ssnc, *ssnp;
1583 /* @nr[curr] cannot normally be greater than @nr_ini */
1584 if (a->nr[curr] > a->nr_ini) {
1585 a->nr_ini = a->nr[curr];
1588 /* Don't display CPU "all" which doesn't exist in file */
1589 for (i = 1; (i < a->nr_ini) && (i < a->bitmap->b_size + 1); i++) {
1592 * The size of a->buf[...] CPU structure may be different from the default
1593 * sizeof(struct stats_pwr_cpufreq) value if data have been read from a file!
1594 * That's why we don't use a syntax like:
1595 * ssnc = (struct stats_softnet *) a->buf[...] + i;
1597 ssnc = (struct stats_softnet *) ((char *) a->buf[curr] + i * a->msize);
1598 ssnp = (struct stats_softnet *) ((char *) a->buf[!curr] + i * a->msize);
1601 * Note: a->nr is in [1, NR_CPUS + 1].
1602 * Bitmap size is provided for (NR_CPUS + 1) CPUs.
1603 * Anyway, NR_CPUS may vary between the version of sysstat
1604 * used by sadc to create a file, and the version of sysstat
1605 * used by sar to read it...
1608 /* Should current CPU (including CPU "all") be displayed? */
1609 if (!(a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))))
1613 /* Yes: Display current CPU stats */
1614 printf("%s; %s", timestr, pfield(a->hdr_line, FIRST));
1615 if (DISPLAY_DEBUG_MODE(flags) && i) {
1616 if (ssnc->processed + ssnc->dropped + ssnc->time_squeeze +
1617 ssnc->received_rps + ssnc->flow_limit == 0) {
1618 /* CPU is considered offline */
1622 printf("; %d;", i - 1);
1624 printf(" %s", pfield(NULL, 0));
1625 pval((unsigned long long) ssnp->processed, (unsigned long long) ssnc->processed);
1626 printf(" %s", pfield(NULL, 0));
1627 pval((unsigned long long) ssnp->dropped, (unsigned long long) ssnc->dropped);
1628 printf(" %s", pfield(NULL, 0));
1629 pval((unsigned long long) ssnp->time_squeeze, (unsigned long long) ssnc->time_squeeze);
1630 printf(" %s", pfield(NULL, 0));
1631 pval((unsigned long long) ssnp->received_rps, (unsigned long long) ssnc->received_rps);
1632 printf(" %s", pfield(NULL, 0));
1633 pval((unsigned long long) ssnp->flow_limit, (unsigned long long) ssnc->flow_limit);