2 * pr_stats.c: Functions used by sar to display statistics
3 * (C) 1999-2016 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 ***************************************************************************
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" */
104 cprintf_in(IS_STR, " %s", " all", 0);
107 cprintf_in(IS_INT, " %7d", "", 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 */
127 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
129 if (DISPLAY_CPU_ALL(a->opt_flags)) {
131 * Four additional fields to display:
132 * %irq, %soft, %guest, %gnice.
141 /* Recalculate interval for current proc */
142 g_itv = get_per_cpu_interval(scc, scp);
146 * If the CPU is tickless then there is no change in CPU values
147 * but the sum of values is not zero.
148 * %user, %nice, %system, %iowait, %steal, ..., %idle
151 0.0, 0.0, 0.0, 0.0, 0.0);
153 if (DISPLAY_CPU_DEF(a->opt_flags)) {
154 cprintf_pc(1, 9, 2, 100.0);
158 * Four additional fields to display:
159 * %irq, %soft, %guest, %gnice.
161 else if (DISPLAY_CPU_ALL(a->opt_flags)) {
163 0.0, 0.0, 0.0, 100.0);
170 if (DISPLAY_CPU_DEF(a->opt_flags)) {
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));
184 else if (DISPLAY_CPU_ALL(a->opt_flags)) {
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));
211 ***************************************************************************
212 * Display tasks creation and context switches statistics.
215 * @a Activity structure with statistics.
216 * @prev Index in array where stats used as reference are.
217 * @curr Index in array for current sample statistics.
218 * @itv Interval of time in jiffies.
219 ***************************************************************************
221 __print_funct_t print_pcsw_stats(struct activity *a, int prev, int curr,
222 unsigned long long itv)
225 *spc = (struct stats_pcsw *) a->buf[curr],
226 *spp = (struct stats_pcsw *) a->buf[prev];
229 printf("\n%-11s proc/s cswch/s\n", timestamp[!curr]);
232 printf("%-11s", timestamp[curr]);
234 S_VALUE(spp->processes, spc->processes, itv),
235 S_VALUE(spp->context_switch, spc->context_switch, itv));
240 ***************************************************************************
241 * Display interrupts statistics.
244 * @a Activity structure with statistics.
245 * @prev Index in array where stats used as reference are.
246 * @curr Index in array for current sample statistics.
247 * @itv Interval of time in jiffies.
248 ***************************************************************************
250 __print_funct_t print_irq_stats(struct activity *a, int prev, int curr,
251 unsigned long long itv)
254 struct stats_irq *sic, *sip;
257 printf("\n%-11s INTR intr/s\n", timestamp[!curr]);
260 for (i = 0; (i < a->nr) && (i < a->bitmap->b_size + 1); i++) {
262 sic = (struct stats_irq *) ((char *) a->buf[curr] + i * a->msize);
263 sip = (struct stats_irq *) ((char *) a->buf[prev] + i * a->msize);
266 * Note: a->nr is in [0, NR_IRQS + 1].
267 * Bitmap size is provided for (NR_IRQS + 1) interrupts.
268 * Anyway, NR_IRQS may vary between the version of sysstat
269 * used by sadc to create a file, and the version of sysstat
270 * used by sar to read it...
273 /* Should current interrupt (including int "sum") be displayed? */
274 if (a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))) {
276 /* Yes: Display it */
277 printf("%-11s", timestamp[curr]);
279 /* This is interrupt "sum" */
280 cprintf_in(IS_STR, " %s", " sum", 0);
283 cprintf_in(IS_INT, " %9d", "", i -1);
286 cprintf_f(1, 9, 2, S_VALUE(sip->irq_nr, sic->irq_nr, itv));
293 ***************************************************************************
294 * Display swapping statistics.
297 * @a Activity structure with statistics.
298 * @prev Index in array where stats used as reference are.
299 * @curr Index in array for current sample statistics.
300 * @itv Interval of time in jiffies.
301 ***************************************************************************
303 __print_funct_t print_swap_stats(struct activity *a, int prev, int curr,
304 unsigned long long itv)
307 *ssc = (struct stats_swap *) a->buf[curr],
308 *ssp = (struct stats_swap *) a->buf[prev];
311 printf("\n%-11s pswpin/s pswpout/s\n", timestamp[!curr]);
314 printf("%-11s", timestamp[curr]);
316 S_VALUE(ssp->pswpin, ssc->pswpin, itv),
317 S_VALUE(ssp->pswpout, ssc->pswpout, itv));
322 ***************************************************************************
323 * Display paging statistics.
326 * @a Activity structure with statistics.
327 * @prev Index in array where stats used as reference are.
328 * @curr Index in array for current sample statistics.
329 * @itv Interval of time in jiffies.
330 ***************************************************************************
332 __print_funct_t print_paging_stats(struct activity *a, int prev, int curr,
333 unsigned long long itv)
336 *spc = (struct stats_paging *) a->buf[curr],
337 *spp = (struct stats_paging *) a->buf[prev];
340 printf("\n%-11s pgpgin/s pgpgout/s fault/s majflt/s pgfree/s"
341 " pgscank/s pgscand/s pgsteal/s %%vmeff\n",
345 printf("%-11s", timestamp[curr]);
347 S_VALUE(spp->pgpgin, spc->pgpgin, itv),
348 S_VALUE(spp->pgpgout, spc->pgpgout, itv),
349 S_VALUE(spp->pgfault, spc->pgfault, itv),
350 S_VALUE(spp->pgmajfault, spc->pgmajfault, itv),
351 S_VALUE(spp->pgfree, spc->pgfree, itv),
352 S_VALUE(spp->pgscan_kswapd, spc->pgscan_kswapd, itv),
353 S_VALUE(spp->pgscan_direct, spc->pgscan_direct, itv),
354 S_VALUE(spp->pgsteal, spc->pgsteal, itv));
356 (spc->pgscan_kswapd + spc->pgscan_direct -
357 spp->pgscan_kswapd - spp->pgscan_direct) ?
358 SP_VALUE(spp->pgsteal, spc->pgsteal,
359 spc->pgscan_kswapd + spc->pgscan_direct -
360 spp->pgscan_kswapd - spp->pgscan_direct)
366 ***************************************************************************
367 * Display I/O and transfer rate statistics.
370 * @a Activity structure with statistics.
371 * @prev Index in array where stats used as reference are.
372 * @curr Index in array for current sample statistics.
373 * @itv Interval of time in jiffies.
374 ***************************************************************************
376 __print_funct_t print_io_stats(struct activity *a, int prev, int curr,
377 unsigned long long itv)
380 *sic = (struct stats_io *) a->buf[curr],
381 *sip = (struct stats_io *) a->buf[prev];
384 printf("\n%-11s tps rtps wtps bread/s bwrtn/s\n",
388 printf("%-11s", timestamp[curr]);
390 * If we get negative values, this is probably because
391 * one or more devices/filesystems have been unmounted.
392 * We display 0.0 in this case though we should rather tell
393 * the user that the value cannot be calculated here.
396 sic->dk_drive < sip->dk_drive ? 0.0 :
397 S_VALUE(sip->dk_drive, sic->dk_drive, itv),
398 sic->dk_drive_rio < sip->dk_drive_rio ? 0.0 :
399 S_VALUE(sip->dk_drive_rio, sic->dk_drive_rio, itv),
400 sic->dk_drive_wio < sip->dk_drive_wio ? 0.0 :
401 S_VALUE(sip->dk_drive_wio, sic->dk_drive_wio, itv),
402 sic->dk_drive_rblk < sip->dk_drive_rblk ? 0.0 :
403 S_VALUE(sip->dk_drive_rblk, sic->dk_drive_rblk, itv),
404 sic->dk_drive_wblk < sip->dk_drive_wblk ? 0.0 :
405 S_VALUE(sip->dk_drive_wblk, sic->dk_drive_wblk, itv));
410 ***************************************************************************
411 * Display memory and swap statistics. This function is used to
412 * display instantaneous and average statistics.
415 * @a Activity structure with statistics.
416 * @prev Index in array where stats used as reference are.
417 * @curr Index in array for current sample statistics.
418 * @itv Interval of time in jiffies.
419 * @dispavg TRUE if displaying average statistics.
420 ***************************************************************************
422 void stub_print_memory_stats(struct activity *a, int prev, int curr,
423 unsigned long long itv, int dispavg)
426 *smc = (struct stats_memory *) a->buf[curr],
427 *smp = (struct stats_memory *) a->buf[prev];
428 static unsigned long long
441 static unsigned long long
446 if (DISPLAY_MEMORY(a->opt_flags)) {
448 printf("\n%-11s frmpg/s bufpg/s campg/s\n",
452 printf("%-11s", timestamp[curr]);
454 S_VALUE((double) KB_TO_PG(smp->frmkb), (double) KB_TO_PG(smc->frmkb), itv),
455 S_VALUE((double) KB_TO_PG(smp->bufkb), (double) KB_TO_PG(smc->bufkb), itv),
456 S_VALUE((double) KB_TO_PG(smp->camkb), (double) KB_TO_PG(smc->camkb), itv));
460 if (DISPLAY_MEM_AMT(a->opt_flags)) {
462 printf("\n%-11s kbmemfree kbmemused %%memused kbbuffers kbcached"
463 " kbcommit %%commit kbactive kbinact kbdirty", timestamp[!curr]);
464 if (DISPLAY_MEM_ALL(a->opt_flags)) {
465 printf(" kbanonpg kbslab kbkstack kbpgtbl kbvmused");
471 /* Display instantaneous values */
472 printf("%-11s", timestamp[curr]);
474 (unsigned long long) smc->frmkb,
475 (unsigned long long) (smc->tlmkb - smc->frmkb));
478 SP_VALUE(smc->frmkb, smc->tlmkb, smc->tlmkb)
481 (unsigned long long) smc->bufkb,
482 (unsigned long long) smc->camkb,
483 (unsigned long long) smc->comkb);
485 (smc->tlmkb + smc->tlskb) ?
486 SP_VALUE(0, smc->comkb, smc->tlmkb + smc->tlskb)
489 (unsigned long long) smc->activekb,
490 (unsigned long long) smc->inactkb,
491 (unsigned long long) smc->dirtykb);
493 if (DISPLAY_MEM_ALL(a->opt_flags)) {
494 /* Display extended memory statistics */
496 (unsigned long long) smc->anonpgkb,
497 (unsigned long long) smc->slabkb,
498 (unsigned long long) smc->kstackkb,
499 (unsigned long long) smc->pgtblkb,
500 (unsigned long long) smc->vmusedkb);
506 * Will be used to compute the average.
507 * We assume that the total amount of memory installed can not vary
508 * during the interval given on the command line.
510 avg_frmkb += smc->frmkb;
511 avg_bufkb += smc->bufkb;
512 avg_camkb += smc->camkb;
513 avg_comkb += smc->comkb;
514 avg_activekb += smc->activekb;
515 avg_inactkb += smc->inactkb;
516 avg_dirtykb += smc->dirtykb;
517 avg_anonpgkb += smc->anonpgkb;
518 avg_slabkb += smc->slabkb;
519 avg_kstackkb += smc->kstackkb;
520 avg_pgtblkb += smc->pgtblkb;
521 avg_vmusedkb += smc->vmusedkb;
524 /* Display average values */
525 printf("%-11s", timestamp[curr]);
527 (double) avg_frmkb / avg_count,
528 (double) smc->tlmkb - ((double) avg_frmkb / avg_count));
531 SP_VALUE((double) (avg_frmkb / avg_count), smc->tlmkb, smc->tlmkb)
534 (double) avg_bufkb / avg_count,
535 (double) avg_camkb / avg_count,
536 (double) avg_comkb / avg_count);
538 (smc->tlmkb + smc->tlskb) ?
539 SP_VALUE(0.0, (double) (avg_comkb / avg_count), smc->tlmkb + smc->tlskb)
542 (double) avg_activekb / avg_count,
543 (double) avg_inactkb / avg_count,
544 (double) avg_dirtykb / avg_count);
546 if (DISPLAY_MEM_ALL(a->opt_flags)) {
548 (double) avg_anonpgkb / avg_count,
549 (double) avg_slabkb / avg_count,
550 (double) avg_kstackkb / avg_count,
551 (double) avg_pgtblkb / avg_count,
552 (double) avg_vmusedkb / avg_count);
557 /* Reset average counters */
558 avg_frmkb = avg_bufkb = avg_camkb = avg_comkb = 0;
559 avg_activekb = avg_inactkb = avg_dirtykb = 0;
560 avg_anonpgkb = avg_slabkb = avg_kstackkb = 0;
561 avg_pgtblkb = avg_vmusedkb = 0;
565 if (DISPLAY_SWAP(a->opt_flags)) {
567 printf("\n%-11s kbswpfree kbswpused %%swpused kbswpcad %%swpcad\n",
572 /* Display instantaneous values */
573 printf("%-11s", timestamp[curr]);
575 (unsigned long long) smc->frskb,
576 (unsigned long long) (smc->tlskb - smc->frskb));
579 SP_VALUE(smc->frskb, smc->tlskb, smc->tlskb)
582 (unsigned long long) smc->caskb);
584 (smc->tlskb - smc->frskb) ?
585 SP_VALUE(0, smc->caskb, smc->tlskb - smc->frskb)
591 * Will be used to compute the average.
592 * We assume that the total amount of swap space may vary.
594 avg_frskb += smc->frskb;
595 avg_tlskb += smc->tlskb;
596 avg_caskb += smc->caskb;
599 /* Display average values */
600 printf("%-11s", timestamp[curr]);
602 (double) avg_frskb / avg_count,
603 ((double) avg_tlskb / avg_count) -
604 ((double) avg_frskb / avg_count));
607 SP_VALUE((double) avg_frskb / avg_count,
608 (double) avg_tlskb / avg_count,
609 (double) avg_tlskb / avg_count)
612 (double) avg_caskb / avg_count);
614 (avg_tlskb != avg_frskb) ?
615 SP_VALUE(0.0, (double) avg_caskb / avg_count,
616 ((double) avg_tlskb / avg_count) -
617 ((double) avg_frskb / avg_count))
621 /* Reset average counters */
622 avg_frskb = avg_tlskb = avg_caskb = 0;
628 ***************************************************************************
629 * Display memory and swap statistics.
632 * @a Activity structure with statistics.
633 * @prev Index in array where stats used as reference are.
634 * @curr Index in array for current sample statistics.
635 * @itv Interval of time in jiffies.
636 ***************************************************************************
638 __print_funct_t print_memory_stats(struct activity *a, int prev, int curr,
639 unsigned long long itv)
641 stub_print_memory_stats(a, prev, curr, itv, FALSE);
645 ***************************************************************************
646 * Display average memory statistics.
649 * @a Activity structure with statistics.
650 * @prev Index in array where stats used as reference are.
651 * @curr Index in array for current sample statistics.
652 * @itv Interval of time in jiffies.
653 ***************************************************************************
655 __print_funct_t print_avg_memory_stats(struct activity *a, int prev, int curr,
656 unsigned long long itv)
658 stub_print_memory_stats(a, prev, curr, itv, TRUE);
662 ***************************************************************************
663 * Display kernel tables statistics. This function is used to display
664 * instantaneous and average statistics.
667 * @a Activity structure with statistics.
668 * @curr Index in array for current sample statistics.
669 * @dispavg True if displaying average statistics.
670 ***************************************************************************
672 void stub_print_ktables_stats(struct activity *a, int curr, int dispavg)
675 *skc = (struct stats_ktables *) a->buf[curr];
676 static unsigned long long
684 printf("\n%-11s dentunusd file-nr inode-nr pty-nr\n",
689 /* Display instantaneous values */
690 printf("%-11s", timestamp[curr]);
692 (unsigned long long) skc->dentry_stat,
693 (unsigned long long) skc->file_used,
694 (unsigned long long) skc->inode_used,
695 (unsigned long long) skc->pty_nr);
699 * Will be used to compute the average.
700 * Note: Overflow unlikely to happen but not impossible...
702 avg_dentry_stat += skc->dentry_stat;
703 avg_file_used += skc->file_used;
704 avg_inode_used += skc->inode_used;
705 avg_pty_nr += skc->pty_nr;
708 /* Display average values */
709 printf("%-11s", timestamp[curr]);
711 (double) avg_dentry_stat / avg_count,
712 (double) avg_file_used / avg_count,
713 (double) avg_inode_used / avg_count,
714 (double) avg_pty_nr / avg_count);
717 /* Reset average counters */
718 avg_dentry_stat = avg_file_used = avg_inode_used = avg_pty_nr = 0;
723 ***************************************************************************
724 * Display kernel tables statistics.
727 * @a Activity structure with statistics.
728 * @prev Index in array where stats used as reference are.
729 * @curr Index in array for current sample statistics.
730 * @itv Interval of time in jiffies.
731 ***************************************************************************
733 __print_funct_t print_ktables_stats(struct activity *a, int prev, int curr,
734 unsigned long long itv)
736 stub_print_ktables_stats(a, curr, FALSE);
740 ***************************************************************************
741 * Display average kernel tables statistics.
744 * @a Activity structure with statistics.
745 * @prev Index in array where stats used as reference are.
746 * @curr Index in array for current sample statistics.
747 * @itv Interval of time in jiffies.
748 ***************************************************************************
750 __print_funct_t print_avg_ktables_stats(struct activity *a, int prev, int curr,
751 unsigned long long itv)
753 stub_print_ktables_stats(a, curr, TRUE);
757 ***************************************************************************
758 * Display queue and load statistics. This function is used to display
759 * instantaneous and average statistics.
762 * @a Activity structure with statistics.
763 * @curr Index in array for current sample statistics.
764 * @dispavg TRUE if displaying average statistics.
765 ***************************************************************************
767 void stub_print_queue_stats(struct activity *a, int curr, int dispavg)
770 *sqc = (struct stats_queue *) a->buf[curr];
771 static unsigned long long
777 avg_procs_blocked = 0;
780 printf("\n%-11s runq-sz plist-sz ldavg-1 ldavg-5 ldavg-15 blocked\n",
785 /* Display instantaneous values */
786 printf("%-11s", timestamp[curr]);
788 (unsigned long long) sqc->nr_running,
789 (unsigned long long) sqc->nr_threads);
791 (double) sqc->load_avg_1 / 100,
792 (double) sqc->load_avg_5 / 100,
793 (double) sqc->load_avg_15 / 100);
795 (unsigned long long) sqc->procs_blocked);
798 /* Will be used to compute the average */
799 avg_nr_running += sqc->nr_running;
800 avg_nr_threads += sqc->nr_threads;
801 avg_load_avg_1 += sqc->load_avg_1;
802 avg_load_avg_5 += sqc->load_avg_5;
803 avg_load_avg_15 += sqc->load_avg_15;
804 avg_procs_blocked += sqc->procs_blocked;
807 /* Display average values */
808 printf("%-11s", timestamp[curr]);
810 (double) avg_nr_running / avg_count,
811 (double) avg_nr_threads / avg_count);
813 (double) avg_load_avg_1 / (avg_count * 100),
814 (double) avg_load_avg_5 / (avg_count * 100),
815 (double) avg_load_avg_15 / (avg_count * 100));
817 (double) avg_procs_blocked / avg_count);
820 /* Reset average counters */
821 avg_nr_running = avg_nr_threads = 0;
822 avg_load_avg_1 = avg_load_avg_5 = avg_load_avg_15 = 0;
823 avg_procs_blocked = 0;
828 ***************************************************************************
829 * Display queue and load statistics.
832 * @a Activity structure with statistics.
833 * @prev Index in array where stats used as reference are.
834 * @curr Index in array for current sample statistics.
835 * @itv Interval of time in jiffies.
836 ***************************************************************************
838 __print_funct_t print_queue_stats(struct activity *a, int prev, int curr,
839 unsigned long long itv)
841 stub_print_queue_stats(a, curr, FALSE);
845 ***************************************************************************
846 * Display average queue and load statistics.
849 * @a Activity structure with statistics.
850 * @prev Index in array where stats used as reference are.
851 * @curr Index in array for current sample statistics.
852 * @itv Interval of time in jiffies.
853 ***************************************************************************
855 __print_funct_t print_avg_queue_stats(struct activity *a, int prev, int curr,
856 unsigned long long itv)
858 stub_print_queue_stats(a, curr, TRUE);
862 ***************************************************************************
863 * Display serial lines statistics.
866 * @a Activity structure with statistics.
867 * @prev Index in array where stats used as reference are.
868 * @curr Index in array for current sample statistics.
869 * @itv Interval of time in jiffies.
870 ***************************************************************************
872 __print_funct_t print_serial_stats(struct activity *a, int prev, int curr,
873 unsigned long long itv)
876 struct stats_serial *ssc, *ssp;
879 printf("\n%-11s TTY rcvin/s xmtin/s framerr/s prtyerr/s"
880 " brk/s ovrun/s\n", timestamp[!curr]);
883 for (i = 0; i < a->nr; i++) {
885 ssc = (struct stats_serial *) ((char *) a->buf[curr] + i * a->msize);
886 ssp = (struct stats_serial *) ((char *) a->buf[prev] + i * a->msize);
891 printf("%-11s", timestamp[curr]);
892 cprintf_in(IS_INT, " %3d", "", ssc->line - 1);
894 if ((ssc->line == ssp->line) || WANT_SINCE_BOOT(flags)) {
896 S_VALUE(ssp->rx, ssc->rx, itv),
897 S_VALUE(ssp->tx, ssc->tx, itv),
898 S_VALUE(ssp->frame, ssc->frame, itv),
899 S_VALUE(ssp->parity, ssc->parity, itv),
900 S_VALUE(ssp->brk, ssc->brk, itv),
901 S_VALUE(ssp->overrun, ssc->overrun, itv));
905 printf(" N/A N/A N/A N/A"
912 ***************************************************************************
913 * Display disks statistics.
916 * @a Activity structure with statistics.
917 * @prev Index in array where stats used as reference are.
918 * @curr Index in array for current sample statistics.
919 * @itv Interval of time in jiffies.
920 ***************************************************************************
922 __print_funct_t print_disk_stats(struct activity *a, int prev, int curr,
923 unsigned long long itv)
926 struct stats_disk *sdc, *sdp;
927 struct ext_disk_stats xds;
928 char *dev_name, *persist_dev_name;
931 printf("\n%-11s DEV tps rd_sec/s wr_sec/s avgrq-sz"
932 " avgqu-sz await svctm %%util\n",
936 for (i = 0; i < a->nr; i++) {
938 sdc = (struct stats_disk *) ((char *) a->buf[curr] + i * a->msize);
940 if (!(sdc->major + sdc->minor))
943 j = check_disk_reg(a, curr, prev, i);
944 sdp = (struct stats_disk *) ((char *) a->buf[prev] + j * a->msize);
946 /* Compute service time, etc. */
947 compute_ext_disk_stats(sdc, sdp, itv, &xds);
950 persist_dev_name = NULL;
952 if (DISPLAY_PERSIST_NAME_S(flags)) {
953 persist_dev_name = get_persistent_name_from_pretty(get_devname(sdc->major, sdc->minor, TRUE));
956 if (persist_dev_name) {
957 dev_name = persist_dev_name;
960 if ((USE_PRETTY_OPTION(flags)) && (sdc->major == dm_major)) {
961 dev_name = transform_devmapname(sdc->major, sdc->minor);
965 dev_name = get_devname(sdc->major, sdc->minor,
966 USE_PRETTY_OPTION(flags));
970 printf("%-11s", timestamp[curr]);
972 cprintf_in(IS_STR, " %9s", dev_name, 0);
974 S_VALUE(sdp->nr_ios, sdc->nr_ios, itv),
975 S_VALUE(sdp->rd_sect, sdc->rd_sect, itv),
976 S_VALUE(sdp->wr_sect, sdc->wr_sect, itv),
977 /* See iostat for explanations */
979 S_VALUE(sdp->rq_ticks, sdc->rq_ticks, itv) / 1000.0,
989 ***************************************************************************
990 * Display network interfaces statistics.
993 * @a Activity structure with statistics.
994 * @prev Index in array where stats used as reference are.
995 * @curr Index in array for current sample statistics.
996 * @itv Interval of time in jiffies.
997 ***************************************************************************
999 __print_funct_t print_net_dev_stats(struct activity *a, int prev, int curr,
1000 unsigned long long itv)
1003 struct stats_net_dev *sndc, *sndp;
1004 double rxkb, txkb, ifutil;
1007 printf("\n%-11s IFACE rxpck/s txpck/s rxkB/s txkB/s"
1008 " rxcmp/s txcmp/s rxmcst/s %%ifutil\n", timestamp[!curr]);
1011 for (i = 0; i < a->nr; i++) {
1013 sndc = (struct stats_net_dev *) ((char *) a->buf[curr] + i * a->msize);
1015 if (!strcmp(sndc->interface, ""))
1018 j = check_net_dev_reg(a, curr, prev, i);
1019 sndp = (struct stats_net_dev *) ((char *) a->buf[prev] + j * a->msize);
1021 printf("%-11s", timestamp[curr]);
1022 cprintf_in(IS_STR, " %9s", sndc->interface, 0);
1024 rxkb = S_VALUE(sndp->rx_bytes, sndc->rx_bytes, itv);
1025 txkb = S_VALUE(sndp->tx_bytes, sndc->tx_bytes, itv);
1028 S_VALUE(sndp->rx_packets, sndc->rx_packets, itv),
1029 S_VALUE(sndp->tx_packets, sndc->tx_packets, itv),
1032 S_VALUE(sndp->rx_compressed, sndc->rx_compressed, itv),
1033 S_VALUE(sndp->tx_compressed, sndc->tx_compressed, itv),
1034 S_VALUE(sndp->multicast, sndc->multicast, itv));
1035 ifutil = compute_ifutil(sndc, rxkb, txkb);
1036 cprintf_pc(1, 9, 2, ifutil);
1042 ***************************************************************************
1043 * Display network interface errors statistics.
1046 * @a Activity structure with statistics.
1047 * @prev Index in array where stats used as reference are.
1048 * @curr Index in array for current sample statistics.
1049 * @itv Interval of time in jiffies.
1050 ***************************************************************************
1052 __print_funct_t print_net_edev_stats(struct activity *a, int prev, int curr,
1053 unsigned long long itv)
1056 struct stats_net_edev *snedc, *snedp;
1059 printf("\n%-11s IFACE rxerr/s txerr/s coll/s rxdrop/s"
1060 " txdrop/s txcarr/s rxfram/s rxfifo/s txfifo/s\n",
1064 for (i = 0; i < a->nr; i++) {
1066 snedc = (struct stats_net_edev *) ((char *) a->buf[curr] + i * a->msize);
1068 if (!strcmp(snedc->interface, ""))
1071 j = check_net_edev_reg(a, curr, prev, i);
1072 snedp = (struct stats_net_edev *) ((char *) a->buf[prev] + j * a->msize);
1074 printf("%-11s", timestamp[curr]);
1075 cprintf_in(IS_STR, " %9s", snedc->interface, 0);
1078 S_VALUE(snedp->rx_errors, snedc->rx_errors, itv),
1079 S_VALUE(snedp->tx_errors, snedc->tx_errors, itv),
1080 S_VALUE(snedp->collisions, snedc->collisions, itv),
1081 S_VALUE(snedp->rx_dropped, snedc->rx_dropped, itv),
1082 S_VALUE(snedp->tx_dropped, snedc->tx_dropped, itv),
1083 S_VALUE(snedp->tx_carrier_errors, snedc->tx_carrier_errors, itv),
1084 S_VALUE(snedp->rx_frame_errors, snedc->rx_frame_errors, itv),
1085 S_VALUE(snedp->rx_fifo_errors, snedc->rx_fifo_errors, itv),
1086 S_VALUE(snedp->tx_fifo_errors, snedc->tx_fifo_errors, itv));
1092 ***************************************************************************
1093 * Display NFS client statistics.
1096 * @a Activity structure with statistics.
1097 * @prev Index in array where stats used as reference are.
1098 * @curr Index in array for current sample statistics.
1099 * @itv Interval of time in jiffies.
1100 ***************************************************************************
1102 __print_funct_t print_net_nfs_stats(struct activity *a, int prev, int curr,
1103 unsigned long long itv)
1105 struct stats_net_nfs
1106 *snnc = (struct stats_net_nfs *) a->buf[curr],
1107 *snnp = (struct stats_net_nfs *) a->buf[prev];
1110 printf("\n%-11s call/s retrans/s read/s write/s access/s"
1111 " getatt/s\n", timestamp[!curr]);
1114 printf("%-11s", timestamp[curr]);
1116 S_VALUE(snnp->nfs_rpccnt, snnc->nfs_rpccnt, itv),
1117 S_VALUE(snnp->nfs_rpcretrans, snnc->nfs_rpcretrans, itv),
1118 S_VALUE(snnp->nfs_readcnt, snnc->nfs_readcnt, itv),
1119 S_VALUE(snnp->nfs_writecnt, snnc->nfs_writecnt, itv),
1120 S_VALUE(snnp->nfs_accesscnt, snnc->nfs_accesscnt, itv),
1121 S_VALUE(snnp->nfs_getattcnt, snnc->nfs_getattcnt, itv));
1126 ***************************************************************************
1127 * Display NFS server statistics.
1130 * @a Activity structure with statistics.
1131 * @prev Index in array where stats used as reference are.
1132 * @curr Index in array for current sample statistics.
1133 * @itv Interval of time in jiffies.
1134 ***************************************************************************
1136 __print_funct_t print_net_nfsd_stats(struct activity *a, int prev, int curr,
1137 unsigned long long itv)
1139 struct stats_net_nfsd
1140 *snndc = (struct stats_net_nfsd *) a->buf[curr],
1141 *snndp = (struct stats_net_nfsd *) a->buf[prev];
1144 printf("\n%-11s scall/s badcall/s packet/s udp/s tcp/s "
1145 "hit/s miss/s sread/s swrite/s saccess/s sgetatt/s\n",
1149 printf("%-11s", timestamp[curr]);
1151 S_VALUE(snndp->nfsd_rpccnt, snndc->nfsd_rpccnt, itv),
1152 S_VALUE(snndp->nfsd_rpcbad, snndc->nfsd_rpcbad, itv),
1153 S_VALUE(snndp->nfsd_netcnt, snndc->nfsd_netcnt, itv),
1154 S_VALUE(snndp->nfsd_netudpcnt, snndc->nfsd_netudpcnt, itv),
1155 S_VALUE(snndp->nfsd_nettcpcnt, snndc->nfsd_nettcpcnt, itv),
1156 S_VALUE(snndp->nfsd_rchits, snndc->nfsd_rchits, itv),
1157 S_VALUE(snndp->nfsd_rcmisses, snndc->nfsd_rcmisses, itv),
1158 S_VALUE(snndp->nfsd_readcnt, snndc->nfsd_readcnt, itv),
1159 S_VALUE(snndp->nfsd_writecnt, snndc->nfsd_writecnt, itv),
1160 S_VALUE(snndp->nfsd_accesscnt, snndc->nfsd_accesscnt, itv),
1161 S_VALUE(snndp->nfsd_getattcnt, snndc->nfsd_getattcnt, itv));
1166 ***************************************************************************
1167 * Display network sockets statistics. This function is used to display
1168 * instantaneous and average statistics.
1171 * @a Activity structure with statistics.
1172 * @curr Index in array for current sample statistics.
1173 * @dispavg TRUE if displaying average statistics.
1174 ***************************************************************************
1176 void stub_print_net_sock_stats(struct activity *a, int curr, int dispavg)
1178 struct stats_net_sock
1179 *snsc = (struct stats_net_sock *) a->buf[curr];
1180 static unsigned long long
1189 printf("\n%-11s totsck tcpsck udpsck rawsck ip-frag tcp-tw\n",
1194 /* Display instantaneous values */
1195 printf("%-11s", timestamp[curr]);
1197 (unsigned long long) snsc->sock_inuse,
1198 (unsigned long long) snsc->tcp_inuse,
1199 (unsigned long long) snsc->udp_inuse,
1200 (unsigned long long) snsc->raw_inuse,
1201 (unsigned long long) snsc->frag_inuse,
1202 (unsigned long long) snsc->tcp_tw);
1205 /* Will be used to compute the average */
1206 avg_sock_inuse += snsc->sock_inuse;
1207 avg_tcp_inuse += snsc->tcp_inuse;
1208 avg_udp_inuse += snsc->udp_inuse;
1209 avg_raw_inuse += snsc->raw_inuse;
1210 avg_frag_inuse += snsc->frag_inuse;
1211 avg_tcp_tw += snsc->tcp_tw;
1214 /* Display average values */
1215 printf("%-11s", timestamp[curr]);
1217 (double) avg_sock_inuse / avg_count,
1218 (double) avg_tcp_inuse / avg_count,
1219 (double) avg_udp_inuse / avg_count,
1220 (double) avg_raw_inuse / avg_count,
1221 (double) avg_frag_inuse / avg_count,
1222 (double) avg_tcp_tw / avg_count);
1225 /* Reset average counters */
1226 avg_sock_inuse = avg_tcp_inuse = avg_udp_inuse = 0;
1227 avg_raw_inuse = avg_frag_inuse = avg_tcp_tw = 0;
1232 ***************************************************************************
1233 * Display network sockets statistics.
1236 * @a Activity structure with statistics.
1237 * @prev Index in array where stats used as reference are.
1238 * @curr Index in array for current sample statistics.
1239 * @itv Interval of time in jiffies.
1240 ***************************************************************************
1242 __print_funct_t print_net_sock_stats(struct activity *a, int prev, int curr,
1243 unsigned long long itv)
1245 stub_print_net_sock_stats(a, curr, FALSE);
1249 ***************************************************************************
1250 * Display average network sockets statistics.
1253 * @a Activity structure with statistics.
1254 * @prev Index in array where stats used as reference are.
1255 * @curr Index in array for current sample statistics.
1256 * @itv Interval of time in jiffies.
1257 ***************************************************************************
1259 __print_funct_t print_avg_net_sock_stats(struct activity *a, int prev, int curr,
1260 unsigned long long itv)
1262 stub_print_net_sock_stats(a, curr, TRUE);
1266 ***************************************************************************
1267 * Display IP network traffic statistics.
1270 * @a Activity structure with statistics.
1271 * @prev Index in array where stats used as reference are.
1272 * @curr Index in array for current sample statistics.
1273 * @itv Interval of time in jiffies.
1274 ***************************************************************************
1276 __print_funct_t print_net_ip_stats(struct activity *a, int prev, int curr,
1277 unsigned long long itv)
1280 *snic = (struct stats_net_ip *) a->buf[curr],
1281 *snip = (struct stats_net_ip *) a->buf[prev];
1284 printf("\n%-11s irec/s fwddgm/s idel/s orq/s asmrq/s"
1285 " asmok/s fragok/s fragcrt/s\n", timestamp[!curr]);
1288 printf("%-11s", timestamp[curr]);
1290 S_VALUE(snip->InReceives, snic->InReceives, itv),
1291 S_VALUE(snip->ForwDatagrams, snic->ForwDatagrams, itv),
1292 S_VALUE(snip->InDelivers, snic->InDelivers, itv),
1293 S_VALUE(snip->OutRequests, snic->OutRequests, itv),
1294 S_VALUE(snip->ReasmReqds, snic->ReasmReqds, itv),
1295 S_VALUE(snip->ReasmOKs, snic->ReasmOKs, itv),
1296 S_VALUE(snip->FragOKs, snic->FragOKs, itv),
1297 S_VALUE(snip->FragCreates, snic->FragCreates, itv));
1302 ***************************************************************************
1303 * Display IP network errors statistics.
1306 * @a Activity structure with statistics.
1307 * @prev Index in array where stats used as reference are.
1308 * @curr Index in array for current sample statistics.
1309 * @itv Interval of time in jiffies.
1310 ***************************************************************************
1312 __print_funct_t print_net_eip_stats(struct activity *a, int prev, int curr,
1313 unsigned long long itv)
1315 struct stats_net_eip
1316 *sneic = (struct stats_net_eip *) a->buf[curr],
1317 *sneip = (struct stats_net_eip *) a->buf[prev];
1320 printf("\n%-11s ihdrerr/s iadrerr/s iukwnpr/s idisc/s odisc/s"
1321 " onort/s asmf/s fragf/s\n", timestamp[!curr]);
1324 printf("%-11s", timestamp[curr]);
1326 S_VALUE(sneip->InHdrErrors, sneic->InHdrErrors, itv),
1327 S_VALUE(sneip->InAddrErrors, sneic->InAddrErrors, itv),
1328 S_VALUE(sneip->InUnknownProtos, sneic->InUnknownProtos, itv),
1329 S_VALUE(sneip->InDiscards, sneic->InDiscards, itv),
1330 S_VALUE(sneip->OutDiscards, sneic->OutDiscards, itv),
1331 S_VALUE(sneip->OutNoRoutes, sneic->OutNoRoutes, itv),
1332 S_VALUE(sneip->ReasmFails, sneic->ReasmFails, itv),
1333 S_VALUE(sneip->FragFails, sneic->FragFails, itv));
1338 ***************************************************************************
1339 * Display ICMP network traffic statistics.
1342 * @a Activity structure with statistics.
1343 * @prev Index in array where stats used as reference are.
1344 * @curr Index in array for current sample statistics.
1345 * @itv Interval of time in jiffies.
1346 ***************************************************************************
1348 __print_funct_t print_net_icmp_stats(struct activity *a, int prev, int curr,
1349 unsigned long long itv)
1351 struct stats_net_icmp
1352 *snic = (struct stats_net_icmp *) a->buf[curr],
1353 *snip = (struct stats_net_icmp *) a->buf[prev];
1356 printf("\n%-11s imsg/s omsg/s iech/s iechr/s oech/s"
1357 " oechr/s itm/s itmr/s otm/s otmr/s"
1358 " iadrmk/s iadrmkr/s oadrmk/s oadrmkr/s\n", timestamp[!curr]);
1361 printf("%-11s", timestamp[curr]);
1363 S_VALUE(snip->InMsgs, snic->InMsgs, itv),
1364 S_VALUE(snip->OutMsgs, snic->OutMsgs, itv),
1365 S_VALUE(snip->InEchos, snic->InEchos, itv),
1366 S_VALUE(snip->InEchoReps, snic->InEchoReps, itv),
1367 S_VALUE(snip->OutEchos, snic->OutEchos, itv),
1368 S_VALUE(snip->OutEchoReps, snic->OutEchoReps, itv),
1369 S_VALUE(snip->InTimestamps, snic->InTimestamps, itv),
1370 S_VALUE(snip->InTimestampReps, snic->InTimestampReps, itv),
1371 S_VALUE(snip->OutTimestamps, snic->OutTimestamps, itv),
1372 S_VALUE(snip->OutTimestampReps, snic->OutTimestampReps, itv),
1373 S_VALUE(snip->InAddrMasks, snic->InAddrMasks, itv),
1374 S_VALUE(snip->InAddrMaskReps, snic->InAddrMaskReps, itv),
1375 S_VALUE(snip->OutAddrMasks, snic->OutAddrMasks, itv),
1376 S_VALUE(snip->OutAddrMaskReps, snic->OutAddrMaskReps, itv));
1381 ***************************************************************************
1382 * Display ICMP network errors statistics.
1385 * @a Activity structure with statistics.
1386 * @prev Index in array where stats used as reference are.
1387 * @curr Index in array for current sample statistics.
1388 * @itv Interval of time in jiffies.
1389 ***************************************************************************
1391 __print_funct_t print_net_eicmp_stats(struct activity *a, int prev, int curr,
1392 unsigned long long itv)
1394 struct stats_net_eicmp
1395 *sneic = (struct stats_net_eicmp *) a->buf[curr],
1396 *sneip = (struct stats_net_eicmp *) a->buf[prev];
1399 printf("\n%-11s ierr/s oerr/s idstunr/s odstunr/s itmex/s"
1400 " otmex/s iparmpb/s oparmpb/s isrcq/s osrcq/s"
1401 " iredir/s oredir/s\n", timestamp[!curr]);
1404 printf("%-11s", timestamp[curr]);
1406 S_VALUE(sneip->InErrors, sneic->InErrors, itv),
1407 S_VALUE(sneip->OutErrors, sneic->OutErrors, itv),
1408 S_VALUE(sneip->InDestUnreachs, sneic->InDestUnreachs, itv),
1409 S_VALUE(sneip->OutDestUnreachs, sneic->OutDestUnreachs, itv),
1410 S_VALUE(sneip->InTimeExcds, sneic->InTimeExcds, itv),
1411 S_VALUE(sneip->OutTimeExcds, sneic->OutTimeExcds, itv),
1412 S_VALUE(sneip->InParmProbs, sneic->InParmProbs, itv),
1413 S_VALUE(sneip->OutParmProbs, sneic->OutParmProbs, itv),
1414 S_VALUE(sneip->InSrcQuenchs, sneic->InSrcQuenchs, itv),
1415 S_VALUE(sneip->OutSrcQuenchs, sneic->OutSrcQuenchs, itv),
1416 S_VALUE(sneip->InRedirects, sneic->InRedirects, itv),
1417 S_VALUE(sneip->OutRedirects, sneic->OutRedirects, itv));
1422 ***************************************************************************
1423 * Display TCP network traffic statistics.
1426 * @a Activity structure with statistics.
1427 * @prev Index in array where stats used as reference are.
1428 * @curr Index in array for current sample statistics.
1429 * @itv Interval of time in jiffies.
1430 ***************************************************************************
1432 __print_funct_t print_net_tcp_stats(struct activity *a, int prev, int curr,
1433 unsigned long long itv)
1435 struct stats_net_tcp
1436 *sntc = (struct stats_net_tcp *) a->buf[curr],
1437 *sntp = (struct stats_net_tcp *) a->buf[prev];
1440 printf("\n%-11s active/s passive/s iseg/s oseg/s\n",
1444 printf("%-11s", timestamp[curr]);
1446 S_VALUE(sntp->ActiveOpens, sntc->ActiveOpens, itv),
1447 S_VALUE(sntp->PassiveOpens, sntc->PassiveOpens, itv),
1448 S_VALUE(sntp->InSegs, sntc->InSegs, itv),
1449 S_VALUE(sntp->OutSegs, sntc->OutSegs, itv));
1454 ***************************************************************************
1455 * Display TCP network errors statistics.
1458 * @a Activity structure with statistics.
1459 * @prev Index in array where stats used as reference are.
1460 * @curr Index in array for current sample statistics.
1461 * @itv Interval of time in jiffies.
1462 ***************************************************************************
1464 __print_funct_t print_net_etcp_stats(struct activity *a, int prev, int curr,
1465 unsigned long long itv)
1467 struct stats_net_etcp
1468 *snetc = (struct stats_net_etcp *) a->buf[curr],
1469 *snetp = (struct stats_net_etcp *) a->buf[prev];
1472 printf("\n%-11s atmptf/s estres/s retrans/s isegerr/s orsts/s\n",
1476 printf("%-11s", timestamp[curr]);
1478 S_VALUE(snetp->AttemptFails, snetc->AttemptFails, itv),
1479 S_VALUE(snetp->EstabResets, snetc->EstabResets, itv),
1480 S_VALUE(snetp->RetransSegs, snetc->RetransSegs, itv),
1481 S_VALUE(snetp->InErrs, snetc->InErrs, itv),
1482 S_VALUE(snetp->OutRsts, snetc->OutRsts, itv));
1487 ***************************************************************************
1488 * Display UDP network traffic statistics.
1491 * @a Activity structure with statistics.
1492 * @prev Index in array where stats used as reference are.
1493 * @curr Index in array for current sample statistics.
1494 * @itv Interval of time in jiffies.
1495 ***************************************************************************
1497 __print_funct_t print_net_udp_stats(struct activity *a, int prev, int curr,
1498 unsigned long long itv)
1500 struct stats_net_udp
1501 *snuc = (struct stats_net_udp *) a->buf[curr],
1502 *snup = (struct stats_net_udp *) a->buf[prev];
1505 printf("\n%-11s idgm/s odgm/s noport/s idgmerr/s\n",
1509 printf("%-11s", timestamp[curr]);
1511 S_VALUE(snup->InDatagrams, snuc->InDatagrams, itv),
1512 S_VALUE(snup->OutDatagrams, snuc->OutDatagrams, itv),
1513 S_VALUE(snup->NoPorts, snuc->NoPorts, itv),
1514 S_VALUE(snup->InErrors, snuc->InErrors, itv));
1519 ***************************************************************************
1520 * Display IPv6 sockets statistics. This function is used to display
1521 * instantaneous and average statistics.
1524 * @a Activity structure with statistics.
1525 * @curr Index in array for current sample statistics.
1526 * @dispavg TRUE if displaying average statistics.
1527 ***************************************************************************
1529 void stub_print_net_sock6_stats(struct activity *a, int curr, int dispavg)
1531 struct stats_net_sock6
1532 *snsc = (struct stats_net_sock6 *) a->buf[curr];
1533 static unsigned long long
1537 avg_frag6_inuse = 0;
1540 printf("\n%-11s tcp6sck udp6sck raw6sck ip6-frag\n",
1545 /* Display instantaneous values */
1546 printf("%-11s", timestamp[curr]);
1548 (unsigned long long) snsc->tcp6_inuse,
1549 (unsigned long long) snsc->udp6_inuse,
1550 (unsigned long long) snsc->raw6_inuse,
1551 (unsigned long long) snsc->frag6_inuse);
1554 /* Will be used to compute the average */
1555 avg_tcp6_inuse += snsc->tcp6_inuse;
1556 avg_udp6_inuse += snsc->udp6_inuse;
1557 avg_raw6_inuse += snsc->raw6_inuse;
1558 avg_frag6_inuse += snsc->frag6_inuse;
1561 /* Display average values */
1562 printf("%-11s", timestamp[curr]);
1564 (double) avg_tcp6_inuse / avg_count,
1565 (double) avg_udp6_inuse / avg_count,
1566 (double) avg_raw6_inuse / avg_count,
1567 (double) avg_frag6_inuse / avg_count);
1570 /* Reset average counters */
1571 avg_tcp6_inuse = avg_udp6_inuse = avg_raw6_inuse = avg_frag6_inuse = 0;
1576 ***************************************************************************
1577 * Display IPv6 sockets statistics.
1580 * @a Activity structure with statistics.
1581 * @prev Index in array where stats used as reference are.
1582 * @curr Index in array for current sample statistics.
1583 * @itv Interval of time in jiffies.
1584 ***************************************************************************
1586 __print_funct_t print_net_sock6_stats(struct activity *a, int prev, int curr,
1587 unsigned long long itv)
1589 stub_print_net_sock6_stats(a, curr, FALSE);
1593 ***************************************************************************
1594 * Display average IPv6 sockets statistics.
1597 * @a Activity structure with statistics.
1598 * @prev Index in array where stats used as reference are.
1599 * @curr Index in array for current sample statistics.
1600 * @itv Interval of time in jiffies.
1601 ***************************************************************************
1603 __print_funct_t print_avg_net_sock6_stats(struct activity *a, int prev, int curr,
1604 unsigned long long itv)
1606 stub_print_net_sock6_stats(a, curr, TRUE);
1610 ***************************************************************************
1611 * Display IPv6 network traffic statistics.
1614 * @a Activity structure with statistics.
1615 * @prev Index in array where stats used as reference are.
1616 * @curr Index in array for current sample statistics.
1617 * @itv Interval of time in jiffies.
1618 ***************************************************************************
1620 __print_funct_t print_net_ip6_stats(struct activity *a, int prev, int curr,
1621 unsigned long long itv)
1623 struct stats_net_ip6
1624 *snic = (struct stats_net_ip6 *) a->buf[curr],
1625 *snip = (struct stats_net_ip6 *) a->buf[prev];
1628 printf("\n%-11s irec6/s fwddgm6/s idel6/s orq6/s asmrq6/s"
1629 " asmok6/s imcpck6/s omcpck6/s fragok6/s fragcr6/s\n",
1633 printf("%-11s", timestamp[curr]);
1635 S_VALUE(snip->InReceives6, snic->InReceives6, itv),
1636 S_VALUE(snip->OutForwDatagrams6, snic->OutForwDatagrams6, itv),
1637 S_VALUE(snip->InDelivers6, snic->InDelivers6, itv),
1638 S_VALUE(snip->OutRequests6, snic->OutRequests6, itv),
1639 S_VALUE(snip->ReasmReqds6, snic->ReasmReqds6, itv),
1640 S_VALUE(snip->ReasmOKs6, snic->ReasmOKs6, itv),
1641 S_VALUE(snip->InMcastPkts6, snic->InMcastPkts6, itv),
1642 S_VALUE(snip->OutMcastPkts6, snic->OutMcastPkts6, itv),
1643 S_VALUE(snip->FragOKs6, snic->FragOKs6, itv),
1644 S_VALUE(snip->FragCreates6, snic->FragCreates6, itv));
1649 ***************************************************************************
1650 * Display IPv6 network errors statistics.
1653 * @a Activity structure with statistics.
1654 * @prev Index in array where stats used as reference are.
1655 * @curr Index in array for current sample statistics.
1656 * @itv Interval of time in jiffies.
1657 ***************************************************************************
1659 __print_funct_t print_net_eip6_stats(struct activity *a, int prev, int curr,
1660 unsigned long long itv)
1662 struct stats_net_eip6
1663 *sneic = (struct stats_net_eip6 *) a->buf[curr],
1664 *sneip = (struct stats_net_eip6 *) a->buf[prev];
1667 printf("\n%-11s ihdrer6/s iadrer6/s iukwnp6/s i2big6/s idisc6/s odisc6/s"
1668 " inort6/s onort6/s asmf6/s fragf6/s itrpck6/s\n",
1672 printf("%-11s", timestamp[curr]);
1674 S_VALUE(sneip->InHdrErrors6, sneic->InHdrErrors6, itv),
1675 S_VALUE(sneip->InAddrErrors6, sneic->InAddrErrors6, itv),
1676 S_VALUE(sneip->InUnknownProtos6, sneic->InUnknownProtos6, itv),
1677 S_VALUE(sneip->InTooBigErrors6, sneic->InTooBigErrors6, itv),
1678 S_VALUE(sneip->InDiscards6, sneic->InDiscards6, itv),
1679 S_VALUE(sneip->OutDiscards6, sneic->OutDiscards6, itv),
1680 S_VALUE(sneip->InNoRoutes6, sneic->InNoRoutes6, itv),
1681 S_VALUE(sneip->OutNoRoutes6, sneic->OutNoRoutes6, itv),
1682 S_VALUE(sneip->ReasmFails6, sneic->ReasmFails6, itv),
1683 S_VALUE(sneip->FragFails6, sneic->FragFails6, itv),
1684 S_VALUE(sneip->InTruncatedPkts6, sneic->InTruncatedPkts6, itv));
1689 ***************************************************************************
1690 * Display ICMPv6 network traffic statistics.
1693 * @a Activity structure with statistics.
1694 * @prev Index in array where stats used as reference are.
1695 * @curr Index in array for current sample statistics.
1696 * @itv Interval of time in jiffies.
1697 ***************************************************************************
1699 __print_funct_t print_net_icmp6_stats(struct activity *a, int prev, int curr,
1700 unsigned long long itv)
1702 struct stats_net_icmp6
1703 *snic = (struct stats_net_icmp6 *) a->buf[curr],
1704 *snip = (struct stats_net_icmp6 *) a->buf[prev];
1707 printf("\n%-11s imsg6/s omsg6/s iech6/s iechr6/s oechr6/s"
1708 " igmbq6/s igmbr6/s ogmbr6/s igmbrd6/s ogmbrd6/s irtsol6/s ortsol6/s"
1709 " irtad6/s inbsol6/s onbsol6/s inbad6/s onbad6/s\n",
1713 printf("%-11s", timestamp[curr]);
1715 S_VALUE(snip->InMsgs6, snic->InMsgs6, itv),
1716 S_VALUE(snip->OutMsgs6, snic->OutMsgs6, itv),
1717 S_VALUE(snip->InEchos6, snic->InEchos6, itv),
1718 S_VALUE(snip->InEchoReplies6, snic->InEchoReplies6, itv),
1719 S_VALUE(snip->OutEchoReplies6, snic->OutEchoReplies6, itv),
1720 S_VALUE(snip->InGroupMembQueries6, snic->InGroupMembQueries6, itv),
1721 S_VALUE(snip->InGroupMembResponses6, snic->InGroupMembResponses6, itv),
1722 S_VALUE(snip->OutGroupMembResponses6, snic->OutGroupMembResponses6, itv),
1723 S_VALUE(snip->InGroupMembReductions6, snic->InGroupMembReductions6, itv),
1724 S_VALUE(snip->OutGroupMembReductions6, snic->OutGroupMembReductions6, itv),
1725 S_VALUE(snip->InRouterSolicits6, snic->InRouterSolicits6, itv),
1726 S_VALUE(snip->OutRouterSolicits6, snic->OutRouterSolicits6, itv),
1727 S_VALUE(snip->InRouterAdvertisements6, snic->InRouterAdvertisements6, itv),
1728 S_VALUE(snip->InNeighborSolicits6, snic->InNeighborSolicits6, itv),
1729 S_VALUE(snip->OutNeighborSolicits6, snic->OutNeighborSolicits6, itv),
1730 S_VALUE(snip->InNeighborAdvertisements6, snic->InNeighborAdvertisements6, itv),
1731 S_VALUE(snip->OutNeighborAdvertisements6, snic->OutNeighborAdvertisements6, itv));
1736 ***************************************************************************
1737 * Display ICMPv6 network errors statistics.
1740 * @a Activity structure with statistics.
1741 * @prev Index in array where stats used as reference are.
1742 * @curr Index in array for current sample statistics.
1743 * @itv Interval of time in jiffies.
1744 ***************************************************************************
1746 __print_funct_t print_net_eicmp6_stats(struct activity *a, int prev, int curr,
1747 unsigned long long itv)
1749 struct stats_net_eicmp6
1750 *sneic = (struct stats_net_eicmp6 *) a->buf[curr],
1751 *sneip = (struct stats_net_eicmp6 *) a->buf[prev];
1754 printf("\n%-11s ierr6/s idtunr6/s odtunr6/s itmex6/s otmex6/s"
1755 " iprmpb6/s oprmpb6/s iredir6/s oredir6/s ipck2b6/s opck2b6/s\n",
1759 printf("%-11s", timestamp[curr]);
1761 S_VALUE(sneip->InErrors6, sneic->InErrors6, itv),
1762 S_VALUE(sneip->InDestUnreachs6, sneic->InDestUnreachs6, itv),
1763 S_VALUE(sneip->OutDestUnreachs6, sneic->OutDestUnreachs6, itv),
1764 S_VALUE(sneip->InTimeExcds6, sneic->InTimeExcds6, itv),
1765 S_VALUE(sneip->OutTimeExcds6, sneic->OutTimeExcds6, itv),
1766 S_VALUE(sneip->InParmProblems6, sneic->InParmProblems6, itv),
1767 S_VALUE(sneip->OutParmProblems6, sneic->OutParmProblems6, itv),
1768 S_VALUE(sneip->InRedirects6, sneic->InRedirects6, itv),
1769 S_VALUE(sneip->OutRedirects6, sneic->OutRedirects6, itv),
1770 S_VALUE(sneip->InPktTooBigs6, sneic->InPktTooBigs6, itv),
1771 S_VALUE(sneip->OutPktTooBigs6, sneic->OutPktTooBigs6, itv));
1776 ***************************************************************************
1777 * Display UDPv6 network traffic statistics.
1780 * @a Activity structure with statistics.
1781 * @prev Index in array where stats used as reference are.
1782 * @curr Index in array for current sample statistics.
1783 * @itv Interval of time in jiffies.
1784 ***************************************************************************
1786 __print_funct_t print_net_udp6_stats(struct activity *a, int prev, int curr,
1787 unsigned long long itv)
1789 struct stats_net_udp6
1790 *snuc = (struct stats_net_udp6 *) a->buf[curr],
1791 *snup = (struct stats_net_udp6 *) a->buf[prev];
1794 printf("\n%-11s idgm6/s odgm6/s noport6/s idgmer6/s\n",
1798 printf("%-11s", timestamp[curr]);
1800 S_VALUE(snup->InDatagrams6, snuc->InDatagrams6, itv),
1801 S_VALUE(snup->OutDatagrams6, snuc->OutDatagrams6, itv),
1802 S_VALUE(snup->NoPorts6, snuc->NoPorts6, itv),
1803 S_VALUE(snup->InErrors6, snuc->InErrors6, itv));
1808 ***************************************************************************
1809 * Display CPU frequency statistics. This function is used to display
1810 * instantaneous and average statistics.
1813 * @a Activity structure with statistics.
1814 * @curr Index in array for current sample statistics.
1815 * @dispavg True if displaying average statistics.
1816 ***************************************************************************
1818 void stub_print_pwr_cpufreq_stats(struct activity *a, int curr, int dispavg)
1821 struct stats_pwr_cpufreq *spc;
1822 static unsigned long long
1823 *avg_cpufreq = NULL;
1826 /* Allocate array of CPU frequency */
1827 if ((avg_cpufreq = (unsigned long long *) malloc(sizeof(unsigned long long) * a->nr))
1832 memset(avg_cpufreq, 0, sizeof(unsigned long long) * a->nr);
1836 printf("\n%-11s CPU MHz\n",
1840 for (i = 0; (i < a->nr) && (i < a->bitmap->b_size + 1); i++) {
1843 * The size of a->buf[...] CPU structure may be different from the default
1844 * sizeof(struct stats_pwr_cpufreq) value if data have been read from a file!
1845 * That's why we don't use a syntax like:
1846 * spc = (struct stats_pwr_cpufreq *) a->buf[...] + i;
1848 spc = (struct stats_pwr_cpufreq *) ((char *) a->buf[curr] + i * a->msize);
1851 * Note: a->nr is in [1, NR_CPUS + 1].
1852 * Bitmap size is provided for (NR_CPUS + 1) CPUs.
1853 * Anyway, NR_CPUS may vary between the version of sysstat
1854 * used by sadc to create a file, and the version of sysstat
1855 * used by sar to read it...
1858 /* Should current CPU (including CPU "all") be displayed? */
1859 if (a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))) {
1861 /* Yes: Display it */
1862 printf("%-11s", timestamp[curr]);
1865 /* This is CPU "all" */
1866 cprintf_in(IS_STR, "%s", " all", 0);
1869 cprintf_in(IS_INT, " %3d", "", i - 1);
1873 /* Display instantaneous values */
1875 ((double) spc->cpufreq) / 100);
1878 * Will be used to compute the average.
1879 * Note: overflow unlikely to happen but not impossible...
1881 avg_cpufreq[i] += spc->cpufreq;
1884 /* Display average values */
1886 (double) avg_cpufreq[i] / (100 * avg_count));
1893 /* Array of CPU frequency no longer needed: Free it! */
1902 ***************************************************************************
1903 * Display CPU frequency statistics.
1906 * @a Activity structure with statistics.
1907 * @prev Index in array where stats used as reference are.
1908 * @curr Index in array for current sample statistics.
1909 * @itv Interval of time in jiffies.
1910 ***************************************************************************
1912 __print_funct_t print_pwr_cpufreq_stats(struct activity *a, int prev, int curr,
1913 unsigned long long itv)
1915 stub_print_pwr_cpufreq_stats(a, curr, FALSE);
1919 ***************************************************************************
1920 * Display average CPU frequency statistics.
1923 * @a Activity structure with statistics.
1924 * @prev Index in array where stats used as reference are.
1925 * @curr Index in array for current sample statistics.
1926 * @itv Interval of time in jiffies.
1927 ***************************************************************************
1929 __print_funct_t print_avg_pwr_cpufreq_stats(struct activity *a, int prev, int curr,
1930 unsigned long long itv)
1932 stub_print_pwr_cpufreq_stats(a, curr, TRUE);
1936 ***************************************************************************
1937 * Display fan statistics. This function is used to display
1938 * instantaneous and average statistics.
1941 * @a Activity structure with statistics.
1942 * @curr Index in array for current sample statistics.
1943 * @dispavg True if displaying average statistics.
1944 ***************************************************************************
1946 void stub_print_pwr_fan_stats(struct activity *a, int curr, int dispavg)
1950 struct stats_pwr_fan *spc;
1951 static double *avg_fan = NULL;
1952 static double *avg_fan_min = NULL;
1954 /* Allocate arrays of fan RPMs */
1956 if ((avg_fan = (double *) malloc(sizeof(double) * a->nr)) == NULL) {
1960 memset(avg_fan, 0, sizeof(double) * a->nr);
1963 if ((avg_fan_min = (double *) malloc(sizeof(double) * a->nr)) == NULL) {
1967 memset(avg_fan_min, 0, sizeof(double) * a->nr);
1971 printf("\n%-11s FAN rpm drpm %*s\n",
1972 timestamp[!curr], MAX_SENSORS_DEV_LEN, "DEVICE");
1975 for (i = 0; i < a->nr; i++) {
1976 spc = (struct stats_pwr_fan *) ((char *) a->buf[curr] + i * a->msize);
1978 printf("%-11s", timestamp[curr]);
1979 cprintf_in(IS_INT, " %3d", "", i + 1);
1982 /* Display average values */
1984 (double) avg_fan[i] / avg_count,
1985 (double) (avg_fan[i] - avg_fan_min[i]) / avg_count);
1988 /* Display instantaneous values */
1991 spc->rpm - spc->rpm_min);
1992 avg_fan[i] += spc->rpm;
1993 avg_fan_min[i] += spc->rpm_min;
1996 snprintf(fmt, 16, " %%%ds\n", MAX_SENSORS_DEV_LEN);
1997 cprintf_in(IS_STR, fmt, spc->device, 0);
2013 ***************************************************************************
2014 * Display fan statistics.
2017 * @a Activity structure with statistics.
2018 * @prev Index in array where stats used as reference are.
2019 * @curr Index in array for current sample statistics.
2020 * @itv Interval of time in jiffies.
2021 ***************************************************************************
2023 __print_funct_t print_pwr_fan_stats(struct activity *a, int prev, int curr,
2024 unsigned long long itv)
2026 stub_print_pwr_fan_stats(a, curr, FALSE);
2030 ***************************************************************************
2031 * Display average fan statistics.
2034 * @a Activity structure with statistics.
2035 * @prev Index in array where stats used as reference are.
2036 * @curr Index in array for current sample statistics.
2037 * @itv Interval of time in jiffies.
2038 ***************************************************************************
2040 __print_funct_t print_avg_pwr_fan_stats(struct activity *a, int prev, int curr,
2041 unsigned long long itv)
2043 stub_print_pwr_fan_stats(a, curr, TRUE);
2047 ***************************************************************************
2048 * Display device temperature statistics. This function is used to display
2049 * instantaneous and average statistics.
2052 * @a Activity structure with statistics.
2053 * @curr Index in array for current sample statistics.
2054 * @dispavg True if displaying average statistics.
2055 ***************************************************************************
2057 void stub_print_pwr_temp_stats(struct activity *a, int curr, int dispavg)
2061 struct stats_pwr_temp *spc;
2062 static double *avg_temp = NULL;
2063 static double *avg_temp_min = NULL, *avg_temp_max = NULL;
2065 /* Allocate arrays of temperatures */
2067 if ((avg_temp = (double *) malloc(sizeof(double) * a->nr)) == NULL) {
2071 memset(avg_temp, 0, sizeof(double) * a->nr);
2073 if (!avg_temp_min) {
2074 if ((avg_temp_min = (double *) malloc(sizeof(double) * a->nr)) == NULL) {
2078 memset(avg_temp_min, 0, sizeof(double) * a->nr);
2080 if (!avg_temp_max) {
2081 if ((avg_temp_max = (double *) malloc(sizeof(double) * a->nr)) == NULL) {
2085 memset(avg_temp_max, 0, sizeof(double) * a->nr);
2089 printf("\n%-11s TEMP degC %%temp %*s\n",
2090 timestamp[!curr], MAX_SENSORS_DEV_LEN, "DEVICE");
2093 for (i = 0; i < a->nr; i++) {
2094 spc = (struct stats_pwr_temp *) ((char *) a->buf[curr] + i * a->msize);
2096 printf("%-11s", timestamp[curr]);
2097 cprintf_in(IS_INT, " %3d", "", i + 1);
2100 /* Display average values */
2101 cprintf_f(1, 9, 2, (double) avg_temp[i] / avg_count);
2103 (avg_temp_max[i] - avg_temp_min[i]) ?
2104 ((double) (avg_temp[i] / avg_count) - avg_temp_min[i]) / (avg_temp_max[i] - avg_temp_min[i]) * 100
2108 /* Display instantaneous values */
2109 cprintf_f(1, 9, 2, spc->temp);
2111 (spc->temp_max - spc->temp_min) ?
2112 (spc->temp - spc->temp_min) / (spc->temp_max - spc->temp_min) * 100
2114 avg_temp[i] += spc->temp;
2115 /* Assume that min and max temperatures cannot vary */
2116 avg_temp_min[i] = spc->temp_min;
2117 avg_temp_max[i] = spc->temp_max;
2120 snprintf(fmt, 16, " %%%ds\n", MAX_SENSORS_DEV_LEN);
2121 cprintf_in(IS_STR, fmt, spc->device, 0);
2131 avg_temp_min = NULL;
2135 avg_temp_max = NULL;
2141 ***************************************************************************
2142 * Display temperature statistics.
2145 * @a Activity structure with statistics.
2146 * @prev Index in array where stats used as reference are.
2147 * @curr Index in array for current sample statistics.
2148 * @itv Interval of time in jiffies.
2149 ***************************************************************************
2151 __print_funct_t print_pwr_temp_stats(struct activity *a, int prev, int curr,
2152 unsigned long long itv)
2154 stub_print_pwr_temp_stats(a, curr, FALSE);
2158 ***************************************************************************
2159 * Display average temperature statistics.
2162 * @a Activity structure with statistics.
2163 * @prev Index in array where stats used as reference are.
2164 * @curr Index in array for current sample statistics.
2165 * @itv Interval of time in jiffies.
2166 ***************************************************************************
2168 __print_funct_t print_avg_pwr_temp_stats(struct activity *a, int prev, int curr,
2169 unsigned long long itv)
2171 stub_print_pwr_temp_stats(a, curr, TRUE);
2175 ***************************************************************************
2176 * Display voltage inputs statistics. This function is used to display
2177 * instantaneous and average statistics.
2180 * @a Activity structure with statistics.
2181 * @curr Index in array for current sample statistics.
2182 * @dispavg True if displaying average statistics.
2183 ***************************************************************************
2185 void stub_print_pwr_in_stats(struct activity *a, int curr, int dispavg)
2189 struct stats_pwr_in *spc;
2190 static double *avg_in = NULL;
2191 static double *avg_in_min = NULL, *avg_in_max = NULL;
2193 /* Allocate arrays of voltage inputs */
2195 if ((avg_in = (double *) malloc(sizeof(double) * a->nr)) == NULL) {
2199 memset(avg_in, 0, sizeof(double) * a->nr);
2202 if ((avg_in_min = (double *) malloc(sizeof(double) * a->nr)) == NULL) {
2206 memset(avg_in_min, 0, sizeof(double) * a->nr);
2209 if ((avg_in_max = (double *) malloc(sizeof(double) * a->nr)) == NULL) {
2213 memset(avg_in_max, 0, sizeof(double) * a->nr);
2217 printf("\n%-11s IN inV %%in %*s\n",
2218 timestamp[!curr], MAX_SENSORS_DEV_LEN, "DEVICE");
2221 for (i = 0; i < a->nr; i++) {
2222 spc = (struct stats_pwr_in *) ((char *) a->buf[curr] + i * a->msize);
2224 printf("%-11s", timestamp[curr]);
2225 cprintf_in(IS_INT, " %3d", "", i);
2228 /* Display average values */
2229 cprintf_f(1, 9, 2, (double) avg_in[i] / avg_count);
2231 (avg_in_max[i] - avg_in_min[i]) ?
2232 ((double) (avg_in[i] / avg_count) - avg_in_min[i]) / (avg_in_max[i] - avg_in_min[i]) * 100
2236 /* Display instantaneous values */
2237 cprintf_f(1, 9, 2, spc->in);
2239 (spc->in_max - spc->in_min) ?
2240 (spc->in - spc->in_min) / (spc->in_max - spc->in_min) * 100
2242 avg_in[i] += spc->in;
2243 /* Assume that min and max voltage inputs cannot vary */
2244 avg_in_min[i] = spc->in_min;
2245 avg_in_max[i] = spc->in_max;
2248 snprintf(fmt, 16, " %%%ds\n", MAX_SENSORS_DEV_LEN);
2249 cprintf_in(IS_STR, fmt, spc->device, 0);
2269 ***************************************************************************
2270 * Display voltage inputs statistics.
2273 * @a Activity structure with statistics.
2274 * @prev Index in array where stats used as reference are.
2275 * @curr Index in array for current sample statistics.
2276 * @itv Interval of time in jiffies.
2277 ***************************************************************************
2279 __print_funct_t print_pwr_in_stats(struct activity *a, int prev, int curr,
2280 unsigned long long itv)
2282 stub_print_pwr_in_stats(a, curr, FALSE);
2286 ***************************************************************************
2287 * Display average voltage inputs statistics.
2290 * @a Activity structure with statistics.
2291 * @prev Index in array where stats used as reference are.
2292 * @curr Index in array for current sample statistics.
2293 * @itv Interval of time in jiffies.
2294 ***************************************************************************
2296 __print_funct_t print_avg_pwr_in_stats(struct activity *a, int prev, int curr,
2297 unsigned long long itv)
2299 stub_print_pwr_in_stats(a, curr, TRUE);
2303 ***************************************************************************
2304 * Display huge pages statistics. This function is used to
2305 * display instantaneous and average statistics.
2308 * @a Activity structure with statistics.
2309 * @curr Index in array for current sample statistics.
2310 * @dispavg TRUE if displaying average statistics.
2311 ***************************************************************************
2313 void stub_print_huge_stats(struct activity *a, int curr, int dispavg)
2316 *smc = (struct stats_huge *) a->buf[curr];
2317 static unsigned long long
2322 printf("\n%-11s kbhugfree kbhugused %%hugused\n",
2327 /* Display instantaneous values */
2328 printf("%-11s", timestamp[curr]);
2330 (unsigned long long) smc->frhkb,
2331 (unsigned long long) (smc->tlhkb - smc->frhkb));
2334 SP_VALUE(smc->frhkb, smc->tlhkb, smc->tlhkb) : 0.0);
2337 /* Will be used to compute the average */
2338 avg_frhkb += smc->frhkb;
2339 avg_tlhkb += smc->tlhkb;
2342 /* Display average values */
2343 printf("%-11s", timestamp[curr]);
2345 (double) avg_frhkb / avg_count,
2346 ((double) avg_tlhkb / avg_count) -
2347 ((double) avg_frhkb / avg_count));
2350 SP_VALUE((double) avg_frhkb / avg_count,
2351 (double) avg_tlhkb / avg_count,
2352 (double) avg_tlhkb / avg_count) : 0.0);
2355 /* Reset average counters */
2356 avg_frhkb = avg_tlhkb = 0;
2361 ***************************************************************************
2362 * Display huge pages statistics.
2365 * @a Activity structure with statistics.
2366 * @prev Index in array where stats used as reference are.
2367 * @curr Index in array for current sample statistics.
2368 * @itv Interval of time in jiffies.
2369 ***************************************************************************
2371 __print_funct_t print_huge_stats(struct activity *a, int prev, int curr,
2372 unsigned long long itv)
2374 stub_print_huge_stats(a, curr, FALSE);
2378 ***************************************************************************
2379 * Display huge pages statistics.
2382 * @a Activity structure with statistics.
2383 * @prev Index in array where stats used as reference are.
2384 * @curr Index in array for current sample statistics.
2385 * @itv Interval of time in jiffies.
2386 ***************************************************************************
2388 __print_funct_t print_avg_huge_stats(struct activity *a, int prev, int curr,
2389 unsigned long long itv)
2391 stub_print_huge_stats(a, curr, TRUE);
2395 ***************************************************************************
2396 * Display CPU weighted frequency statistics. This function is used to
2397 * display instantaneous and average statistics.
2400 * @a Activity structure with statistics.
2401 * @prev Index in array where stats used as reference are.
2402 * @curr Index in array for current sample statistics.
2403 * @itv Interval of time in jiffies.
2404 ***************************************************************************
2406 void print_pwr_wghfreq_stats(struct activity *a, int prev, int curr,
2407 unsigned long long itv)
2410 struct stats_pwr_wghfreq *spc, *spp, *spc_k, *spp_k;
2411 unsigned long long tis, tisfreq;
2414 printf("\n%-11s CPU wghMHz\n",
2418 for (i = 0; (i < a->nr) && (i < a->bitmap->b_size + 1); i++) {
2421 * The size of a->buf[...] CPU structure may be different from the default
2422 * sizeof(struct stats_pwr_wghfreq) value if data have been read from a file!
2423 * That's why we don't use a syntax like:
2424 * spc = (struct stats_pwr_wghfreq *) a->buf[...] + i;
2426 spc = (struct stats_pwr_wghfreq *) ((char *) a->buf[curr] + i * a->msize * a->nr2);
2427 spp = (struct stats_pwr_wghfreq *) ((char *) a->buf[prev] + i * a->msize * a->nr2);
2430 * Note: a->nr is in [1, NR_CPUS + 1].
2431 * Bitmap size is provided for (NR_CPUS + 1) CPUs.
2432 * Anyway, NR_CPUS may vary between the version of sysstat
2433 * used by sadc to create a file, and the version of sysstat
2434 * used by sar to read it...
2437 /* Should current CPU (including CPU "all") be displayed? */
2438 if (a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))) {
2440 /* Yes: Display it */
2441 printf("%-11s", timestamp[curr]);
2444 /* This is CPU "all" */
2445 cprintf_in(IS_STR, "%s", " all", 0);
2448 cprintf_in(IS_INT, " %3d", "", i - 1);
2454 for (k = 0; k < a->nr2; k++) {
2456 spc_k = (struct stats_pwr_wghfreq *) ((char *) spc + k * a->msize);
2459 spp_k = (struct stats_pwr_wghfreq *) ((char *) spp + k * a->msize);
2461 tisfreq += (spc_k->freq / 1000) *
2462 (spc_k->time_in_state - spp_k->time_in_state);
2463 tis += (spc_k->time_in_state - spp_k->time_in_state);
2466 /* Display weighted frequency for current CPU */
2468 tis ? ((double) tisfreq) / tis : 0.0);
2475 ***************************************************************************
2476 * Display USB devices statistics. This function is used to
2477 * display instantaneous and summary statistics.
2480 * @a Activity structure with statistics.
2481 * @curr Index in array for current sample statistics.
2482 * @itv Interval of time in jiffies.
2483 * @dispavg TRUE if displaying average statistics.
2484 ***************************************************************************
2486 void stub_print_pwr_usb_stats(struct activity *a, int curr, int dispavg)
2490 struct stats_pwr_usb *suc, *sum;
2493 printf("\n%-11s BUS idvendor idprod maxpower",
2494 (dispavg ? _("Summary:") : timestamp[!curr]));
2495 printf(" %*s", MAX_MANUF_LEN - 1, "manufact");
2496 printf(" %*s\n", MAX_PROD_LEN - 1, "product");
2499 for (i = 0; i < a->nr; i++) {
2500 suc = (struct stats_pwr_usb *) ((char *) a->buf[curr] + i * a->msize);
2503 /* Bus#0 doesn't exist: We are at the end of the list */
2506 printf("%-11s", (dispavg ? _("Summary:") : timestamp[curr]));
2507 cprintf_in(IS_INT, " %6d", "", suc->bus_nr);
2512 /* bMaxPower is expressed in 2 mA units */
2513 (unsigned long long) (suc->bmaxpower << 1));
2515 snprintf(fmt, 16, " %%%ds", MAX_MANUF_LEN - 1);
2516 cprintf_s(IS_STR, fmt, suc->manufacturer);
2517 snprintf(fmt, 16, " %%%ds\n", MAX_PROD_LEN - 1);
2518 cprintf_s(IS_STR, fmt, suc->product);
2521 /* Save current USB device in summary list */
2522 for (j = 0; j < a->nr; j++) {
2523 sum = (struct stats_pwr_usb *) ((char *) a->buf[2] + j * a->msize);
2525 if ((sum->bus_nr == suc->bus_nr) &&
2526 (sum->vendor_id == suc->vendor_id) &&
2527 (sum->product_id == suc->product_id))
2528 /* USB device found in summary list */
2532 * Current slot is free:
2533 * Save USB device in summary list.
2538 if (j == a->nr - 1) {
2540 * This is the last slot and
2541 * we still havent't found the device.
2542 * So create a dummy device here.
2545 sum->vendor_id = sum->product_id = 0;
2547 sum->manufacturer[0] = '\0';
2548 snprintf(sum->product, MAX_PROD_LEN, "%s",
2549 _("Other devices not listed here"));
2550 sum->product[MAX_PROD_LEN - 1] = '\0';
2558 ***************************************************************************
2559 * Display USB devices statistics.
2562 * @a Activity structure with statistics.
2563 * @prev Index in array where stats used as reference are.
2564 * @curr Index in array for current sample statistics.
2565 * @itv Interval of time in jiffies.
2566 ***************************************************************************
2568 __print_funct_t print_pwr_usb_stats(struct activity *a, int prev, int curr,
2569 unsigned long long itv)
2571 stub_print_pwr_usb_stats(a, curr, FALSE);
2575 ***************************************************************************
2576 * Display average USB devices statistics.
2579 * @a Activity structure with statistics.
2580 * @prev Index in array where stats used as reference are.
2581 * @curr Index in array for current sample statistics.
2582 * @itv Interval of time in jiffies.
2583 ***************************************************************************
2585 __print_funct_t print_avg_pwr_usb_stats(struct activity *a, int prev, int curr,
2586 unsigned long long itv)
2588 stub_print_pwr_usb_stats(a, 2, TRUE);
2592 ***************************************************************************
2593 * Display filesystems statistics. This function is used to
2594 * display instantaneous and average statistics.
2597 * @a Activity structure with statistics.
2598 * @curr Index in array for current sample statistics.
2599 * @dispavg TRUE if displaying average statistics.
2600 ***************************************************************************
2602 __print_funct_t stub_print_filesystem_stats(struct activity *a, int curr, int dispavg)
2605 struct stats_filesystem *sfc, *sfm;
2608 printf("\n%-11s MBfsfree MBfsused %%fsused %%ufsused"
2609 " Ifree Iused %%Iused %s\n",
2610 (dispavg ? _("Summary:") : timestamp[!curr]),
2611 DISPLAY_MOUNT(a->opt_flags) ? "MOUNTPOINT" : "FILESYSTEM");
2614 for (i = 0; i < a->nr; i++) {
2615 sfc = (struct stats_filesystem *) ((char *) a->buf[curr] + i * a->msize);
2618 /* Size of filesystem is zero: We are at the end of the list */
2621 printf("%-11s", (dispavg ? _("Summary:") : timestamp[curr]));
2623 (double) sfc->f_bfree / 1024 / 1024,
2624 (double) (sfc->f_blocks - sfc->f_bfree) / 1024 / 1024);
2626 /* f_blocks is not zero. But test it anyway ;-) */
2627 sfc->f_blocks ? SP_VALUE(sfc->f_bfree, sfc->f_blocks, sfc->f_blocks)
2629 sfc->f_blocks ? SP_VALUE(sfc->f_bavail, sfc->f_blocks, sfc->f_blocks)
2632 (unsigned long long) sfc->f_ffree,
2633 (unsigned long long) (sfc->f_files - sfc->f_ffree));
2635 sfc->f_files ? SP_VALUE(sfc->f_ffree, sfc->f_files, sfc->f_files)
2637 cprintf_in(IS_STR, " %s\n",
2638 DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name, 0);
2641 /* Save current filesystem in summary list */
2642 for (j = 0; j < a->nr; j++) {
2643 sfm = (struct stats_filesystem *) ((char *) a->buf[2] + j * a->msize);
2645 if (!strcmp(sfm->fs_name, sfc->fs_name) ||
2648 * Filesystem found in list (then save again its stats)
2649 * or free slot (end of list).
2660 ***************************************************************************
2661 * Display filesystems statistics.
2664 * @a Activity structure with statistics.
2665 * @prev Index in array where stats used as reference are.
2666 * @curr Index in array for current sample statistics.
2667 * @itv Interval of time in jiffies.
2668 ***************************************************************************
2670 __print_funct_t print_filesystem_stats(struct activity *a, int prev, int curr,
2671 unsigned long long itv)
2673 stub_print_filesystem_stats(a, curr, FALSE);
2677 ***************************************************************************
2678 * Display average filesystems statistics.
2681 * @a Activity structure with statistics.
2682 * @prev Index in array where stats used as reference are.
2683 * @curr Index in array for current sample statistics.
2684 * @itv Interval of time in jiffies.
2685 ***************************************************************************
2687 __print_funct_t print_avg_filesystem_stats(struct activity *a, int prev, int curr,
2688 unsigned long long itv)
2690 stub_print_filesystem_stats(a, 2, TRUE);
2694 ***************************************************************************
2695 * Display Fibre Channel HBA statistics.
2698 * @a Activity structure with statistics.
2699 * @prev Index in array where stats used as reference are.
2700 * @curr Index in array for current sample statistics.
2701 * @itv Interval of time in jiffies.
2702 ***************************************************************************
2704 __print_funct_t print_fchost_stats(struct activity *a, int prev, int curr,
2705 unsigned long long itv)
2708 struct stats_fchost *sfcc,*sfcp;
2711 printf("\n%-11s fch_rxf/s fch_txf/s fch_rxw/s fch_txw/s FCHOST\n",
2715 for (i = 0; i < a->nr; i++) {
2717 sfcc = (struct stats_fchost *) ((char *) a->buf[curr] + i * a->msize);
2718 sfcp = (struct stats_fchost *) ((char *) a->buf[prev] + i * a->msize);
2720 if (!sfcc->fchost_name[0])
2721 /* We are at the end of the list */
2724 printf("%-11s", timestamp[curr]);
2726 S_VALUE(sfcp->f_rxframes, sfcc->f_rxframes, itv),
2727 S_VALUE(sfcp->f_txframes, sfcc->f_txframes, itv),
2728 S_VALUE(sfcp->f_rxwords, sfcc->f_rxwords, itv),
2729 S_VALUE(sfcp->f_txwords, sfcc->f_txwords, itv));
2730 cprintf_in(IS_STR, " %s\n", sfcc->fchost_name, 0);