2 * pr_stats.c: Functions used by sar to display statistics
3 * (C) 1999-2012 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 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
19 ***************************************************************************
34 #define _(string) gettext(string)
36 #define _(string) (string)
39 extern unsigned int flags;
40 extern unsigned int dm_major;
42 extern char timestamp[][TIMESTAMP_LEN];
43 extern unsigned long avg_count;
46 ***************************************************************************
47 * Display CPU statistics.
50 * @a Activity structure with statistics.
51 * @prev Index in array where stats used as reference are.
52 * @curr Index in array for current sample statistics.
53 * @g_itv Interval of time in jiffies multiplied by the number
55 ***************************************************************************
57 __print_funct_t print_cpu_stats(struct activity *a, int prev, int curr,
58 unsigned long long g_itv)
61 struct stats_cpu *scc, *scp;
64 if (DISPLAY_CPU_DEF(a->opt_flags)) {
65 printf("\n%-11s CPU %%user %%nice %%system"
66 " %%iowait %%steal %%idle\n",
69 else if (DISPLAY_CPU_ALL(a->opt_flags)) {
70 printf("\n%-11s CPU %%usr %%nice %%sys"
71 " %%iowait %%steal %%irq %%soft"
72 " %%guest %%gnice %%idle\n",
77 for (i = 0; (i < a->nr) && (i < a->bitmap->b_size + 1); i++) {
80 * The size of a->buf[...] CPU structure may be different from the default
81 * sizeof(struct stats_cpu) value if data have been read from a file!
82 * That's why we don't use a syntax like:
83 * scc = (struct stats_cpu *) a->buf[...] + i;
85 scc = (struct stats_cpu *) ((char *) a->buf[curr] + i * a->msize);
86 scp = (struct stats_cpu *) ((char *) a->buf[prev] + i * a->msize);
89 * Note: a->nr is in [1, NR_CPUS + 1].
90 * Bitmap size is provided for (NR_CPUS + 1) CPUs.
91 * Anyway, NR_CPUS may vary between the version of sysstat
92 * used by sadc to create a file, and the version of sysstat
93 * used by sar to read it...
96 /* Should current CPU (including CPU "all") be displayed? */
97 if (a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))) {
100 printf("%-11s", timestamp[curr]);
103 /* This is CPU "all" */
107 printf(" %3d", i - 1);
110 * If the CPU is offline then it is omited from /proc/stat:
111 * All the fields couldn't have been read and the sum of them is zero.
112 * (Remember that guest/guest_nice times are already included in
115 if ((scc->cpu_user + scc->cpu_nice + scc->cpu_sys +
116 scc->cpu_iowait + scc->cpu_idle + scc->cpu_steal +
117 scc->cpu_hardirq + scc->cpu_softirq) == 0) {
119 * Set current struct fields (which have been set to zero)
120 * to values from previous iteration. Hence their values won't
121 * jump from zero when the CPU comes back online.
125 /* %user, %nice, %system, %iowait, %steal, ..., %idle */
126 printf(" %6.2f %6.2f %6.2f"
127 " %6.2f %6.2f %6.2f",
128 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
130 if (DISPLAY_CPU_ALL(a->opt_flags)) {
132 * Four additional fields to display:
133 * %irq, %soft, %guest, %gnice.
135 printf(" %6.2f %6.2f %6.2f %6.2f",
142 /* Recalculate interval for current proc */
143 g_itv = get_per_cpu_interval(scc, scp);
147 * If the CPU is tickless then there is no change in CPU values
148 * but the sum of values is not zero.
149 * %user, %nice, %system, %iowait, %steal, ..., %idle
151 printf(" %6.2f %6.2f %6.2f"
153 0.0, 0.0, 0.0, 0.0, 0.0);
155 if (DISPLAY_CPU_DEF(a->opt_flags)) {
156 printf(" %6.2f\n", 100.0);
159 * Four additional fields to display:
160 * %irq, %soft, %guest, %gnice.
162 else if (DISPLAY_CPU_ALL(a->opt_flags)) {
163 printf(" %6.2f %6.2f %6.2f %6.2f\n",
164 0.0, 0.0, 0.0, 100.0);
170 if (DISPLAY_CPU_DEF(a->opt_flags)) {
171 printf(" %6.2f %6.2f %6.2f %6.2f %6.2f %6.2f\n",
172 ll_sp_value(scp->cpu_user, scc->cpu_user, g_itv),
173 ll_sp_value(scp->cpu_nice, scc->cpu_nice, g_itv),
174 ll_sp_value(scp->cpu_sys + scp->cpu_hardirq + scp->cpu_softirq,
175 scc->cpu_sys + scc->cpu_hardirq + scc->cpu_softirq,
177 ll_sp_value(scp->cpu_iowait, scc->cpu_iowait, g_itv),
178 ll_sp_value(scp->cpu_steal, scc->cpu_steal, g_itv),
179 scc->cpu_idle < scp->cpu_idle ?
181 ll_sp_value(scp->cpu_idle, scc->cpu_idle, g_itv));
183 else if (DISPLAY_CPU_ALL(a->opt_flags)) {
184 printf(" %6.2f %6.2f %6.2f %6.2f %6.2f %6.2f"
185 " %6.2f %6.2f %6.2f %6.2f\n",
186 (scc->cpu_user - scc->cpu_guest) < (scp->cpu_user - scp->cpu_guest) ?
188 ll_sp_value(scp->cpu_user - scp->cpu_guest,
189 scc->cpu_user - scc->cpu_guest, g_itv),
190 (scc->cpu_nice - scc->cpu_guest_nice) < (scp->cpu_nice - scp->cpu_guest_nice) ?
192 ll_sp_value(scp->cpu_nice - scp->cpu_guest_nice,
193 scc->cpu_nice - scc->cpu_guest_nice, g_itv),
194 ll_sp_value(scp->cpu_sys, scc->cpu_sys, g_itv),
195 ll_sp_value(scp->cpu_iowait, scc->cpu_iowait, g_itv),
196 ll_sp_value(scp->cpu_steal, scc->cpu_steal, g_itv),
197 ll_sp_value(scp->cpu_hardirq, scc->cpu_hardirq, g_itv),
198 ll_sp_value(scp->cpu_softirq, scc->cpu_softirq, g_itv),
199 ll_sp_value(scp->cpu_guest, scc->cpu_guest, g_itv),
200 ll_sp_value(scp->cpu_guest_nice, scc->cpu_guest_nice, g_itv),
201 scc->cpu_idle < scp->cpu_idle ?
203 ll_sp_value(scp->cpu_idle, scc->cpu_idle, g_itv));
210 ***************************************************************************
211 * Display tasks creation and context switches statistics.
214 * @a Activity structure with statistics.
215 * @prev Index in array where stats used as reference are.
216 * @curr Index in array for current sample statistics.
217 * @itv Interval of time in jiffies.
218 ***************************************************************************
220 __print_funct_t print_pcsw_stats(struct activity *a, int prev, int curr,
221 unsigned long long itv)
224 *spc = (struct stats_pcsw *) a->buf[curr],
225 *spp = (struct stats_pcsw *) a->buf[prev];
228 printf("\n%-11s proc/s cswch/s\n", timestamp[!curr]);
231 printf("%-11s %9.2f %9.2f\n", timestamp[curr],
232 S_VALUE (spp->processes, spc->processes, itv),
233 ll_s_value(spp->context_switch, spc->context_switch, itv));
237 ***************************************************************************
238 * Display interrupts statistics.
241 * @a Activity structure with statistics.
242 * @prev Index in array where stats used as reference are.
243 * @curr Index in array for current sample statistics.
244 * @itv Interval of time in jiffies.
245 ***************************************************************************
247 __print_funct_t print_irq_stats(struct activity *a, int prev, int curr,
248 unsigned long long itv)
251 struct stats_irq *sic, *sip;
254 printf("\n%-11s INTR intr/s\n", timestamp[!curr]);
257 for (i = 0; (i < a->nr) && (i < a->bitmap->b_size + 1); i++) {
259 sic = (struct stats_irq *) ((char *) a->buf[curr] + i * a->msize);
260 sip = (struct stats_irq *) ((char *) a->buf[prev] + i * a->msize);
263 * Note: a->nr is in [0, NR_IRQS + 1].
264 * Bitmap size is provided for (NR_IRQS + 1) interrupts.
265 * Anyway, NR_IRQS may vary between the version of sysstat
266 * used by sadc to create a file, and the version of sysstat
267 * used by sar to read it...
270 /* Should current interrupt (including int "sum") be displayed? */
271 if (a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))) {
273 /* Yes: Display it */
274 printf("%-11s", timestamp[curr]);
276 /* This is interrupt "sum" */
280 printf(" %3d", i - 1);
284 ll_s_value(sip->irq_nr, sic->irq_nr, itv));
290 ***************************************************************************
291 * Display swapping statistics.
294 * @a Activity structure with statistics.
295 * @prev Index in array where stats used as reference are.
296 * @curr Index in array for current sample statistics.
297 * @itv Interval of time in jiffies.
298 ***************************************************************************
300 __print_funct_t print_swap_stats(struct activity *a, int prev, int curr,
301 unsigned long long itv)
304 *ssc = (struct stats_swap *) a->buf[curr],
305 *ssp = (struct stats_swap *) a->buf[prev];
308 printf("\n%-11s pswpin/s pswpout/s\n", timestamp[!curr]);
311 printf("%-11s %9.2f %9.2f\n", timestamp[curr],
312 S_VALUE(ssp->pswpin, ssc->pswpin, itv),
313 S_VALUE(ssp->pswpout, ssc->pswpout, itv));
317 ***************************************************************************
318 * Display paging statistics.
321 * @a Activity structure with statistics.
322 * @prev Index in array where stats used as reference are.
323 * @curr Index in array for current sample statistics.
324 * @itv Interval of time in jiffies.
325 ***************************************************************************
327 __print_funct_t print_paging_stats(struct activity *a, int prev, int curr,
328 unsigned long long itv)
331 *spc = (struct stats_paging *) a->buf[curr],
332 *spp = (struct stats_paging *) a->buf[prev];
335 printf("\n%-11s pgpgin/s pgpgout/s fault/s majflt/s pgfree/s"
336 " pgscank/s pgscand/s pgsteal/s %%vmeff\n",
340 printf("%-11s %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f\n",
342 S_VALUE(spp->pgpgin, spc->pgpgin, itv),
343 S_VALUE(spp->pgpgout, spc->pgpgout, itv),
344 S_VALUE(spp->pgfault, spc->pgfault, itv),
345 S_VALUE(spp->pgmajfault, spc->pgmajfault, itv),
346 S_VALUE(spp->pgfree, spc->pgfree, itv),
347 S_VALUE(spp->pgscan_kswapd, spc->pgscan_kswapd, itv),
348 S_VALUE(spp->pgscan_direct, spc->pgscan_direct, itv),
349 S_VALUE(spp->pgsteal, spc->pgsteal, itv),
350 (spc->pgscan_kswapd + spc->pgscan_direct -
351 spp->pgscan_kswapd - spp->pgscan_direct) ?
352 SP_VALUE(spp->pgsteal, spc->pgsteal,
353 spc->pgscan_kswapd + spc->pgscan_direct -
354 spp->pgscan_kswapd - spp->pgscan_direct) : 0.0);
358 ***************************************************************************
359 * Display I/O and transfer rate statistics.
362 * @a Activity structure with statistics.
363 * @prev Index in array where stats used as reference are.
364 * @curr Index in array for current sample statistics.
365 * @itv Interval of time in jiffies.
366 ***************************************************************************
368 __print_funct_t print_io_stats(struct activity *a, int prev, int curr,
369 unsigned long long itv)
372 *sic = (struct stats_io *) a->buf[curr],
373 *sip = (struct stats_io *) a->buf[prev];
376 printf("\n%-11s tps rtps wtps bread/s bwrtn/s\n",
380 printf("%-11s %9.2f %9.2f %9.2f %9.2f %9.2f\n", timestamp[curr],
381 S_VALUE(sip->dk_drive, sic->dk_drive, itv),
382 S_VALUE(sip->dk_drive_rio, sic->dk_drive_rio, itv),
383 S_VALUE(sip->dk_drive_wio, sic->dk_drive_wio, itv),
384 S_VALUE(sip->dk_drive_rblk, sic->dk_drive_rblk, itv),
385 S_VALUE(sip->dk_drive_wblk, sic->dk_drive_wblk, itv));
389 ***************************************************************************
390 * Display memory and swap statistics. This function is used to
391 * display instantaneous and average statistics.
394 * @a Activity structure with statistics.
395 * @prev Index in array where stats used as reference are.
396 * @curr Index in array for current sample statistics.
397 * @itv Interval of time in jiffies.
398 * @dispavg TRUE if displaying average statistics.
399 ***************************************************************************
401 void stub_print_memory_stats(struct activity *a, int prev, int curr,
402 unsigned long long itv, int dispavg)
405 *smc = (struct stats_memory *) a->buf[curr],
406 *smp = (struct stats_memory *) a->buf[prev];
407 static unsigned long long
415 static unsigned long long
420 if (DISPLAY_MEMORY(a->opt_flags)) {
422 printf("\n%-11s frmpg/s bufpg/s campg/s\n",
426 printf("%-11s %9.2f %9.2f %9.2f\n", timestamp[curr],
427 S_VALUE((double) KB_TO_PG(smp->frmkb), (double) KB_TO_PG(smc->frmkb), itv),
428 S_VALUE((double) KB_TO_PG(smp->bufkb), (double) KB_TO_PG(smc->bufkb), itv),
429 S_VALUE((double) KB_TO_PG(smp->camkb), (double) KB_TO_PG(smc->camkb), itv));
432 if (DISPLAY_MEM_AMT(a->opt_flags)) {
434 printf("\n%-11s kbmemfree kbmemused %%memused kbbuffers kbcached"
435 " kbcommit %%commit kbactive kbinact kbdirty\n", timestamp[!curr]);
439 /* Display instantaneous values */
440 printf("%-11s %9lu %9lu %6.2f %9lu %9lu %9lu %7.2f %9lu %9lu %9lu\n",
443 smc->tlmkb - smc->frmkb,
445 SP_VALUE(smc->frmkb, smc->tlmkb, smc->tlmkb) : 0.0,
449 (smc->tlmkb + smc->tlskb) ?
450 SP_VALUE(0, smc->comkb, smc->tlmkb + smc->tlskb) : 0.0,
456 * Will be used to compute the average.
457 * We assume that the total amount of memory installed can not vary
458 * during the interval given on the command line.
460 avg_frmkb += smc->frmkb;
461 avg_bufkb += smc->bufkb;
462 avg_camkb += smc->camkb;
463 avg_comkb += smc->comkb;
464 avg_activekb += smc->activekb;
465 avg_inactkb += smc->inactkb;
466 avg_dirtykb += smc->dirtykb;
469 /* Display average values */
470 printf("%-11s %9.0f %9.0f %6.2f %9.0f %9.0f %9.0f %7.2f %9.0f %9.0f %9.0f\n",
472 (double) avg_frmkb / avg_count,
473 (double) smc->tlmkb - ((double) avg_frmkb / avg_count),
475 SP_VALUE((double) (avg_frmkb / avg_count), smc->tlmkb,
478 (double) avg_bufkb / avg_count,
479 (double) avg_camkb / avg_count,
480 (double) avg_comkb / avg_count,
481 (smc->tlmkb + smc->tlskb) ?
482 SP_VALUE(0.0, (double) (avg_comkb / avg_count),
483 smc->tlmkb + smc->tlskb) : 0.0,
484 (double) avg_activekb / avg_count,
485 (double) avg_inactkb / avg_count,
486 (double) avg_dirtykb / avg_count);
488 /* Reset average counters */
489 avg_frmkb = avg_bufkb = avg_camkb = avg_comkb = 0;
490 avg_activekb = avg_inactkb = avg_dirtykb = 0;
494 if (DISPLAY_SWAP(a->opt_flags)) {
496 printf("\n%-11s kbswpfree kbswpused %%swpused kbswpcad %%swpcad\n",
501 /* Display instantaneous values */
502 printf("%-11s %9lu %9lu %6.2f %9lu %6.2f\n",
505 smc->tlskb - smc->frskb,
507 SP_VALUE(smc->frskb, smc->tlskb, smc->tlskb) : 0.0,
509 (smc->tlskb - smc->frskb) ?
510 SP_VALUE(0, smc->caskb, smc->tlskb - smc->frskb) : 0.0);
513 * Will be used to compute the average.
514 * We assume that the total amount of swap space may vary.
516 avg_frskb += smc->frskb;
517 avg_tlskb += smc->tlskb;
518 avg_caskb += smc->caskb;
521 /* Display average values */
522 printf("%-11s %9.0f %9.0f %6.2f %9.0f %6.2f\n",
524 (double) avg_frskb / avg_count,
525 ((double) avg_tlskb / avg_count) -
526 ((double) avg_frskb / avg_count),
527 ((double) (avg_tlskb / avg_count)) ?
528 SP_VALUE((double) (avg_frskb / avg_count),
529 (double) (avg_tlskb / avg_count),
530 (double) (avg_tlskb / avg_count)) :
532 (double) (avg_caskb / avg_count),
533 (((double) avg_tlskb / avg_count) -
534 ((double) avg_frskb / avg_count)) ?
535 SP_VALUE(0.0, (double) (avg_caskb / avg_count),
536 ((double) avg_tlskb / avg_count) -
537 ((double) avg_frskb / avg_count)) :
540 /* Reset average counters */
541 avg_frskb = avg_tlskb = avg_caskb = 0;
547 ***************************************************************************
548 * Display memory and swap statistics.
551 * @a Activity structure with statistics.
552 * @prev Index in array where stats used as reference are.
553 * @curr Index in array for current sample statistics.
554 * @itv Interval of time in jiffies.
555 ***************************************************************************
557 __print_funct_t print_memory_stats(struct activity *a, int prev, int curr,
558 unsigned long long itv)
560 stub_print_memory_stats(a, prev, curr, itv, FALSE);
564 ***************************************************************************
565 * Display average memory statistics.
568 * @a Activity structure with statistics.
569 * @prev Index in array where stats used as reference are.
570 * @curr Index in array for current sample statistics.
571 * @itv Interval of time in jiffies.
572 ***************************************************************************
574 __print_funct_t print_avg_memory_stats(struct activity *a, int prev, int curr,
575 unsigned long long itv)
577 stub_print_memory_stats(a, prev, curr, itv, TRUE);
581 ***************************************************************************
582 * Display kernel tables statistics. This function is used to display
583 * instantaneous and average statistics.
586 * @a Activity structure with statistics.
587 * @curr Index in array for current sample statistics.
588 * @dispavg True if displaying average statistics.
589 ***************************************************************************
591 void stub_print_ktables_stats(struct activity *a, int curr, int dispavg)
594 *skc = (struct stats_ktables *) a->buf[curr];
595 static unsigned long long
603 printf("\n%-11s dentunusd file-nr inode-nr pty-nr\n",
608 /* Display instantaneous values */
609 printf("%-11s %9u %9u %9u %9u\n", timestamp[curr],
616 * Will be used to compute the average.
617 * Note: Overflow unlikely to happen but not impossible...
619 avg_dentry_stat += skc->dentry_stat;
620 avg_file_used += skc->file_used;
621 avg_inode_used += skc->inode_used;
622 avg_pty_nr += skc->pty_nr;
625 /* Display average values */
626 printf("%-11s %9.0f %9.0f %9.0f %9.0f\n",
628 (double) avg_dentry_stat / avg_count,
629 (double) avg_file_used / avg_count,
630 (double) avg_inode_used / avg_count,
631 (double) avg_pty_nr / avg_count);
633 /* Reset average counters */
634 avg_dentry_stat = avg_file_used = avg_inode_used = avg_pty_nr = 0;
639 ***************************************************************************
640 * Display kernel tables statistics.
643 * @a Activity structure with statistics.
644 * @prev Index in array where stats used as reference are.
645 * @curr Index in array for current sample statistics.
646 * @itv Interval of time in jiffies.
647 ***************************************************************************
649 __print_funct_t print_ktables_stats(struct activity *a, int prev, int curr,
650 unsigned long long itv)
652 stub_print_ktables_stats(a, curr, FALSE);
656 ***************************************************************************
657 * Display average kernel tables statistics.
660 * @a Activity structure with statistics.
661 * @prev Index in array where stats used as reference are.
662 * @curr Index in array for current sample statistics.
663 * @itv Interval of time in jiffies.
664 ***************************************************************************
666 __print_funct_t print_avg_ktables_stats(struct activity *a, int prev, int curr,
667 unsigned long long itv)
669 stub_print_ktables_stats(a, curr, TRUE);
673 ***************************************************************************
674 * Display queue and load statistics. This function is used to display
675 * instantaneous and average statistics.
678 * @a Activity structure with statistics.
679 * @curr Index in array for current sample statistics.
680 * @dispavg TRUE if displaying average statistics.
681 ***************************************************************************
683 void stub_print_queue_stats(struct activity *a, int curr, int dispavg)
686 *sqc = (struct stats_queue *) a->buf[curr];
687 static unsigned long long
693 avg_procs_blocked = 0;
696 printf("\n%-11s runq-sz plist-sz ldavg-1 ldavg-5 ldavg-15 blocked\n",
701 /* Display instantaneous values */
702 printf("%-11s %9lu %9u %9.2f %9.2f %9.2f %9lu\n", timestamp[curr],
705 (double) sqc->load_avg_1 / 100,
706 (double) sqc->load_avg_5 / 100,
707 (double) sqc->load_avg_15 / 100,
710 /* Will be used to compute the average */
711 avg_nr_running += sqc->nr_running;
712 avg_nr_threads += sqc->nr_threads;
713 avg_load_avg_1 += sqc->load_avg_1;
714 avg_load_avg_5 += sqc->load_avg_5;
715 avg_load_avg_15 += sqc->load_avg_15;
716 avg_procs_blocked += sqc->procs_blocked;
719 /* Display average values */
720 printf("%-11s %9.0f %9.0f %9.2f %9.2f %9.2f %9.0f\n", timestamp[curr],
721 (double) avg_nr_running / avg_count,
722 (double) avg_nr_threads / avg_count,
723 (double) avg_load_avg_1 / (avg_count * 100),
724 (double) avg_load_avg_5 / (avg_count * 100),
725 (double) avg_load_avg_15 / (avg_count * 100),
726 (double) avg_procs_blocked / avg_count);
728 /* Reset average counters */
729 avg_nr_running = avg_nr_threads = 0;
730 avg_load_avg_1 = avg_load_avg_5 = avg_load_avg_15 = 0;
731 avg_procs_blocked = 0;
736 ***************************************************************************
737 * Display queue and load statistics.
740 * @a Activity structure with statistics.
741 * @prev Index in array where stats used as reference are.
742 * @curr Index in array for current sample statistics.
743 * @itv Interval of time in jiffies.
744 ***************************************************************************
746 __print_funct_t print_queue_stats(struct activity *a, int prev, int curr,
747 unsigned long long itv)
749 stub_print_queue_stats(a, curr, FALSE);
753 ***************************************************************************
754 * Display average queue and load statistics.
757 * @a Activity structure with statistics.
758 * @prev Index in array where stats used as reference are.
759 * @curr Index in array for current sample statistics.
760 * @itv Interval of time in jiffies.
761 ***************************************************************************
763 __print_funct_t print_avg_queue_stats(struct activity *a, int prev, int curr,
764 unsigned long long itv)
766 stub_print_queue_stats(a, curr, TRUE);
770 ***************************************************************************
771 * Display serial lines statistics.
774 * @a Activity structure with statistics.
775 * @prev Index in array where stats used as reference are.
776 * @curr Index in array for current sample statistics.
777 * @itv Interval of time in jiffies.
778 ***************************************************************************
780 __print_funct_t print_serial_stats(struct activity *a, int prev, int curr,
781 unsigned long long itv)
784 struct stats_serial *ssc, *ssp;
787 printf("\n%-11s TTY rcvin/s xmtin/s framerr/s prtyerr/s"
788 " brk/s ovrun/s\n", timestamp[!curr]);
791 for (i = 0; i < a->nr; i++) {
793 ssc = (struct stats_serial *) ((char *) a->buf[curr] + i * a->msize);
794 ssp = (struct stats_serial *) ((char *) a->buf[prev] + i * a->msize);
799 printf("%-11s %3d", timestamp[curr], ssc->line - 1);
801 if ((ssc->line == ssp->line) || WANT_SINCE_BOOT(flags)) {
802 printf(" %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f\n",
803 S_VALUE(ssp->rx, ssc->rx, itv),
804 S_VALUE(ssp->tx, ssc->tx, itv),
805 S_VALUE(ssp->frame, ssc->frame, itv),
806 S_VALUE(ssp->parity, ssc->parity, itv),
807 S_VALUE(ssp->brk, ssc->brk, itv),
808 S_VALUE(ssp->overrun, ssc->overrun, itv));
811 printf(" N/A N/A N/A N/A"
818 ***************************************************************************
819 * Display disks statistics.
822 * @a Activity structure with statistics.
823 * @prev Index in array where stats used as reference are.
824 * @curr Index in array for current sample statistics.
825 * @itv Interval of time in jiffies.
826 ***************************************************************************
828 __print_funct_t print_disk_stats(struct activity *a, int prev, int curr,
829 unsigned long long itv)
832 struct stats_disk *sdc, *sdp;
833 struct ext_disk_stats xds;
834 char *dev_name, *persist_dev_name;
837 printf("\n%-11s DEV tps rd_sec/s wr_sec/s avgrq-sz"
838 " avgqu-sz await svctm %%util\n",
842 for (i = 0; i < a->nr; i++) {
844 sdc = (struct stats_disk *) ((char *) a->buf[curr] + i * a->msize);
846 if (!(sdc->major + sdc->minor))
849 j = check_disk_reg(a, curr, prev, i);
850 sdp = (struct stats_disk *) ((char *) a->buf[prev] + j * a->msize);
852 /* Compute service time, etc. */
853 compute_ext_disk_stats(sdc, sdp, itv, &xds);
856 persist_dev_name = NULL;
858 if (DISPLAY_PERSIST_NAME_S(flags)) {
859 persist_dev_name = get_persistent_name_from_pretty(get_devname(sdc->major, sdc->minor, TRUE));
862 if (persist_dev_name) {
863 dev_name = persist_dev_name;
866 if ((USE_PRETTY_OPTION(flags)) && (sdc->major == dm_major)) {
867 dev_name = transform_devmapname(sdc->major, sdc->minor);
871 dev_name = get_devname(sdc->major, sdc->minor,
872 USE_PRETTY_OPTION(flags));
876 printf("%-11s %9s %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f\n",
878 /* Confusion possible here between index and minor numbers */
880 S_VALUE(sdp->nr_ios, sdc->nr_ios, itv),
881 ll_s_value(sdp->rd_sect, sdc->rd_sect, itv),
882 ll_s_value(sdp->wr_sect, sdc->wr_sect, itv),
883 /* See iostat for explanations */
885 S_VALUE(sdp->rq_ticks, sdc->rq_ticks, itv) / 1000.0,
893 ***************************************************************************
894 * Display network interfaces statistics.
897 * @a Activity structure with statistics.
898 * @prev Index in array where stats used as reference are.
899 * @curr Index in array for current sample statistics.
900 * @itv Interval of time in jiffies.
901 ***************************************************************************
903 __print_funct_t print_net_dev_stats(struct activity *a, int prev, int curr,
904 unsigned long long itv)
907 struct stats_net_dev *sndc, *sndp;
910 printf("\n%-11s IFACE rxpck/s txpck/s rxkB/s txkB/s"
911 " rxcmp/s txcmp/s rxmcst/s\n", timestamp[!curr]);
914 for (i = 0; i < a->nr; i++) {
916 sndc = (struct stats_net_dev *) ((char *) a->buf[curr] + i * a->msize);
918 if (!strcmp(sndc->interface, ""))
921 j = check_net_dev_reg(a, curr, prev, i);
922 sndp = (struct stats_net_dev *) ((char *) a->buf[prev] + j * a->msize);
924 printf("%-11s %9s", timestamp[curr], sndc->interface);
926 printf(" %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f\n",
927 S_VALUE(sndp->rx_packets, sndc->rx_packets, itv),
928 S_VALUE(sndp->tx_packets, sndc->tx_packets, itv),
929 S_VALUE(sndp->rx_bytes, sndc->rx_bytes, itv) / 1024,
930 S_VALUE(sndp->tx_bytes, sndc->tx_bytes, itv) / 1024,
931 S_VALUE(sndp->rx_compressed, sndc->rx_compressed, itv),
932 S_VALUE(sndp->tx_compressed, sndc->tx_compressed, itv),
933 S_VALUE(sndp->multicast, sndc->multicast, itv));
938 ***************************************************************************
939 * Display network interface errors statistics.
942 * @a Activity structure with statistics.
943 * @prev Index in array where stats used as reference are.
944 * @curr Index in array for current sample statistics.
945 * @itv Interval of time in jiffies.
946 ***************************************************************************
948 __print_funct_t print_net_edev_stats(struct activity *a, int prev, int curr,
949 unsigned long long itv)
952 struct stats_net_edev *snedc, *snedp;
955 printf("\n%-11s IFACE rxerr/s txerr/s coll/s rxdrop/s"
956 " txdrop/s txcarr/s rxfram/s rxfifo/s txfifo/s\n",
960 for (i = 0; i < a->nr; i++) {
962 snedc = (struct stats_net_edev *) ((char *) a->buf[curr] + i * a->msize);
964 if (!strcmp(snedc->interface, ""))
967 j = check_net_edev_reg(a, curr, prev, i);
968 snedp = (struct stats_net_edev *) ((char *) a->buf[prev] + j * a->msize);
970 printf("%-11s %9s", timestamp[curr], snedc->interface);
972 printf(" %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f\n",
973 S_VALUE(snedp->rx_errors, snedc->rx_errors, itv),
974 S_VALUE(snedp->tx_errors, snedc->tx_errors, itv),
975 S_VALUE(snedp->collisions, snedc->collisions, itv),
976 S_VALUE(snedp->rx_dropped, snedc->rx_dropped, itv),
977 S_VALUE(snedp->tx_dropped, snedc->tx_dropped, itv),
978 S_VALUE(snedp->tx_carrier_errors, snedc->tx_carrier_errors, itv),
979 S_VALUE(snedp->rx_frame_errors, snedc->rx_frame_errors, itv),
980 S_VALUE(snedp->rx_fifo_errors, snedc->rx_fifo_errors, itv),
981 S_VALUE(snedp->tx_fifo_errors, snedc->tx_fifo_errors, itv));
986 ***************************************************************************
987 * Display NFS client statistics.
990 * @a Activity structure with statistics.
991 * @prev Index in array where stats used as reference are.
992 * @curr Index in array for current sample statistics.
993 * @itv Interval of time in jiffies.
994 ***************************************************************************
996 __print_funct_t print_net_nfs_stats(struct activity *a, int prev, int curr,
997 unsigned long long itv)
1000 *snnc = (struct stats_net_nfs *) a->buf[curr],
1001 *snnp = (struct stats_net_nfs *) a->buf[prev];
1004 printf("\n%-11s call/s retrans/s read/s write/s access/s"
1005 " getatt/s\n", timestamp[!curr]);
1008 printf("%-11s %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f\n", timestamp[curr],
1009 S_VALUE(snnp->nfs_rpccnt, snnc->nfs_rpccnt, itv),
1010 S_VALUE(snnp->nfs_rpcretrans, snnc->nfs_rpcretrans, itv),
1011 S_VALUE(snnp->nfs_readcnt, snnc->nfs_readcnt, itv),
1012 S_VALUE(snnp->nfs_writecnt, snnc->nfs_writecnt, itv),
1013 S_VALUE(snnp->nfs_accesscnt, snnc->nfs_accesscnt, itv),
1014 S_VALUE(snnp->nfs_getattcnt, snnc->nfs_getattcnt, itv));
1018 ***************************************************************************
1019 * Display NFS server statistics.
1022 * @a Activity structure with statistics.
1023 * @prev Index in array where stats used as reference are.
1024 * @curr Index in array for current sample statistics.
1025 * @itv Interval of time in jiffies.
1026 ***************************************************************************
1028 __print_funct_t print_net_nfsd_stats(struct activity *a, int prev, int curr,
1029 unsigned long long itv)
1031 struct stats_net_nfsd
1032 *snndc = (struct stats_net_nfsd *) a->buf[curr],
1033 *snndp = (struct stats_net_nfsd *) a->buf[prev];
1036 printf("\n%-11s scall/s badcall/s packet/s udp/s tcp/s "
1037 "hit/s miss/s sread/s swrite/s saccess/s sgetatt/s\n",
1041 printf("%-11s %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f\n",
1043 S_VALUE(snndp->nfsd_rpccnt, snndc->nfsd_rpccnt, itv),
1044 S_VALUE(snndp->nfsd_rpcbad, snndc->nfsd_rpcbad, itv),
1045 S_VALUE(snndp->nfsd_netcnt, snndc->nfsd_netcnt, itv),
1046 S_VALUE(snndp->nfsd_netudpcnt, snndc->nfsd_netudpcnt, itv),
1047 S_VALUE(snndp->nfsd_nettcpcnt, snndc->nfsd_nettcpcnt, itv),
1048 S_VALUE(snndp->nfsd_rchits, snndc->nfsd_rchits, itv),
1049 S_VALUE(snndp->nfsd_rcmisses, snndc->nfsd_rcmisses, itv),
1050 S_VALUE(snndp->nfsd_readcnt, snndc->nfsd_readcnt, itv),
1051 S_VALUE(snndp->nfsd_writecnt, snndc->nfsd_writecnt, itv),
1052 S_VALUE(snndp->nfsd_accesscnt, snndc->nfsd_accesscnt, itv),
1053 S_VALUE(snndp->nfsd_getattcnt, snndc->nfsd_getattcnt, itv));
1057 ***************************************************************************
1058 * Display network sockets statistics. This function is used to display
1059 * instantaneous and average statistics.
1062 * @a Activity structure with statistics.
1063 * @curr Index in array for current sample statistics.
1064 * @dispavg TRUE if displaying average statistics.
1065 ***************************************************************************
1067 void stub_print_net_sock_stats(struct activity *a, int curr, int dispavg)
1069 struct stats_net_sock
1070 *snsc = (struct stats_net_sock *) a->buf[curr];
1071 static unsigned long long
1080 printf("\n%-11s totsck tcpsck udpsck rawsck ip-frag tcp-tw\n",
1085 /* Display instantaneous values */
1086 printf("%-11s %9u %9u %9u %9u %9u %9u\n", timestamp[curr],
1094 /* Will be used to compute the average */
1095 avg_sock_inuse += snsc->sock_inuse;
1096 avg_tcp_inuse += snsc->tcp_inuse;
1097 avg_udp_inuse += snsc->udp_inuse;
1098 avg_raw_inuse += snsc->raw_inuse;
1099 avg_frag_inuse += snsc->frag_inuse;
1100 avg_tcp_tw += snsc->tcp_tw;
1103 /* Display average values */
1104 printf("%-11s %9.0f %9.0f %9.0f %9.0f %9.0f %9.0f\n", timestamp[curr],
1105 (double) avg_sock_inuse / avg_count,
1106 (double) avg_tcp_inuse / avg_count,
1107 (double) avg_udp_inuse / avg_count,
1108 (double) avg_raw_inuse / avg_count,
1109 (double) avg_frag_inuse / avg_count,
1110 (double) avg_tcp_tw / avg_count);
1112 /* Reset average counters */
1113 avg_sock_inuse = avg_tcp_inuse = avg_udp_inuse = 0;
1114 avg_raw_inuse = avg_frag_inuse = avg_tcp_tw = 0;
1119 ***************************************************************************
1120 * Display network sockets statistics.
1123 * @a Activity structure with statistics.
1124 * @prev Index in array where stats used as reference are.
1125 * @curr Index in array for current sample statistics.
1126 * @itv Interval of time in jiffies.
1127 ***************************************************************************
1129 __print_funct_t print_net_sock_stats(struct activity *a, int prev, int curr,
1130 unsigned long long itv)
1132 stub_print_net_sock_stats(a, curr, FALSE);
1136 ***************************************************************************
1137 * Display average network sockets statistics.
1140 * @a Activity structure with statistics.
1141 * @prev Index in array where stats used as reference are.
1142 * @curr Index in array for current sample statistics.
1143 * @itv Interval of time in jiffies.
1144 ***************************************************************************
1146 __print_funct_t print_avg_net_sock_stats(struct activity *a, int prev, int curr,
1147 unsigned long long itv)
1149 stub_print_net_sock_stats(a, curr, TRUE);
1153 ***************************************************************************
1154 * Display IP network traffic statistics.
1157 * @a Activity structure with statistics.
1158 * @prev Index in array where stats used as reference are.
1159 * @curr Index in array for current sample statistics.
1160 * @itv Interval of time in jiffies.
1161 ***************************************************************************
1163 __print_funct_t print_net_ip_stats(struct activity *a, int prev, int curr,
1164 unsigned long long itv)
1167 *snic = (struct stats_net_ip *) a->buf[curr],
1168 *snip = (struct stats_net_ip *) a->buf[prev];
1171 printf("\n%-11s irec/s fwddgm/s idel/s orq/s asmrq/s"
1172 " asmok/s fragok/s fragcrt/s\n", timestamp[!curr]);
1175 printf("%-11s %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f\n",
1177 S_VALUE(snip->InReceives, snic->InReceives, itv),
1178 S_VALUE(snip->ForwDatagrams, snic->ForwDatagrams, itv),
1179 S_VALUE(snip->InDelivers, snic->InDelivers, itv),
1180 S_VALUE(snip->OutRequests, snic->OutRequests, itv),
1181 S_VALUE(snip->ReasmReqds, snic->ReasmReqds, itv),
1182 S_VALUE(snip->ReasmOKs, snic->ReasmOKs, itv),
1183 S_VALUE(snip->FragOKs, snic->FragOKs, itv),
1184 S_VALUE(snip->FragCreates, snic->FragCreates, itv));
1188 ***************************************************************************
1189 * Display IP network error statistics.
1192 * @a Activity structure with statistics.
1193 * @prev Index in array where stats used as reference are.
1194 * @curr Index in array for current sample statistics.
1195 * @itv Interval of time in jiffies.
1196 ***************************************************************************
1198 __print_funct_t print_net_eip_stats(struct activity *a, int prev, int curr,
1199 unsigned long long itv)
1201 struct stats_net_eip
1202 *sneic = (struct stats_net_eip *) a->buf[curr],
1203 *sneip = (struct stats_net_eip *) a->buf[prev];
1206 printf("\n%-11s ihdrerr/s iadrerr/s iukwnpr/s idisc/s odisc/s"
1207 " onort/s asmf/s fragf/s\n", timestamp[!curr]);
1210 printf("%-11s %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f\n",
1212 S_VALUE(sneip->InHdrErrors, sneic->InHdrErrors, itv),
1213 S_VALUE(sneip->InAddrErrors, sneic->InAddrErrors, itv),
1214 S_VALUE(sneip->InUnknownProtos, sneic->InUnknownProtos, itv),
1215 S_VALUE(sneip->InDiscards, sneic->InDiscards, itv),
1216 S_VALUE(sneip->OutDiscards, sneic->OutDiscards, itv),
1217 S_VALUE(sneip->OutNoRoutes, sneic->OutNoRoutes, itv),
1218 S_VALUE(sneip->ReasmFails, sneic->ReasmFails, itv),
1219 S_VALUE(sneip->FragFails, sneic->FragFails, itv));
1223 ***************************************************************************
1224 * Display ICMP network traffic statistics.
1227 * @a Activity structure with statistics.
1228 * @prev Index in array where stats used as reference are.
1229 * @curr Index in array for current sample statistics.
1230 * @itv Interval of time in jiffies.
1231 ***************************************************************************
1233 __print_funct_t print_net_icmp_stats(struct activity *a, int prev, int curr,
1234 unsigned long long itv)
1236 struct stats_net_icmp
1237 *snic = (struct stats_net_icmp *) a->buf[curr],
1238 *snip = (struct stats_net_icmp *) a->buf[prev];
1241 printf("\n%-11s imsg/s omsg/s iech/s iechr/s oech/s"
1242 " oechr/s itm/s itmr/s otm/s otmr/s"
1243 " iadrmk/s iadrmkr/s oadrmk/s oadrmkr/s\n", timestamp[!curr]);
1246 printf("%-11s %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f"
1247 " %9.2f %9.2f %9.2f %9.2f\n", timestamp[curr],
1248 S_VALUE(snip->InMsgs, snic->InMsgs, itv),
1249 S_VALUE(snip->OutMsgs, snic->OutMsgs, itv),
1250 S_VALUE(snip->InEchos, snic->InEchos, itv),
1251 S_VALUE(snip->InEchoReps, snic->InEchoReps, itv),
1252 S_VALUE(snip->OutEchos, snic->OutEchos, itv),
1253 S_VALUE(snip->OutEchoReps, snic->OutEchoReps, itv),
1254 S_VALUE(snip->InTimestamps, snic->InTimestamps, itv),
1255 S_VALUE(snip->InTimestampReps, snic->InTimestampReps, itv),
1256 S_VALUE(snip->OutTimestamps, snic->OutTimestamps, itv),
1257 S_VALUE(snip->OutTimestampReps, snic->OutTimestampReps, itv),
1258 S_VALUE(snip->InAddrMasks, snic->InAddrMasks, itv),
1259 S_VALUE(snip->InAddrMaskReps, snic->InAddrMaskReps, itv),
1260 S_VALUE(snip->OutAddrMasks, snic->OutAddrMasks, itv),
1261 S_VALUE(snip->OutAddrMaskReps, snic->OutAddrMaskReps, itv));
1265 ***************************************************************************
1266 * Display ICMP network error statistics.
1269 * @a Activity structure with statistics.
1270 * @prev Index in array where stats used as reference are.
1271 * @curr Index in array for current sample statistics.
1272 * @itv Interval of time in jiffies.
1273 ***************************************************************************
1275 __print_funct_t print_net_eicmp_stats(struct activity *a, int prev, int curr,
1276 unsigned long long itv)
1278 struct stats_net_eicmp
1279 *sneic = (struct stats_net_eicmp *) a->buf[curr],
1280 *sneip = (struct stats_net_eicmp *) a->buf[prev];
1283 printf("\n%-11s ierr/s oerr/s idstunr/s odstunr/s itmex/s"
1284 " otmex/s iparmpb/s oparmpb/s isrcq/s osrcq/s"
1285 " iredir/s oredir/s\n", timestamp[!curr]);
1288 printf("%-11s %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f"
1289 " %9.2f %9.2f\n", timestamp[curr],
1290 S_VALUE(sneip->InErrors, sneic->InErrors, itv),
1291 S_VALUE(sneip->OutErrors, sneic->OutErrors, itv),
1292 S_VALUE(sneip->InDestUnreachs, sneic->InDestUnreachs, itv),
1293 S_VALUE(sneip->OutDestUnreachs, sneic->OutDestUnreachs, itv),
1294 S_VALUE(sneip->InTimeExcds, sneic->InTimeExcds, itv),
1295 S_VALUE(sneip->OutTimeExcds, sneic->OutTimeExcds, itv),
1296 S_VALUE(sneip->InParmProbs, sneic->InParmProbs, itv),
1297 S_VALUE(sneip->OutParmProbs, sneic->OutParmProbs, itv),
1298 S_VALUE(sneip->InSrcQuenchs, sneic->InSrcQuenchs, itv),
1299 S_VALUE(sneip->OutSrcQuenchs, sneic->OutSrcQuenchs, itv),
1300 S_VALUE(sneip->InRedirects, sneic->InRedirects, itv),
1301 S_VALUE(sneip->OutRedirects, sneic->OutRedirects, itv));
1305 ***************************************************************************
1306 * Display TCP network traffic statistics.
1309 * @a Activity structure with statistics.
1310 * @prev Index in array where stats used as reference are.
1311 * @curr Index in array for current sample statistics.
1312 * @itv Interval of time in jiffies.
1313 ***************************************************************************
1315 __print_funct_t print_net_tcp_stats(struct activity *a, int prev, int curr,
1316 unsigned long long itv)
1318 struct stats_net_tcp
1319 *sntc = (struct stats_net_tcp *) a->buf[curr],
1320 *sntp = (struct stats_net_tcp *) a->buf[prev];
1323 printf("\n%-11s active/s passive/s iseg/s oseg/s\n",
1327 printf("%-11s %9.2f %9.2f %9.2f %9.2f\n",
1329 S_VALUE(sntp->ActiveOpens, sntc->ActiveOpens, itv),
1330 S_VALUE(sntp->PassiveOpens, sntc->PassiveOpens, itv),
1331 S_VALUE(sntp->InSegs, sntc->InSegs, itv),
1332 S_VALUE(sntp->OutSegs, sntc->OutSegs, itv));
1336 ***************************************************************************
1337 * Display TCP network error statistics.
1340 * @a Activity structure with statistics.
1341 * @prev Index in array where stats used as reference are.
1342 * @curr Index in array for current sample statistics.
1343 * @itv Interval of time in jiffies.
1344 ***************************************************************************
1346 __print_funct_t print_net_etcp_stats(struct activity *a, int prev, int curr,
1347 unsigned long long itv)
1349 struct stats_net_etcp
1350 *snetc = (struct stats_net_etcp *) a->buf[curr],
1351 *snetp = (struct stats_net_etcp *) a->buf[prev];
1354 printf("\n%-11s atmptf/s estres/s retrans/s isegerr/s orsts/s\n",
1358 printf("%-11s %9.2f %9.2f %9.2f %9.2f %9.2f\n",
1360 S_VALUE(snetp->AttemptFails, snetc->AttemptFails, itv),
1361 S_VALUE(snetp->EstabResets, snetc->EstabResets, itv),
1362 S_VALUE(snetp->RetransSegs, snetc->RetransSegs, itv),
1363 S_VALUE(snetp->InErrs, snetc->InErrs, itv),
1364 S_VALUE(snetp->OutRsts, snetc->OutRsts, itv));
1368 ***************************************************************************
1369 * Display UDP network traffic statistics.
1372 * @a Activity structure with statistics.
1373 * @prev Index in array where stats used as reference are.
1374 * @curr Index in array for current sample statistics.
1375 * @itv Interval of time in jiffies.
1376 ***************************************************************************
1378 __print_funct_t print_net_udp_stats(struct activity *a, int prev, int curr,
1379 unsigned long long itv)
1381 struct stats_net_udp
1382 *snuc = (struct stats_net_udp *) a->buf[curr],
1383 *snup = (struct stats_net_udp *) a->buf[prev];
1386 printf("\n%-11s idgm/s odgm/s noport/s idgmerr/s\n",
1390 printf("%-11s %9.2f %9.2f %9.2f %9.2f\n",
1392 S_VALUE(snup->InDatagrams, snuc->InDatagrams, itv),
1393 S_VALUE(snup->OutDatagrams, snuc->OutDatagrams, itv),
1394 S_VALUE(snup->NoPorts, snuc->NoPorts, itv),
1395 S_VALUE(snup->InErrors, snuc->InErrors, itv));
1399 ***************************************************************************
1400 * Display IPv6 sockets statistics. This function is used to display
1401 * instantaneous and average statistics.
1404 * @a Activity structure with statistics.
1405 * @curr Index in array for current sample statistics.
1406 * @dispavg TRUE if displaying average statistics.
1407 ***************************************************************************
1409 void stub_print_net_sock6_stats(struct activity *a, int curr, int dispavg)
1411 struct stats_net_sock6
1412 *snsc = (struct stats_net_sock6 *) a->buf[curr];
1413 static unsigned long long
1417 avg_frag6_inuse = 0;
1420 printf("\n%-11s tcp6sck udp6sck raw6sck ip6-frag\n",
1425 /* Display instantaneous values */
1426 printf("%-11s %9u %9u %9u %9u\n", timestamp[curr],
1432 /* Will be used to compute the average */
1433 avg_tcp6_inuse += snsc->tcp6_inuse;
1434 avg_udp6_inuse += snsc->udp6_inuse;
1435 avg_raw6_inuse += snsc->raw6_inuse;
1436 avg_frag6_inuse += snsc->frag6_inuse;
1439 /* Display average values */
1440 printf("%-11s %9.0f %9.0f %9.0f %9.0f\n", timestamp[curr],
1441 (double) avg_tcp6_inuse / avg_count,
1442 (double) avg_udp6_inuse / avg_count,
1443 (double) avg_raw6_inuse / avg_count,
1444 (double) avg_frag6_inuse / avg_count);
1446 /* Reset average counters */
1447 avg_tcp6_inuse = avg_udp6_inuse = avg_raw6_inuse = avg_frag6_inuse = 0;
1452 ***************************************************************************
1453 * Display IPv6 sockets statistics.
1456 * @a Activity structure with statistics.
1457 * @prev Index in array where stats used as reference are.
1458 * @curr Index in array for current sample statistics.
1459 * @itv Interval of time in jiffies.
1460 ***************************************************************************
1462 __print_funct_t print_net_sock6_stats(struct activity *a, int prev, int curr,
1463 unsigned long long itv)
1465 stub_print_net_sock6_stats(a, curr, FALSE);
1469 ***************************************************************************
1470 * Display average IPv6 sockets statistics.
1473 * @a Activity structure with statistics.
1474 * @prev Index in array where stats used as reference are.
1475 * @curr Index in array for current sample statistics.
1476 * @itv Interval of time in jiffies.
1477 ***************************************************************************
1479 __print_funct_t print_avg_net_sock6_stats(struct activity *a, int prev, int curr,
1480 unsigned long long itv)
1482 stub_print_net_sock6_stats(a, curr, TRUE);
1486 ***************************************************************************
1487 * Display IPv6 network traffic statistics.
1490 * @a Activity structure with statistics.
1491 * @prev Index in array where stats used as reference are.
1492 * @curr Index in array for current sample statistics.
1493 * @itv Interval of time in jiffies.
1494 ***************************************************************************
1496 __print_funct_t print_net_ip6_stats(struct activity *a, int prev, int curr,
1497 unsigned long long itv)
1499 struct stats_net_ip6
1500 *snic = (struct stats_net_ip6 *) a->buf[curr],
1501 *snip = (struct stats_net_ip6 *) a->buf[prev];
1504 printf("\n%-11s irec6/s fwddgm6/s idel6/s orq6/s asmrq6/s"
1505 " asmok6/s imcpck6/s omcpck6/s fragok6/s fragcr6/s\n",
1509 printf("%-11s %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f\n",
1511 S_VALUE(snip->InReceives6, snic->InReceives6, itv),
1512 S_VALUE(snip->OutForwDatagrams6, snic->OutForwDatagrams6, itv),
1513 S_VALUE(snip->InDelivers6, snic->InDelivers6, itv),
1514 S_VALUE(snip->OutRequests6, snic->OutRequests6, itv),
1515 S_VALUE(snip->ReasmReqds6, snic->ReasmReqds6, itv),
1516 S_VALUE(snip->ReasmOKs6, snic->ReasmOKs6, itv),
1517 S_VALUE(snip->InMcastPkts6, snic->InMcastPkts6, itv),
1518 S_VALUE(snip->OutMcastPkts6, snic->OutMcastPkts6, itv),
1519 S_VALUE(snip->FragOKs6, snic->FragOKs6, itv),
1520 S_VALUE(snip->FragCreates6, snic->FragCreates6, itv));
1524 ***************************************************************************
1525 * Display IPv6 network error statistics.
1528 * @a Activity structure with statistics.
1529 * @prev Index in array where stats used as reference are.
1530 * @curr Index in array for current sample statistics.
1531 * @itv Interval of time in jiffies.
1532 ***************************************************************************
1534 __print_funct_t print_net_eip6_stats(struct activity *a, int prev, int curr,
1535 unsigned long long itv)
1537 struct stats_net_eip6
1538 *sneic = (struct stats_net_eip6 *) a->buf[curr],
1539 *sneip = (struct stats_net_eip6 *) a->buf[prev];
1542 printf("\n%-11s ihdrer6/s iadrer6/s iukwnp6/s i2big6/s idisc6/s odisc6/s"
1543 " inort6/s onort6/s asmf6/s fragf6/s itrpck6/s\n",
1547 printf("%-11s %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f\n",
1549 S_VALUE(sneip->InHdrErrors6, sneic->InHdrErrors6, itv),
1550 S_VALUE(sneip->InAddrErrors6, sneic->InAddrErrors6, itv),
1551 S_VALUE(sneip->InUnknownProtos6, sneic->InUnknownProtos6, itv),
1552 S_VALUE(sneip->InTooBigErrors6, sneic->InTooBigErrors6, itv),
1553 S_VALUE(sneip->InDiscards6, sneic->InDiscards6, itv),
1554 S_VALUE(sneip->OutDiscards6, sneic->OutDiscards6, itv),
1555 S_VALUE(sneip->InNoRoutes6, sneic->InNoRoutes6, itv),
1556 S_VALUE(sneip->OutNoRoutes6, sneic->OutNoRoutes6, itv),
1557 S_VALUE(sneip->ReasmFails6, sneic->ReasmFails6, itv),
1558 S_VALUE(sneip->FragFails6, sneic->FragFails6, itv),
1559 S_VALUE(sneip->InTruncatedPkts6, sneic->InTruncatedPkts6, itv));
1563 ***************************************************************************
1564 * Display ICMPv6 network traffic statistics.
1567 * @a Activity structure with statistics.
1568 * @prev Index in array where stats used as reference are.
1569 * @curr Index in array for current sample statistics.
1570 * @itv Interval of time in jiffies.
1571 ***************************************************************************
1573 __print_funct_t print_net_icmp6_stats(struct activity *a, int prev, int curr,
1574 unsigned long long itv)
1576 struct stats_net_icmp6
1577 *snic = (struct stats_net_icmp6 *) a->buf[curr],
1578 *snip = (struct stats_net_icmp6 *) a->buf[prev];
1581 printf("\n%-11s imsg6/s omsg6/s iech6/s iechr6/s oechr6/s"
1582 " igmbq6/s igmbr6/s ogmbr6/s igmbrd6/s ogmbrd6/s irtsol6/s ortsol6/s"
1583 " irtad6/s inbsol6/s onbsol6/s inbad6/s onbad6/s\n",
1587 printf("%-11s %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f"
1588 " %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f\n", timestamp[curr],
1589 S_VALUE(snip->InMsgs6, snic->InMsgs6, itv),
1590 S_VALUE(snip->OutMsgs6, snic->OutMsgs6, itv),
1591 S_VALUE(snip->InEchos6, snic->InEchos6, itv),
1592 S_VALUE(snip->InEchoReplies6, snic->InEchoReplies6, itv),
1593 S_VALUE(snip->OutEchoReplies6, snic->OutEchoReplies6, itv),
1594 S_VALUE(snip->InGroupMembQueries6, snic->InGroupMembQueries6, itv),
1595 S_VALUE(snip->InGroupMembResponses6, snic->InGroupMembResponses6, itv),
1596 S_VALUE(snip->OutGroupMembResponses6, snic->OutGroupMembResponses6, itv),
1597 S_VALUE(snip->InGroupMembReductions6, snic->InGroupMembReductions6, itv),
1598 S_VALUE(snip->OutGroupMembReductions6, snic->OutGroupMembReductions6, itv),
1599 S_VALUE(snip->InRouterSolicits6, snic->InRouterSolicits6, itv),
1600 S_VALUE(snip->OutRouterSolicits6, snic->OutRouterSolicits6, itv),
1601 S_VALUE(snip->InRouterAdvertisements6, snic->InRouterAdvertisements6, itv),
1602 S_VALUE(snip->InNeighborSolicits6, snic->InNeighborSolicits6, itv),
1603 S_VALUE(snip->OutNeighborSolicits6, snic->OutNeighborSolicits6, itv),
1604 S_VALUE(snip->InNeighborAdvertisements6, snic->InNeighborAdvertisements6, itv),
1605 S_VALUE(snip->OutNeighborAdvertisements6, snic->OutNeighborAdvertisements6, itv));
1609 ***************************************************************************
1610 * Display ICMPv6 network error statistics.
1613 * @a Activity structure with statistics.
1614 * @prev Index in array where stats used as reference are.
1615 * @curr Index in array for current sample statistics.
1616 * @itv Interval of time in jiffies.
1617 ***************************************************************************
1619 __print_funct_t print_net_eicmp6_stats(struct activity *a, int prev, int curr,
1620 unsigned long long itv)
1622 struct stats_net_eicmp6
1623 *sneic = (struct stats_net_eicmp6 *) a->buf[curr],
1624 *sneip = (struct stats_net_eicmp6 *) a->buf[prev];
1627 printf("\n%-11s ierr6/s idtunr6/s odtunr6/s itmex6/s otmex6/s"
1628 " iprmpb6/s oprmpb6/s iredir6/s oredir6/s ipck2b6/s opck2b6/s\n",
1632 printf("%-11s %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f"
1633 " %9.2f\n", timestamp[curr],
1634 S_VALUE(sneip->InErrors6, sneic->InErrors6, itv),
1635 S_VALUE(sneip->InDestUnreachs6, sneic->InDestUnreachs6, itv),
1636 S_VALUE(sneip->OutDestUnreachs6, sneic->OutDestUnreachs6, itv),
1637 S_VALUE(sneip->InTimeExcds6, sneic->InTimeExcds6, itv),
1638 S_VALUE(sneip->OutTimeExcds6, sneic->OutTimeExcds6, itv),
1639 S_VALUE(sneip->InParmProblems6, sneic->InParmProblems6, itv),
1640 S_VALUE(sneip->OutParmProblems6, sneic->OutParmProblems6, itv),
1641 S_VALUE(sneip->InRedirects6, sneic->InRedirects6, itv),
1642 S_VALUE(sneip->OutRedirects6, sneic->OutRedirects6, itv),
1643 S_VALUE(sneip->InPktTooBigs6, sneic->InPktTooBigs6, itv),
1644 S_VALUE(sneip->OutPktTooBigs6, sneic->OutPktTooBigs6, itv));
1648 ***************************************************************************
1649 * Display UDPv6 network traffic statistics.
1652 * @a Activity structure with statistics.
1653 * @prev Index in array where stats used as reference are.
1654 * @curr Index in array for current sample statistics.
1655 * @itv Interval of time in jiffies.
1656 ***************************************************************************
1658 __print_funct_t print_net_udp6_stats(struct activity *a, int prev, int curr,
1659 unsigned long long itv)
1661 struct stats_net_udp6
1662 *snuc = (struct stats_net_udp6 *) a->buf[curr],
1663 *snup = (struct stats_net_udp6 *) a->buf[prev];
1666 printf("\n%-11s idgm6/s odgm6/s noport6/s idgmer6/s\n",
1670 printf("%-11s %9.2f %9.2f %9.2f %9.2f\n",
1672 S_VALUE(snup->InDatagrams6, snuc->InDatagrams6, itv),
1673 S_VALUE(snup->OutDatagrams6, snuc->OutDatagrams6, itv),
1674 S_VALUE(snup->NoPorts6, snuc->NoPorts6, itv),
1675 S_VALUE(snup->InErrors6, snuc->InErrors6, itv));
1679 ***************************************************************************
1680 * Display CPU frequency statistics. This function is used to display
1681 * instantaneous and average statistics.
1684 * @a Activity structure with statistics.
1685 * @curr Index in array for current sample statistics.
1686 * @dispavg True if displaying average statistics.
1687 ***************************************************************************
1689 void stub_print_pwr_cpufreq_stats(struct activity *a, int curr, int dispavg)
1692 struct stats_pwr_cpufreq *spc;
1693 static unsigned long long
1694 *avg_cpufreq = NULL;
1697 /* Allocate array of CPU frequency */
1698 if ((avg_cpufreq = (unsigned long long *) malloc(sizeof(unsigned long long) * a->nr))
1703 memset(avg_cpufreq, 0, sizeof(unsigned long long) * a->nr);
1707 printf("\n%-11s CPU MHz\n",
1711 for (i = 0; (i < a->nr) && (i < a->bitmap->b_size + 1); i++) {
1714 * The size of a->buf[...] CPU structure may be different from the default
1715 * sizeof(struct stats_pwr_cpufreq) value if data have been read from a file!
1716 * That's why we don't use a syntax like:
1717 * spc = (struct stats_pwr_cpufreq *) a->buf[...] + i;
1719 spc = (struct stats_pwr_cpufreq *) ((char *) a->buf[curr] + i * a->msize);
1722 * Note: a->nr is in [1, NR_CPUS + 1].
1723 * Bitmap size is provided for (NR_CPUS + 1) CPUs.
1724 * Anyway, NR_CPUS may vary between the version of sysstat
1725 * used by sadc to create a file, and the version of sysstat
1726 * used by sar to read it...
1729 /* Should current CPU (including CPU "all") be displayed? */
1730 if (a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))) {
1732 /* Yes: Display it */
1733 printf("%-11s", timestamp[curr]);
1736 /* This is CPU "all" */
1740 printf(" %3d", i - 1);
1744 /* Display instantaneous values */
1746 ((double) spc->cpufreq) / 100);
1748 * Will be used to compute the average.
1749 * Note: overflow unlikely to happen but not impossible...
1751 avg_cpufreq[i] += spc->cpufreq;
1754 /* Display average values */
1756 (double) avg_cpufreq[i] / (100 * avg_count));
1762 /* Array of CPU frequency no longer needed: Free it! */
1771 ***************************************************************************
1772 * Display CPU frequency statistics.
1775 * @a Activity structure with statistics.
1776 * @prev Index in array where stats used as reference are.
1777 * @curr Index in array for current sample statistics.
1778 * @itv Interval of time in jiffies.
1779 ***************************************************************************
1781 __print_funct_t print_pwr_cpufreq_stats(struct activity *a, int prev, int curr,
1782 unsigned long long itv)
1784 stub_print_pwr_cpufreq_stats(a, curr, FALSE);
1788 ***************************************************************************
1789 * Display average CPU frequency statistics.
1792 * @a Activity structure with statistics.
1793 * @prev Index in array where stats used as reference are.
1794 * @curr Index in array for current sample statistics.
1795 * @itv Interval of time in jiffies.
1796 ***************************************************************************
1798 __print_funct_t print_avg_pwr_cpufreq_stats(struct activity *a, int prev, int curr,
1799 unsigned long long itv)
1801 stub_print_pwr_cpufreq_stats(a, curr, TRUE);
1805 ***************************************************************************
1806 * Display fan statistics. This function is used to display
1807 * instantaneous and average statistics.
1810 * @a Activity structure with statistics.
1811 * @curr Index in array for current sample statistics.
1812 * @dispavg True if displaying average statistics.
1813 ***************************************************************************
1815 void stub_print_pwr_fan_stats(struct activity *a, int curr, int dispavg)
1818 struct stats_pwr_fan *spc;
1819 static double *avg_fan = NULL;
1820 static double *avg_fan_min = NULL;
1822 /* Allocate arrays of fan RPMs */
1824 if ((avg_fan = (double *) malloc(sizeof(double) * a->nr)) == NULL) {
1828 memset(avg_fan, 0, sizeof(double) * a->nr);
1831 if ((avg_fan_min = (double *) malloc(sizeof(double) * a->nr)) == NULL) {
1835 memset(avg_fan_min, 0, sizeof(double) * a->nr);
1839 printf("\n%-11s FAN rpm drpm %*s\n",
1840 timestamp[!curr], MAX_SENSORS_DEV_LEN, "DEVICE");
1843 for (i = 0; i < a->nr; i++) {
1844 spc = (struct stats_pwr_fan *) ((char *) a->buf[curr] + i * a->msize);
1846 printf("%-11s %3d", timestamp[curr], i + 1);
1849 /* Display average values */
1850 printf(" %9.2f %9.2f",
1851 (double) avg_fan[i] / avg_count,
1852 (double) (avg_fan[i] - avg_fan_min[i]) / avg_count);
1855 /* Display instantaneous values */
1856 printf(" %9.2f %9.2f",
1858 spc->rpm - spc->rpm_min);
1859 avg_fan[i] += spc->rpm;
1860 avg_fan_min[i] += spc->rpm_min;
1863 printf(" %*s\n", MAX_SENSORS_DEV_LEN, spc->device);
1879 ***************************************************************************
1880 * Display fan statistics.
1883 * @a Activity structure with statistics.
1884 * @prev Index in array where stats used as reference are.
1885 * @curr Index in array for current sample statistics.
1886 * @itv Interval of time in jiffies.
1887 ***************************************************************************
1889 __print_funct_t print_pwr_fan_stats(struct activity *a, int prev, int curr,
1890 unsigned long long itv)
1892 stub_print_pwr_fan_stats(a, curr, FALSE);
1896 ***************************************************************************
1897 * Display average fan statistics.
1900 * @a Activity structure with statistics.
1901 * @prev Index in array where stats used as reference are.
1902 * @curr Index in array for current sample statistics.
1903 * @itv Interval of time in jiffies.
1904 ***************************************************************************
1906 __print_funct_t print_avg_pwr_fan_stats(struct activity *a, int prev, int curr,
1907 unsigned long long itv)
1909 stub_print_pwr_fan_stats(a, curr, TRUE);
1913 ***************************************************************************
1914 * Display device temperature statistics. This function is used to display
1915 * instantaneous and average statistics.
1918 * @a Activity structure with statistics.
1919 * @curr Index in array for current sample statistics.
1920 * @dispavg True if displaying average statistics.
1921 ***************************************************************************
1923 void stub_print_pwr_temp_stats(struct activity *a, int curr, int dispavg)
1926 struct stats_pwr_temp *spc;
1927 static double *avg_temp = NULL;
1928 static double *avg_temp_min = NULL, *avg_temp_max = NULL;
1930 /* Allocate arrays of temperatures */
1932 if ((avg_temp = (double *) malloc(sizeof(double) * a->nr)) == NULL) {
1936 memset(avg_temp, 0, sizeof(double) * a->nr);
1938 if (!avg_temp_min) {
1939 if ((avg_temp_min = (double *) malloc(sizeof(double) * a->nr)) == NULL) {
1943 memset(avg_temp_min, 0, sizeof(double) * a->nr);
1945 if (!avg_temp_max) {
1946 if ((avg_temp_max = (double *) malloc(sizeof(double) * a->nr)) == NULL) {
1950 memset(avg_temp_max, 0, sizeof(double) * a->nr);
1954 printf("\n%-11s TEMP degC %%temp %*s\n",
1955 timestamp[!curr], MAX_SENSORS_DEV_LEN, "DEVICE");
1958 for (i = 0; i < a->nr; i++) {
1959 spc = (struct stats_pwr_temp *) ((char *) a->buf[curr] + i * a->msize);
1961 printf("%-11s %3d", timestamp[curr], i + 1);
1964 /* Display average values */
1965 printf(" %9.2f %9.2f",
1966 (double) avg_temp[i] / avg_count,
1967 (avg_temp_max[i] - avg_temp_min[i]) ?
1968 ((double) (avg_temp[i] / avg_count) - avg_temp_min[i]) / (avg_temp_max[i] - avg_temp_min[i]) * 100 :
1972 /* Display instantaneous values */
1973 printf(" %9.2f %9.2f",
1975 (spc->temp_max - spc->temp_min) ?
1976 (spc->temp - spc->temp_min) / (spc->temp_max - spc->temp_min) * 100 :
1978 avg_temp[i] += spc->temp;
1979 /* Assume that min and max temperatures cannot vary */
1980 avg_temp_min[i] = spc->temp_min;
1981 avg_temp_max[i] = spc->temp_max;
1984 printf(" %*s\n", MAX_SENSORS_DEV_LEN, spc->device);
1994 avg_temp_min = NULL;
1998 avg_temp_max = NULL;
2004 ***************************************************************************
2005 * Display temperature statistics.
2008 * @a Activity structure with statistics.
2009 * @prev Index in array where stats used as reference are.
2010 * @curr Index in array for current sample statistics.
2011 * @itv Interval of time in jiffies.
2012 ***************************************************************************
2014 __print_funct_t print_pwr_temp_stats(struct activity *a, int prev, int curr,
2015 unsigned long long itv)
2017 stub_print_pwr_temp_stats(a, curr, FALSE);
2021 ***************************************************************************
2022 * Display average temperature statistics.
2025 * @a Activity structure with statistics.
2026 * @prev Index in array where stats used as reference are.
2027 * @curr Index in array for current sample statistics.
2028 * @itv Interval of time in jiffies.
2029 ***************************************************************************
2031 __print_funct_t print_avg_pwr_temp_stats(struct activity *a, int prev, int curr,
2032 unsigned long long itv)
2034 stub_print_pwr_temp_stats(a, curr, TRUE);
2038 ***************************************************************************
2039 * Display voltage inputs statistics. This function is used to display
2040 * instantaneous and average statistics.
2043 * @a Activity structure with statistics.
2044 * @curr Index in array for current sample statistics.
2045 * @dispavg True if displaying average statistics.
2046 ***************************************************************************
2048 void stub_print_pwr_in_stats(struct activity *a, int curr, int dispavg)
2051 struct stats_pwr_in *spc;
2052 static double *avg_in = NULL;
2053 static double *avg_in_min = NULL, *avg_in_max = NULL;
2055 /* Allocate arrays of voltage inputs */
2057 if ((avg_in = (double *) malloc(sizeof(double) * a->nr)) == NULL) {
2061 memset(avg_in, 0, sizeof(double) * a->nr);
2064 if ((avg_in_min = (double *) malloc(sizeof(double) * a->nr)) == NULL) {
2068 memset(avg_in_min, 0, sizeof(double) * a->nr);
2071 if ((avg_in_max = (double *) malloc(sizeof(double) * a->nr)) == NULL) {
2075 memset(avg_in_max, 0, sizeof(double) * a->nr);
2079 printf("\n%-11s IN inV %%in %*s\n",
2080 timestamp[!curr], MAX_SENSORS_DEV_LEN, "DEVICE");
2083 for (i = 0; i < a->nr; i++) {
2084 spc = (struct stats_pwr_in *) ((char *) a->buf[curr] + i * a->msize);
2086 printf("%-11s %3d", timestamp[curr], i);
2089 /* Display average values */
2090 printf(" %9.2f %9.2f",
2091 (double) avg_in[i] / avg_count,
2092 (avg_in_max[i] - avg_in_min[i]) ?
2093 ((double) (avg_in[i] / avg_count) - avg_in_min[i]) / (avg_in_max[i] - avg_in_min[i]) * 100 :
2097 /* Display instantaneous values */
2098 printf(" %9.2f %9.2f",
2100 (spc->in_max - spc->in_min) ?
2101 (spc->in - spc->in_min) / (spc->in_max - spc->in_min) * 100 :
2103 avg_in[i] += spc->in;
2104 /* Assume that min and max voltage inputs cannot vary */
2105 avg_in_min[i] = spc->in_min;
2106 avg_in_max[i] = spc->in_max;
2109 printf(" %*s\n", MAX_SENSORS_DEV_LEN, spc->device);
2129 ***************************************************************************
2130 * Display voltage inputs statistics.
2133 * @a Activity structure with statistics.
2134 * @prev Index in array where stats used as reference are.
2135 * @curr Index in array for current sample statistics.
2136 * @itv Interval of time in jiffies.
2137 ***************************************************************************
2139 __print_funct_t print_pwr_in_stats(struct activity *a, int prev, int curr,
2140 unsigned long long itv)
2142 stub_print_pwr_in_stats(a, curr, FALSE);
2146 ***************************************************************************
2147 * Display average voltage inputs statistics.
2150 * @a Activity structure with statistics.
2151 * @prev Index in array where stats used as reference are.
2152 * @curr Index in array for current sample statistics.
2153 * @itv Interval of time in jiffies.
2154 ***************************************************************************
2156 __print_funct_t print_avg_pwr_in_stats(struct activity *a, int prev, int curr,
2157 unsigned long long itv)
2159 stub_print_pwr_in_stats(a, curr, TRUE);
2163 ***************************************************************************
2164 * Display huge pages statistics. This function is used to
2165 * display instantaneous and average statistics.
2168 * @a Activity structure with statistics.
2169 * @curr Index in array for current sample statistics.
2170 * @dispavg TRUE if displaying average statistics.
2171 ***************************************************************************
2173 void stub_print_huge_stats(struct activity *a, int curr, int dispavg)
2176 *smc = (struct stats_huge *) a->buf[curr];
2177 static unsigned long long
2182 printf("\n%-11s kbhugfree kbhugused %%hugused\n",
2187 /* Display instantaneous values */
2188 printf("%-11s %9lu %9lu %6.2f\n",
2191 smc->tlhkb - smc->frhkb,
2193 SP_VALUE(smc->frhkb, smc->tlhkb, smc->tlhkb) : 0.0);
2195 /* Will be used to compute the average */
2196 avg_frhkb += smc->frhkb;
2197 avg_tlhkb += smc->tlhkb;
2200 /* Display average values */
2201 printf("%-11s %9.0f %9.0f %6.2f\n",
2203 (double) avg_frhkb / avg_count,
2204 ((double) avg_tlhkb / avg_count) -
2205 ((double) avg_frhkb / avg_count),
2206 ((double) (avg_tlhkb / avg_count)) ?
2207 SP_VALUE((double) (avg_frhkb / avg_count),
2208 (double) (avg_tlhkb / avg_count),
2209 (double) (avg_tlhkb / avg_count)) :
2212 /* Reset average counters */
2213 avg_frhkb = avg_tlhkb = 0;
2218 ***************************************************************************
2219 * Display huge pages statistics.
2222 * @a Activity structure with statistics.
2223 * @prev Index in array where stats used as reference are.
2224 * @curr Index in array for current sample statistics.
2225 * @itv Interval of time in jiffies.
2226 ***************************************************************************
2228 __print_funct_t print_huge_stats(struct activity *a, int prev, int curr,
2229 unsigned long long itv)
2231 stub_print_huge_stats(a, curr, FALSE);
2235 ***************************************************************************
2236 * Display huge pages statistics.
2239 * @a Activity structure with statistics.
2240 * @prev Index in array where stats used as reference are.
2241 * @curr Index in array for current sample statistics.
2242 * @itv Interval of time in jiffies.
2243 ***************************************************************************
2245 __print_funct_t print_avg_huge_stats(struct activity *a, int prev, int curr,
2246 unsigned long long itv)
2248 stub_print_huge_stats(a, curr, TRUE);
2252 ***************************************************************************
2253 * Display CPU weighted frequency statistics. This function is used to
2254 * display instantaneous and average statistics.
2257 * @a Activity structure with statistics.
2258 * @prev Index in array where stats used as reference are.
2259 * @curr Index in array for current sample statistics.
2260 * @itv Interval of time in jiffies.
2261 ***************************************************************************
2263 void print_pwr_wghfreq_stats(struct activity *a, int prev, int curr,
2264 unsigned long long itv)
2267 struct stats_pwr_wghfreq *spc, *spp, *spc_k, *spp_k;
2268 unsigned long long tis, tisfreq;
2271 printf("\n%-11s CPU wghMHz\n",
2275 for (i = 0; (i < a->nr) && (i < a->bitmap->b_size + 1); i++) {
2278 * The size of a->buf[...] CPU structure may be different from the default
2279 * sizeof(struct stats_pwr_wghfreq) value if data have been read from a file!
2280 * That's why we don't use a syntax like:
2281 * spc = (struct stats_pwr_wghfreq *) a->buf[...] + i;
2283 spc = (struct stats_pwr_wghfreq *) ((char *) a->buf[curr] + i * a->msize * a->nr2);
2284 spp = (struct stats_pwr_wghfreq *) ((char *) a->buf[prev] + i * a->msize * a->nr2);
2287 * Note: a->nr is in [1, NR_CPUS + 1].
2288 * Bitmap size is provided for (NR_CPUS + 1) CPUs.
2289 * Anyway, NR_CPUS may vary between the version of sysstat
2290 * used by sadc to create a file, and the version of sysstat
2291 * used by sar to read it...
2294 /* Should current CPU (including CPU "all") be displayed? */
2295 if (a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))) {
2297 /* Yes: Display it */
2298 printf("%-11s", timestamp[curr]);
2301 /* This is CPU "all" */
2305 printf(" %3d", i - 1);
2311 for (k = 0; k < a->nr2; k++) {
2313 spc_k = (struct stats_pwr_wghfreq *) ((char *) spc + k * a->msize);
2316 spp_k = (struct stats_pwr_wghfreq *) ((char *) spp + k * a->msize);
2318 tisfreq += (spc_k->freq / 1000) *
2319 (spc_k->time_in_state - spp_k->time_in_state);
2320 tis += (spc_k->time_in_state - spp_k->time_in_state);
2323 /* Display weighted frequency for current CPU */
2324 printf(" %9.2f\n", tis ? ((double) tisfreq) / tis : 0.0);
2330 ***************************************************************************
2331 * Display USB devices statistics. This function is used to
2332 * display instantaneous and summary statistics.
2335 * @a Activity structure with statistics.
2336 * @curr Index in array for current sample statistics.
2337 * @itv Interval of time in jiffies.
2338 * @dispavg TRUE if displaying average statistics.
2339 ***************************************************************************
2341 void stub_print_pwr_usb_stats(struct activity *a, int curr, int dispavg)
2344 struct stats_pwr_usb *suc, *sum;
2347 printf("\n%-11s BUS idvendor idprod maxpower",
2348 (dispavg ? _("Summary") : timestamp[!curr]));
2349 printf(" %*s", MAX_MANUF_LEN - 1, "manufact");
2350 printf(" %*s\n", MAX_PROD_LEN - 1, "product");
2353 for (i = 0; i < a->nr; i++) {
2354 suc = (struct stats_pwr_usb *) ((char *) a->buf[curr] + i * a->msize);
2357 /* Bus#0 doesn't exist: We are at the end of the list */
2360 printf("%-11s %6d %9x %9x %9u",
2361 (dispavg ? _("Summary") : timestamp[curr]),
2363 suc->vendor_id, suc->product_id,
2364 /* bMaxPower is expressed in 2 mA units */
2365 suc->bmaxpower << 1);
2367 printf(" %*s", MAX_MANUF_LEN - 1, suc->manufacturer);
2368 printf(" %*s\n", MAX_PROD_LEN - 1, suc->product);
2371 /* Save current USB device in summary list */
2372 for (j = 0; j < a->nr; j++) {
2373 sum = (struct stats_pwr_usb *) ((char *) a->buf[2] + j * a->msize);
2375 if ((sum->bus_nr == suc->bus_nr) &&
2376 (sum->vendor_id == suc->vendor_id) &&
2377 (sum->product_id == suc->product_id))
2378 /* USB device found in summary list */
2382 * Current slot is free:
2383 * Save USB device in summary list.
2388 if (j == a->nr - 1) {
2390 * This is the last slot and
2391 * we still havent't found the device.
2392 * So create a dummy device here.
2395 sum->vendor_id = sum->product_id = 0;
2397 sum->manufacturer[0] = '\0';
2398 snprintf(sum->product, MAX_PROD_LEN, "%s",
2399 _("Other devices not listed here"));
2400 sum->product[MAX_PROD_LEN - 1] = '\0';
2408 ***************************************************************************
2409 * Display USB devices statistics.
2412 * @a Activity structure with statistics.
2413 * @prev Index in array where stats used as reference are.
2414 * @curr Index in array for current sample statistics.
2415 * @itv Interval of time in jiffies.
2416 ***************************************************************************
2418 __print_funct_t print_pwr_usb_stats(struct activity *a, int prev, int curr,
2419 unsigned long long itv)
2421 stub_print_pwr_usb_stats(a, curr, FALSE);
2425 ***************************************************************************
2426 * Display average USB devices statistics.
2429 * @a Activity structure with statistics.
2430 * @prev Index in array where stats used as reference are.
2431 * @curr Index in array for current sample statistics.
2432 * @itv Interval of time in jiffies.
2433 ***************************************************************************
2435 __print_funct_t print_avg_pwr_usb_stats(struct activity *a, int prev, int curr,
2436 unsigned long long itv)
2438 stub_print_pwr_usb_stats(a, 2, TRUE);
2442 ***************************************************************************
2443 * Display filesystems statistics. This function is used to
2444 * display instantaneous and average statistics.
2447 * @a Activity structure with statistics.
2448 * @curr Index in array for current sample statistics.
2449 * @dispavg TRUE if displaying average statistics.
2450 ***************************************************************************
2452 __print_funct_t stub_print_filesystem_stats(struct activity *a, int curr, int dispavg)
2455 struct stats_filesystem *sfc, *sfm;
2459 printf("\n%-11s MBfsfree MBfsused %%fsused %%ufsused"
2460 " Ifree Iused %%Iused FILESYSTEM\n",
2461 (dispavg ? _("Summary") : timestamp[!curr]));
2464 for (i = 0; i < a->nr; i++) {
2465 sfc = (struct stats_filesystem *) ((char *) a->buf[curr] + i * a->msize);
2468 /* Size of filesystem is null: We are at the end of the list */
2471 printf("%-11s %9.0f %9.0f %6.2f %6.2f"
2472 " %9llu %9llu %6.2f %s\n",
2473 (dispavg ? _("Summary") : timestamp[curr]),
2474 (double) sfc->f_bfree / 1024 / 1024,
2475 (double) (sfc->f_blocks - sfc->f_bfree) / 1024 / 1024,
2476 /* f_blocks is not null. But test it anyway ;-) */
2477 sfc->f_blocks ? SP_VALUE(sfc->f_bfree, sfc->f_blocks, sfc->f_blocks)
2479 sfc->f_blocks ? SP_VALUE(sfc->f_bavail, sfc->f_blocks, sfc->f_blocks)
2482 sfc->f_files - sfc->f_ffree,
2483 sfc->f_files ? SP_VALUE(sfc->f_ffree, sfc->f_files, sfc->f_files)
2488 /* Save current filesystem in summary list */
2489 for (j = 0; j < a->nr; j++) {
2490 sfm = (struct stats_filesystem *) ((char *) a->buf[2] + j * a->msize);
2492 if (!strcmp(sfm->fs_name, sfc->fs_name) ||
2495 * Filesystem found in list (then save again its stats)
2496 * or free slot (end of list).
2507 ***************************************************************************
2508 * Display filesystems statistics.
2511 * @a Activity structure with statistics.
2512 * @prev Index in array where stats used as reference are.
2513 * @curr Index in array for current sample statistics.
2514 * @itv Interval of time in jiffies.
2515 ***************************************************************************
2517 __print_funct_t print_filesystem_stats(struct activity *a, int prev, int curr,
2518 unsigned long long itv)
2520 stub_print_filesystem_stats(a, curr, FALSE);
2524 ***************************************************************************
2525 * Display average filesystems statistics.
2528 * @a Activity structure with statistics.
2529 * @prev Index in array where stats used as reference are.
2530 * @curr Index in array for current sample statistics.
2531 * @itv Interval of time in jiffies.
2532 ***************************************************************************
2534 __print_funct_t print_avg_filesystem_stats(struct activity *a, int prev, int curr,
2535 unsigned long long itv)
2537 stub_print_filesystem_stats(a, 2, TRUE);