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 S_VALUE(sip->dk_drive, sic->dk_drive, itv),
391 S_VALUE(sip->dk_drive_rio, sic->dk_drive_rio, itv),
392 S_VALUE(sip->dk_drive_wio, sic->dk_drive_wio, itv),
393 S_VALUE(sip->dk_drive_rblk, sic->dk_drive_rblk, itv),
394 S_VALUE(sip->dk_drive_wblk, sic->dk_drive_wblk, itv));
399 ***************************************************************************
400 * Display memory and swap statistics. This function is used to
401 * display instantaneous and average statistics.
404 * @a Activity structure with statistics.
405 * @prev Index in array where stats used as reference are.
406 * @curr Index in array for current sample statistics.
407 * @itv Interval of time in jiffies.
408 * @dispavg TRUE if displaying average statistics.
409 ***************************************************************************
411 void stub_print_memory_stats(struct activity *a, int prev, int curr,
412 unsigned long long itv, int dispavg)
415 *smc = (struct stats_memory *) a->buf[curr],
416 *smp = (struct stats_memory *) a->buf[prev];
417 static unsigned long long
430 static unsigned long long
435 if (DISPLAY_MEMORY(a->opt_flags)) {
437 printf("\n%-11s frmpg/s bufpg/s campg/s\n",
441 printf("%-11s", timestamp[curr]);
443 S_VALUE((double) KB_TO_PG(smp->frmkb), (double) KB_TO_PG(smc->frmkb), itv),
444 S_VALUE((double) KB_TO_PG(smp->bufkb), (double) KB_TO_PG(smc->bufkb), itv),
445 S_VALUE((double) KB_TO_PG(smp->camkb), (double) KB_TO_PG(smc->camkb), itv));
449 if (DISPLAY_MEM_AMT(a->opt_flags)) {
451 printf("\n%-11s kbmemfree kbmemused %%memused kbbuffers kbcached"
452 " kbcommit %%commit kbactive kbinact kbdirty", timestamp[!curr]);
453 if (DISPLAY_MEM_ALL(a->opt_flags)) {
454 printf(" kbanonpg kbslab kbkstack kbpgtbl kbvmused");
460 /* Display instantaneous values */
461 printf("%-11s", timestamp[curr]);
463 (unsigned long long) smc->frmkb,
464 (unsigned long long) (smc->tlmkb - smc->frmkb));
467 SP_VALUE(smc->frmkb, smc->tlmkb, smc->tlmkb)
470 (unsigned long long) smc->bufkb,
471 (unsigned long long) smc->camkb,
472 (unsigned long long) smc->comkb);
474 (smc->tlmkb + smc->tlskb) ?
475 SP_VALUE(0, smc->comkb, smc->tlmkb + smc->tlskb)
478 (unsigned long long) smc->activekb,
479 (unsigned long long) smc->inactkb,
480 (unsigned long long) smc->dirtykb);
482 if (DISPLAY_MEM_ALL(a->opt_flags)) {
483 /* Display extended memory statistics */
485 (unsigned long long) smc->anonpgkb,
486 (unsigned long long) smc->slabkb,
487 (unsigned long long) smc->kstackkb,
488 (unsigned long long) smc->pgtblkb,
489 (unsigned long long) smc->vmusedkb);
495 * Will be used to compute the average.
496 * We assume that the total amount of memory installed can not vary
497 * during the interval given on the command line.
499 avg_frmkb += smc->frmkb;
500 avg_bufkb += smc->bufkb;
501 avg_camkb += smc->camkb;
502 avg_comkb += smc->comkb;
503 avg_activekb += smc->activekb;
504 avg_inactkb += smc->inactkb;
505 avg_dirtykb += smc->dirtykb;
506 avg_anonpgkb += smc->anonpgkb;
507 avg_slabkb += smc->slabkb;
508 avg_kstackkb += smc->kstackkb;
509 avg_pgtblkb += smc->pgtblkb;
510 avg_vmusedkb += smc->vmusedkb;
513 /* Display average values */
514 printf("%-11s", timestamp[curr]);
516 (double) avg_frmkb / avg_count,
517 (double) smc->tlmkb - ((double) avg_frmkb / avg_count));
520 SP_VALUE((double) (avg_frmkb / avg_count), smc->tlmkb, smc->tlmkb)
523 (double) avg_bufkb / avg_count,
524 (double) avg_camkb / avg_count,
525 (double) avg_comkb / avg_count);
527 (smc->tlmkb + smc->tlskb) ?
528 SP_VALUE(0.0, (double) (avg_comkb / avg_count), smc->tlmkb + smc->tlskb)
531 (double) avg_activekb / avg_count,
532 (double) avg_inactkb / avg_count,
533 (double) avg_dirtykb / avg_count);
535 if (DISPLAY_MEM_ALL(a->opt_flags)) {
537 (double) avg_anonpgkb / avg_count,
538 (double) avg_slabkb / avg_count,
539 (double) avg_kstackkb / avg_count,
540 (double) avg_pgtblkb / avg_count,
541 (double) avg_vmusedkb / avg_count);
546 /* Reset average counters */
547 avg_frmkb = avg_bufkb = avg_camkb = avg_comkb = 0;
548 avg_activekb = avg_inactkb = avg_dirtykb = 0;
549 avg_anonpgkb = avg_slabkb = avg_kstackkb = 0;
550 avg_pgtblkb = avg_vmusedkb = 0;
554 if (DISPLAY_SWAP(a->opt_flags)) {
556 printf("\n%-11s kbswpfree kbswpused %%swpused kbswpcad %%swpcad\n",
561 /* Display instantaneous values */
562 printf("%-11s", timestamp[curr]);
564 (unsigned long long) smc->frskb,
565 (unsigned long long) (smc->tlskb - smc->frskb));
568 SP_VALUE(smc->frskb, smc->tlskb, smc->tlskb)
571 (unsigned long long) smc->caskb);
573 (smc->tlskb - smc->frskb) ?
574 SP_VALUE(0, smc->caskb, smc->tlskb - smc->frskb)
580 * Will be used to compute the average.
581 * We assume that the total amount of swap space may vary.
583 avg_frskb += smc->frskb;
584 avg_tlskb += smc->tlskb;
585 avg_caskb += smc->caskb;
588 /* Display average values */
589 printf("%-11s", timestamp[curr]);
591 (double) avg_frskb / avg_count,
592 ((double) avg_tlskb / avg_count) -
593 ((double) avg_frskb / avg_count));
596 SP_VALUE((double) avg_frskb / avg_count,
597 (double) avg_tlskb / avg_count,
598 (double) avg_tlskb / avg_count)
601 (double) avg_caskb / avg_count);
603 (avg_tlskb != avg_frskb) ?
604 SP_VALUE(0.0, (double) avg_caskb / avg_count,
605 ((double) avg_tlskb / avg_count) -
606 ((double) avg_frskb / avg_count))
610 /* Reset average counters */
611 avg_frskb = avg_tlskb = avg_caskb = 0;
617 ***************************************************************************
618 * Display memory and swap statistics.
621 * @a Activity structure with statistics.
622 * @prev Index in array where stats used as reference are.
623 * @curr Index in array for current sample statistics.
624 * @itv Interval of time in jiffies.
625 ***************************************************************************
627 __print_funct_t print_memory_stats(struct activity *a, int prev, int curr,
628 unsigned long long itv)
630 stub_print_memory_stats(a, prev, curr, itv, FALSE);
634 ***************************************************************************
635 * Display average memory statistics.
638 * @a Activity structure with statistics.
639 * @prev Index in array where stats used as reference are.
640 * @curr Index in array for current sample statistics.
641 * @itv Interval of time in jiffies.
642 ***************************************************************************
644 __print_funct_t print_avg_memory_stats(struct activity *a, int prev, int curr,
645 unsigned long long itv)
647 stub_print_memory_stats(a, prev, curr, itv, TRUE);
651 ***************************************************************************
652 * Display kernel tables statistics. This function is used to display
653 * instantaneous and average statistics.
656 * @a Activity structure with statistics.
657 * @curr Index in array for current sample statistics.
658 * @dispavg True if displaying average statistics.
659 ***************************************************************************
661 void stub_print_ktables_stats(struct activity *a, int curr, int dispavg)
664 *skc = (struct stats_ktables *) a->buf[curr];
665 static unsigned long long
673 printf("\n%-11s dentunusd file-nr inode-nr pty-nr\n",
678 /* Display instantaneous values */
679 printf("%-11s", timestamp[curr]);
681 (unsigned long long) skc->dentry_stat,
682 (unsigned long long) skc->file_used,
683 (unsigned long long) skc->inode_used,
684 (unsigned long long) skc->pty_nr);
688 * Will be used to compute the average.
689 * Note: Overflow unlikely to happen but not impossible...
691 avg_dentry_stat += skc->dentry_stat;
692 avg_file_used += skc->file_used;
693 avg_inode_used += skc->inode_used;
694 avg_pty_nr += skc->pty_nr;
697 /* Display average values */
698 printf("%-11s", timestamp[curr]);
700 (double) avg_dentry_stat / avg_count,
701 (double) avg_file_used / avg_count,
702 (double) avg_inode_used / avg_count,
703 (double) avg_pty_nr / avg_count);
706 /* Reset average counters */
707 avg_dentry_stat = avg_file_used = avg_inode_used = avg_pty_nr = 0;
712 ***************************************************************************
713 * Display kernel tables statistics.
716 * @a Activity structure with statistics.
717 * @prev Index in array where stats used as reference are.
718 * @curr Index in array for current sample statistics.
719 * @itv Interval of time in jiffies.
720 ***************************************************************************
722 __print_funct_t print_ktables_stats(struct activity *a, int prev, int curr,
723 unsigned long long itv)
725 stub_print_ktables_stats(a, curr, FALSE);
729 ***************************************************************************
730 * Display average kernel tables statistics.
733 * @a Activity structure with statistics.
734 * @prev Index in array where stats used as reference are.
735 * @curr Index in array for current sample statistics.
736 * @itv Interval of time in jiffies.
737 ***************************************************************************
739 __print_funct_t print_avg_ktables_stats(struct activity *a, int prev, int curr,
740 unsigned long long itv)
742 stub_print_ktables_stats(a, curr, TRUE);
746 ***************************************************************************
747 * Display queue and load statistics. This function is used to display
748 * instantaneous and average statistics.
751 * @a Activity structure with statistics.
752 * @curr Index in array for current sample statistics.
753 * @dispavg TRUE if displaying average statistics.
754 ***************************************************************************
756 void stub_print_queue_stats(struct activity *a, int curr, int dispavg)
759 *sqc = (struct stats_queue *) a->buf[curr];
760 static unsigned long long
766 avg_procs_blocked = 0;
769 printf("\n%-11s runq-sz plist-sz ldavg-1 ldavg-5 ldavg-15 blocked\n",
774 /* Display instantaneous values */
775 printf("%-11s", timestamp[curr]);
777 (unsigned long long) sqc->nr_running,
778 (unsigned long long) sqc->nr_threads);
780 (double) sqc->load_avg_1 / 100,
781 (double) sqc->load_avg_5 / 100,
782 (double) sqc->load_avg_15 / 100);
784 (unsigned long long) sqc->procs_blocked);
787 /* Will be used to compute the average */
788 avg_nr_running += sqc->nr_running;
789 avg_nr_threads += sqc->nr_threads;
790 avg_load_avg_1 += sqc->load_avg_1;
791 avg_load_avg_5 += sqc->load_avg_5;
792 avg_load_avg_15 += sqc->load_avg_15;
793 avg_procs_blocked += sqc->procs_blocked;
796 /* Display average values */
797 printf("%-11s", timestamp[curr]);
799 (double) avg_nr_running / avg_count,
800 (double) avg_nr_threads / avg_count);
802 (double) avg_load_avg_1 / (avg_count * 100),
803 (double) avg_load_avg_5 / (avg_count * 100),
804 (double) avg_load_avg_15 / (avg_count * 100));
806 (double) avg_procs_blocked / avg_count);
809 /* Reset average counters */
810 avg_nr_running = avg_nr_threads = 0;
811 avg_load_avg_1 = avg_load_avg_5 = avg_load_avg_15 = 0;
812 avg_procs_blocked = 0;
817 ***************************************************************************
818 * Display queue and load statistics.
821 * @a Activity structure with statistics.
822 * @prev Index in array where stats used as reference are.
823 * @curr Index in array for current sample statistics.
824 * @itv Interval of time in jiffies.
825 ***************************************************************************
827 __print_funct_t print_queue_stats(struct activity *a, int prev, int curr,
828 unsigned long long itv)
830 stub_print_queue_stats(a, curr, FALSE);
834 ***************************************************************************
835 * Display average queue and load statistics.
838 * @a Activity structure with statistics.
839 * @prev Index in array where stats used as reference are.
840 * @curr Index in array for current sample statistics.
841 * @itv Interval of time in jiffies.
842 ***************************************************************************
844 __print_funct_t print_avg_queue_stats(struct activity *a, int prev, int curr,
845 unsigned long long itv)
847 stub_print_queue_stats(a, curr, TRUE);
851 ***************************************************************************
852 * Display serial lines statistics.
855 * @a Activity structure with statistics.
856 * @prev Index in array where stats used as reference are.
857 * @curr Index in array for current sample statistics.
858 * @itv Interval of time in jiffies.
859 ***************************************************************************
861 __print_funct_t print_serial_stats(struct activity *a, int prev, int curr,
862 unsigned long long itv)
865 struct stats_serial *ssc, *ssp;
868 printf("\n%-11s TTY rcvin/s xmtin/s framerr/s prtyerr/s"
869 " brk/s ovrun/s\n", timestamp[!curr]);
872 for (i = 0; i < a->nr; i++) {
874 ssc = (struct stats_serial *) ((char *) a->buf[curr] + i * a->msize);
875 ssp = (struct stats_serial *) ((char *) a->buf[prev] + i * a->msize);
880 printf("%-11s", timestamp[curr]);
881 cprintf_in(IS_INT, " %3d", "", ssc->line - 1);
883 if ((ssc->line == ssp->line) || WANT_SINCE_BOOT(flags)) {
885 S_VALUE(ssp->rx, ssc->rx, itv),
886 S_VALUE(ssp->tx, ssc->tx, itv),
887 S_VALUE(ssp->frame, ssc->frame, itv),
888 S_VALUE(ssp->parity, ssc->parity, itv),
889 S_VALUE(ssp->brk, ssc->brk, itv),
890 S_VALUE(ssp->overrun, ssc->overrun, itv));
894 printf(" N/A N/A N/A N/A"
901 ***************************************************************************
902 * Display disks statistics.
905 * @a Activity structure with statistics.
906 * @prev Index in array where stats used as reference are.
907 * @curr Index in array for current sample statistics.
908 * @itv Interval of time in jiffies.
909 ***************************************************************************
911 __print_funct_t print_disk_stats(struct activity *a, int prev, int curr,
912 unsigned long long itv)
915 struct stats_disk *sdc, *sdp;
916 struct ext_disk_stats xds;
917 char *dev_name, *persist_dev_name;
920 printf("\n%-11s DEV tps rd_sec/s wr_sec/s avgrq-sz"
921 " avgqu-sz await svctm %%util\n",
925 for (i = 0; i < a->nr; i++) {
927 sdc = (struct stats_disk *) ((char *) a->buf[curr] + i * a->msize);
929 if (!(sdc->major + sdc->minor))
932 j = check_disk_reg(a, curr, prev, i);
933 sdp = (struct stats_disk *) ((char *) a->buf[prev] + j * a->msize);
935 /* Compute service time, etc. */
936 compute_ext_disk_stats(sdc, sdp, itv, &xds);
939 persist_dev_name = NULL;
941 if (DISPLAY_PERSIST_NAME_S(flags)) {
942 persist_dev_name = get_persistent_name_from_pretty(get_devname(sdc->major, sdc->minor, TRUE));
945 if (persist_dev_name) {
946 dev_name = persist_dev_name;
949 if ((USE_PRETTY_OPTION(flags)) && (sdc->major == dm_major)) {
950 dev_name = transform_devmapname(sdc->major, sdc->minor);
954 dev_name = get_devname(sdc->major, sdc->minor,
955 USE_PRETTY_OPTION(flags));
959 printf("%-11s", timestamp[curr]);
961 cprintf_in(IS_STR, " %9s", dev_name, 0);
963 S_VALUE(sdp->nr_ios, sdc->nr_ios, itv),
964 S_VALUE(sdp->rd_sect, sdc->rd_sect, itv),
965 S_VALUE(sdp->wr_sect, sdc->wr_sect, itv),
966 /* See iostat for explanations */
968 S_VALUE(sdp->rq_ticks, sdc->rq_ticks, itv) / 1000.0,
978 ***************************************************************************
979 * Display network interfaces statistics.
982 * @a Activity structure with statistics.
983 * @prev Index in array where stats used as reference are.
984 * @curr Index in array for current sample statistics.
985 * @itv Interval of time in jiffies.
986 ***************************************************************************
988 __print_funct_t print_net_dev_stats(struct activity *a, int prev, int curr,
989 unsigned long long itv)
992 struct stats_net_dev *sndc, *sndp;
993 double rxkb, txkb, ifutil;
996 printf("\n%-11s IFACE rxpck/s txpck/s rxkB/s txkB/s"
997 " rxcmp/s txcmp/s rxmcst/s %%ifutil\n", timestamp[!curr]);
1000 for (i = 0; i < a->nr; i++) {
1002 sndc = (struct stats_net_dev *) ((char *) a->buf[curr] + i * a->msize);
1004 if (!strcmp(sndc->interface, ""))
1007 j = check_net_dev_reg(a, curr, prev, i);
1008 sndp = (struct stats_net_dev *) ((char *) a->buf[prev] + j * a->msize);
1010 printf("%-11s", timestamp[curr]);
1011 cprintf_in(IS_STR, " %9s", sndc->interface, 0);
1013 rxkb = S_VALUE(sndp->rx_bytes, sndc->rx_bytes, itv);
1014 txkb = S_VALUE(sndp->tx_bytes, sndc->tx_bytes, itv);
1017 S_VALUE(sndp->rx_packets, sndc->rx_packets, itv),
1018 S_VALUE(sndp->tx_packets, sndc->tx_packets, itv),
1021 S_VALUE(sndp->rx_compressed, sndc->rx_compressed, itv),
1022 S_VALUE(sndp->tx_compressed, sndc->tx_compressed, itv),
1023 S_VALUE(sndp->multicast, sndc->multicast, itv));
1024 ifutil = compute_ifutil(sndc, rxkb, txkb);
1025 cprintf_pc(1, 9, 2, ifutil);
1031 ***************************************************************************
1032 * Display network interface errors statistics.
1035 * @a Activity structure with statistics.
1036 * @prev Index in array where stats used as reference are.
1037 * @curr Index in array for current sample statistics.
1038 * @itv Interval of time in jiffies.
1039 ***************************************************************************
1041 __print_funct_t print_net_edev_stats(struct activity *a, int prev, int curr,
1042 unsigned long long itv)
1045 struct stats_net_edev *snedc, *snedp;
1048 printf("\n%-11s IFACE rxerr/s txerr/s coll/s rxdrop/s"
1049 " txdrop/s txcarr/s rxfram/s rxfifo/s txfifo/s\n",
1053 for (i = 0; i < a->nr; i++) {
1055 snedc = (struct stats_net_edev *) ((char *) a->buf[curr] + i * a->msize);
1057 if (!strcmp(snedc->interface, ""))
1060 j = check_net_edev_reg(a, curr, prev, i);
1061 snedp = (struct stats_net_edev *) ((char *) a->buf[prev] + j * a->msize);
1063 printf("%-11s", timestamp[curr]);
1064 cprintf_in(IS_STR, " %9s", snedc->interface, 0);
1067 S_VALUE(snedp->rx_errors, snedc->rx_errors, itv),
1068 S_VALUE(snedp->tx_errors, snedc->tx_errors, itv),
1069 S_VALUE(snedp->collisions, snedc->collisions, itv),
1070 S_VALUE(snedp->rx_dropped, snedc->rx_dropped, itv),
1071 S_VALUE(snedp->tx_dropped, snedc->tx_dropped, itv),
1072 S_VALUE(snedp->tx_carrier_errors, snedc->tx_carrier_errors, itv),
1073 S_VALUE(snedp->rx_frame_errors, snedc->rx_frame_errors, itv),
1074 S_VALUE(snedp->rx_fifo_errors, snedc->rx_fifo_errors, itv),
1075 S_VALUE(snedp->tx_fifo_errors, snedc->tx_fifo_errors, itv));
1081 ***************************************************************************
1082 * Display NFS client statistics.
1085 * @a Activity structure with statistics.
1086 * @prev Index in array where stats used as reference are.
1087 * @curr Index in array for current sample statistics.
1088 * @itv Interval of time in jiffies.
1089 ***************************************************************************
1091 __print_funct_t print_net_nfs_stats(struct activity *a, int prev, int curr,
1092 unsigned long long itv)
1094 struct stats_net_nfs
1095 *snnc = (struct stats_net_nfs *) a->buf[curr],
1096 *snnp = (struct stats_net_nfs *) a->buf[prev];
1099 printf("\n%-11s call/s retrans/s read/s write/s access/s"
1100 " getatt/s\n", timestamp[!curr]);
1103 printf("%-11s", timestamp[curr]);
1105 S_VALUE(snnp->nfs_rpccnt, snnc->nfs_rpccnt, itv),
1106 S_VALUE(snnp->nfs_rpcretrans, snnc->nfs_rpcretrans, itv),
1107 S_VALUE(snnp->nfs_readcnt, snnc->nfs_readcnt, itv),
1108 S_VALUE(snnp->nfs_writecnt, snnc->nfs_writecnt, itv),
1109 S_VALUE(snnp->nfs_accesscnt, snnc->nfs_accesscnt, itv),
1110 S_VALUE(snnp->nfs_getattcnt, snnc->nfs_getattcnt, itv));
1115 ***************************************************************************
1116 * Display NFS server statistics.
1119 * @a Activity structure with statistics.
1120 * @prev Index in array where stats used as reference are.
1121 * @curr Index in array for current sample statistics.
1122 * @itv Interval of time in jiffies.
1123 ***************************************************************************
1125 __print_funct_t print_net_nfsd_stats(struct activity *a, int prev, int curr,
1126 unsigned long long itv)
1128 struct stats_net_nfsd
1129 *snndc = (struct stats_net_nfsd *) a->buf[curr],
1130 *snndp = (struct stats_net_nfsd *) a->buf[prev];
1133 printf("\n%-11s scall/s badcall/s packet/s udp/s tcp/s "
1134 "hit/s miss/s sread/s swrite/s saccess/s sgetatt/s\n",
1138 printf("%-11s", timestamp[curr]);
1140 S_VALUE(snndp->nfsd_rpccnt, snndc->nfsd_rpccnt, itv),
1141 S_VALUE(snndp->nfsd_rpcbad, snndc->nfsd_rpcbad, itv),
1142 S_VALUE(snndp->nfsd_netcnt, snndc->nfsd_netcnt, itv),
1143 S_VALUE(snndp->nfsd_netudpcnt, snndc->nfsd_netudpcnt, itv),
1144 S_VALUE(snndp->nfsd_nettcpcnt, snndc->nfsd_nettcpcnt, itv),
1145 S_VALUE(snndp->nfsd_rchits, snndc->nfsd_rchits, itv),
1146 S_VALUE(snndp->nfsd_rcmisses, snndc->nfsd_rcmisses, itv),
1147 S_VALUE(snndp->nfsd_readcnt, snndc->nfsd_readcnt, itv),
1148 S_VALUE(snndp->nfsd_writecnt, snndc->nfsd_writecnt, itv),
1149 S_VALUE(snndp->nfsd_accesscnt, snndc->nfsd_accesscnt, itv),
1150 S_VALUE(snndp->nfsd_getattcnt, snndc->nfsd_getattcnt, itv));
1155 ***************************************************************************
1156 * Display network sockets statistics. This function is used to display
1157 * instantaneous and average statistics.
1160 * @a Activity structure with statistics.
1161 * @curr Index in array for current sample statistics.
1162 * @dispavg TRUE if displaying average statistics.
1163 ***************************************************************************
1165 void stub_print_net_sock_stats(struct activity *a, int curr, int dispavg)
1167 struct stats_net_sock
1168 *snsc = (struct stats_net_sock *) a->buf[curr];
1169 static unsigned long long
1178 printf("\n%-11s totsck tcpsck udpsck rawsck ip-frag tcp-tw\n",
1183 /* Display instantaneous values */
1184 printf("%-11s", timestamp[curr]);
1186 (unsigned long long) snsc->sock_inuse,
1187 (unsigned long long) snsc->tcp_inuse,
1188 (unsigned long long) snsc->udp_inuse,
1189 (unsigned long long) snsc->raw_inuse,
1190 (unsigned long long) snsc->frag_inuse,
1191 (unsigned long long) snsc->tcp_tw);
1194 /* Will be used to compute the average */
1195 avg_sock_inuse += snsc->sock_inuse;
1196 avg_tcp_inuse += snsc->tcp_inuse;
1197 avg_udp_inuse += snsc->udp_inuse;
1198 avg_raw_inuse += snsc->raw_inuse;
1199 avg_frag_inuse += snsc->frag_inuse;
1200 avg_tcp_tw += snsc->tcp_tw;
1203 /* Display average values */
1204 printf("%-11s", timestamp[curr]);
1206 (double) avg_sock_inuse / avg_count,
1207 (double) avg_tcp_inuse / avg_count,
1208 (double) avg_udp_inuse / avg_count,
1209 (double) avg_raw_inuse / avg_count,
1210 (double) avg_frag_inuse / avg_count,
1211 (double) avg_tcp_tw / avg_count);
1214 /* Reset average counters */
1215 avg_sock_inuse = avg_tcp_inuse = avg_udp_inuse = 0;
1216 avg_raw_inuse = avg_frag_inuse = avg_tcp_tw = 0;
1221 ***************************************************************************
1222 * Display network sockets statistics.
1225 * @a Activity structure with statistics.
1226 * @prev Index in array where stats used as reference are.
1227 * @curr Index in array for current sample statistics.
1228 * @itv Interval of time in jiffies.
1229 ***************************************************************************
1231 __print_funct_t print_net_sock_stats(struct activity *a, int prev, int curr,
1232 unsigned long long itv)
1234 stub_print_net_sock_stats(a, curr, FALSE);
1238 ***************************************************************************
1239 * Display average network sockets statistics.
1242 * @a Activity structure with statistics.
1243 * @prev Index in array where stats used as reference are.
1244 * @curr Index in array for current sample statistics.
1245 * @itv Interval of time in jiffies.
1246 ***************************************************************************
1248 __print_funct_t print_avg_net_sock_stats(struct activity *a, int prev, int curr,
1249 unsigned long long itv)
1251 stub_print_net_sock_stats(a, curr, TRUE);
1255 ***************************************************************************
1256 * Display IP network traffic statistics.
1259 * @a Activity structure with statistics.
1260 * @prev Index in array where stats used as reference are.
1261 * @curr Index in array for current sample statistics.
1262 * @itv Interval of time in jiffies.
1263 ***************************************************************************
1265 __print_funct_t print_net_ip_stats(struct activity *a, int prev, int curr,
1266 unsigned long long itv)
1269 *snic = (struct stats_net_ip *) a->buf[curr],
1270 *snip = (struct stats_net_ip *) a->buf[prev];
1273 printf("\n%-11s irec/s fwddgm/s idel/s orq/s asmrq/s"
1274 " asmok/s fragok/s fragcrt/s\n", timestamp[!curr]);
1277 printf("%-11s", timestamp[curr]);
1279 S_VALUE(snip->InReceives, snic->InReceives, itv),
1280 S_VALUE(snip->ForwDatagrams, snic->ForwDatagrams, itv),
1281 S_VALUE(snip->InDelivers, snic->InDelivers, itv),
1282 S_VALUE(snip->OutRequests, snic->OutRequests, itv),
1283 S_VALUE(snip->ReasmReqds, snic->ReasmReqds, itv),
1284 S_VALUE(snip->ReasmOKs, snic->ReasmOKs, itv),
1285 S_VALUE(snip->FragOKs, snic->FragOKs, itv),
1286 S_VALUE(snip->FragCreates, snic->FragCreates, itv));
1291 ***************************************************************************
1292 * Display IP network error statistics.
1295 * @a Activity structure with statistics.
1296 * @prev Index in array where stats used as reference are.
1297 * @curr Index in array for current sample statistics.
1298 * @itv Interval of time in jiffies.
1299 ***************************************************************************
1301 __print_funct_t print_net_eip_stats(struct activity *a, int prev, int curr,
1302 unsigned long long itv)
1304 struct stats_net_eip
1305 *sneic = (struct stats_net_eip *) a->buf[curr],
1306 *sneip = (struct stats_net_eip *) a->buf[prev];
1309 printf("\n%-11s ihdrerr/s iadrerr/s iukwnpr/s idisc/s odisc/s"
1310 " onort/s asmf/s fragf/s\n", timestamp[!curr]);
1313 printf("%-11s", timestamp[curr]);
1315 S_VALUE(sneip->InHdrErrors, sneic->InHdrErrors, itv),
1316 S_VALUE(sneip->InAddrErrors, sneic->InAddrErrors, itv),
1317 S_VALUE(sneip->InUnknownProtos, sneic->InUnknownProtos, itv),
1318 S_VALUE(sneip->InDiscards, sneic->InDiscards, itv),
1319 S_VALUE(sneip->OutDiscards, sneic->OutDiscards, itv),
1320 S_VALUE(sneip->OutNoRoutes, sneic->OutNoRoutes, itv),
1321 S_VALUE(sneip->ReasmFails, sneic->ReasmFails, itv),
1322 S_VALUE(sneip->FragFails, sneic->FragFails, itv));
1327 ***************************************************************************
1328 * Display ICMP network traffic statistics.
1331 * @a Activity structure with statistics.
1332 * @prev Index in array where stats used as reference are.
1333 * @curr Index in array for current sample statistics.
1334 * @itv Interval of time in jiffies.
1335 ***************************************************************************
1337 __print_funct_t print_net_icmp_stats(struct activity *a, int prev, int curr,
1338 unsigned long long itv)
1340 struct stats_net_icmp
1341 *snic = (struct stats_net_icmp *) a->buf[curr],
1342 *snip = (struct stats_net_icmp *) a->buf[prev];
1345 printf("\n%-11s imsg/s omsg/s iech/s iechr/s oech/s"
1346 " oechr/s itm/s itmr/s otm/s otmr/s"
1347 " iadrmk/s iadrmkr/s oadrmk/s oadrmkr/s\n", timestamp[!curr]);
1350 printf("%-11s", timestamp[curr]);
1352 S_VALUE(snip->InMsgs, snic->InMsgs, itv),
1353 S_VALUE(snip->OutMsgs, snic->OutMsgs, itv),
1354 S_VALUE(snip->InEchos, snic->InEchos, itv),
1355 S_VALUE(snip->InEchoReps, snic->InEchoReps, itv),
1356 S_VALUE(snip->OutEchos, snic->OutEchos, itv),
1357 S_VALUE(snip->OutEchoReps, snic->OutEchoReps, itv),
1358 S_VALUE(snip->InTimestamps, snic->InTimestamps, itv),
1359 S_VALUE(snip->InTimestampReps, snic->InTimestampReps, itv),
1360 S_VALUE(snip->OutTimestamps, snic->OutTimestamps, itv),
1361 S_VALUE(snip->OutTimestampReps, snic->OutTimestampReps, itv),
1362 S_VALUE(snip->InAddrMasks, snic->InAddrMasks, itv),
1363 S_VALUE(snip->InAddrMaskReps, snic->InAddrMaskReps, itv),
1364 S_VALUE(snip->OutAddrMasks, snic->OutAddrMasks, itv),
1365 S_VALUE(snip->OutAddrMaskReps, snic->OutAddrMaskReps, itv));
1370 ***************************************************************************
1371 * Display ICMP network error statistics.
1374 * @a Activity structure with statistics.
1375 * @prev Index in array where stats used as reference are.
1376 * @curr Index in array for current sample statistics.
1377 * @itv Interval of time in jiffies.
1378 ***************************************************************************
1380 __print_funct_t print_net_eicmp_stats(struct activity *a, int prev, int curr,
1381 unsigned long long itv)
1383 struct stats_net_eicmp
1384 *sneic = (struct stats_net_eicmp *) a->buf[curr],
1385 *sneip = (struct stats_net_eicmp *) a->buf[prev];
1388 printf("\n%-11s ierr/s oerr/s idstunr/s odstunr/s itmex/s"
1389 " otmex/s iparmpb/s oparmpb/s isrcq/s osrcq/s"
1390 " iredir/s oredir/s\n", timestamp[!curr]);
1393 printf("%-11s", timestamp[curr]);
1395 S_VALUE(sneip->InErrors, sneic->InErrors, itv),
1396 S_VALUE(sneip->OutErrors, sneic->OutErrors, itv),
1397 S_VALUE(sneip->InDestUnreachs, sneic->InDestUnreachs, itv),
1398 S_VALUE(sneip->OutDestUnreachs, sneic->OutDestUnreachs, itv),
1399 S_VALUE(sneip->InTimeExcds, sneic->InTimeExcds, itv),
1400 S_VALUE(sneip->OutTimeExcds, sneic->OutTimeExcds, itv),
1401 S_VALUE(sneip->InParmProbs, sneic->InParmProbs, itv),
1402 S_VALUE(sneip->OutParmProbs, sneic->OutParmProbs, itv),
1403 S_VALUE(sneip->InSrcQuenchs, sneic->InSrcQuenchs, itv),
1404 S_VALUE(sneip->OutSrcQuenchs, sneic->OutSrcQuenchs, itv),
1405 S_VALUE(sneip->InRedirects, sneic->InRedirects, itv),
1406 S_VALUE(sneip->OutRedirects, sneic->OutRedirects, itv));
1411 ***************************************************************************
1412 * Display TCP network traffic statistics.
1415 * @a Activity structure with statistics.
1416 * @prev Index in array where stats used as reference are.
1417 * @curr Index in array for current sample statistics.
1418 * @itv Interval of time in jiffies.
1419 ***************************************************************************
1421 __print_funct_t print_net_tcp_stats(struct activity *a, int prev, int curr,
1422 unsigned long long itv)
1424 struct stats_net_tcp
1425 *sntc = (struct stats_net_tcp *) a->buf[curr],
1426 *sntp = (struct stats_net_tcp *) a->buf[prev];
1429 printf("\n%-11s active/s passive/s iseg/s oseg/s\n",
1433 printf("%-11s", timestamp[curr]);
1435 S_VALUE(sntp->ActiveOpens, sntc->ActiveOpens, itv),
1436 S_VALUE(sntp->PassiveOpens, sntc->PassiveOpens, itv),
1437 S_VALUE(sntp->InSegs, sntc->InSegs, itv),
1438 S_VALUE(sntp->OutSegs, sntc->OutSegs, itv));
1443 ***************************************************************************
1444 * Display TCP network error statistics.
1447 * @a Activity structure with statistics.
1448 * @prev Index in array where stats used as reference are.
1449 * @curr Index in array for current sample statistics.
1450 * @itv Interval of time in jiffies.
1451 ***************************************************************************
1453 __print_funct_t print_net_etcp_stats(struct activity *a, int prev, int curr,
1454 unsigned long long itv)
1456 struct stats_net_etcp
1457 *snetc = (struct stats_net_etcp *) a->buf[curr],
1458 *snetp = (struct stats_net_etcp *) a->buf[prev];
1461 printf("\n%-11s atmptf/s estres/s retrans/s isegerr/s orsts/s\n",
1465 printf("%-11s", timestamp[curr]);
1467 S_VALUE(snetp->AttemptFails, snetc->AttemptFails, itv),
1468 S_VALUE(snetp->EstabResets, snetc->EstabResets, itv),
1469 S_VALUE(snetp->RetransSegs, snetc->RetransSegs, itv),
1470 S_VALUE(snetp->InErrs, snetc->InErrs, itv),
1471 S_VALUE(snetp->OutRsts, snetc->OutRsts, itv));
1476 ***************************************************************************
1477 * Display UDP network traffic statistics.
1480 * @a Activity structure with statistics.
1481 * @prev Index in array where stats used as reference are.
1482 * @curr Index in array for current sample statistics.
1483 * @itv Interval of time in jiffies.
1484 ***************************************************************************
1486 __print_funct_t print_net_udp_stats(struct activity *a, int prev, int curr,
1487 unsigned long long itv)
1489 struct stats_net_udp
1490 *snuc = (struct stats_net_udp *) a->buf[curr],
1491 *snup = (struct stats_net_udp *) a->buf[prev];
1494 printf("\n%-11s idgm/s odgm/s noport/s idgmerr/s\n",
1498 printf("%-11s", timestamp[curr]);
1500 S_VALUE(snup->InDatagrams, snuc->InDatagrams, itv),
1501 S_VALUE(snup->OutDatagrams, snuc->OutDatagrams, itv),
1502 S_VALUE(snup->NoPorts, snuc->NoPorts, itv),
1503 S_VALUE(snup->InErrors, snuc->InErrors, itv));
1508 ***************************************************************************
1509 * Display IPv6 sockets statistics. This function is used to display
1510 * instantaneous and average statistics.
1513 * @a Activity structure with statistics.
1514 * @curr Index in array for current sample statistics.
1515 * @dispavg TRUE if displaying average statistics.
1516 ***************************************************************************
1518 void stub_print_net_sock6_stats(struct activity *a, int curr, int dispavg)
1520 struct stats_net_sock6
1521 *snsc = (struct stats_net_sock6 *) a->buf[curr];
1522 static unsigned long long
1526 avg_frag6_inuse = 0;
1529 printf("\n%-11s tcp6sck udp6sck raw6sck ip6-frag\n",
1534 /* Display instantaneous values */
1535 printf("%-11s", timestamp[curr]);
1537 (unsigned long long) snsc->tcp6_inuse,
1538 (unsigned long long) snsc->udp6_inuse,
1539 (unsigned long long) snsc->raw6_inuse,
1540 (unsigned long long) snsc->frag6_inuse);
1543 /* Will be used to compute the average */
1544 avg_tcp6_inuse += snsc->tcp6_inuse;
1545 avg_udp6_inuse += snsc->udp6_inuse;
1546 avg_raw6_inuse += snsc->raw6_inuse;
1547 avg_frag6_inuse += snsc->frag6_inuse;
1550 /* Display average values */
1551 printf("%-11s", timestamp[curr]);
1553 (double) avg_tcp6_inuse / avg_count,
1554 (double) avg_udp6_inuse / avg_count,
1555 (double) avg_raw6_inuse / avg_count,
1556 (double) avg_frag6_inuse / avg_count);
1559 /* Reset average counters */
1560 avg_tcp6_inuse = avg_udp6_inuse = avg_raw6_inuse = avg_frag6_inuse = 0;
1565 ***************************************************************************
1566 * Display IPv6 sockets statistics.
1569 * @a Activity structure with statistics.
1570 * @prev Index in array where stats used as reference are.
1571 * @curr Index in array for current sample statistics.
1572 * @itv Interval of time in jiffies.
1573 ***************************************************************************
1575 __print_funct_t print_net_sock6_stats(struct activity *a, int prev, int curr,
1576 unsigned long long itv)
1578 stub_print_net_sock6_stats(a, curr, FALSE);
1582 ***************************************************************************
1583 * Display average IPv6 sockets statistics.
1586 * @a Activity structure with statistics.
1587 * @prev Index in array where stats used as reference are.
1588 * @curr Index in array for current sample statistics.
1589 * @itv Interval of time in jiffies.
1590 ***************************************************************************
1592 __print_funct_t print_avg_net_sock6_stats(struct activity *a, int prev, int curr,
1593 unsigned long long itv)
1595 stub_print_net_sock6_stats(a, curr, TRUE);
1599 ***************************************************************************
1600 * Display IPv6 network traffic statistics.
1603 * @a Activity structure with statistics.
1604 * @prev Index in array where stats used as reference are.
1605 * @curr Index in array for current sample statistics.
1606 * @itv Interval of time in jiffies.
1607 ***************************************************************************
1609 __print_funct_t print_net_ip6_stats(struct activity *a, int prev, int curr,
1610 unsigned long long itv)
1612 struct stats_net_ip6
1613 *snic = (struct stats_net_ip6 *) a->buf[curr],
1614 *snip = (struct stats_net_ip6 *) a->buf[prev];
1617 printf("\n%-11s irec6/s fwddgm6/s idel6/s orq6/s asmrq6/s"
1618 " asmok6/s imcpck6/s omcpck6/s fragok6/s fragcr6/s\n",
1622 printf("%-11s", timestamp[curr]);
1624 S_VALUE(snip->InReceives6, snic->InReceives6, itv),
1625 S_VALUE(snip->OutForwDatagrams6, snic->OutForwDatagrams6, itv),
1626 S_VALUE(snip->InDelivers6, snic->InDelivers6, itv),
1627 S_VALUE(snip->OutRequests6, snic->OutRequests6, itv),
1628 S_VALUE(snip->ReasmReqds6, snic->ReasmReqds6, itv),
1629 S_VALUE(snip->ReasmOKs6, snic->ReasmOKs6, itv),
1630 S_VALUE(snip->InMcastPkts6, snic->InMcastPkts6, itv),
1631 S_VALUE(snip->OutMcastPkts6, snic->OutMcastPkts6, itv),
1632 S_VALUE(snip->FragOKs6, snic->FragOKs6, itv),
1633 S_VALUE(snip->FragCreates6, snic->FragCreates6, itv));
1638 ***************************************************************************
1639 * Display IPv6 network error statistics.
1642 * @a Activity structure with statistics.
1643 * @prev Index in array where stats used as reference are.
1644 * @curr Index in array for current sample statistics.
1645 * @itv Interval of time in jiffies.
1646 ***************************************************************************
1648 __print_funct_t print_net_eip6_stats(struct activity *a, int prev, int curr,
1649 unsigned long long itv)
1651 struct stats_net_eip6
1652 *sneic = (struct stats_net_eip6 *) a->buf[curr],
1653 *sneip = (struct stats_net_eip6 *) a->buf[prev];
1656 printf("\n%-11s ihdrer6/s iadrer6/s iukwnp6/s i2big6/s idisc6/s odisc6/s"
1657 " inort6/s onort6/s asmf6/s fragf6/s itrpck6/s\n",
1661 printf("%-11s", timestamp[curr]);
1663 S_VALUE(sneip->InHdrErrors6, sneic->InHdrErrors6, itv),
1664 S_VALUE(sneip->InAddrErrors6, sneic->InAddrErrors6, itv),
1665 S_VALUE(sneip->InUnknownProtos6, sneic->InUnknownProtos6, itv),
1666 S_VALUE(sneip->InTooBigErrors6, sneic->InTooBigErrors6, itv),
1667 S_VALUE(sneip->InDiscards6, sneic->InDiscards6, itv),
1668 S_VALUE(sneip->OutDiscards6, sneic->OutDiscards6, itv),
1669 S_VALUE(sneip->InNoRoutes6, sneic->InNoRoutes6, itv),
1670 S_VALUE(sneip->OutNoRoutes6, sneic->OutNoRoutes6, itv),
1671 S_VALUE(sneip->ReasmFails6, sneic->ReasmFails6, itv),
1672 S_VALUE(sneip->FragFails6, sneic->FragFails6, itv),
1673 S_VALUE(sneip->InTruncatedPkts6, sneic->InTruncatedPkts6, itv));
1678 ***************************************************************************
1679 * Display ICMPv6 network traffic statistics.
1682 * @a Activity structure with statistics.
1683 * @prev Index in array where stats used as reference are.
1684 * @curr Index in array for current sample statistics.
1685 * @itv Interval of time in jiffies.
1686 ***************************************************************************
1688 __print_funct_t print_net_icmp6_stats(struct activity *a, int prev, int curr,
1689 unsigned long long itv)
1691 struct stats_net_icmp6
1692 *snic = (struct stats_net_icmp6 *) a->buf[curr],
1693 *snip = (struct stats_net_icmp6 *) a->buf[prev];
1696 printf("\n%-11s imsg6/s omsg6/s iech6/s iechr6/s oechr6/s"
1697 " igmbq6/s igmbr6/s ogmbr6/s igmbrd6/s ogmbrd6/s irtsol6/s ortsol6/s"
1698 " irtad6/s inbsol6/s onbsol6/s inbad6/s onbad6/s\n",
1702 printf("%-11s", timestamp[curr]);
1704 S_VALUE(snip->InMsgs6, snic->InMsgs6, itv),
1705 S_VALUE(snip->OutMsgs6, snic->OutMsgs6, itv),
1706 S_VALUE(snip->InEchos6, snic->InEchos6, itv),
1707 S_VALUE(snip->InEchoReplies6, snic->InEchoReplies6, itv),
1708 S_VALUE(snip->OutEchoReplies6, snic->OutEchoReplies6, itv),
1709 S_VALUE(snip->InGroupMembQueries6, snic->InGroupMembQueries6, itv),
1710 S_VALUE(snip->InGroupMembResponses6, snic->InGroupMembResponses6, itv),
1711 S_VALUE(snip->OutGroupMembResponses6, snic->OutGroupMembResponses6, itv),
1712 S_VALUE(snip->InGroupMembReductions6, snic->InGroupMembReductions6, itv),
1713 S_VALUE(snip->OutGroupMembReductions6, snic->OutGroupMembReductions6, itv),
1714 S_VALUE(snip->InRouterSolicits6, snic->InRouterSolicits6, itv),
1715 S_VALUE(snip->OutRouterSolicits6, snic->OutRouterSolicits6, itv),
1716 S_VALUE(snip->InRouterAdvertisements6, snic->InRouterAdvertisements6, itv),
1717 S_VALUE(snip->InNeighborSolicits6, snic->InNeighborSolicits6, itv),
1718 S_VALUE(snip->OutNeighborSolicits6, snic->OutNeighborSolicits6, itv),
1719 S_VALUE(snip->InNeighborAdvertisements6, snic->InNeighborAdvertisements6, itv),
1720 S_VALUE(snip->OutNeighborAdvertisements6, snic->OutNeighborAdvertisements6, itv));
1725 ***************************************************************************
1726 * Display ICMPv6 network error statistics.
1729 * @a Activity structure with statistics.
1730 * @prev Index in array where stats used as reference are.
1731 * @curr Index in array for current sample statistics.
1732 * @itv Interval of time in jiffies.
1733 ***************************************************************************
1735 __print_funct_t print_net_eicmp6_stats(struct activity *a, int prev, int curr,
1736 unsigned long long itv)
1738 struct stats_net_eicmp6
1739 *sneic = (struct stats_net_eicmp6 *) a->buf[curr],
1740 *sneip = (struct stats_net_eicmp6 *) a->buf[prev];
1743 printf("\n%-11s ierr6/s idtunr6/s odtunr6/s itmex6/s otmex6/s"
1744 " iprmpb6/s oprmpb6/s iredir6/s oredir6/s ipck2b6/s opck2b6/s\n",
1748 printf("%-11s", timestamp[curr]);
1750 S_VALUE(sneip->InErrors6, sneic->InErrors6, itv),
1751 S_VALUE(sneip->InDestUnreachs6, sneic->InDestUnreachs6, itv),
1752 S_VALUE(sneip->OutDestUnreachs6, sneic->OutDestUnreachs6, itv),
1753 S_VALUE(sneip->InTimeExcds6, sneic->InTimeExcds6, itv),
1754 S_VALUE(sneip->OutTimeExcds6, sneic->OutTimeExcds6, itv),
1755 S_VALUE(sneip->InParmProblems6, sneic->InParmProblems6, itv),
1756 S_VALUE(sneip->OutParmProblems6, sneic->OutParmProblems6, itv),
1757 S_VALUE(sneip->InRedirects6, sneic->InRedirects6, itv),
1758 S_VALUE(sneip->OutRedirects6, sneic->OutRedirects6, itv),
1759 S_VALUE(sneip->InPktTooBigs6, sneic->InPktTooBigs6, itv),
1760 S_VALUE(sneip->OutPktTooBigs6, sneic->OutPktTooBigs6, itv));
1765 ***************************************************************************
1766 * Display UDPv6 network traffic statistics.
1769 * @a Activity structure with statistics.
1770 * @prev Index in array where stats used as reference are.
1771 * @curr Index in array for current sample statistics.
1772 * @itv Interval of time in jiffies.
1773 ***************************************************************************
1775 __print_funct_t print_net_udp6_stats(struct activity *a, int prev, int curr,
1776 unsigned long long itv)
1778 struct stats_net_udp6
1779 *snuc = (struct stats_net_udp6 *) a->buf[curr],
1780 *snup = (struct stats_net_udp6 *) a->buf[prev];
1783 printf("\n%-11s idgm6/s odgm6/s noport6/s idgmer6/s\n",
1787 printf("%-11s", timestamp[curr]);
1789 S_VALUE(snup->InDatagrams6, snuc->InDatagrams6, itv),
1790 S_VALUE(snup->OutDatagrams6, snuc->OutDatagrams6, itv),
1791 S_VALUE(snup->NoPorts6, snuc->NoPorts6, itv),
1792 S_VALUE(snup->InErrors6, snuc->InErrors6, itv));
1797 ***************************************************************************
1798 * Display CPU frequency statistics. This function is used to display
1799 * instantaneous and average statistics.
1802 * @a Activity structure with statistics.
1803 * @curr Index in array for current sample statistics.
1804 * @dispavg True if displaying average statistics.
1805 ***************************************************************************
1807 void stub_print_pwr_cpufreq_stats(struct activity *a, int curr, int dispavg)
1810 struct stats_pwr_cpufreq *spc;
1811 static unsigned long long
1812 *avg_cpufreq = NULL;
1815 /* Allocate array of CPU frequency */
1816 if ((avg_cpufreq = (unsigned long long *) malloc(sizeof(unsigned long long) * a->nr))
1821 memset(avg_cpufreq, 0, sizeof(unsigned long long) * a->nr);
1825 printf("\n%-11s CPU MHz\n",
1829 for (i = 0; (i < a->nr) && (i < a->bitmap->b_size + 1); i++) {
1832 * The size of a->buf[...] CPU structure may be different from the default
1833 * sizeof(struct stats_pwr_cpufreq) value if data have been read from a file!
1834 * That's why we don't use a syntax like:
1835 * spc = (struct stats_pwr_cpufreq *) a->buf[...] + i;
1837 spc = (struct stats_pwr_cpufreq *) ((char *) a->buf[curr] + i * a->msize);
1840 * Note: a->nr is in [1, NR_CPUS + 1].
1841 * Bitmap size is provided for (NR_CPUS + 1) CPUs.
1842 * Anyway, NR_CPUS may vary between the version of sysstat
1843 * used by sadc to create a file, and the version of sysstat
1844 * used by sar to read it...
1847 /* Should current CPU (including CPU "all") be displayed? */
1848 if (a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))) {
1850 /* Yes: Display it */
1851 printf("%-11s", timestamp[curr]);
1854 /* This is CPU "all" */
1855 cprintf_in(IS_STR, "%s", " all", 0);
1858 cprintf_in(IS_INT, " %3d", "", i - 1);
1862 /* Display instantaneous values */
1864 ((double) spc->cpufreq) / 100);
1867 * Will be used to compute the average.
1868 * Note: overflow unlikely to happen but not impossible...
1870 avg_cpufreq[i] += spc->cpufreq;
1873 /* Display average values */
1875 (double) avg_cpufreq[i] / (100 * avg_count));
1882 /* Array of CPU frequency no longer needed: Free it! */
1891 ***************************************************************************
1892 * Display CPU frequency statistics.
1895 * @a Activity structure with statistics.
1896 * @prev Index in array where stats used as reference are.
1897 * @curr Index in array for current sample statistics.
1898 * @itv Interval of time in jiffies.
1899 ***************************************************************************
1901 __print_funct_t print_pwr_cpufreq_stats(struct activity *a, int prev, int curr,
1902 unsigned long long itv)
1904 stub_print_pwr_cpufreq_stats(a, curr, FALSE);
1908 ***************************************************************************
1909 * Display average CPU frequency statistics.
1912 * @a Activity structure with statistics.
1913 * @prev Index in array where stats used as reference are.
1914 * @curr Index in array for current sample statistics.
1915 * @itv Interval of time in jiffies.
1916 ***************************************************************************
1918 __print_funct_t print_avg_pwr_cpufreq_stats(struct activity *a, int prev, int curr,
1919 unsigned long long itv)
1921 stub_print_pwr_cpufreq_stats(a, curr, TRUE);
1925 ***************************************************************************
1926 * Display fan statistics. This function is used to display
1927 * instantaneous and average statistics.
1930 * @a Activity structure with statistics.
1931 * @curr Index in array for current sample statistics.
1932 * @dispavg True if displaying average statistics.
1933 ***************************************************************************
1935 void stub_print_pwr_fan_stats(struct activity *a, int curr, int dispavg)
1939 struct stats_pwr_fan *spc;
1940 static double *avg_fan = NULL;
1941 static double *avg_fan_min = NULL;
1943 /* Allocate arrays of fan RPMs */
1945 if ((avg_fan = (double *) malloc(sizeof(double) * a->nr)) == NULL) {
1949 memset(avg_fan, 0, sizeof(double) * a->nr);
1952 if ((avg_fan_min = (double *) malloc(sizeof(double) * a->nr)) == NULL) {
1956 memset(avg_fan_min, 0, sizeof(double) * a->nr);
1960 printf("\n%-11s FAN rpm drpm %*s\n",
1961 timestamp[!curr], MAX_SENSORS_DEV_LEN, "DEVICE");
1964 for (i = 0; i < a->nr; i++) {
1965 spc = (struct stats_pwr_fan *) ((char *) a->buf[curr] + i * a->msize);
1967 printf("%-11s", timestamp[curr]);
1968 cprintf_in(IS_INT, " %3d", "", i + 1);
1971 /* Display average values */
1973 (double) avg_fan[i] / avg_count,
1974 (double) (avg_fan[i] - avg_fan_min[i]) / avg_count);
1977 /* Display instantaneous values */
1980 spc->rpm - spc->rpm_min);
1981 avg_fan[i] += spc->rpm;
1982 avg_fan_min[i] += spc->rpm_min;
1985 snprintf(fmt, 16, " %%%ds\n", MAX_SENSORS_DEV_LEN);
1986 cprintf_in(IS_STR, fmt, spc->device, 0);
2002 ***************************************************************************
2003 * Display fan statistics.
2006 * @a Activity structure with statistics.
2007 * @prev Index in array where stats used as reference are.
2008 * @curr Index in array for current sample statistics.
2009 * @itv Interval of time in jiffies.
2010 ***************************************************************************
2012 __print_funct_t print_pwr_fan_stats(struct activity *a, int prev, int curr,
2013 unsigned long long itv)
2015 stub_print_pwr_fan_stats(a, curr, FALSE);
2019 ***************************************************************************
2020 * Display average fan statistics.
2023 * @a Activity structure with statistics.
2024 * @prev Index in array where stats used as reference are.
2025 * @curr Index in array for current sample statistics.
2026 * @itv Interval of time in jiffies.
2027 ***************************************************************************
2029 __print_funct_t print_avg_pwr_fan_stats(struct activity *a, int prev, int curr,
2030 unsigned long long itv)
2032 stub_print_pwr_fan_stats(a, curr, TRUE);
2036 ***************************************************************************
2037 * Display device temperature statistics. This function is used to display
2038 * instantaneous and average statistics.
2041 * @a Activity structure with statistics.
2042 * @curr Index in array for current sample statistics.
2043 * @dispavg True if displaying average statistics.
2044 ***************************************************************************
2046 void stub_print_pwr_temp_stats(struct activity *a, int curr, int dispavg)
2050 struct stats_pwr_temp *spc;
2051 static double *avg_temp = NULL;
2052 static double *avg_temp_min = NULL, *avg_temp_max = NULL;
2054 /* Allocate arrays of temperatures */
2056 if ((avg_temp = (double *) malloc(sizeof(double) * a->nr)) == NULL) {
2060 memset(avg_temp, 0, sizeof(double) * a->nr);
2062 if (!avg_temp_min) {
2063 if ((avg_temp_min = (double *) malloc(sizeof(double) * a->nr)) == NULL) {
2067 memset(avg_temp_min, 0, sizeof(double) * a->nr);
2069 if (!avg_temp_max) {
2070 if ((avg_temp_max = (double *) malloc(sizeof(double) * a->nr)) == NULL) {
2074 memset(avg_temp_max, 0, sizeof(double) * a->nr);
2078 printf("\n%-11s TEMP degC %%temp %*s\n",
2079 timestamp[!curr], MAX_SENSORS_DEV_LEN, "DEVICE");
2082 for (i = 0; i < a->nr; i++) {
2083 spc = (struct stats_pwr_temp *) ((char *) a->buf[curr] + i * a->msize);
2085 printf("%-11s", timestamp[curr]);
2086 cprintf_in(IS_INT, " %3d", "", i + 1);
2089 /* Display average values */
2090 cprintf_f(1, 9, 2, (double) avg_temp[i] / avg_count);
2092 (avg_temp_max[i] - avg_temp_min[i]) ?
2093 ((double) (avg_temp[i] / avg_count) - avg_temp_min[i]) / (avg_temp_max[i] - avg_temp_min[i]) * 100
2097 /* Display instantaneous values */
2098 cprintf_f(1, 9, 2, spc->temp);
2100 (spc->temp_max - spc->temp_min) ?
2101 (spc->temp - spc->temp_min) / (spc->temp_max - spc->temp_min) * 100
2103 avg_temp[i] += spc->temp;
2104 /* Assume that min and max temperatures cannot vary */
2105 avg_temp_min[i] = spc->temp_min;
2106 avg_temp_max[i] = spc->temp_max;
2109 snprintf(fmt, 16, " %%%ds\n", MAX_SENSORS_DEV_LEN);
2110 cprintf_in(IS_STR, fmt, spc->device, 0);
2120 avg_temp_min = NULL;
2124 avg_temp_max = NULL;
2130 ***************************************************************************
2131 * Display temperature statistics.
2134 * @a Activity structure with statistics.
2135 * @prev Index in array where stats used as reference are.
2136 * @curr Index in array for current sample statistics.
2137 * @itv Interval of time in jiffies.
2138 ***************************************************************************
2140 __print_funct_t print_pwr_temp_stats(struct activity *a, int prev, int curr,
2141 unsigned long long itv)
2143 stub_print_pwr_temp_stats(a, curr, FALSE);
2147 ***************************************************************************
2148 * Display average temperature statistics.
2151 * @a Activity structure with statistics.
2152 * @prev Index in array where stats used as reference are.
2153 * @curr Index in array for current sample statistics.
2154 * @itv Interval of time in jiffies.
2155 ***************************************************************************
2157 __print_funct_t print_avg_pwr_temp_stats(struct activity *a, int prev, int curr,
2158 unsigned long long itv)
2160 stub_print_pwr_temp_stats(a, curr, TRUE);
2164 ***************************************************************************
2165 * Display voltage inputs statistics. This function is used to display
2166 * instantaneous and average statistics.
2169 * @a Activity structure with statistics.
2170 * @curr Index in array for current sample statistics.
2171 * @dispavg True if displaying average statistics.
2172 ***************************************************************************
2174 void stub_print_pwr_in_stats(struct activity *a, int curr, int dispavg)
2178 struct stats_pwr_in *spc;
2179 static double *avg_in = NULL;
2180 static double *avg_in_min = NULL, *avg_in_max = NULL;
2182 /* Allocate arrays of voltage inputs */
2184 if ((avg_in = (double *) malloc(sizeof(double) * a->nr)) == NULL) {
2188 memset(avg_in, 0, sizeof(double) * a->nr);
2191 if ((avg_in_min = (double *) malloc(sizeof(double) * a->nr)) == NULL) {
2195 memset(avg_in_min, 0, sizeof(double) * a->nr);
2198 if ((avg_in_max = (double *) malloc(sizeof(double) * a->nr)) == NULL) {
2202 memset(avg_in_max, 0, sizeof(double) * a->nr);
2206 printf("\n%-11s IN inV %%in %*s\n",
2207 timestamp[!curr], MAX_SENSORS_DEV_LEN, "DEVICE");
2210 for (i = 0; i < a->nr; i++) {
2211 spc = (struct stats_pwr_in *) ((char *) a->buf[curr] + i * a->msize);
2213 printf("%-11s", timestamp[curr]);
2214 cprintf_in(IS_INT, " %3d", "", i);
2217 /* Display average values */
2218 cprintf_f(1, 9, 2, (double) avg_in[i] / avg_count);
2220 (avg_in_max[i] - avg_in_min[i]) ?
2221 ((double) (avg_in[i] / avg_count) - avg_in_min[i]) / (avg_in_max[i] - avg_in_min[i]) * 100
2225 /* Display instantaneous values */
2226 cprintf_f(1, 9, 2, spc->in);
2228 (spc->in_max - spc->in_min) ?
2229 (spc->in - spc->in_min) / (spc->in_max - spc->in_min) * 100
2231 avg_in[i] += spc->in;
2232 /* Assume that min and max voltage inputs cannot vary */
2233 avg_in_min[i] = spc->in_min;
2234 avg_in_max[i] = spc->in_max;
2237 snprintf(fmt, 16, " %%%ds\n", MAX_SENSORS_DEV_LEN);
2238 cprintf_in(IS_STR, fmt, spc->device, 0);
2258 ***************************************************************************
2259 * Display voltage inputs statistics.
2262 * @a Activity structure with statistics.
2263 * @prev Index in array where stats used as reference are.
2264 * @curr Index in array for current sample statistics.
2265 * @itv Interval of time in jiffies.
2266 ***************************************************************************
2268 __print_funct_t print_pwr_in_stats(struct activity *a, int prev, int curr,
2269 unsigned long long itv)
2271 stub_print_pwr_in_stats(a, curr, FALSE);
2275 ***************************************************************************
2276 * Display average voltage inputs statistics.
2279 * @a Activity structure with statistics.
2280 * @prev Index in array where stats used as reference are.
2281 * @curr Index in array for current sample statistics.
2282 * @itv Interval of time in jiffies.
2283 ***************************************************************************
2285 __print_funct_t print_avg_pwr_in_stats(struct activity *a, int prev, int curr,
2286 unsigned long long itv)
2288 stub_print_pwr_in_stats(a, curr, TRUE);
2292 ***************************************************************************
2293 * Display huge pages statistics. This function is used to
2294 * display instantaneous and average statistics.
2297 * @a Activity structure with statistics.
2298 * @curr Index in array for current sample statistics.
2299 * @dispavg TRUE if displaying average statistics.
2300 ***************************************************************************
2302 void stub_print_huge_stats(struct activity *a, int curr, int dispavg)
2305 *smc = (struct stats_huge *) a->buf[curr];
2306 static unsigned long long
2311 printf("\n%-11s kbhugfree kbhugused %%hugused\n",
2316 /* Display instantaneous values */
2317 printf("%-11s", timestamp[curr]);
2319 (unsigned long long) smc->frhkb,
2320 (unsigned long long) (smc->tlhkb - smc->frhkb));
2323 SP_VALUE(smc->frhkb, smc->tlhkb, smc->tlhkb) : 0.0);
2326 /* Will be used to compute the average */
2327 avg_frhkb += smc->frhkb;
2328 avg_tlhkb += smc->tlhkb;
2331 /* Display average values */
2332 printf("%-11s", timestamp[curr]);
2334 (double) avg_frhkb / avg_count,
2335 ((double) avg_tlhkb / avg_count) -
2336 ((double) avg_frhkb / avg_count));
2339 SP_VALUE((double) avg_frhkb / avg_count,
2340 (double) avg_tlhkb / avg_count,
2341 (double) avg_tlhkb / avg_count) : 0.0);
2344 /* Reset average counters */
2345 avg_frhkb = avg_tlhkb = 0;
2350 ***************************************************************************
2351 * Display huge pages statistics.
2354 * @a Activity structure with statistics.
2355 * @prev Index in array where stats used as reference are.
2356 * @curr Index in array for current sample statistics.
2357 * @itv Interval of time in jiffies.
2358 ***************************************************************************
2360 __print_funct_t print_huge_stats(struct activity *a, int prev, int curr,
2361 unsigned long long itv)
2363 stub_print_huge_stats(a, curr, FALSE);
2367 ***************************************************************************
2368 * Display huge pages statistics.
2371 * @a Activity structure with statistics.
2372 * @prev Index in array where stats used as reference are.
2373 * @curr Index in array for current sample statistics.
2374 * @itv Interval of time in jiffies.
2375 ***************************************************************************
2377 __print_funct_t print_avg_huge_stats(struct activity *a, int prev, int curr,
2378 unsigned long long itv)
2380 stub_print_huge_stats(a, curr, TRUE);
2384 ***************************************************************************
2385 * Display CPU weighted frequency statistics. This function is used to
2386 * display instantaneous and average statistics.
2389 * @a Activity structure with statistics.
2390 * @prev Index in array where stats used as reference are.
2391 * @curr Index in array for current sample statistics.
2392 * @itv Interval of time in jiffies.
2393 ***************************************************************************
2395 void print_pwr_wghfreq_stats(struct activity *a, int prev, int curr,
2396 unsigned long long itv)
2399 struct stats_pwr_wghfreq *spc, *spp, *spc_k, *spp_k;
2400 unsigned long long tis, tisfreq;
2403 printf("\n%-11s CPU wghMHz\n",
2407 for (i = 0; (i < a->nr) && (i < a->bitmap->b_size + 1); i++) {
2410 * The size of a->buf[...] CPU structure may be different from the default
2411 * sizeof(struct stats_pwr_wghfreq) value if data have been read from a file!
2412 * That's why we don't use a syntax like:
2413 * spc = (struct stats_pwr_wghfreq *) a->buf[...] + i;
2415 spc = (struct stats_pwr_wghfreq *) ((char *) a->buf[curr] + i * a->msize * a->nr2);
2416 spp = (struct stats_pwr_wghfreq *) ((char *) a->buf[prev] + i * a->msize * a->nr2);
2419 * Note: a->nr is in [1, NR_CPUS + 1].
2420 * Bitmap size is provided for (NR_CPUS + 1) CPUs.
2421 * Anyway, NR_CPUS may vary between the version of sysstat
2422 * used by sadc to create a file, and the version of sysstat
2423 * used by sar to read it...
2426 /* Should current CPU (including CPU "all") be displayed? */
2427 if (a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))) {
2429 /* Yes: Display it */
2430 printf("%-11s", timestamp[curr]);
2433 /* This is CPU "all" */
2434 cprintf_in(IS_STR, "%s", " all", 0);
2437 cprintf_in(IS_INT, " %3d", "", i - 1);
2443 for (k = 0; k < a->nr2; k++) {
2445 spc_k = (struct stats_pwr_wghfreq *) ((char *) spc + k * a->msize);
2448 spp_k = (struct stats_pwr_wghfreq *) ((char *) spp + k * a->msize);
2450 tisfreq += (spc_k->freq / 1000) *
2451 (spc_k->time_in_state - spp_k->time_in_state);
2452 tis += (spc_k->time_in_state - spp_k->time_in_state);
2455 /* Display weighted frequency for current CPU */
2457 tis ? ((double) tisfreq) / tis : 0.0);
2464 ***************************************************************************
2465 * Display USB devices statistics. This function is used to
2466 * display instantaneous and summary statistics.
2469 * @a Activity structure with statistics.
2470 * @curr Index in array for current sample statistics.
2471 * @itv Interval of time in jiffies.
2472 * @dispavg TRUE if displaying average statistics.
2473 ***************************************************************************
2475 void stub_print_pwr_usb_stats(struct activity *a, int curr, int dispavg)
2479 struct stats_pwr_usb *suc, *sum;
2482 printf("\n%-11s BUS idvendor idprod maxpower",
2483 (dispavg ? _("Summary:") : timestamp[!curr]));
2484 printf(" %*s", MAX_MANUF_LEN - 1, "manufact");
2485 printf(" %*s\n", MAX_PROD_LEN - 1, "product");
2488 for (i = 0; i < a->nr; i++) {
2489 suc = (struct stats_pwr_usb *) ((char *) a->buf[curr] + i * a->msize);
2492 /* Bus#0 doesn't exist: We are at the end of the list */
2495 printf("%-11s", (dispavg ? _("Summary:") : timestamp[curr]));
2496 cprintf_in(IS_INT, " %6d", "", suc->bus_nr);
2501 /* bMaxPower is expressed in 2 mA units */
2502 (unsigned long long) (suc->bmaxpower << 1));
2504 snprintf(fmt, 16, " %%%ds", MAX_MANUF_LEN - 1);
2505 cprintf_s(IS_STR, fmt, suc->manufacturer);
2506 snprintf(fmt, 16, " %%%ds\n", MAX_PROD_LEN - 1);
2507 cprintf_s(IS_STR, fmt, suc->product);
2510 /* Save current USB device in summary list */
2511 for (j = 0; j < a->nr; j++) {
2512 sum = (struct stats_pwr_usb *) ((char *) a->buf[2] + j * a->msize);
2514 if ((sum->bus_nr == suc->bus_nr) &&
2515 (sum->vendor_id == suc->vendor_id) &&
2516 (sum->product_id == suc->product_id))
2517 /* USB device found in summary list */
2521 * Current slot is free:
2522 * Save USB device in summary list.
2527 if (j == a->nr - 1) {
2529 * This is the last slot and
2530 * we still havent't found the device.
2531 * So create a dummy device here.
2534 sum->vendor_id = sum->product_id = 0;
2536 sum->manufacturer[0] = '\0';
2537 snprintf(sum->product, MAX_PROD_LEN, "%s",
2538 _("Other devices not listed here"));
2539 sum->product[MAX_PROD_LEN - 1] = '\0';
2547 ***************************************************************************
2548 * Display USB devices statistics.
2551 * @a Activity structure with statistics.
2552 * @prev Index in array where stats used as reference are.
2553 * @curr Index in array for current sample statistics.
2554 * @itv Interval of time in jiffies.
2555 ***************************************************************************
2557 __print_funct_t print_pwr_usb_stats(struct activity *a, int prev, int curr,
2558 unsigned long long itv)
2560 stub_print_pwr_usb_stats(a, curr, FALSE);
2564 ***************************************************************************
2565 * Display average USB devices statistics.
2568 * @a Activity structure with statistics.
2569 * @prev Index in array where stats used as reference are.
2570 * @curr Index in array for current sample statistics.
2571 * @itv Interval of time in jiffies.
2572 ***************************************************************************
2574 __print_funct_t print_avg_pwr_usb_stats(struct activity *a, int prev, int curr,
2575 unsigned long long itv)
2577 stub_print_pwr_usb_stats(a, 2, TRUE);
2581 ***************************************************************************
2582 * Display filesystems statistics. This function is used to
2583 * display instantaneous and average statistics.
2586 * @a Activity structure with statistics.
2587 * @curr Index in array for current sample statistics.
2588 * @dispavg TRUE if displaying average statistics.
2589 ***************************************************************************
2591 __print_funct_t stub_print_filesystem_stats(struct activity *a, int curr, int dispavg)
2594 struct stats_filesystem *sfc, *sfm;
2597 printf("\n%-11s MBfsfree MBfsused %%fsused %%ufsused"
2598 " Ifree Iused %%Iused %s\n",
2599 (dispavg ? _("Summary:") : timestamp[!curr]),
2600 DISPLAY_MOUNT(a->opt_flags) ? "MOUNTPOINT" : "FILESYSTEM");
2603 for (i = 0; i < a->nr; i++) {
2604 sfc = (struct stats_filesystem *) ((char *) a->buf[curr] + i * a->msize);
2607 /* Size of filesystem is null: We are at the end of the list */
2610 printf("%-11s", (dispavg ? _("Summary:") : timestamp[curr]));
2612 (double) sfc->f_bfree / 1024 / 1024,
2613 (double) (sfc->f_blocks - sfc->f_bfree) / 1024 / 1024);
2615 /* f_blocks is not null. But test it anyway ;-) */
2616 sfc->f_blocks ? SP_VALUE(sfc->f_bfree, sfc->f_blocks, sfc->f_blocks)
2618 sfc->f_blocks ? SP_VALUE(sfc->f_bavail, sfc->f_blocks, sfc->f_blocks)
2621 (unsigned long long) sfc->f_ffree,
2622 (unsigned long long) (sfc->f_files - sfc->f_ffree));
2624 sfc->f_files ? SP_VALUE(sfc->f_ffree, sfc->f_files, sfc->f_files)
2626 cprintf_in(IS_STR, " %s\n",
2627 DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name, 0);
2630 /* Save current filesystem in summary list */
2631 for (j = 0; j < a->nr; j++) {
2632 sfm = (struct stats_filesystem *) ((char *) a->buf[2] + j * a->msize);
2634 if (!strcmp(sfm->fs_name, sfc->fs_name) ||
2637 * Filesystem found in list (then save again its stats)
2638 * or free slot (end of list).
2649 ***************************************************************************
2650 * Display filesystems statistics.
2653 * @a Activity structure with statistics.
2654 * @prev Index in array where stats used as reference are.
2655 * @curr Index in array for current sample statistics.
2656 * @itv Interval of time in jiffies.
2657 ***************************************************************************
2659 __print_funct_t print_filesystem_stats(struct activity *a, int prev, int curr,
2660 unsigned long long itv)
2662 stub_print_filesystem_stats(a, curr, FALSE);
2666 ***************************************************************************
2667 * Display average filesystems statistics.
2670 * @a Activity structure with statistics.
2671 * @prev Index in array where stats used as reference are.
2672 * @curr Index in array for current sample statistics.
2673 * @itv Interval of time in jiffies.
2674 ***************************************************************************
2676 __print_funct_t print_avg_filesystem_stats(struct activity *a, int prev, int curr,
2677 unsigned long long itv)
2679 stub_print_filesystem_stats(a, 2, TRUE);
2683 ***************************************************************************
2684 * Display Fibre Channel HBA statistics.
2687 * @a Activity structure with statistics.
2688 * @prev Index in array where stats used as reference are.
2689 * @curr Index in array for current sample statistics.
2690 * @itv Interval of time in jiffies.
2691 ***************************************************************************
2693 __print_funct_t print_fchost_stats(struct activity *a, int prev, int curr,
2694 unsigned long long itv)
2697 struct stats_fchost *sfcc,*sfcp;
2700 printf("\n%-11s fch_rxf/s fch_txf/s fch_rxw/s fch_txw/s FCHOST\n",
2704 for (i = 0; i < a->nr; i++) {
2706 sfcc = (struct stats_fchost *) ((char *) a->buf[curr] + i * a->msize);
2707 sfcp = (struct stats_fchost *) ((char *) a->buf[prev] + i * a->msize);
2709 if (!sfcc->fchost_name[0])
2710 /* We are at the end of the list */
2713 printf("%-11s", timestamp[curr]);
2715 S_VALUE(sfcp->f_rxframes, sfcc->f_rxframes, itv),
2716 S_VALUE(sfcp->f_txframes, sfcc->f_txframes, itv),
2717 S_VALUE(sfcp->f_rxwords, sfcc->f_rxwords, itv),
2718 S_VALUE(sfcp->f_txwords, sfcc->f_txwords, itv));
2719 cprintf_in(IS_STR, " %s\n", sfcc->fchost_name, 0);