2 * pr_stats.c: Functions used by sar to display statistics
3 * (C) 1999-2010 by Sebastien GODARD (sysstat <at> orange.fr)
5 ***************************************************************************
6 * This program is free software; you can redistribute it and/or modify it *
7 * under the terms of the GNU General Public License as published by the *
8 * Free Software Foundation; either version 2 of the License, or (at your *
9 * option) any later version. *
11 * This program is distributed in the hope that it will be useful, but *
12 * WITHOUT ANY WARRANTY; without the implied warranty of MERCHANTABILITY *
13 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License *
16 * You should have received a copy of the GNU General Public License along *
17 * with this program; if not, write to the Free Software Foundation, Inc., *
18 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
19 ***************************************************************************
34 #define _(string) gettext(string)
36 #define _(string) (string)
39 extern unsigned int flags;
40 extern unsigned int dm_major;
42 extern char timestamp[][TIMESTAMP_LEN];
43 extern unsigned long avg_count;
46 ***************************************************************************
47 * Display CPU statistics.
50 * @a Activity structure with statistics.
51 * @prev Index in array where stats used as reference are.
52 * @curr Index in array for current sample statistics.
53 * @g_itv Interval of time in jiffies multiplied by the number
55 ***************************************************************************
57 __print_funct_t print_cpu_stats(struct activity *a, int prev, int curr,
58 unsigned long long g_itv)
61 struct stats_cpu *scc, *scp;
64 if (DISPLAY_CPU_DEF(a->opt_flags)) {
65 printf("\n%-11s CPU %%user %%nice %%system"
66 " %%iowait %%steal %%idle\n",
69 else if (DISPLAY_CPU_ALL(a->opt_flags)) {
70 printf("\n%-11s CPU %%usr %%nice %%sys"
71 " %%iowait %%steal %%irq %%soft"
77 for (i = 0; (i < a->nr) && (i < a->bitmap->b_size + 1); i++) {
80 * The size of a->buf[...] CPU structure may be different from the default
81 * sizeof(struct stats_cpu) value if data have been read from a file!
82 * That's why we don't use a syntax like:
83 * scc = (struct stats_cpu *) a->buf[...] + i;
85 scc = (struct stats_cpu *) ((char *) a->buf[curr] + i * a->msize);
86 scp = (struct stats_cpu *) ((char *) a->buf[prev] + i * a->msize);
89 * Note: a->nr is in [1, NR_CPUS + 1].
90 * Bitmap size is provided for (NR_CPUS + 1) CPUs.
91 * Anyway, NR_CPUS may vary between the version of sysstat
92 * used by sadc to create a file, and the version of sysstat
93 * used by sar to read it...
96 /* Should current CPU (including CPU "all") be displayed? */
97 if (a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))) {
100 printf("%-11s", timestamp[curr]);
103 /* This is CPU "all" */
107 printf(" %3d", i - 1);
110 * If the CPU is offline then it is omited from /proc/stat:
111 * All the fields couldn't have been read and the sum of them is zero.
112 * (Remember that guest time is already included in user mode.)
114 if ((scc->cpu_user + scc->cpu_nice + scc->cpu_sys +
115 scc->cpu_iowait + scc->cpu_idle + scc->cpu_steal +
116 scc->cpu_hardirq + scc->cpu_softirq) == 0) {
118 * Set current struct fields (which have been set to zero)
119 * to values from previous iteration. Hence their values won't
120 * jump from zero when the CPU comes back online.
124 printf(" %6.2f %6.2f %6.2f"
125 " %6.2f %6.2f %6.2f",
126 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
128 if (DISPLAY_CPU_ALL(a->opt_flags)) {
129 printf(" %6.2f %6.2f %6.2f",
136 /* Recalculate interval for current proc */
137 g_itv = get_per_cpu_interval(scc, scp);
141 * If the CPU is tickless then there is no change in CPU values
142 * but the sum of values is not zero.
144 printf(" %6.2f %6.2f %6.2f"
146 0.0, 0.0, 0.0, 0.0, 0.0);
148 if (DISPLAY_CPU_DEF(a->opt_flags)) {
149 printf(" %6.2f\n", 100.0);
151 else if (DISPLAY_CPU_ALL(a->opt_flags)) {
152 printf(" %6.2f %6.2f %6.2f %6.2f\n",
153 0.0, 0.0, 0.0, 100.0);
159 if (DISPLAY_CPU_DEF(a->opt_flags)) {
160 printf(" %6.2f %6.2f %6.2f %6.2f %6.2f %6.2f\n",
161 ll_sp_value(scp->cpu_user, scc->cpu_user, g_itv),
162 ll_sp_value(scp->cpu_nice, scc->cpu_nice, g_itv),
163 ll_sp_value(scp->cpu_sys + scp->cpu_hardirq + scp->cpu_softirq,
164 scc->cpu_sys + scc->cpu_hardirq + scc->cpu_softirq,
166 ll_sp_value(scp->cpu_iowait, scc->cpu_iowait, g_itv),
167 ll_sp_value(scp->cpu_steal, scc->cpu_steal, g_itv),
168 scc->cpu_idle < scp->cpu_idle ?
170 ll_sp_value(scp->cpu_idle, scc->cpu_idle, g_itv));
172 else if (DISPLAY_CPU_ALL(a->opt_flags)) {
173 printf(" %6.2f %6.2f %6.2f %6.2f %6.2f %6.2f"
174 " %6.2f %6.2f %6.2f\n",
175 (scc->cpu_user - scc->cpu_guest) < (scp->cpu_user - scp->cpu_guest) ?
177 ll_sp_value(scp->cpu_user - scp->cpu_guest,
178 scc->cpu_user - scc->cpu_guest, g_itv),
179 ll_sp_value(scp->cpu_nice, scc->cpu_nice, g_itv),
180 ll_sp_value(scp->cpu_sys, scc->cpu_sys, g_itv),
181 ll_sp_value(scp->cpu_iowait, scc->cpu_iowait, g_itv),
182 ll_sp_value(scp->cpu_steal, scc->cpu_steal, g_itv),
183 ll_sp_value(scp->cpu_hardirq, scc->cpu_hardirq, g_itv),
184 ll_sp_value(scp->cpu_softirq, scc->cpu_softirq, g_itv),
185 ll_sp_value(scp->cpu_guest, scc->cpu_guest, g_itv),
186 scc->cpu_idle < scp->cpu_idle ?
188 ll_sp_value(scp->cpu_idle, scc->cpu_idle, g_itv));
195 ***************************************************************************
196 * Display tasks creation and context switches statistics.
199 * @a Activity structure with statistics.
200 * @prev Index in array where stats used as reference are.
201 * @curr Index in array for current sample statistics.
202 * @itv Interval of time in jiffies.
203 ***************************************************************************
205 __print_funct_t print_pcsw_stats(struct activity *a, int prev, int curr,
206 unsigned long long itv)
209 *spc = (struct stats_pcsw *) a->buf[curr],
210 *spp = (struct stats_pcsw *) a->buf[prev];
213 printf("\n%-11s proc/s cswch/s\n", timestamp[!curr]);
216 printf("%-11s %9.2f %9.2f\n", timestamp[curr],
217 S_VALUE (spp->processes, spc->processes, itv),
218 ll_s_value(spp->context_switch, spc->context_switch, itv));
222 ***************************************************************************
223 * Display interrupts statistics.
226 * @a Activity structure with statistics.
227 * @prev Index in array where stats used as reference are.
228 * @curr Index in array for current sample statistics.
229 * @itv Interval of time in jiffies.
230 ***************************************************************************
232 __print_funct_t print_irq_stats(struct activity *a, int prev, int curr,
233 unsigned long long itv)
236 struct stats_irq *sic, *sip;
239 printf("\n%-11s INTR intr/s\n", timestamp[!curr]);
242 for (i = 0; (i < a->nr) && (i < a->bitmap->b_size + 1); i++) {
244 sic = (struct stats_irq *) ((char *) a->buf[curr] + i * a->msize);
245 sip = (struct stats_irq *) ((char *) a->buf[prev] + i * a->msize);
248 * Note: a->nr is in [0, NR_IRQS + 1].
249 * Bitmap size is provided for (NR_IRQS + 1) interrupts.
250 * Anyway, NR_IRQS may vary between the version of sysstat
251 * used by sadc to create a file, and the version of sysstat
252 * used by sar to read it...
255 /* Should current interrupt (including int "sum") be displayed? */
256 if (a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))) {
258 /* Yes: Display it */
259 printf("%-11s", timestamp[curr]);
261 /* This is interrupt "sum" */
265 printf(" %3d", i - 1);
269 ll_s_value(sip->irq_nr, sic->irq_nr, itv));
275 ***************************************************************************
276 * Display swapping statistics.
279 * @a Activity structure with statistics.
280 * @prev Index in array where stats used as reference are.
281 * @curr Index in array for current sample statistics.
282 * @itv Interval of time in jiffies.
283 ***************************************************************************
285 __print_funct_t print_swap_stats(struct activity *a, int prev, int curr,
286 unsigned long long itv)
289 *ssc = (struct stats_swap *) a->buf[curr],
290 *ssp = (struct stats_swap *) a->buf[prev];
293 printf("\n%-11s pswpin/s pswpout/s\n", timestamp[!curr]);
296 printf("%-11s %9.2f %9.2f\n", timestamp[curr],
297 S_VALUE(ssp->pswpin, ssc->pswpin, itv),
298 S_VALUE(ssp->pswpout, ssc->pswpout, itv));
302 ***************************************************************************
303 * Display paging statistics.
306 * @a Activity structure with statistics.
307 * @prev Index in array where stats used as reference are.
308 * @curr Index in array for current sample statistics.
309 * @itv Interval of time in jiffies.
310 ***************************************************************************
312 __print_funct_t print_paging_stats(struct activity *a, int prev, int curr,
313 unsigned long long itv)
316 *spc = (struct stats_paging *) a->buf[curr],
317 *spp = (struct stats_paging *) a->buf[prev];
320 printf("\n%-11s pgpgin/s pgpgout/s fault/s majflt/s pgfree/s"
321 " pgscank/s pgscand/s pgsteal/s %%vmeff\n",
325 printf("%-11s %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f\n",
327 S_VALUE(spp->pgpgin, spc->pgpgin, itv),
328 S_VALUE(spp->pgpgout, spc->pgpgout, itv),
329 S_VALUE(spp->pgfault, spc->pgfault, itv),
330 S_VALUE(spp->pgmajfault, spc->pgmajfault, itv),
331 S_VALUE(spp->pgfree, spc->pgfree, itv),
332 S_VALUE(spp->pgscan_kswapd, spc->pgscan_kswapd, itv),
333 S_VALUE(spp->pgscan_direct, spc->pgscan_direct, itv),
334 S_VALUE(spp->pgsteal, spc->pgsteal, itv),
335 (spc->pgscan_kswapd + spc->pgscan_direct -
336 spp->pgscan_kswapd - spp->pgscan_direct) ?
337 SP_VALUE(spp->pgsteal, spc->pgsteal,
338 spc->pgscan_kswapd + spc->pgscan_direct -
339 spp->pgscan_kswapd - spp->pgscan_direct) : 0.0);
343 ***************************************************************************
344 * Display I/O and transfer rate statistics.
347 * @a Activity structure with statistics.
348 * @prev Index in array where stats used as reference are.
349 * @curr Index in array for current sample statistics.
350 * @itv Interval of time in jiffies.
351 ***************************************************************************
353 __print_funct_t print_io_stats(struct activity *a, int prev, int curr,
354 unsigned long long itv)
357 *sic = (struct stats_io *) a->buf[curr],
358 *sip = (struct stats_io *) a->buf[prev];
361 printf("\n%-11s tps rtps wtps bread/s bwrtn/s\n",
365 printf("%-11s %9.2f %9.2f %9.2f %9.2f %9.2f\n", timestamp[curr],
366 S_VALUE(sip->dk_drive, sic->dk_drive, itv),
367 S_VALUE(sip->dk_drive_rio, sic->dk_drive_rio, itv),
368 S_VALUE(sip->dk_drive_wio, sic->dk_drive_wio, itv),
369 S_VALUE(sip->dk_drive_rblk, sic->dk_drive_rblk, itv),
370 S_VALUE(sip->dk_drive_wblk, sic->dk_drive_wblk, itv));
374 ***************************************************************************
375 * Display memory and swap statistics. This function is used to
376 * display instantaneous and average statistics.
379 * @a Activity structure with statistics.
380 * @prev Index in array where stats used as reference are.
381 * @curr Index in array for current sample statistics.
382 * @itv Interval of time in jiffies.
383 * @dispavg TRUE if displaying average statistics.
384 ***************************************************************************
386 void stub_print_memory_stats(struct activity *a, int prev, int curr,
387 unsigned long long itv, int dispavg)
390 *smc = (struct stats_memory *) a->buf[curr],
391 *smp = (struct stats_memory *) a->buf[prev];
392 static unsigned long long
397 static unsigned long long
402 if (DISPLAY_MEMORY(a->opt_flags)) {
404 printf("\n%-11s frmpg/s bufpg/s campg/s\n",
408 printf("%-11s %9.2f %9.2f %9.2f\n", timestamp[curr],
409 S_VALUE((double) KB_TO_PG(smp->frmkb), (double) KB_TO_PG(smc->frmkb), itv),
410 S_VALUE((double) KB_TO_PG(smp->bufkb), (double) KB_TO_PG(smc->bufkb), itv),
411 S_VALUE((double) KB_TO_PG(smp->camkb), (double) KB_TO_PG(smc->camkb), itv));
414 if (DISPLAY_MEM_AMT(a->opt_flags)) {
416 printf("\n%-11s kbmemfree kbmemused %%memused kbbuffers kbcached"
417 " kbcommit %%commit\n", timestamp[!curr]);
421 /* Display instantaneous values */
422 printf("%-11s %9lu %9lu %6.2f %9lu %9lu %9lu %7.2f\n",
425 smc->tlmkb - smc->frmkb,
427 SP_VALUE(smc->frmkb, smc->tlmkb, smc->tlmkb) : 0.0,
431 (smc->tlmkb + smc->tlskb) ?
432 SP_VALUE(0, smc->comkb, smc->tlmkb + smc->tlskb) : 0.0);
435 * Will be used to compute the average.
436 * We assume that the total amount of memory installed can not vary
437 * during the interval given on the command line.
439 avg_frmkb += smc->frmkb;
440 avg_bufkb += smc->bufkb;
441 avg_camkb += smc->camkb;
442 avg_comkb += smc->comkb;
445 /* Display average values */
446 printf("%-11s %9.0f %9.0f %6.2f %9.0f %9.0f %9.0f %7.2f\n",
448 (double) avg_frmkb / avg_count,
449 (double) smc->tlmkb - ((double) avg_frmkb / avg_count),
451 SP_VALUE((double) (avg_frmkb / avg_count), smc->tlmkb,
454 (double) avg_bufkb / avg_count,
455 (double) avg_camkb / avg_count,
456 (double) avg_comkb / avg_count,
457 (smc->tlmkb + smc->tlskb) ?
458 SP_VALUE(0.0, (double) (avg_comkb / avg_count),
459 smc->tlmkb + smc->tlskb) :
462 /* Reset average counters */
463 avg_frmkb = avg_bufkb = avg_camkb = avg_comkb = 0;
467 if (DISPLAY_SWAP(a->opt_flags)) {
469 printf("\n%-11s kbswpfree kbswpused %%swpused kbswpcad %%swpcad\n",
474 /* Display instantaneous values */
475 printf("%-11s %9lu %9lu %6.2f %9lu %6.2f\n",
478 smc->tlskb - smc->frskb,
480 SP_VALUE(smc->frskb, smc->tlskb, smc->tlskb) : 0.0,
482 (smc->tlskb - smc->frskb) ?
483 SP_VALUE(0, smc->caskb, smc->tlskb - smc->frskb) : 0.0);
486 * Will be used to compute the average.
487 * We assume that the total amount of swap space may vary.
489 avg_frskb += smc->frskb;
490 avg_tlskb += smc->tlskb;
491 avg_caskb += smc->caskb;
494 /* Display average values */
495 printf("%-11s %9.0f %9.0f %6.2f %9.0f %6.2f\n",
497 (double) avg_frskb / avg_count,
498 ((double) avg_tlskb / avg_count) -
499 ((double) avg_frskb / avg_count),
500 ((double) (avg_tlskb / avg_count)) ?
501 SP_VALUE((double) (avg_frskb / avg_count),
502 (double) (avg_tlskb / avg_count),
503 (double) (avg_tlskb / avg_count)) :
505 (double) (avg_caskb / avg_count),
506 (((double) avg_tlskb / avg_count) -
507 ((double) avg_frskb / avg_count)) ?
508 SP_VALUE(0.0, (double) (avg_caskb / avg_count),
509 ((double) avg_tlskb / avg_count) -
510 ((double) avg_frskb / avg_count)) :
513 /* Reset average counters */
514 avg_frskb = avg_tlskb = avg_caskb = 0;
520 ***************************************************************************
521 * Display memory and swap statistics.
524 * @a Activity structure with statistics.
525 * @prev Index in array where stats used as reference are.
526 * @curr Index in array for current sample statistics.
527 * @itv Interval of time in jiffies.
528 ***************************************************************************
530 __print_funct_t print_memory_stats(struct activity *a, int prev, int curr,
531 unsigned long long itv)
533 stub_print_memory_stats(a, prev, curr, itv, FALSE);
537 ***************************************************************************
538 * Display average memory statistics.
541 * @a Activity structure with statistics.
542 * @prev Index in array where stats used as reference are.
543 * @curr Index in array for current sample statistics.
544 * @itv Interval of time in jiffies.
545 ***************************************************************************
547 __print_funct_t print_avg_memory_stats(struct activity *a, int prev, int curr,
548 unsigned long long itv)
550 stub_print_memory_stats(a, prev, curr, itv, TRUE);
554 ***************************************************************************
555 * Display kernel tables statistics. This function is used to display
556 * instantaneous and average statistics.
559 * @a Activity structure with statistics.
560 * @prev Index in array where stats used as reference are.
561 * @curr Index in array for current sample statistics.
562 * @dispavg True if displaying average statistics.
563 ***************************************************************************
565 void stub_print_ktables_stats(struct activity *a, int prev, int curr, int dispavg)
568 *skc = (struct stats_ktables *) a->buf[curr];
569 static unsigned long long
577 printf("\n%-11s dentunusd file-nr inode-nr pty-nr\n",
582 /* Display instantaneous values */
583 printf("%-11s %9u %9u %9u %9u\n", timestamp[curr],
590 * Will be used to compute the average.
591 * Note: Overflow unlikely to happen but not impossible...
593 avg_dentry_stat += skc->dentry_stat;
594 avg_file_used += skc->file_used;
595 avg_inode_used += skc->inode_used;
596 avg_pty_nr += skc->pty_nr;
599 /* Display average values */
600 printf("%-11s %9.0f %9.0f %9.0f %9.0f\n",
602 (double) avg_dentry_stat / avg_count,
603 (double) avg_file_used / avg_count,
604 (double) avg_inode_used / avg_count,
605 (double) avg_pty_nr / avg_count);
607 /* Reset average counters */
608 avg_dentry_stat = avg_file_used = avg_inode_used = avg_pty_nr = 0;
613 ***************************************************************************
614 * Display kernel tables statistics.
617 * @a Activity structure with statistics.
618 * @prev Index in array where stats used as reference are.
619 * @curr Index in array for current sample statistics.
620 * @itv Interval of time in jiffies.
621 ***************************************************************************
623 __print_funct_t print_ktables_stats(struct activity *a, int prev, int curr,
624 unsigned long long itv)
626 stub_print_ktables_stats(a, prev, curr, FALSE);
630 ***************************************************************************
631 * Display average kernel tables statistics.
634 * @a Activity structure with statistics.
635 * @prev Index in array where stats used as reference are.
636 * @curr Index in array for current sample statistics.
637 * @itv Interval of time in jiffies.
638 ***************************************************************************
640 __print_funct_t print_avg_ktables_stats(struct activity *a, int prev, int curr,
641 unsigned long long itv)
643 stub_print_ktables_stats(a, prev, curr, TRUE);
647 ***************************************************************************
648 * Display queue and load statistics. This function is used to display
649 * instantaneous and average statistics.
652 * @a Activity structure with statistics.
653 * @prev Index in array where stats used as reference are.
654 * @curr Index in array for current sample statistics.
655 * @dispavg TRUE if displaying average statistics.
656 ***************************************************************************
658 void stub_print_queue_stats(struct activity *a, int prev, int curr, int dispavg)
661 *sqc = (struct stats_queue *) a->buf[curr];
662 static unsigned long long
668 avg_procs_blocked = 0;
671 printf("\n%-11s runq-sz plist-sz ldavg-1 ldavg-5 ldavg-15 blocked\n",
676 /* Display instantaneous values */
677 printf("%-11s %9lu %9u %9.2f %9.2f %9.2f %9lu\n", timestamp[curr],
680 (double) sqc->load_avg_1 / 100,
681 (double) sqc->load_avg_5 / 100,
682 (double) sqc->load_avg_15 / 100,
685 /* Will be used to compute the average */
686 avg_nr_running += sqc->nr_running;
687 avg_nr_threads += sqc->nr_threads;
688 avg_load_avg_1 += sqc->load_avg_1;
689 avg_load_avg_5 += sqc->load_avg_5;
690 avg_load_avg_15 += sqc->load_avg_15;
691 avg_procs_blocked += sqc->procs_blocked;
694 /* Display average values */
695 printf("%-11s %9.0f %9.0f %9.2f %9.2f %9.2f %9.0f\n", timestamp[curr],
696 (double) avg_nr_running / avg_count,
697 (double) avg_nr_threads / avg_count,
698 (double) avg_load_avg_1 / (avg_count * 100),
699 (double) avg_load_avg_5 / (avg_count * 100),
700 (double) avg_load_avg_15 / (avg_count * 100),
701 (double) avg_procs_blocked / avg_count);
703 /* Reset average counters */
704 avg_nr_running = avg_nr_threads = 0;
705 avg_load_avg_1 = avg_load_avg_5 = avg_load_avg_15 = 0;
706 avg_procs_blocked = 0;
711 ***************************************************************************
712 * Display queue and load statistics.
715 * @a Activity structure with statistics.
716 * @prev Index in array where stats used as reference are.
717 * @curr Index in array for current sample statistics.
718 * @itv Interval of time in jiffies.
719 ***************************************************************************
721 __print_funct_t print_queue_stats(struct activity *a, int prev, int curr,
722 unsigned long long itv)
724 stub_print_queue_stats(a, prev, curr, FALSE);
728 ***************************************************************************
729 * Display average queue and load statistics.
732 * @a Activity structure with statistics.
733 * @prev Index in array where stats used as reference are.
734 * @curr Index in array for current sample statistics.
735 * @itv Interval of time in jiffies.
736 ***************************************************************************
738 __print_funct_t print_avg_queue_stats(struct activity *a, int prev, int curr,
739 unsigned long long itv)
741 stub_print_queue_stats(a, prev, curr, TRUE);
745 ***************************************************************************
746 * Display serial lines statistics.
749 * @a Activity structure with statistics.
750 * @prev Index in array where stats used as reference are.
751 * @curr Index in array for current sample statistics.
752 * @itv Interval of time in jiffies.
753 ***************************************************************************
755 __print_funct_t print_serial_stats(struct activity *a, int prev, int curr,
756 unsigned long long itv)
759 struct stats_serial *ssc, *ssp;
762 printf("\n%-11s TTY rcvin/s xmtin/s framerr/s prtyerr/s"
763 " brk/s ovrun/s\n", timestamp[!curr]);
766 for (i = 0; i < a->nr; i++) {
768 ssc = (struct stats_serial *) ((char *) a->buf[curr] + i * a->msize);
769 ssp = (struct stats_serial *) ((char *) a->buf[prev] + i * a->msize);
774 printf("%-11s %3d", timestamp[curr], ssc->line - 1);
776 if ((ssc->line == ssp->line) || WANT_SINCE_BOOT(flags)) {
777 printf(" %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f\n",
778 S_VALUE(ssp->rx, ssc->rx, itv),
779 S_VALUE(ssp->tx, ssc->tx, itv),
780 S_VALUE(ssp->frame, ssc->frame, itv),
781 S_VALUE(ssp->parity, ssc->parity, itv),
782 S_VALUE(ssp->brk, ssc->brk, itv),
783 S_VALUE(ssp->overrun, ssc->overrun, itv));
786 printf(" N/A N/A N/A N/A"
793 ***************************************************************************
794 * Display disks statistics.
797 * @a Activity structure with statistics.
798 * @prev Index in array where stats used as reference are.
799 * @curr Index in array for current sample statistics.
800 * @itv Interval of time in jiffies.
801 ***************************************************************************
803 __print_funct_t print_disk_stats(struct activity *a, int prev, int curr,
804 unsigned long long itv)
807 struct stats_disk *sdc, *sdp;
808 struct ext_disk_stats xds;
812 printf("\n%-11s DEV tps rd_sec/s wr_sec/s avgrq-sz"
813 " avgqu-sz await svctm %%util\n",
817 for (i = 0; i < a->nr; i++) {
819 sdc = (struct stats_disk *) ((char *) a->buf[curr] + i * a->msize);
821 if (!(sdc->major + sdc->minor))
824 j = check_disk_reg(a, curr, prev, i);
825 sdp = (struct stats_disk *) ((char *) a->buf[prev] + j * a->msize);
827 /* Compute service time, etc. */
828 compute_ext_disk_stats(sdc, sdp, itv, &xds);
832 if ((USE_PRETTY_OPTION(flags)) && (sdc->major == dm_major)) {
833 dev_name = transform_devmapname(sdc->major, sdc->minor);
837 dev_name = get_devname(sdc->major, sdc->minor,
838 USE_PRETTY_OPTION(flags));
841 printf("%-11s %9s %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f\n",
843 /* Confusion possible here between index and minor numbers */
845 S_VALUE(sdp->nr_ios, sdc->nr_ios, itv),
846 ll_s_value(sdp->rd_sect, sdc->rd_sect, itv),
847 ll_s_value(sdp->wr_sect, sdc->wr_sect, itv),
848 /* See iostat for explanations */
850 S_VALUE(sdp->rq_ticks, sdc->rq_ticks, itv) / 1000.0,
858 ***************************************************************************
859 * Display network interfaces statistics.
862 * @a Activity structure with statistics.
863 * @prev Index in array where stats used as reference are.
864 * @curr Index in array for current sample statistics.
865 * @itv Interval of time in jiffies.
866 ***************************************************************************
868 __print_funct_t print_net_dev_stats(struct activity *a, int prev, int curr,
869 unsigned long long itv)
872 struct stats_net_dev *sndc, *sndp;
875 printf("\n%-11s IFACE rxpck/s txpck/s rxkB/s txkB/s"
876 " rxcmp/s txcmp/s rxmcst/s\n", timestamp[!curr]);
879 for (i = 0; i < a->nr; i++) {
881 sndc = (struct stats_net_dev *) ((char *) a->buf[curr] + i * a->msize);
883 if (!strcmp(sndc->interface, ""))
886 j = check_net_dev_reg(a, curr, prev, i);
887 sndp = (struct stats_net_dev *) ((char *) a->buf[prev] + j * a->msize);
889 printf("%-11s %9s", timestamp[curr], sndc->interface);
891 printf(" %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f\n",
892 S_VALUE(sndp->rx_packets, sndc->rx_packets, itv),
893 S_VALUE(sndp->tx_packets, sndc->tx_packets, itv),
894 S_VALUE(sndp->rx_bytes, sndc->rx_bytes, itv) / 1024,
895 S_VALUE(sndp->tx_bytes, sndc->tx_bytes, itv) / 1024,
896 S_VALUE(sndp->rx_compressed, sndc->rx_compressed, itv),
897 S_VALUE(sndp->tx_compressed, sndc->tx_compressed, itv),
898 S_VALUE(sndp->multicast, sndc->multicast, itv));
903 ***************************************************************************
904 * Display network interface errors statistics.
907 * @a Activity structure with statistics.
908 * @prev Index in array where stats used as reference are.
909 * @curr Index in array for current sample statistics.
910 * @itv Interval of time in jiffies.
911 ***************************************************************************
913 __print_funct_t print_net_edev_stats(struct activity *a, int prev, int curr,
914 unsigned long long itv)
917 struct stats_net_edev *snedc, *snedp;
920 printf("\n%-11s IFACE rxerr/s txerr/s coll/s rxdrop/s"
921 " txdrop/s txcarr/s rxfram/s rxfifo/s txfifo/s\n",
925 for (i = 0; i < a->nr; i++) {
927 snedc = (struct stats_net_edev *) ((char *) a->buf[curr] + i * a->msize);
929 if (!strcmp(snedc->interface, ""))
932 j = check_net_edev_reg(a, curr, prev, i);
933 snedp = (struct stats_net_edev *) ((char *) a->buf[prev] + j * a->msize);
935 printf("%-11s %9s", timestamp[curr], snedc->interface);
937 printf(" %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f\n",
938 S_VALUE(snedp->rx_errors, snedc->rx_errors, itv),
939 S_VALUE(snedp->tx_errors, snedc->tx_errors, itv),
940 S_VALUE(snedp->collisions, snedc->collisions, itv),
941 S_VALUE(snedp->rx_dropped, snedc->rx_dropped, itv),
942 S_VALUE(snedp->tx_dropped, snedc->tx_dropped, itv),
943 S_VALUE(snedp->tx_carrier_errors, snedc->tx_carrier_errors, itv),
944 S_VALUE(snedp->rx_frame_errors, snedc->rx_frame_errors, itv),
945 S_VALUE(snedp->rx_fifo_errors, snedc->rx_fifo_errors, itv),
946 S_VALUE(snedp->tx_fifo_errors, snedc->tx_fifo_errors, itv));
951 ***************************************************************************
952 * Display NFS client statistics.
955 * @a Activity structure with statistics.
956 * @prev Index in array where stats used as reference are.
957 * @curr Index in array for current sample statistics.
958 * @itv Interval of time in jiffies.
959 ***************************************************************************
961 __print_funct_t print_net_nfs_stats(struct activity *a, int prev, int curr,
962 unsigned long long itv)
965 *snnc = (struct stats_net_nfs *) a->buf[curr],
966 *snnp = (struct stats_net_nfs *) a->buf[prev];
969 printf("\n%-11s call/s retrans/s read/s write/s access/s"
970 " getatt/s\n", timestamp[!curr]);
973 printf("%-11s %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f\n", timestamp[curr],
974 S_VALUE(snnp->nfs_rpccnt, snnc->nfs_rpccnt, itv),
975 S_VALUE(snnp->nfs_rpcretrans, snnc->nfs_rpcretrans, itv),
976 S_VALUE(snnp->nfs_readcnt, snnc->nfs_readcnt, itv),
977 S_VALUE(snnp->nfs_writecnt, snnc->nfs_writecnt, itv),
978 S_VALUE(snnp->nfs_accesscnt, snnc->nfs_accesscnt, itv),
979 S_VALUE(snnp->nfs_getattcnt, snnc->nfs_getattcnt, itv));
983 ***************************************************************************
984 * Display NFS server statistics.
987 * @a Activity structure with statistics.
988 * @prev Index in array where stats used as reference are.
989 * @curr Index in array for current sample statistics.
990 * @itv Interval of time in jiffies.
991 ***************************************************************************
993 __print_funct_t print_net_nfsd_stats(struct activity *a, int prev, int curr,
994 unsigned long long itv)
996 struct stats_net_nfsd
997 *snndc = (struct stats_net_nfsd *) a->buf[curr],
998 *snndp = (struct stats_net_nfsd *) a->buf[prev];
1001 printf("\n%-11s scall/s badcall/s packet/s udp/s tcp/s "
1002 "hit/s miss/s sread/s swrite/s saccess/s sgetatt/s\n",
1006 printf("%-11s %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f\n",
1008 S_VALUE(snndp->nfsd_rpccnt, snndc->nfsd_rpccnt, itv),
1009 S_VALUE(snndp->nfsd_rpcbad, snndc->nfsd_rpcbad, itv),
1010 S_VALUE(snndp->nfsd_netcnt, snndc->nfsd_netcnt, itv),
1011 S_VALUE(snndp->nfsd_netudpcnt, snndc->nfsd_netudpcnt, itv),
1012 S_VALUE(snndp->nfsd_nettcpcnt, snndc->nfsd_nettcpcnt, itv),
1013 S_VALUE(snndp->nfsd_rchits, snndc->nfsd_rchits, itv),
1014 S_VALUE(snndp->nfsd_rcmisses, snndc->nfsd_rcmisses, itv),
1015 S_VALUE(snndp->nfsd_readcnt, snndc->nfsd_readcnt, itv),
1016 S_VALUE(snndp->nfsd_writecnt, snndc->nfsd_writecnt, itv),
1017 S_VALUE(snndp->nfsd_accesscnt, snndc->nfsd_accesscnt, itv),
1018 S_VALUE(snndp->nfsd_getattcnt, snndc->nfsd_getattcnt, itv));
1022 ***************************************************************************
1023 * Display network sockets statistics. This function is used to display
1024 * instantaneous and average statistics.
1027 * @a Activity structure with statistics.
1028 * @prev Index in array where stats used as reference are.
1029 * @curr Index in array for current sample statistics.
1030 * @itv Interval of time in jiffies.
1031 * @dispavg TRUE if displaying average statistics.
1032 ***************************************************************************
1034 void stub_print_net_sock_stats(struct activity *a, int prev, int curr,
1035 unsigned long long itv, int dispavg)
1037 struct stats_net_sock
1038 *snsc = (struct stats_net_sock *) a->buf[curr];
1039 static unsigned long long
1048 printf("\n%-11s totsck tcpsck udpsck rawsck ip-frag tcp-tw\n",
1053 /* Display instantaneous values */
1054 printf("%-11s %9u %9u %9u %9u %9u %9u\n", timestamp[curr],
1062 /* Will be used to compute the average */
1063 avg_sock_inuse += snsc->sock_inuse;
1064 avg_tcp_inuse += snsc->tcp_inuse;
1065 avg_udp_inuse += snsc->udp_inuse;
1066 avg_raw_inuse += snsc->raw_inuse;
1067 avg_frag_inuse += snsc->frag_inuse;
1068 avg_tcp_tw += snsc->tcp_tw;
1071 /* Display average values */
1072 printf("%-11s %9.0f %9.0f %9.0f %9.0f %9.0f %9.0f\n", timestamp[curr],
1073 (double) avg_sock_inuse / avg_count,
1074 (double) avg_tcp_inuse / avg_count,
1075 (double) avg_udp_inuse / avg_count,
1076 (double) avg_raw_inuse / avg_count,
1077 (double) avg_frag_inuse / avg_count,
1078 (double) avg_tcp_tw / avg_count);
1080 /* Reset average counters */
1081 avg_sock_inuse = avg_tcp_inuse = avg_udp_inuse = 0;
1082 avg_raw_inuse = avg_frag_inuse = avg_tcp_tw = 0;
1087 ***************************************************************************
1088 * Display network sockets statistics.
1091 * @a Activity structure with statistics.
1092 * @prev Index in array where stats used as reference are.
1093 * @curr Index in array for current sample statistics.
1094 * @itv Interval of time in jiffies.
1095 ***************************************************************************
1097 __print_funct_t print_net_sock_stats(struct activity *a, int prev, int curr,
1098 unsigned long long itv)
1100 stub_print_net_sock_stats(a, prev, curr, itv, FALSE);
1104 ***************************************************************************
1105 * Display average network sockets statistics.
1108 * @a Activity structure with statistics.
1109 * @prev Index in array where stats used as reference are.
1110 * @curr Index in array for current sample statistics.
1111 * @itv Interval of time in jiffies.
1112 ***************************************************************************
1114 __print_funct_t print_avg_net_sock_stats(struct activity *a, int prev, int curr,
1115 unsigned long long itv)
1117 stub_print_net_sock_stats(a, prev, curr, itv, TRUE);
1121 ***************************************************************************
1122 * Display IP network traffic statistics.
1125 * @a Activity structure with statistics.
1126 * @prev Index in array where stats used as reference are.
1127 * @curr Index in array for current sample statistics.
1128 * @itv Interval of time in jiffies.
1129 ***************************************************************************
1131 __print_funct_t print_net_ip_stats(struct activity *a, int prev, int curr,
1132 unsigned long long itv)
1135 *snic = (struct stats_net_ip *) a->buf[curr],
1136 *snip = (struct stats_net_ip *) a->buf[prev];
1139 printf("\n%-11s irec/s fwddgm/s idel/s orq/s asmrq/s"
1140 " asmok/s fragok/s fragcrt/s\n", timestamp[!curr]);
1143 printf("%-11s %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f\n",
1145 S_VALUE(snip->InReceives, snic->InReceives, itv),
1146 S_VALUE(snip->ForwDatagrams, snic->ForwDatagrams, itv),
1147 S_VALUE(snip->InDelivers, snic->InDelivers, itv),
1148 S_VALUE(snip->OutRequests, snic->OutRequests, itv),
1149 S_VALUE(snip->ReasmReqds, snic->ReasmReqds, itv),
1150 S_VALUE(snip->ReasmOKs, snic->ReasmOKs, itv),
1151 S_VALUE(snip->FragOKs, snic->FragOKs, itv),
1152 S_VALUE(snip->FragCreates, snic->FragCreates, itv));
1156 ***************************************************************************
1157 * Display IP network error statistics.
1160 * @a Activity structure with statistics.
1161 * @prev Index in array where stats used as reference are.
1162 * @curr Index in array for current sample statistics.
1163 * @itv Interval of time in jiffies.
1164 ***************************************************************************
1166 __print_funct_t print_net_eip_stats(struct activity *a, int prev, int curr,
1167 unsigned long long itv)
1169 struct stats_net_eip
1170 *sneic = (struct stats_net_eip *) a->buf[curr],
1171 *sneip = (struct stats_net_eip *) a->buf[prev];
1174 printf("\n%-11s ihdrerr/s iadrerr/s iukwnpr/s idisc/s odisc/s"
1175 " onort/s asmf/s fragf/s\n", timestamp[!curr]);
1178 printf("%-11s %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f\n",
1180 S_VALUE(sneip->InHdrErrors, sneic->InHdrErrors, itv),
1181 S_VALUE(sneip->InAddrErrors, sneic->InAddrErrors, itv),
1182 S_VALUE(sneip->InUnknownProtos, sneic->InUnknownProtos, itv),
1183 S_VALUE(sneip->InDiscards, sneic->InDiscards, itv),
1184 S_VALUE(sneip->OutDiscards, sneic->OutDiscards, itv),
1185 S_VALUE(sneip->OutNoRoutes, sneic->OutNoRoutes, itv),
1186 S_VALUE(sneip->ReasmFails, sneic->ReasmFails, itv),
1187 S_VALUE(sneip->FragFails, sneic->FragFails, itv));
1191 ***************************************************************************
1192 * Display ICMP network traffic statistics.
1195 * @a Activity structure with statistics.
1196 * @prev Index in array where stats used as reference are.
1197 * @curr Index in array for current sample statistics.
1198 * @itv Interval of time in jiffies.
1199 ***************************************************************************
1201 __print_funct_t print_net_icmp_stats(struct activity *a, int prev, int curr,
1202 unsigned long long itv)
1204 struct stats_net_icmp
1205 *snic = (struct stats_net_icmp *) a->buf[curr],
1206 *snip = (struct stats_net_icmp *) a->buf[prev];
1209 printf("\n%-11s imsg/s omsg/s iech/s iechr/s oech/s"
1210 " oechr/s itm/s itmr/s otm/s otmr/s"
1211 " iadrmk/s iadrmkr/s oadrmk/s oadrmkr/s\n", timestamp[!curr]);
1214 printf("%-11s %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f"
1215 " %9.2f %9.2f %9.2f %9.2f\n", timestamp[curr],
1216 S_VALUE(snip->InMsgs, snic->InMsgs, itv),
1217 S_VALUE(snip->OutMsgs, snic->OutMsgs, itv),
1218 S_VALUE(snip->InEchos, snic->InEchos, itv),
1219 S_VALUE(snip->InEchoReps, snic->InEchoReps, itv),
1220 S_VALUE(snip->OutEchos, snic->OutEchos, itv),
1221 S_VALUE(snip->OutEchoReps, snic->OutEchoReps, itv),
1222 S_VALUE(snip->InTimestamps, snic->InTimestamps, itv),
1223 S_VALUE(snip->InTimestampReps, snic->InTimestampReps, itv),
1224 S_VALUE(snip->OutTimestamps, snic->OutTimestamps, itv),
1225 S_VALUE(snip->OutTimestampReps, snic->OutTimestampReps, itv),
1226 S_VALUE(snip->InAddrMasks, snic->InAddrMasks, itv),
1227 S_VALUE(snip->InAddrMaskReps, snic->InAddrMaskReps, itv),
1228 S_VALUE(snip->OutAddrMasks, snic->OutAddrMasks, itv),
1229 S_VALUE(snip->OutAddrMaskReps, snic->OutAddrMaskReps, itv));
1233 ***************************************************************************
1234 * Display ICMP network error statistics.
1237 * @a Activity structure with statistics.
1238 * @prev Index in array where stats used as reference are.
1239 * @curr Index in array for current sample statistics.
1240 * @itv Interval of time in jiffies.
1241 ***************************************************************************
1243 __print_funct_t print_net_eicmp_stats(struct activity *a, int prev, int curr,
1244 unsigned long long itv)
1246 struct stats_net_eicmp
1247 *sneic = (struct stats_net_eicmp *) a->buf[curr],
1248 *sneip = (struct stats_net_eicmp *) a->buf[prev];
1251 printf("\n%-11s ierr/s oerr/s idstunr/s odstunr/s itmex/s"
1252 " otmex/s iparmpb/s oparmpb/s isrcq/s osrcq/s"
1253 " iredir/s oredir/s\n", timestamp[!curr]);
1256 printf("%-11s %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f"
1257 " %9.2f %9.2f\n", timestamp[curr],
1258 S_VALUE(sneip->InErrors, sneic->InErrors, itv),
1259 S_VALUE(sneip->OutErrors, sneic->OutErrors, itv),
1260 S_VALUE(sneip->InDestUnreachs, sneic->InDestUnreachs, itv),
1261 S_VALUE(sneip->OutDestUnreachs, sneic->OutDestUnreachs, itv),
1262 S_VALUE(sneip->InTimeExcds, sneic->InTimeExcds, itv),
1263 S_VALUE(sneip->OutTimeExcds, sneic->OutTimeExcds, itv),
1264 S_VALUE(sneip->InParmProbs, sneic->InParmProbs, itv),
1265 S_VALUE(sneip->OutParmProbs, sneic->OutParmProbs, itv),
1266 S_VALUE(sneip->InSrcQuenchs, sneic->InSrcQuenchs, itv),
1267 S_VALUE(sneip->OutSrcQuenchs, sneic->OutSrcQuenchs, itv),
1268 S_VALUE(sneip->InRedirects, sneic->InRedirects, itv),
1269 S_VALUE(sneip->OutRedirects, sneic->OutRedirects, itv));
1273 ***************************************************************************
1274 * Display TCP network traffic statistics.
1277 * @a Activity structure with statistics.
1278 * @prev Index in array where stats used as reference are.
1279 * @curr Index in array for current sample statistics.
1280 * @itv Interval of time in jiffies.
1281 ***************************************************************************
1283 __print_funct_t print_net_tcp_stats(struct activity *a, int prev, int curr,
1284 unsigned long long itv)
1286 struct stats_net_tcp
1287 *sntc = (struct stats_net_tcp *) a->buf[curr],
1288 *sntp = (struct stats_net_tcp *) a->buf[prev];
1291 printf("\n%-11s active/s passive/s iseg/s oseg/s\n",
1295 printf("%-11s %9.2f %9.2f %9.2f %9.2f\n",
1297 S_VALUE(sntp->ActiveOpens, sntc->ActiveOpens, itv),
1298 S_VALUE(sntp->PassiveOpens, sntc->PassiveOpens, itv),
1299 S_VALUE(sntp->InSegs, sntc->InSegs, itv),
1300 S_VALUE(sntp->OutSegs, sntc->OutSegs, itv));
1304 ***************************************************************************
1305 * Display TCP network error statistics.
1308 * @a Activity structure with statistics.
1309 * @prev Index in array where stats used as reference are.
1310 * @curr Index in array for current sample statistics.
1311 * @itv Interval of time in jiffies.
1312 ***************************************************************************
1314 __print_funct_t print_net_etcp_stats(struct activity *a, int prev, int curr,
1315 unsigned long long itv)
1317 struct stats_net_etcp
1318 *snetc = (struct stats_net_etcp *) a->buf[curr],
1319 *snetp = (struct stats_net_etcp *) a->buf[prev];
1322 printf("\n%-11s atmptf/s estres/s retrans/s isegerr/s orsts/s\n",
1326 printf("%-11s %9.2f %9.2f %9.2f %9.2f %9.2f\n",
1328 S_VALUE(snetp->AttemptFails, snetc->AttemptFails, itv),
1329 S_VALUE(snetp->EstabResets, snetc->EstabResets, itv),
1330 S_VALUE(snetp->RetransSegs, snetc->RetransSegs, itv),
1331 S_VALUE(snetp->InErrs, snetc->InErrs, itv),
1332 S_VALUE(snetp->OutRsts, snetc->OutRsts, itv));
1336 ***************************************************************************
1337 * Display UDP network traffic statistics.
1340 * @a Activity structure with statistics.
1341 * @prev Index in array where stats used as reference are.
1342 * @curr Index in array for current sample statistics.
1343 * @itv Interval of time in jiffies.
1344 ***************************************************************************
1346 __print_funct_t print_net_udp_stats(struct activity *a, int prev, int curr,
1347 unsigned long long itv)
1349 struct stats_net_udp
1350 *snuc = (struct stats_net_udp *) a->buf[curr],
1351 *snup = (struct stats_net_udp *) a->buf[prev];
1354 printf("\n%-11s idgm/s odgm/s noport/s idgmerr/s\n",
1358 printf("%-11s %9.2f %9.2f %9.2f %9.2f\n",
1360 S_VALUE(snup->InDatagrams, snuc->InDatagrams, itv),
1361 S_VALUE(snup->OutDatagrams, snuc->OutDatagrams, itv),
1362 S_VALUE(snup->NoPorts, snuc->NoPorts, itv),
1363 S_VALUE(snup->InErrors, snuc->InErrors, itv));
1367 ***************************************************************************
1368 * Display IPv6 sockets statistics. This function is used to display
1369 * instantaneous and average statistics.
1372 * @a Activity structure with statistics.
1373 * @prev Index in array where stats used as reference are.
1374 * @curr Index in array for current sample statistics.
1375 * @itv Interval of time in jiffies.
1376 * @dispavg TRUE if displaying average statistics.
1377 ***************************************************************************
1379 void stub_print_net_sock6_stats(struct activity *a, int prev, int curr,
1380 unsigned long long itv, int dispavg)
1382 struct stats_net_sock6
1383 *snsc = (struct stats_net_sock6 *) a->buf[curr];
1384 static unsigned long long
1388 avg_frag6_inuse = 0;
1391 printf("\n%-11s tcp6sck udp6sck raw6sck ip6-frag\n",
1396 /* Display instantaneous values */
1397 printf("%-11s %9u %9u %9u %9u\n", timestamp[curr],
1403 /* Will be used to compute the average */
1404 avg_tcp6_inuse += snsc->tcp6_inuse;
1405 avg_udp6_inuse += snsc->udp6_inuse;
1406 avg_raw6_inuse += snsc->raw6_inuse;
1407 avg_frag6_inuse += snsc->frag6_inuse;
1410 /* Display average values */
1411 printf("%-11s %9.0f %9.0f %9.0f %9.0f\n", timestamp[curr],
1412 (double) avg_tcp6_inuse / avg_count,
1413 (double) avg_udp6_inuse / avg_count,
1414 (double) avg_raw6_inuse / avg_count,
1415 (double) avg_frag6_inuse / avg_count);
1417 /* Reset average counters */
1418 avg_tcp6_inuse = avg_udp6_inuse = avg_raw6_inuse = avg_frag6_inuse = 0;
1423 ***************************************************************************
1424 * Display IPv6 sockets statistics.
1427 * @a Activity structure with statistics.
1428 * @prev Index in array where stats used as reference are.
1429 * @curr Index in array for current sample statistics.
1430 * @itv Interval of time in jiffies.
1431 ***************************************************************************
1433 __print_funct_t print_net_sock6_stats(struct activity *a, int prev, int curr,
1434 unsigned long long itv)
1436 stub_print_net_sock6_stats(a, prev, curr, itv, FALSE);
1440 ***************************************************************************
1441 * Display average IPv6 sockets statistics.
1444 * @a Activity structure with statistics.
1445 * @prev Index in array where stats used as reference are.
1446 * @curr Index in array for current sample statistics.
1447 * @itv Interval of time in jiffies.
1448 ***************************************************************************
1450 __print_funct_t print_avg_net_sock6_stats(struct activity *a, int prev, int curr,
1451 unsigned long long itv)
1453 stub_print_net_sock6_stats(a, prev, curr, itv, TRUE);
1457 ***************************************************************************
1458 * Display IPv6 network traffic statistics.
1461 * @a Activity structure with statistics.
1462 * @prev Index in array where stats used as reference are.
1463 * @curr Index in array for current sample statistics.
1464 * @itv Interval of time in jiffies.
1465 ***************************************************************************
1467 __print_funct_t print_net_ip6_stats(struct activity *a, int prev, int curr,
1468 unsigned long long itv)
1470 struct stats_net_ip6
1471 *snic = (struct stats_net_ip6 *) a->buf[curr],
1472 *snip = (struct stats_net_ip6 *) a->buf[prev];
1475 printf("\n%-11s irec6/s fwddgm6/s idel6/s orq6/s asmrq6/s"
1476 " asmok6/s imcpck6/s omcpck6/s fragok6/s fragcr6/s\n",
1480 printf("%-11s %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f\n",
1482 S_VALUE(snip->InReceives6, snic->InReceives6, itv),
1483 S_VALUE(snip->OutForwDatagrams6, snic->OutForwDatagrams6, itv),
1484 S_VALUE(snip->InDelivers6, snic->InDelivers6, itv),
1485 S_VALUE(snip->OutRequests6, snic->OutRequests6, itv),
1486 S_VALUE(snip->ReasmReqds6, snic->ReasmReqds6, itv),
1487 S_VALUE(snip->ReasmOKs6, snic->ReasmOKs6, itv),
1488 S_VALUE(snip->InMcastPkts6, snic->InMcastPkts6, itv),
1489 S_VALUE(snip->OutMcastPkts6, snic->OutMcastPkts6, itv),
1490 S_VALUE(snip->FragOKs6, snic->FragOKs6, itv),
1491 S_VALUE(snip->FragCreates6, snic->FragCreates6, itv));
1495 ***************************************************************************
1496 * Display IPv6 network error statistics.
1499 * @a Activity structure with statistics.
1500 * @prev Index in array where stats used as reference are.
1501 * @curr Index in array for current sample statistics.
1502 * @itv Interval of time in jiffies.
1503 ***************************************************************************
1505 __print_funct_t print_net_eip6_stats(struct activity *a, int prev, int curr,
1506 unsigned long long itv)
1508 struct stats_net_eip6
1509 *sneic = (struct stats_net_eip6 *) a->buf[curr],
1510 *sneip = (struct stats_net_eip6 *) a->buf[prev];
1513 printf("\n%-11s ihdrer6/s iadrer6/s iukwnp6/s i2big6/s idisc6/s odisc6/s"
1514 " inort6/s onort6/s asmf6/s fragf6/s itrpck6/s\n",
1518 printf("%-11s %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f\n",
1520 S_VALUE(sneip->InHdrErrors6, sneic->InHdrErrors6, itv),
1521 S_VALUE(sneip->InAddrErrors6, sneic->InAddrErrors6, itv),
1522 S_VALUE(sneip->InUnknownProtos6, sneic->InUnknownProtos6, itv),
1523 S_VALUE(sneip->InTooBigErrors6, sneic->InTooBigErrors6, itv),
1524 S_VALUE(sneip->InDiscards6, sneic->InDiscards6, itv),
1525 S_VALUE(sneip->OutDiscards6, sneic->OutDiscards6, itv),
1526 S_VALUE(sneip->InNoRoutes6, sneic->InNoRoutes6, itv),
1527 S_VALUE(sneip->OutNoRoutes6, sneic->OutNoRoutes6, itv),
1528 S_VALUE(sneip->ReasmFails6, sneic->ReasmFails6, itv),
1529 S_VALUE(sneip->FragFails6, sneic->FragFails6, itv),
1530 S_VALUE(sneip->InTruncatedPkts6, sneic->InTruncatedPkts6, itv));
1534 ***************************************************************************
1535 * Display ICMPv6 network traffic statistics.
1538 * @a Activity structure with statistics.
1539 * @prev Index in array where stats used as reference are.
1540 * @curr Index in array for current sample statistics.
1541 * @itv Interval of time in jiffies.
1542 ***************************************************************************
1544 __print_funct_t print_net_icmp6_stats(struct activity *a, int prev, int curr,
1545 unsigned long long itv)
1547 struct stats_net_icmp6
1548 *snic = (struct stats_net_icmp6 *) a->buf[curr],
1549 *snip = (struct stats_net_icmp6 *) a->buf[prev];
1552 printf("\n%-11s imsg6/s omsg6/s iech6/s iechr6/s oechr6/s"
1553 " igmbq6/s igmbr6/s ogmbr6/s igmbrd6/s ogmbrd6/s irtsol6/s ortsol6/s"
1554 " irtad6/s inbsol6/s onbsol6/s inbad6/s onbad6/s\n",
1558 printf("%-11s %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f"
1559 " %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f\n", timestamp[curr],
1560 S_VALUE(snip->InMsgs6, snic->InMsgs6, itv),
1561 S_VALUE(snip->OutMsgs6, snic->OutMsgs6, itv),
1562 S_VALUE(snip->InEchos6, snic->InEchos6, itv),
1563 S_VALUE(snip->InEchoReplies6, snic->InEchoReplies6, itv),
1564 S_VALUE(snip->OutEchoReplies6, snic->OutEchoReplies6, itv),
1565 S_VALUE(snip->InGroupMembQueries6, snic->InGroupMembQueries6, itv),
1566 S_VALUE(snip->InGroupMembResponses6, snic->InGroupMembResponses6, itv),
1567 S_VALUE(snip->OutGroupMembResponses6, snic->OutGroupMembResponses6, itv),
1568 S_VALUE(snip->InGroupMembReductions6, snic->InGroupMembReductions6, itv),
1569 S_VALUE(snip->OutGroupMembReductions6, snic->OutGroupMembReductions6, itv),
1570 S_VALUE(snip->InRouterSolicits6, snic->InRouterSolicits6, itv),
1571 S_VALUE(snip->OutRouterSolicits6, snic->OutRouterSolicits6, itv),
1572 S_VALUE(snip->InRouterAdvertisements6, snic->InRouterAdvertisements6, itv),
1573 S_VALUE(snip->InNeighborSolicits6, snic->InNeighborSolicits6, itv),
1574 S_VALUE(snip->OutNeighborSolicits6, snic->OutNeighborSolicits6, itv),
1575 S_VALUE(snip->InNeighborAdvertisements6, snic->InNeighborAdvertisements6, itv),
1576 S_VALUE(snip->OutNeighborAdvertisements6, snic->OutNeighborAdvertisements6, itv));
1580 ***************************************************************************
1581 * Display ICMPv6 network error statistics.
1584 * @a Activity structure with statistics.
1585 * @prev Index in array where stats used as reference are.
1586 * @curr Index in array for current sample statistics.
1587 * @itv Interval of time in jiffies.
1588 ***************************************************************************
1590 __print_funct_t print_net_eicmp6_stats(struct activity *a, int prev, int curr,
1591 unsigned long long itv)
1593 struct stats_net_eicmp6
1594 *sneic = (struct stats_net_eicmp6 *) a->buf[curr],
1595 *sneip = (struct stats_net_eicmp6 *) a->buf[prev];
1598 printf("\n%-11s ierr6/s idtunr6/s odtunr6/s itmex6/s otmex6/s"
1599 " iprmpb6/s oprmpb6/s iredir6/s oredir6/s ipck2b6/s opck2b6/s\n",
1603 printf("%-11s %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f"
1604 " %9.2f\n", timestamp[curr],
1605 S_VALUE(sneip->InErrors6, sneic->InErrors6, itv),
1606 S_VALUE(sneip->InDestUnreachs6, sneic->InDestUnreachs6, itv),
1607 S_VALUE(sneip->OutDestUnreachs6, sneic->OutDestUnreachs6, itv),
1608 S_VALUE(sneip->InTimeExcds6, sneic->InTimeExcds6, itv),
1609 S_VALUE(sneip->OutTimeExcds6, sneic->OutTimeExcds6, itv),
1610 S_VALUE(sneip->InParmProblems6, sneic->InParmProblems6, itv),
1611 S_VALUE(sneip->OutParmProblems6, sneic->OutParmProblems6, itv),
1612 S_VALUE(sneip->InRedirects6, sneic->InRedirects6, itv),
1613 S_VALUE(sneip->OutRedirects6, sneic->OutRedirects6, itv),
1614 S_VALUE(sneip->InPktTooBigs6, sneic->InPktTooBigs6, itv),
1615 S_VALUE(sneip->OutPktTooBigs6, sneic->OutPktTooBigs6, itv));
1619 ***************************************************************************
1620 * Display UDPv6 network traffic statistics.
1623 * @a Activity structure with statistics.
1624 * @prev Index in array where stats used as reference are.
1625 * @curr Index in array for current sample statistics.
1626 * @itv Interval of time in jiffies.
1627 ***************************************************************************
1629 __print_funct_t print_net_udp6_stats(struct activity *a, int prev, int curr,
1630 unsigned long long itv)
1632 struct stats_net_udp6
1633 *snuc = (struct stats_net_udp6 *) a->buf[curr],
1634 *snup = (struct stats_net_udp6 *) a->buf[prev];
1637 printf("\n%-11s idgm6/s odgm6/s noport6/s idgmer6/s\n",
1641 printf("%-11s %9.2f %9.2f %9.2f %9.2f\n",
1643 S_VALUE(snup->InDatagrams6, snuc->InDatagrams6, itv),
1644 S_VALUE(snup->OutDatagrams6, snuc->OutDatagrams6, itv),
1645 S_VALUE(snup->NoPorts6, snuc->NoPorts6, itv),
1646 S_VALUE(snup->InErrors6, snuc->InErrors6, itv));
1650 ***************************************************************************
1651 * Display CPU frequency statistics. This function is used to display
1652 * instantaneous and average statistics.
1655 * @a Activity structure with statistics.
1656 * @prev Index in array where stats used as reference are.
1657 * @curr Index in array for current sample statistics.
1658 * @dispavg True if displaying average statistics.
1659 ***************************************************************************
1661 void stub_print_pwr_cpufreq_stats(struct activity *a, int prev, int curr, int dispavg)
1664 struct stats_pwr_cpufreq *spc;
1665 static unsigned long long
1666 *avg_cpufreq = NULL;
1669 /* Allocate array of CPU frequency */
1670 if ((avg_cpufreq = (unsigned long long *) malloc(sizeof(unsigned long long) * a->nr))
1675 memset(avg_cpufreq, 0, sizeof(unsigned long long) * a->nr);
1679 printf("\n%-11s CPU MHz\n",
1683 for (i = 0; (i < a->nr) && (i < a->bitmap->b_size + 1); i++) {
1686 * The size of a->buf[...] CPU structure may be different from the default
1687 * sizeof(struct stats_pwr_cpufreq) value if data have been read from a file!
1688 * That's why we don't use a syntax like:
1689 * spc = (struct stats_pwr_cpufreq *) a->buf[...] + i;
1691 spc = (struct stats_pwr_cpufreq *) ((char *) a->buf[curr] + i * a->msize);
1694 * Note: a->nr is in [1, NR_CPUS + 1].
1695 * Bitmap size is provided for (NR_CPUS + 1) CPUs.
1696 * Anyway, NR_CPUS may vary between the version of sysstat
1697 * used by sadc to create a file, and the version of sysstat
1698 * used by sar to read it...
1701 /* Should current CPU (including CPU "all") be displayed? */
1702 if (a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))) {
1704 /* Yes: Display it */
1705 printf("%-11s", timestamp[curr]);
1708 /* This is CPU "all" */
1712 printf(" %3d", i - 1);
1716 /* Display instantaneous values */
1718 ((double) spc->cpufreq) / 100);
1720 * Will be used to compute the average.
1721 * Note: overflow unlikely to happen but not impossible...
1723 avg_cpufreq[i] += spc->cpufreq;
1726 /* Display average values */
1728 (double) avg_cpufreq[i] / (100 * avg_count));
1734 /* Array of CPU frequency no longer needed: Free it! */
1743 ***************************************************************************
1744 * Display CPU frequency statistics.
1747 * @a Activity structure with statistics.
1748 * @prev Index in array where stats used as reference are.
1749 * @curr Index in array for current sample statistics.
1750 * @itv Interval of time in jiffies.
1751 ***************************************************************************
1753 __print_funct_t print_pwr_cpufreq_stats(struct activity *a, int prev, int curr,
1754 unsigned long long itv)
1756 stub_print_pwr_cpufreq_stats(a, prev, curr, FALSE);
1760 ***************************************************************************
1761 * Display average CPU frequency statistics.
1764 * @a Activity structure with statistics.
1765 * @prev Index in array where stats used as reference are.
1766 * @curr Index in array for current sample statistics.
1767 * @itv Interval of time in jiffies.
1768 ***************************************************************************
1770 __print_funct_t print_avg_pwr_cpufreq_stats(struct activity *a, int prev, int curr,
1771 unsigned long long itv)
1773 stub_print_pwr_cpufreq_stats(a, prev, curr, TRUE);
1777 ***************************************************************************
1778 * Display fan statistics. This function is used to display
1779 * instantaneous and average statistics.
1782 * @a Activity structure with statistics.
1783 * @prev Index in array where stats used as reference are.
1784 * @curr Index in array for current sample statistics.
1785 * @dispavg True if displaying average statistics.
1786 ***************************************************************************
1788 void stub_print_pwr_fan_stats(struct activity *a, int prev, int curr, int dispavg)
1791 struct stats_pwr_fan *spc;
1792 static double *avg_fan = NULL;
1793 static double *avg_fan_min = NULL;
1795 /* Allocate arrays of fan RPMs */
1797 if ((avg_fan = (double *) malloc(sizeof(double) * a->nr)) == NULL) {
1801 memset(avg_fan, 0, sizeof(double) * a->nr);
1804 if ((avg_fan_min = (double *) malloc(sizeof(double) * a->nr)) == NULL) {
1808 memset(avg_fan_min, 0, sizeof(double) * a->nr);
1812 printf("\n%-11s FAN rpm drpm %*s\n",
1813 timestamp[!curr], MAX_SENSORS_DEV_LEN, "DEVICE");
1816 for (i = 0; i < a->nr; i++) {
1817 spc = (struct stats_pwr_fan *) ((char *) a->buf[curr] + i * a->msize);
1819 printf("%-11s %3d", timestamp[curr], i + 1);
1822 /* Display average values */
1823 printf(" %9.2f %9.2f",
1824 (double) avg_fan[i] / avg_count,
1825 (double) (avg_fan[i] - avg_fan_min[i]) / avg_count);
1828 /* Display instantaneous values */
1829 printf(" %9.2f %9.2f",
1831 spc->rpm - spc->rpm_min);
1832 avg_fan[i] += spc->rpm;
1833 avg_fan_min[i] += spc->rpm_min;
1836 printf(" %*s\n", MAX_SENSORS_DEV_LEN, spc->device);
1852 ***************************************************************************
1853 * Display fan statistics.
1856 * @a Activity structure with statistics.
1857 * @prev Index in array where stats used as reference are.
1858 * @curr Index in array for current sample statistics.
1859 * @itv Interval of time in jiffies.
1860 ***************************************************************************
1862 __print_funct_t print_pwr_fan_stats(struct activity *a, int prev, int curr,
1863 unsigned long long itv)
1865 stub_print_pwr_fan_stats(a, prev, curr, FALSE);
1869 ***************************************************************************
1870 * Display average fan statistics.
1873 * @a Activity structure with statistics.
1874 * @prev Index in array where stats used as reference are.
1875 * @curr Index in array for current sample statistics.
1876 * @itv Interval of time in jiffies.
1877 ***************************************************************************
1879 __print_funct_t print_avg_pwr_fan_stats(struct activity *a, int prev, int curr,
1880 unsigned long long itv)
1882 stub_print_pwr_fan_stats(a, prev, curr, TRUE);
1886 ***************************************************************************
1887 * Display device temperature statistics. This function is used to display
1888 * instantaneous and average statistics.
1891 * @a Activity structure with statistics.
1892 * @prev Index in array where stats used as reference are.
1893 * @curr Index in array for current sample statistics.
1894 * @dispavg True if displaying average statistics.
1895 ***************************************************************************
1897 void stub_print_pwr_temp_stats(struct activity *a, int prev, int curr, int dispavg)
1900 struct stats_pwr_temp *spc;
1901 static double *avg_temp = NULL;
1902 static double *avg_temp_min = NULL, *avg_temp_max = NULL;
1904 /* Allocate arrays of temperatures */
1906 if ((avg_temp = (double *) malloc(sizeof(double) * a->nr)) == NULL) {
1910 memset(avg_temp, 0, sizeof(double) * a->nr);
1912 if (!avg_temp_min) {
1913 if ((avg_temp_min = (double *) malloc(sizeof(double) * a->nr)) == NULL) {
1917 memset(avg_temp_min, 0, sizeof(double) * a->nr);
1919 if (!avg_temp_max) {
1920 if ((avg_temp_max = (double *) malloc(sizeof(double) * a->nr)) == NULL) {
1924 memset(avg_temp_max, 0, sizeof(double) * a->nr);
1928 printf("\n%-11s TEMP degC %%temp %*s\n",
1929 timestamp[!curr], MAX_SENSORS_DEV_LEN, "DEVICE");
1932 for (i = 0; i < a->nr; i++) {
1933 spc = (struct stats_pwr_temp *) ((char *) a->buf[curr] + i * a->msize);
1935 printf("%-11s %3d", timestamp[curr], i + 1);
1938 /* Display average values */
1939 printf(" %9.2f %9.2f",
1940 (double) avg_temp[i] / avg_count,
1941 (avg_temp_max[i] - avg_temp_min[i]) ?
1942 ((double) (avg_temp[i] / avg_count) - avg_temp_min[i]) / (avg_temp_max[i] - avg_temp_min[i]) * 100 :
1946 /* Display instantaneous values */
1947 printf(" %9.2f %9.2f",
1949 (spc->temp_max - spc->temp_min) ?
1950 (spc->temp - spc->temp_min) / (spc->temp_max - spc->temp_min) * 100 :
1952 avg_temp[i] += spc->temp;
1953 /* Assume that min and max temperatures cannot vary */
1954 avg_temp_min[i] = spc->temp_min;
1955 avg_temp_max[i] = spc->temp_max;
1958 printf(" %*s\n", MAX_SENSORS_DEV_LEN, spc->device);
1968 avg_temp_min = NULL;
1972 avg_temp_max = NULL;
1978 ***************************************************************************
1979 * Display temperature statistics.
1982 * @a Activity structure with statistics.
1983 * @prev Index in array where stats used as reference are.
1984 * @curr Index in array for current sample statistics.
1985 * @itv Interval of time in jiffies.
1986 ***************************************************************************
1988 __print_funct_t print_pwr_temp_stats(struct activity *a, int prev, int curr,
1989 unsigned long long itv)
1991 stub_print_pwr_temp_stats(a, prev, curr, FALSE);
1995 ***************************************************************************
1996 * Display average temperature statistics.
1999 * @a Activity structure with statistics.
2000 * @prev Index in array where stats used as reference are.
2001 * @curr Index in array for current sample statistics.
2002 * @itv Interval of time in jiffies.
2003 ***************************************************************************
2005 __print_funct_t print_avg_pwr_temp_stats(struct activity *a, int prev, int curr,
2006 unsigned long long itv)
2008 stub_print_pwr_temp_stats(a, prev, curr, TRUE);
2012 ***************************************************************************
2013 * Display voltage inputs statistics. This function is used to display
2014 * instantaneous and average 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 * @dispavg True if displaying average statistics.
2021 ***************************************************************************
2023 void stub_print_pwr_in_stats(struct activity *a, int prev, int curr, int dispavg)
2026 struct stats_pwr_in *spc;
2027 static double *avg_in = NULL;
2028 static double *avg_in_min = NULL, *avg_in_max = NULL;
2030 /* Allocate arrays of voltage inputs */
2032 if ((avg_in = (double *) malloc(sizeof(double) * a->nr)) == NULL) {
2036 memset(avg_in, 0, sizeof(double) * a->nr);
2039 if ((avg_in_min = (double *) malloc(sizeof(double) * a->nr)) == NULL) {
2043 memset(avg_in_min, 0, sizeof(double) * a->nr);
2046 if ((avg_in_max = (double *) malloc(sizeof(double) * a->nr)) == NULL) {
2050 memset(avg_in_max, 0, sizeof(double) * a->nr);
2054 printf("\n%-11s IN inV %%in %*s\n",
2055 timestamp[!curr], MAX_SENSORS_DEV_LEN, "DEVICE");
2058 for (i = 0; i < a->nr; i++) {
2059 spc = (struct stats_pwr_in *) ((char *) a->buf[curr] + i * a->msize);
2061 printf("%-11s %3d", timestamp[curr], i);
2064 /* Display average values */
2065 printf(" %9.2f %9.2f",
2066 (double) avg_in[i] / avg_count,
2067 (avg_in_max[i] - avg_in_min[i]) ?
2068 ((double) (avg_in[i] / avg_count) - avg_in_min[i]) / (avg_in_max[i] - avg_in_min[i]) * 100 :
2072 /* Display instantaneous values */
2073 printf(" %9.2f %9.2f",
2075 (spc->in_max - spc->in_min) ?
2076 (spc->in - spc->in_min) / (spc->in_max - spc->in_min) * 100 :
2078 avg_in[i] += spc->in;
2079 /* Assume that min and max voltage inputs cannot vary */
2080 avg_in_min[i] = spc->in_min;
2081 avg_in_max[i] = spc->in_max;
2084 printf(" %*s\n", MAX_SENSORS_DEV_LEN, spc->device);
2104 ***************************************************************************
2105 * Display voltage inputs statistics.
2108 * @a Activity structure with statistics.
2109 * @prev Index in array where stats used as reference are.
2110 * @curr Index in array for current sample statistics.
2111 * @itv Interval of time in jiffies.
2112 ***************************************************************************
2114 __print_funct_t print_pwr_in_stats(struct activity *a, int prev, int curr,
2115 unsigned long long itv)
2117 stub_print_pwr_in_stats(a, prev, curr, FALSE);
2121 ***************************************************************************
2122 * Display average voltage inputs statistics.
2125 * @a Activity structure with statistics.
2126 * @prev Index in array where stats used as reference are.
2127 * @curr Index in array for current sample statistics.
2128 * @itv Interval of time in jiffies.
2129 ***************************************************************************
2131 __print_funct_t print_avg_pwr_in_stats(struct activity *a, int prev, int curr,
2132 unsigned long long itv)
2134 stub_print_pwr_in_stats(a, prev, curr, TRUE);
2138 ***************************************************************************
2139 * Display huge pages statistics. This function is used to
2140 * display instantaneous and average statistics.
2143 * @a Activity structure with statistics.
2144 * @prev Index in array where stats used as reference are.
2145 * @curr Index in array for current sample statistics.
2146 * @itv Interval of time in jiffies.
2147 * @dispavg TRUE if displaying average statistics.
2148 ***************************************************************************
2150 void stub_print_huge_stats(struct activity *a, int prev, int curr,
2151 unsigned long long itv, int dispavg)
2154 *smc = (struct stats_huge *) a->buf[curr];
2155 static unsigned long long
2160 printf("\n%-11s kbhugfree kbhugused %%hugused\n",
2165 /* Display instantaneous values */
2166 printf("%-11s %9lu %9lu %6.2f\n",
2169 smc->tlhkb - smc->frhkb,
2171 SP_VALUE(smc->frhkb, smc->tlhkb, smc->tlhkb) : 0.0);
2173 /* Will be used to compute the average */
2174 avg_frhkb += smc->frhkb;
2175 avg_tlhkb += smc->tlhkb;
2178 /* Display average values */
2179 printf("%-11s %9.0f %9.0f %6.2f\n",
2181 (double) avg_frhkb / avg_count,
2182 ((double) avg_tlhkb / avg_count) -
2183 ((double) avg_frhkb / avg_count),
2184 ((double) (avg_tlhkb / avg_count)) ?
2185 SP_VALUE((double) (avg_frhkb / avg_count),
2186 (double) (avg_tlhkb / avg_count),
2187 (double) (avg_tlhkb / avg_count)) :
2190 /* Reset average counters */
2191 avg_frhkb = avg_tlhkb = 0;
2196 ***************************************************************************
2197 * Display huge pages statistics.
2200 * @a Activity structure with statistics.
2201 * @prev Index in array where stats used as reference are.
2202 * @curr Index in array for current sample statistics.
2203 * @itv Interval of time in jiffies.
2204 ***************************************************************************
2206 __print_funct_t print_huge_stats(struct activity *a, int prev, int curr,
2207 unsigned long long itv)
2209 stub_print_huge_stats(a, prev, curr, itv, FALSE);
2213 ***************************************************************************
2214 * Display huge pages statistics.
2217 * @a Activity structure with statistics.
2218 * @prev Index in array where stats used as reference are.
2219 * @curr Index in array for current sample statistics.
2220 * @itv Interval of time in jiffies.
2221 ***************************************************************************
2223 __print_funct_t print_avg_huge_stats(struct activity *a, int prev, int curr,
2224 unsigned long long itv)
2226 stub_print_huge_stats(a, prev, curr, itv, TRUE);
2230 ***************************************************************************
2231 * Display CPU weighted frequency statistics. This function is used to
2232 * display instantaneous and average statistics.
2235 * @a Activity structure with statistics.
2236 * @prev Index in array where stats used as reference are.
2237 * @curr Index in array for current sample statistics.
2238 * @dispavg True if displaying average statistics.
2239 ***************************************************************************
2241 void print_pwr_wghfreq_stats(struct activity *a, int prev, int curr,
2242 unsigned long long itv)
2245 struct stats_pwr_wghfreq *spc, *spp, *spc_k, *spp_k;
2246 unsigned long long tis, tisfreq;
2249 printf("\n%-11s CPU wghMHz\n",
2253 for (i = 0; (i < a->nr) && (i < a->bitmap->b_size + 1); i++) {
2256 * The size of a->buf[...] CPU structure may be different from the default
2257 * sizeof(struct stats_pwr_wghfreq) value if data have been read from a file!
2258 * That's why we don't use a syntax like:
2259 * spc = (struct stats_pwr_wghfreq *) a->buf[...] + i;
2261 spc = (struct stats_pwr_wghfreq *) ((char *) a->buf[curr] + i * a->msize * a->nr2);
2262 spp = (struct stats_pwr_wghfreq *) ((char *) a->buf[prev] + i * a->msize * a->nr2);
2265 * Note: a->nr is in [1, NR_CPUS + 1].
2266 * Bitmap size is provided for (NR_CPUS + 1) CPUs.
2267 * Anyway, NR_CPUS may vary between the version of sysstat
2268 * used by sadc to create a file, and the version of sysstat
2269 * used by sar to read it...
2272 /* Should current CPU (including CPU "all") be displayed? */
2273 if (a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))) {
2275 /* Yes: Display it */
2276 printf("%-11s", timestamp[curr]);
2279 /* This is CPU "all" */
2283 printf(" %3d", i - 1);
2289 for (k = 0; k < a->nr2; k++) {
2291 spc_k = (struct stats_pwr_wghfreq *) ((char *) spc + k * a->msize);
2294 spp_k = (struct stats_pwr_wghfreq *) ((char *) spp + k * a->msize);
2296 tisfreq += (spc_k->freq / 1000) *
2297 (spc_k->time_in_state - spp_k->time_in_state);
2298 tis += (spc_k->time_in_state - spp_k->time_in_state);
2301 /* Display weighted frequency for current CPU */
2302 printf(" %9.2f\n", tis ? ((double) tisfreq) / tis : 0.0);