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
670 printf("\n%-11s runq-sz plist-sz ldavg-1 ldavg-5 ldavg-15\n",
675 /* Display instantaneous values */
676 printf("%-11s %9lu %9u %9.2f %9.2f %9.2f\n", timestamp[curr],
679 (double) sqc->load_avg_1 / 100,
680 (double) sqc->load_avg_5 / 100,
681 (double) sqc->load_avg_15 / 100);
683 /* Will be used to compute the average */
684 avg_nr_running += sqc->nr_running;
685 avg_nr_threads += sqc->nr_threads;
686 avg_load_avg_1 += sqc->load_avg_1;
687 avg_load_avg_5 += sqc->load_avg_5;
688 avg_load_avg_15 += sqc->load_avg_15;
691 /* Display average values */
692 printf("%-11s %9.0f %9.0f %9.2f %9.2f %9.2f\n", timestamp[curr],
693 (double) avg_nr_running / avg_count,
694 (double) avg_nr_threads / avg_count,
695 (double) avg_load_avg_1 / (avg_count * 100),
696 (double) avg_load_avg_5 / (avg_count * 100),
697 (double) avg_load_avg_15 / (avg_count * 100));
699 /* Reset average counters */
700 avg_nr_running = avg_nr_threads = 0;
701 avg_load_avg_1 = avg_load_avg_5 = avg_load_avg_15 = 0;
706 ***************************************************************************
707 * Display queue and load statistics.
710 * @a Activity structure with statistics.
711 * @prev Index in array where stats used as reference are.
712 * @curr Index in array for current sample statistics.
713 * @itv Interval of time in jiffies.
714 ***************************************************************************
716 __print_funct_t print_queue_stats(struct activity *a, int prev, int curr,
717 unsigned long long itv)
719 stub_print_queue_stats(a, prev, curr, FALSE);
723 ***************************************************************************
724 * Display average queue and load statistics.
727 * @a Activity structure with statistics.
728 * @prev Index in array where stats used as reference are.
729 * @curr Index in array for current sample statistics.
730 * @itv Interval of time in jiffies.
731 ***************************************************************************
733 __print_funct_t print_avg_queue_stats(struct activity *a, int prev, int curr,
734 unsigned long long itv)
736 stub_print_queue_stats(a, prev, curr, TRUE);
740 ***************************************************************************
741 * Display serial lines statistics.
744 * @a Activity structure with statistics.
745 * @prev Index in array where stats used as reference are.
746 * @curr Index in array for current sample statistics.
747 * @itv Interval of time in jiffies.
748 ***************************************************************************
750 __print_funct_t print_serial_stats(struct activity *a, int prev, int curr,
751 unsigned long long itv)
754 struct stats_serial *ssc, *ssp;
757 printf("\n%-11s TTY rcvin/s xmtin/s framerr/s prtyerr/s"
758 " brk/s ovrun/s\n", timestamp[!curr]);
761 for (i = 0; i < a->nr; i++) {
763 ssc = (struct stats_serial *) ((char *) a->buf[curr] + i * a->msize);
764 ssp = (struct stats_serial *) ((char *) a->buf[prev] + i * a->msize);
769 printf("%-11s %3d", timestamp[curr], ssc->line - 1);
771 if ((ssc->line == ssp->line) || WANT_SINCE_BOOT(flags)) {
772 printf(" %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f\n",
773 S_VALUE(ssp->rx, ssc->rx, itv),
774 S_VALUE(ssp->tx, ssc->tx, itv),
775 S_VALUE(ssp->frame, ssc->frame, itv),
776 S_VALUE(ssp->parity, ssc->parity, itv),
777 S_VALUE(ssp->brk, ssc->brk, itv),
778 S_VALUE(ssp->overrun, ssc->overrun, itv));
781 printf(" N/A N/A N/A N/A"
788 ***************************************************************************
789 * Display disks statistics.
792 * @a Activity structure with statistics.
793 * @prev Index in array where stats used as reference are.
794 * @curr Index in array for current sample statistics.
795 * @itv Interval of time in jiffies.
796 ***************************************************************************
798 __print_funct_t print_disk_stats(struct activity *a, int prev, int curr,
799 unsigned long long itv)
802 struct stats_disk *sdc, *sdp;
803 struct ext_disk_stats xds;
807 printf("\n%-11s DEV tps rd_sec/s wr_sec/s avgrq-sz"
808 " avgqu-sz await svctm %%util\n",
812 for (i = 0; i < a->nr; i++) {
814 sdc = (struct stats_disk *) ((char *) a->buf[curr] + i * a->msize);
816 if (!(sdc->major + sdc->minor))
819 j = check_disk_reg(a, curr, prev, i);
820 sdp = (struct stats_disk *) ((char *) a->buf[prev] + j * a->msize);
822 /* Compute service time, etc. */
823 compute_ext_disk_stats(sdc, sdp, itv, &xds);
827 if ((USE_PRETTY_OPTION(flags)) && (sdc->major == dm_major)) {
828 dev_name = transform_devmapname(sdc->major, sdc->minor);
832 dev_name = get_devname(sdc->major, sdc->minor,
833 USE_PRETTY_OPTION(flags));
836 printf("%-11s %9s %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f\n",
838 /* Confusion possible here between index and minor numbers */
840 S_VALUE(sdp->nr_ios, sdc->nr_ios, itv),
841 ll_s_value(sdp->rd_sect, sdc->rd_sect, itv),
842 ll_s_value(sdp->wr_sect, sdc->wr_sect, itv),
843 /* See iostat for explanations */
845 S_VALUE(sdp->rq_ticks, sdc->rq_ticks, itv) / 1000.0,
853 ***************************************************************************
854 * Display network interfaces statistics.
857 * @a Activity structure with statistics.
858 * @prev Index in array where stats used as reference are.
859 * @curr Index in array for current sample statistics.
860 * @itv Interval of time in jiffies.
861 ***************************************************************************
863 __print_funct_t print_net_dev_stats(struct activity *a, int prev, int curr,
864 unsigned long long itv)
867 struct stats_net_dev *sndc, *sndp;
870 printf("\n%-11s IFACE rxpck/s txpck/s rxkB/s txkB/s"
871 " rxcmp/s txcmp/s rxmcst/s\n", timestamp[!curr]);
874 for (i = 0; i < a->nr; i++) {
876 sndc = (struct stats_net_dev *) ((char *) a->buf[curr] + i * a->msize);
878 if (!strcmp(sndc->interface, ""))
881 j = check_net_dev_reg(a, curr, prev, i);
882 sndp = (struct stats_net_dev *) ((char *) a->buf[prev] + j * a->msize);
884 printf("%-11s %9s", timestamp[curr], sndc->interface);
886 printf(" %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f\n",
887 S_VALUE(sndp->rx_packets, sndc->rx_packets, itv),
888 S_VALUE(sndp->tx_packets, sndc->tx_packets, itv),
889 S_VALUE(sndp->rx_bytes, sndc->rx_bytes, itv) / 1024,
890 S_VALUE(sndp->tx_bytes, sndc->tx_bytes, itv) / 1024,
891 S_VALUE(sndp->rx_compressed, sndc->rx_compressed, itv),
892 S_VALUE(sndp->tx_compressed, sndc->tx_compressed, itv),
893 S_VALUE(sndp->multicast, sndc->multicast, itv));
898 ***************************************************************************
899 * Display network interface errors statistics.
902 * @a Activity structure with statistics.
903 * @prev Index in array where stats used as reference are.
904 * @curr Index in array for current sample statistics.
905 * @itv Interval of time in jiffies.
906 ***************************************************************************
908 __print_funct_t print_net_edev_stats(struct activity *a, int prev, int curr,
909 unsigned long long itv)
912 struct stats_net_edev *snedc, *snedp;
915 printf("\n%-11s IFACE rxerr/s txerr/s coll/s rxdrop/s"
916 " txdrop/s txcarr/s rxfram/s rxfifo/s txfifo/s\n",
920 for (i = 0; i < a->nr; i++) {
922 snedc = (struct stats_net_edev *) ((char *) a->buf[curr] + i * a->msize);
924 if (!strcmp(snedc->interface, ""))
927 j = check_net_edev_reg(a, curr, prev, i);
928 snedp = (struct stats_net_edev *) ((char *) a->buf[prev] + j * a->msize);
930 printf("%-11s %9s", timestamp[curr], snedc->interface);
932 printf(" %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f\n",
933 S_VALUE(snedp->rx_errors, snedc->rx_errors, itv),
934 S_VALUE(snedp->tx_errors, snedc->tx_errors, itv),
935 S_VALUE(snedp->collisions, snedc->collisions, itv),
936 S_VALUE(snedp->rx_dropped, snedc->rx_dropped, itv),
937 S_VALUE(snedp->tx_dropped, snedc->tx_dropped, itv),
938 S_VALUE(snedp->tx_carrier_errors, snedc->tx_carrier_errors, itv),
939 S_VALUE(snedp->rx_frame_errors, snedc->rx_frame_errors, itv),
940 S_VALUE(snedp->rx_fifo_errors, snedc->rx_fifo_errors, itv),
941 S_VALUE(snedp->tx_fifo_errors, snedc->tx_fifo_errors, itv));
946 ***************************************************************************
947 * Display NFS client statistics.
950 * @a Activity structure with statistics.
951 * @prev Index in array where stats used as reference are.
952 * @curr Index in array for current sample statistics.
953 * @itv Interval of time in jiffies.
954 ***************************************************************************
956 __print_funct_t print_net_nfs_stats(struct activity *a, int prev, int curr,
957 unsigned long long itv)
960 *snnc = (struct stats_net_nfs *) a->buf[curr],
961 *snnp = (struct stats_net_nfs *) a->buf[prev];
964 printf("\n%-11s call/s retrans/s read/s write/s access/s"
965 " getatt/s\n", timestamp[!curr]);
968 printf("%-11s %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f\n", timestamp[curr],
969 S_VALUE(snnp->nfs_rpccnt, snnc->nfs_rpccnt, itv),
970 S_VALUE(snnp->nfs_rpcretrans, snnc->nfs_rpcretrans, itv),
971 S_VALUE(snnp->nfs_readcnt, snnc->nfs_readcnt, itv),
972 S_VALUE(snnp->nfs_writecnt, snnc->nfs_writecnt, itv),
973 S_VALUE(snnp->nfs_accesscnt, snnc->nfs_accesscnt, itv),
974 S_VALUE(snnp->nfs_getattcnt, snnc->nfs_getattcnt, itv));
978 ***************************************************************************
979 * Display NFS server 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_nfsd_stats(struct activity *a, int prev, int curr,
989 unsigned long long itv)
991 struct stats_net_nfsd
992 *snndc = (struct stats_net_nfsd *) a->buf[curr],
993 *snndp = (struct stats_net_nfsd *) a->buf[prev];
996 printf("\n%-11s scall/s badcall/s packet/s udp/s tcp/s "
997 "hit/s miss/s sread/s swrite/s saccess/s sgetatt/s\n",
1001 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",
1003 S_VALUE(snndp->nfsd_rpccnt, snndc->nfsd_rpccnt, itv),
1004 S_VALUE(snndp->nfsd_rpcbad, snndc->nfsd_rpcbad, itv),
1005 S_VALUE(snndp->nfsd_netcnt, snndc->nfsd_netcnt, itv),
1006 S_VALUE(snndp->nfsd_netudpcnt, snndc->nfsd_netudpcnt, itv),
1007 S_VALUE(snndp->nfsd_nettcpcnt, snndc->nfsd_nettcpcnt, itv),
1008 S_VALUE(snndp->nfsd_rchits, snndc->nfsd_rchits, itv),
1009 S_VALUE(snndp->nfsd_rcmisses, snndc->nfsd_rcmisses, itv),
1010 S_VALUE(snndp->nfsd_readcnt, snndc->nfsd_readcnt, itv),
1011 S_VALUE(snndp->nfsd_writecnt, snndc->nfsd_writecnt, itv),
1012 S_VALUE(snndp->nfsd_accesscnt, snndc->nfsd_accesscnt, itv),
1013 S_VALUE(snndp->nfsd_getattcnt, snndc->nfsd_getattcnt, itv));
1017 ***************************************************************************
1018 * Display network sockets statistics. This function is used to display
1019 * instantaneous and average statistics.
1022 * @a Activity structure with statistics.
1023 * @prev Index in array where stats used as reference are.
1024 * @curr Index in array for current sample statistics.
1025 * @itv Interval of time in jiffies.
1026 * @dispavg TRUE if displaying average statistics.
1027 ***************************************************************************
1029 void stub_print_net_sock_stats(struct activity *a, int prev, int curr,
1030 unsigned long long itv, int dispavg)
1032 struct stats_net_sock
1033 *snsc = (struct stats_net_sock *) a->buf[curr];
1034 static unsigned long long
1043 printf("\n%-11s totsck tcpsck udpsck rawsck ip-frag tcp-tw\n",
1048 /* Display instantaneous values */
1049 printf("%-11s %9u %9u %9u %9u %9u %9u\n", timestamp[curr],
1057 /* Will be used to compute the average */
1058 avg_sock_inuse += snsc->sock_inuse;
1059 avg_tcp_inuse += snsc->tcp_inuse;
1060 avg_udp_inuse += snsc->udp_inuse;
1061 avg_raw_inuse += snsc->raw_inuse;
1062 avg_frag_inuse += snsc->frag_inuse;
1063 avg_tcp_tw += snsc->tcp_tw;
1066 /* Display average values */
1067 printf("%-11s %9.0f %9.0f %9.0f %9.0f %9.0f %9.0f\n", timestamp[curr],
1068 (double) avg_sock_inuse / avg_count,
1069 (double) avg_tcp_inuse / avg_count,
1070 (double) avg_udp_inuse / avg_count,
1071 (double) avg_raw_inuse / avg_count,
1072 (double) avg_frag_inuse / avg_count,
1073 (double) avg_tcp_tw / avg_count);
1075 /* Reset average counters */
1076 avg_sock_inuse = avg_tcp_inuse = avg_udp_inuse = 0;
1077 avg_raw_inuse = avg_frag_inuse = avg_tcp_tw = 0;
1082 ***************************************************************************
1083 * Display network sockets statistics.
1086 * @a Activity structure with statistics.
1087 * @prev Index in array where stats used as reference are.
1088 * @curr Index in array for current sample statistics.
1089 * @itv Interval of time in jiffies.
1090 ***************************************************************************
1092 __print_funct_t print_net_sock_stats(struct activity *a, int prev, int curr,
1093 unsigned long long itv)
1095 stub_print_net_sock_stats(a, prev, curr, itv, FALSE);
1099 ***************************************************************************
1100 * Display average network sockets statistics.
1103 * @a Activity structure with statistics.
1104 * @prev Index in array where stats used as reference are.
1105 * @curr Index in array for current sample statistics.
1106 * @itv Interval of time in jiffies.
1107 ***************************************************************************
1109 __print_funct_t print_avg_net_sock_stats(struct activity *a, int prev, int curr,
1110 unsigned long long itv)
1112 stub_print_net_sock_stats(a, prev, curr, itv, TRUE);
1116 ***************************************************************************
1117 * Display IP network traffic statistics.
1120 * @a Activity structure with statistics.
1121 * @prev Index in array where stats used as reference are.
1122 * @curr Index in array for current sample statistics.
1123 * @itv Interval of time in jiffies.
1124 ***************************************************************************
1126 __print_funct_t print_net_ip_stats(struct activity *a, int prev, int curr,
1127 unsigned long long itv)
1130 *snic = (struct stats_net_ip *) a->buf[curr],
1131 *snip = (struct stats_net_ip *) a->buf[prev];
1134 printf("\n%-11s irec/s fwddgm/s idel/s orq/s asmrq/s"
1135 " asmok/s fragok/s fragcrt/s\n", timestamp[!curr]);
1138 printf("%-11s %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f\n",
1140 S_VALUE(snip->InReceives, snic->InReceives, itv),
1141 S_VALUE(snip->ForwDatagrams, snic->ForwDatagrams, itv),
1142 S_VALUE(snip->InDelivers, snic->InDelivers, itv),
1143 S_VALUE(snip->OutRequests, snic->OutRequests, itv),
1144 S_VALUE(snip->ReasmReqds, snic->ReasmReqds, itv),
1145 S_VALUE(snip->ReasmOKs, snic->ReasmOKs, itv),
1146 S_VALUE(snip->FragOKs, snic->FragOKs, itv),
1147 S_VALUE(snip->FragCreates, snic->FragCreates, itv));
1151 ***************************************************************************
1152 * Display IP network error statistics.
1155 * @a Activity structure with statistics.
1156 * @prev Index in array where stats used as reference are.
1157 * @curr Index in array for current sample statistics.
1158 * @itv Interval of time in jiffies.
1159 ***************************************************************************
1161 __print_funct_t print_net_eip_stats(struct activity *a, int prev, int curr,
1162 unsigned long long itv)
1164 struct stats_net_eip
1165 *sneic = (struct stats_net_eip *) a->buf[curr],
1166 *sneip = (struct stats_net_eip *) a->buf[prev];
1169 printf("\n%-11s ihdrerr/s iadrerr/s iukwnpr/s idisc/s odisc/s"
1170 " onort/s asmf/s fragf/s\n", timestamp[!curr]);
1173 printf("%-11s %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f\n",
1175 S_VALUE(sneip->InHdrErrors, sneic->InHdrErrors, itv),
1176 S_VALUE(sneip->InAddrErrors, sneic->InAddrErrors, itv),
1177 S_VALUE(sneip->InUnknownProtos, sneic->InUnknownProtos, itv),
1178 S_VALUE(sneip->InDiscards, sneic->InDiscards, itv),
1179 S_VALUE(sneip->OutDiscards, sneic->OutDiscards, itv),
1180 S_VALUE(sneip->OutNoRoutes, sneic->OutNoRoutes, itv),
1181 S_VALUE(sneip->ReasmFails, sneic->ReasmFails, itv),
1182 S_VALUE(sneip->FragFails, sneic->FragFails, itv));
1186 ***************************************************************************
1187 * Display ICMP network traffic statistics.
1190 * @a Activity structure with statistics.
1191 * @prev Index in array where stats used as reference are.
1192 * @curr Index in array for current sample statistics.
1193 * @itv Interval of time in jiffies.
1194 ***************************************************************************
1196 __print_funct_t print_net_icmp_stats(struct activity *a, int prev, int curr,
1197 unsigned long long itv)
1199 struct stats_net_icmp
1200 *snic = (struct stats_net_icmp *) a->buf[curr],
1201 *snip = (struct stats_net_icmp *) a->buf[prev];
1204 printf("\n%-11s imsg/s omsg/s iech/s iechr/s oech/s"
1205 " oechr/s itm/s itmr/s otm/s otmr/s"
1206 " iadrmk/s iadrmkr/s oadrmk/s oadrmkr/s\n", timestamp[!curr]);
1209 printf("%-11s %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f"
1210 " %9.2f %9.2f %9.2f %9.2f\n", timestamp[curr],
1211 S_VALUE(snip->InMsgs, snic->InMsgs, itv),
1212 S_VALUE(snip->OutMsgs, snic->OutMsgs, itv),
1213 S_VALUE(snip->InEchos, snic->InEchos, itv),
1214 S_VALUE(snip->InEchoReps, snic->InEchoReps, itv),
1215 S_VALUE(snip->OutEchos, snic->OutEchos, itv),
1216 S_VALUE(snip->OutEchoReps, snic->OutEchoReps, itv),
1217 S_VALUE(snip->InTimestamps, snic->InTimestamps, itv),
1218 S_VALUE(snip->InTimestampReps, snic->InTimestampReps, itv),
1219 S_VALUE(snip->OutTimestamps, snic->OutTimestamps, itv),
1220 S_VALUE(snip->OutTimestampReps, snic->OutTimestampReps, itv),
1221 S_VALUE(snip->InAddrMasks, snic->InAddrMasks, itv),
1222 S_VALUE(snip->InAddrMaskReps, snic->InAddrMaskReps, itv),
1223 S_VALUE(snip->OutAddrMasks, snic->OutAddrMasks, itv),
1224 S_VALUE(snip->OutAddrMaskReps, snic->OutAddrMaskReps, itv));
1228 ***************************************************************************
1229 * Display ICMP network error statistics.
1232 * @a Activity structure with statistics.
1233 * @prev Index in array where stats used as reference are.
1234 * @curr Index in array for current sample statistics.
1235 * @itv Interval of time in jiffies.
1236 ***************************************************************************
1238 __print_funct_t print_net_eicmp_stats(struct activity *a, int prev, int curr,
1239 unsigned long long itv)
1241 struct stats_net_eicmp
1242 *sneic = (struct stats_net_eicmp *) a->buf[curr],
1243 *sneip = (struct stats_net_eicmp *) a->buf[prev];
1246 printf("\n%-11s ierr/s oerr/s idstunr/s odstunr/s itmex/s"
1247 " otmex/s iparmpb/s oparmpb/s isrcq/s osrcq/s"
1248 " iredir/s oredir/s\n", timestamp[!curr]);
1251 printf("%-11s %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f"
1252 " %9.2f %9.2f\n", timestamp[curr],
1253 S_VALUE(sneip->InErrors, sneic->InErrors, itv),
1254 S_VALUE(sneip->OutErrors, sneic->OutErrors, itv),
1255 S_VALUE(sneip->InDestUnreachs, sneic->InDestUnreachs, itv),
1256 S_VALUE(sneip->OutDestUnreachs, sneic->OutDestUnreachs, itv),
1257 S_VALUE(sneip->InTimeExcds, sneic->InTimeExcds, itv),
1258 S_VALUE(sneip->OutTimeExcds, sneic->OutTimeExcds, itv),
1259 S_VALUE(sneip->InParmProbs, sneic->InParmProbs, itv),
1260 S_VALUE(sneip->OutParmProbs, sneic->OutParmProbs, itv),
1261 S_VALUE(sneip->InSrcQuenchs, sneic->InSrcQuenchs, itv),
1262 S_VALUE(sneip->OutSrcQuenchs, sneic->OutSrcQuenchs, itv),
1263 S_VALUE(sneip->InRedirects, sneic->InRedirects, itv),
1264 S_VALUE(sneip->OutRedirects, sneic->OutRedirects, itv));
1268 ***************************************************************************
1269 * Display TCP network traffic statistics.
1272 * @a Activity structure with statistics.
1273 * @prev Index in array where stats used as reference are.
1274 * @curr Index in array for current sample statistics.
1275 * @itv Interval of time in jiffies.
1276 ***************************************************************************
1278 __print_funct_t print_net_tcp_stats(struct activity *a, int prev, int curr,
1279 unsigned long long itv)
1281 struct stats_net_tcp
1282 *sntc = (struct stats_net_tcp *) a->buf[curr],
1283 *sntp = (struct stats_net_tcp *) a->buf[prev];
1286 printf("\n%-11s active/s passive/s iseg/s oseg/s\n",
1290 printf("%-11s %9.2f %9.2f %9.2f %9.2f\n",
1292 S_VALUE(sntp->ActiveOpens, sntc->ActiveOpens, itv),
1293 S_VALUE(sntp->PassiveOpens, sntc->PassiveOpens, itv),
1294 S_VALUE(sntp->InSegs, sntc->InSegs, itv),
1295 S_VALUE(sntp->OutSegs, sntc->OutSegs, itv));
1299 ***************************************************************************
1300 * Display TCP network error statistics.
1303 * @a Activity structure with statistics.
1304 * @prev Index in array where stats used as reference are.
1305 * @curr Index in array for current sample statistics.
1306 * @itv Interval of time in jiffies.
1307 ***************************************************************************
1309 __print_funct_t print_net_etcp_stats(struct activity *a, int prev, int curr,
1310 unsigned long long itv)
1312 struct stats_net_etcp
1313 *snetc = (struct stats_net_etcp *) a->buf[curr],
1314 *snetp = (struct stats_net_etcp *) a->buf[prev];
1317 printf("\n%-11s atmptf/s estres/s retrans/s isegerr/s orsts/s\n",
1321 printf("%-11s %9.2f %9.2f %9.2f %9.2f %9.2f\n",
1323 S_VALUE(snetp->AttemptFails, snetc->AttemptFails, itv),
1324 S_VALUE(snetp->EstabResets, snetc->EstabResets, itv),
1325 S_VALUE(snetp->RetransSegs, snetc->RetransSegs, itv),
1326 S_VALUE(snetp->InErrs, snetc->InErrs, itv),
1327 S_VALUE(snetp->OutRsts, snetc->OutRsts, itv));
1331 ***************************************************************************
1332 * Display UDP network traffic statistics.
1335 * @a Activity structure with statistics.
1336 * @prev Index in array where stats used as reference are.
1337 * @curr Index in array for current sample statistics.
1338 * @itv Interval of time in jiffies.
1339 ***************************************************************************
1341 __print_funct_t print_net_udp_stats(struct activity *a, int prev, int curr,
1342 unsigned long long itv)
1344 struct stats_net_udp
1345 *snuc = (struct stats_net_udp *) a->buf[curr],
1346 *snup = (struct stats_net_udp *) a->buf[prev];
1349 printf("\n%-11s idgm/s odgm/s noport/s idgmerr/s\n",
1353 printf("%-11s %9.2f %9.2f %9.2f %9.2f\n",
1355 S_VALUE(snup->InDatagrams, snuc->InDatagrams, itv),
1356 S_VALUE(snup->OutDatagrams, snuc->OutDatagrams, itv),
1357 S_VALUE(snup->NoPorts, snuc->NoPorts, itv),
1358 S_VALUE(snup->InErrors, snuc->InErrors, itv));
1362 ***************************************************************************
1363 * Display IPv6 sockets statistics. This function is used to display
1364 * instantaneous and average statistics.
1367 * @a Activity structure with statistics.
1368 * @prev Index in array where stats used as reference are.
1369 * @curr Index in array for current sample statistics.
1370 * @itv Interval of time in jiffies.
1371 * @dispavg TRUE if displaying average statistics.
1372 ***************************************************************************
1374 void stub_print_net_sock6_stats(struct activity *a, int prev, int curr,
1375 unsigned long long itv, int dispavg)
1377 struct stats_net_sock6
1378 *snsc = (struct stats_net_sock6 *) a->buf[curr];
1379 static unsigned long long
1383 avg_frag6_inuse = 0;
1386 printf("\n%-11s tcp6sck udp6sck raw6sck ip6-frag\n",
1391 /* Display instantaneous values */
1392 printf("%-11s %9u %9u %9u %9u\n", timestamp[curr],
1398 /* Will be used to compute the average */
1399 avg_tcp6_inuse += snsc->tcp6_inuse;
1400 avg_udp6_inuse += snsc->udp6_inuse;
1401 avg_raw6_inuse += snsc->raw6_inuse;
1402 avg_frag6_inuse += snsc->frag6_inuse;
1405 /* Display average values */
1406 printf("%-11s %9.0f %9.0f %9.0f %9.0f\n", timestamp[curr],
1407 (double) avg_tcp6_inuse / avg_count,
1408 (double) avg_udp6_inuse / avg_count,
1409 (double) avg_raw6_inuse / avg_count,
1410 (double) avg_frag6_inuse / avg_count);
1412 /* Reset average counters */
1413 avg_tcp6_inuse = avg_udp6_inuse = avg_raw6_inuse = avg_frag6_inuse = 0;
1418 ***************************************************************************
1419 * Display IPv6 sockets statistics.
1422 * @a Activity structure with statistics.
1423 * @prev Index in array where stats used as reference are.
1424 * @curr Index in array for current sample statistics.
1425 * @itv Interval of time in jiffies.
1426 ***************************************************************************
1428 __print_funct_t print_net_sock6_stats(struct activity *a, int prev, int curr,
1429 unsigned long long itv)
1431 stub_print_net_sock6_stats(a, prev, curr, itv, FALSE);
1435 ***************************************************************************
1436 * Display average IPv6 sockets statistics.
1439 * @a Activity structure with statistics.
1440 * @prev Index in array where stats used as reference are.
1441 * @curr Index in array for current sample statistics.
1442 * @itv Interval of time in jiffies.
1443 ***************************************************************************
1445 __print_funct_t print_avg_net_sock6_stats(struct activity *a, int prev, int curr,
1446 unsigned long long itv)
1448 stub_print_net_sock6_stats(a, prev, curr, itv, TRUE);
1452 ***************************************************************************
1453 * Display IPv6 network traffic statistics.
1456 * @a Activity structure with statistics.
1457 * @prev Index in array where stats used as reference are.
1458 * @curr Index in array for current sample statistics.
1459 * @itv Interval of time in jiffies.
1460 ***************************************************************************
1462 __print_funct_t print_net_ip6_stats(struct activity *a, int prev, int curr,
1463 unsigned long long itv)
1465 struct stats_net_ip6
1466 *snic = (struct stats_net_ip6 *) a->buf[curr],
1467 *snip = (struct stats_net_ip6 *) a->buf[prev];
1470 printf("\n%-11s irec6/s fwddgm6/s idel6/s orq6/s asmrq6/s"
1471 " asmok6/s imcpck6/s omcpck6/s fragok6/s fragcr6/s\n",
1475 printf("%-11s %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f\n",
1477 S_VALUE(snip->InReceives6, snic->InReceives6, itv),
1478 S_VALUE(snip->OutForwDatagrams6, snic->OutForwDatagrams6, itv),
1479 S_VALUE(snip->InDelivers6, snic->InDelivers6, itv),
1480 S_VALUE(snip->OutRequests6, snic->OutRequests6, itv),
1481 S_VALUE(snip->ReasmReqds6, snic->ReasmReqds6, itv),
1482 S_VALUE(snip->ReasmOKs6, snic->ReasmOKs6, itv),
1483 S_VALUE(snip->InMcastPkts6, snic->InMcastPkts6, itv),
1484 S_VALUE(snip->OutMcastPkts6, snic->OutMcastPkts6, itv),
1485 S_VALUE(snip->FragOKs6, snic->FragOKs6, itv),
1486 S_VALUE(snip->FragCreates6, snic->FragCreates6, itv));
1490 ***************************************************************************
1491 * Display IPv6 network error statistics.
1494 * @a Activity structure with statistics.
1495 * @prev Index in array where stats used as reference are.
1496 * @curr Index in array for current sample statistics.
1497 * @itv Interval of time in jiffies.
1498 ***************************************************************************
1500 __print_funct_t print_net_eip6_stats(struct activity *a, int prev, int curr,
1501 unsigned long long itv)
1503 struct stats_net_eip6
1504 *sneic = (struct stats_net_eip6 *) a->buf[curr],
1505 *sneip = (struct stats_net_eip6 *) a->buf[prev];
1508 printf("\n%-11s ihdrer6/s iadrer6/s iukwnp6/s i2big6/s idisc6/s odisc6/s"
1509 " inort6/s onort6/s asmf6/s fragf6/s itrpck6/s\n",
1513 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",
1515 S_VALUE(sneip->InHdrErrors6, sneic->InHdrErrors6, itv),
1516 S_VALUE(sneip->InAddrErrors6, sneic->InAddrErrors6, itv),
1517 S_VALUE(sneip->InUnknownProtos6, sneic->InUnknownProtos6, itv),
1518 S_VALUE(sneip->InTooBigErrors6, sneic->InTooBigErrors6, itv),
1519 S_VALUE(sneip->InDiscards6, sneic->InDiscards6, itv),
1520 S_VALUE(sneip->OutDiscards6, sneic->OutDiscards6, itv),
1521 S_VALUE(sneip->InNoRoutes6, sneic->InNoRoutes6, itv),
1522 S_VALUE(sneip->OutNoRoutes6, sneic->OutNoRoutes6, itv),
1523 S_VALUE(sneip->ReasmFails6, sneic->ReasmFails6, itv),
1524 S_VALUE(sneip->FragFails6, sneic->FragFails6, itv),
1525 S_VALUE(sneip->InTruncatedPkts6, sneic->InTruncatedPkts6, itv));
1529 ***************************************************************************
1530 * Display ICMPv6 network traffic statistics.
1533 * @a Activity structure with statistics.
1534 * @prev Index in array where stats used as reference are.
1535 * @curr Index in array for current sample statistics.
1536 * @itv Interval of time in jiffies.
1537 ***************************************************************************
1539 __print_funct_t print_net_icmp6_stats(struct activity *a, int prev, int curr,
1540 unsigned long long itv)
1542 struct stats_net_icmp6
1543 *snic = (struct stats_net_icmp6 *) a->buf[curr],
1544 *snip = (struct stats_net_icmp6 *) a->buf[prev];
1547 printf("\n%-11s imsg6/s omsg6/s iech6/s iechr6/s oechr6/s"
1548 " igmbq6/s igmbr6/s ogmbr6/s igmbrd6/s ogmbrd6/s irtsol6/s ortsol6/s"
1549 " irtad6/s inbsol6/s onbsol6/s inbad6/s onbad6/s\n",
1553 printf("%-11s %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f"
1554 " %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f\n", timestamp[curr],
1555 S_VALUE(snip->InMsgs6, snic->InMsgs6, itv),
1556 S_VALUE(snip->OutMsgs6, snic->OutMsgs6, itv),
1557 S_VALUE(snip->InEchos6, snic->InEchos6, itv),
1558 S_VALUE(snip->InEchoReplies6, snic->InEchoReplies6, itv),
1559 S_VALUE(snip->OutEchoReplies6, snic->OutEchoReplies6, itv),
1560 S_VALUE(snip->InGroupMembQueries6, snic->InGroupMembQueries6, itv),
1561 S_VALUE(snip->InGroupMembResponses6, snic->InGroupMembResponses6, itv),
1562 S_VALUE(snip->OutGroupMembResponses6, snic->OutGroupMembResponses6, itv),
1563 S_VALUE(snip->InGroupMembReductions6, snic->InGroupMembReductions6, itv),
1564 S_VALUE(snip->OutGroupMembReductions6, snic->OutGroupMembReductions6, itv),
1565 S_VALUE(snip->InRouterSolicits6, snic->InRouterSolicits6, itv),
1566 S_VALUE(snip->OutRouterSolicits6, snic->OutRouterSolicits6, itv),
1567 S_VALUE(snip->InRouterAdvertisements6, snic->InRouterAdvertisements6, itv),
1568 S_VALUE(snip->InNeighborSolicits6, snic->InNeighborSolicits6, itv),
1569 S_VALUE(snip->OutNeighborSolicits6, snic->OutNeighborSolicits6, itv),
1570 S_VALUE(snip->InNeighborAdvertisements6, snic->InNeighborAdvertisements6, itv),
1571 S_VALUE(snip->OutNeighborAdvertisements6, snic->OutNeighborAdvertisements6, itv));
1575 ***************************************************************************
1576 * Display ICMPv6 network error statistics.
1579 * @a Activity structure with statistics.
1580 * @prev Index in array where stats used as reference are.
1581 * @curr Index in array for current sample statistics.
1582 * @itv Interval of time in jiffies.
1583 ***************************************************************************
1585 __print_funct_t print_net_eicmp6_stats(struct activity *a, int prev, int curr,
1586 unsigned long long itv)
1588 struct stats_net_eicmp6
1589 *sneic = (struct stats_net_eicmp6 *) a->buf[curr],
1590 *sneip = (struct stats_net_eicmp6 *) a->buf[prev];
1593 printf("\n%-11s ierr6/s idtunr6/s odtunr6/s itmex6/s otmex6/s"
1594 " iprmpb6/s oprmpb6/s iredir6/s oredir6/s ipck2b6/s opck2b6/s\n",
1598 printf("%-11s %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f"
1599 " %9.2f\n", timestamp[curr],
1600 S_VALUE(sneip->InErrors6, sneic->InErrors6, itv),
1601 S_VALUE(sneip->InDestUnreachs6, sneic->InDestUnreachs6, itv),
1602 S_VALUE(sneip->OutDestUnreachs6, sneic->OutDestUnreachs6, itv),
1603 S_VALUE(sneip->InTimeExcds6, sneic->InTimeExcds6, itv),
1604 S_VALUE(sneip->OutTimeExcds6, sneic->OutTimeExcds6, itv),
1605 S_VALUE(sneip->InParmProblems6, sneic->InParmProblems6, itv),
1606 S_VALUE(sneip->OutParmProblems6, sneic->OutParmProblems6, itv),
1607 S_VALUE(sneip->InRedirects6, sneic->InRedirects6, itv),
1608 S_VALUE(sneip->OutRedirects6, sneic->OutRedirects6, itv),
1609 S_VALUE(sneip->InPktTooBigs6, sneic->InPktTooBigs6, itv),
1610 S_VALUE(sneip->OutPktTooBigs6, sneic->OutPktTooBigs6, itv));
1614 ***************************************************************************
1615 * Display UDPv6 network traffic statistics.
1618 * @a Activity structure with statistics.
1619 * @prev Index in array where stats used as reference are.
1620 * @curr Index in array for current sample statistics.
1621 * @itv Interval of time in jiffies.
1622 ***************************************************************************
1624 __print_funct_t print_net_udp6_stats(struct activity *a, int prev, int curr,
1625 unsigned long long itv)
1627 struct stats_net_udp6
1628 *snuc = (struct stats_net_udp6 *) a->buf[curr],
1629 *snup = (struct stats_net_udp6 *) a->buf[prev];
1632 printf("\n%-11s idgm6/s odgm6/s noport6/s idgmer6/s\n",
1636 printf("%-11s %9.2f %9.2f %9.2f %9.2f\n",
1638 S_VALUE(snup->InDatagrams6, snuc->InDatagrams6, itv),
1639 S_VALUE(snup->OutDatagrams6, snuc->OutDatagrams6, itv),
1640 S_VALUE(snup->NoPorts6, snuc->NoPorts6, itv),
1641 S_VALUE(snup->InErrors6, snuc->InErrors6, itv));
1645 ***************************************************************************
1646 * Display CPU frequency statistics. This function is used to display
1647 * instantaneous and average statistics.
1650 * @a Activity structure with statistics.
1651 * @prev Index in array where stats used as reference are.
1652 * @curr Index in array for current sample statistics.
1653 * @dispavg True if displaying average statistics.
1654 ***************************************************************************
1656 void stub_print_pwr_cpufreq_stats(struct activity *a, int prev, int curr, int dispavg)
1659 struct stats_pwr_cpufreq *spc;
1660 static unsigned long long
1661 *avg_cpufreq = NULL;
1664 /* Allocate array of CPU frequency */
1665 if ((avg_cpufreq = (unsigned long long *) malloc(sizeof(unsigned long long) * a->nr))
1670 memset(avg_cpufreq, 0, sizeof(unsigned long long) * a->nr);
1674 printf("\n%-11s CPU MHz\n",
1678 for (i = 0; (i < a->nr) && (i < a->bitmap->b_size + 1); i++) {
1681 * The size of a->buf[...] CPU structure may be different from the default
1682 * sizeof(struct stats_pwr_cpufreq) value if data have been read from a file!
1683 * That's why we don't use a syntax like:
1684 * spc = (struct stats_pwr_cpufreq *) a->buf[...] + i;
1686 spc = (struct stats_pwr_cpufreq *) ((char *) a->buf[curr] + i * a->msize);
1689 * Note: a->nr is in [1, NR_CPUS + 1].
1690 * Bitmap size is provided for (NR_CPUS + 1) CPUs.
1691 * Anyway, NR_CPUS may vary between the version of sysstat
1692 * used by sadc to create a file, and the version of sysstat
1693 * used by sar to read it...
1696 /* Should current CPU (including CPU "all") be displayed? */
1697 if (a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))) {
1699 /* Yes: Display it */
1700 printf("%-11s", timestamp[curr]);
1703 /* This is CPU "all" */
1707 printf(" %3d", i - 1);
1711 /* Display instantaneous values */
1713 ((double) spc->cpufreq) / 100);
1715 * Will be used to compute the average.
1716 * Note: overflow unlikely to happen but not impossible...
1718 avg_cpufreq[i] += spc->cpufreq;
1721 /* Display average values */
1723 (double) avg_cpufreq[i] / (100 * avg_count));
1729 /* Array of CPU frequency no longer needed: Free it! */
1738 ***************************************************************************
1739 * Display CPU frequency statistics.
1742 * @a Activity structure with statistics.
1743 * @prev Index in array where stats used as reference are.
1744 * @curr Index in array for current sample statistics.
1745 * @itv Interval of time in jiffies.
1746 ***************************************************************************
1748 __print_funct_t print_pwr_cpufreq_stats(struct activity *a, int prev, int curr,
1749 unsigned long long itv)
1751 stub_print_pwr_cpufreq_stats(a, prev, curr, FALSE);
1755 ***************************************************************************
1756 * Display average CPU frequency statistics.
1759 * @a Activity structure with statistics.
1760 * @prev Index in array where stats used as reference are.
1761 * @curr Index in array for current sample statistics.
1762 * @itv Interval of time in jiffies.
1763 ***************************************************************************
1765 __print_funct_t print_avg_pwr_cpufreq_stats(struct activity *a, int prev, int curr,
1766 unsigned long long itv)
1768 stub_print_pwr_cpufreq_stats(a, prev, curr, TRUE);
1772 ***************************************************************************
1773 * Display fan statistics. This function is used to display
1774 * instantaneous and average statistics.
1777 * @a Activity structure with statistics.
1778 * @prev Index in array where stats used as reference are.
1779 * @curr Index in array for current sample statistics.
1780 * @dispavg True if displaying average statistics.
1781 ***************************************************************************
1783 void stub_print_pwr_fan_stats(struct activity *a, int prev, int curr, int dispavg)
1786 struct stats_pwr_fan *spc;
1787 static double *avg_fan = NULL;
1788 static double *avg_fan_min = NULL;
1790 /* Allocate arrays of fan RPMs */
1792 if ((avg_fan = (double *) malloc(sizeof(double) * a->nr)) == NULL) {
1796 memset(avg_fan, 0, sizeof(double) * a->nr);
1799 if ((avg_fan_min = (double *) malloc(sizeof(double) * a->nr)) == NULL) {
1803 memset(avg_fan_min, 0, sizeof(double) * a->nr);
1807 printf("\n%-11s FAN rpm drpm %*s\n",
1808 timestamp[!curr], MAX_SENSORS_DEV_LEN, "DEVICE");
1811 for (i = 0; i < a->nr; i++) {
1812 spc = (struct stats_pwr_fan *) ((char *) a->buf[curr] + i * a->msize);
1814 printf("%-11s %3d", timestamp[curr], i + 1);
1817 /* Display average values */
1818 printf(" %9.2f %9.2f",
1819 (double) avg_fan[i] / avg_count,
1820 (double) (avg_fan[i] - avg_fan_min[i]) / avg_count);
1823 /* Display instantaneous values */
1824 printf(" %9.2f %9.2f",
1826 spc->rpm - spc->rpm_min);
1827 avg_fan[i] += spc->rpm;
1828 avg_fan_min[i] += spc->rpm_min;
1831 printf(" %*s\n", MAX_SENSORS_DEV_LEN, spc->device);
1847 ***************************************************************************
1848 * Display fan statistics.
1851 * @a Activity structure with statistics.
1852 * @prev Index in array where stats used as reference are.
1853 * @curr Index in array for current sample statistics.
1854 * @itv Interval of time in jiffies.
1855 ***************************************************************************
1857 __print_funct_t print_pwr_fan_stats(struct activity *a, int prev, int curr,
1858 unsigned long long itv)
1860 stub_print_pwr_fan_stats(a, prev, curr, FALSE);
1864 ***************************************************************************
1865 * Display average fan statistics.
1868 * @a Activity structure with statistics.
1869 * @prev Index in array where stats used as reference are.
1870 * @curr Index in array for current sample statistics.
1871 * @itv Interval of time in jiffies.
1872 ***************************************************************************
1874 __print_funct_t print_avg_pwr_fan_stats(struct activity *a, int prev, int curr,
1875 unsigned long long itv)
1877 stub_print_pwr_fan_stats(a, prev, curr, TRUE);
1881 ***************************************************************************
1882 * Display device temperature statistics. This function is used to display
1883 * instantaneous and average statistics.
1886 * @a Activity structure with statistics.
1887 * @prev Index in array where stats used as reference are.
1888 * @curr Index in array for current sample statistics.
1889 * @dispavg True if displaying average statistics.
1890 ***************************************************************************
1892 void stub_print_pwr_temp_stats(struct activity *a, int prev, int curr, int dispavg)
1895 struct stats_pwr_temp *spc;
1896 static double *avg_temp = NULL;
1897 static double *avg_temp_min = NULL, *avg_temp_max = NULL;
1899 /* Allocate arrays of temperatures */
1901 if ((avg_temp = (double *) malloc(sizeof(double) * a->nr)) == NULL) {
1905 memset(avg_temp, 0, sizeof(double) * a->nr);
1907 if (!avg_temp_min) {
1908 if ((avg_temp_min = (double *) malloc(sizeof(double) * a->nr)) == NULL) {
1912 memset(avg_temp_min, 0, sizeof(double) * a->nr);
1914 if (!avg_temp_max) {
1915 if ((avg_temp_max = (double *) malloc(sizeof(double) * a->nr)) == NULL) {
1919 memset(avg_temp_max, 0, sizeof(double) * a->nr);
1923 printf("\n%-11s TEMP degC %%temp %*s\n",
1924 timestamp[!curr], MAX_SENSORS_DEV_LEN, "DEVICE");
1927 for (i = 0; i < a->nr; i++) {
1928 spc = (struct stats_pwr_temp *) ((char *) a->buf[curr] + i * a->msize);
1930 printf("%-11s %3d", timestamp[curr], i + 1);
1933 /* Display average values */
1934 printf(" %9.2f %9.2f",
1935 (double) avg_temp[i] / avg_count,
1936 (avg_temp_max[i] - avg_temp_min[i]) ?
1937 ((double) (avg_temp[i] / avg_count) - avg_temp_min[i]) / (avg_temp_max[i] - avg_temp_min[i]) * 100 :
1941 /* Display instantaneous values */
1942 printf(" %9.2f %9.2f",
1944 (spc->temp_max - spc->temp_min) ?
1945 (spc->temp - spc->temp_min) / (spc->temp_max - spc->temp_min) * 100 :
1947 avg_temp[i] += spc->temp;
1948 /* Assume that min and max temperatures cannot vary */
1949 avg_temp_min[i] = spc->temp_min;
1950 avg_temp_max[i] = spc->temp_max;
1953 printf(" %*s\n", MAX_SENSORS_DEV_LEN, spc->device);
1963 avg_temp_min = NULL;
1967 avg_temp_max = NULL;
1973 ***************************************************************************
1974 * Display temperature statistics.
1977 * @a Activity structure with statistics.
1978 * @prev Index in array where stats used as reference are.
1979 * @curr Index in array for current sample statistics.
1980 * @itv Interval of time in jiffies.
1981 ***************************************************************************
1983 __print_funct_t print_pwr_temp_stats(struct activity *a, int prev, int curr,
1984 unsigned long long itv)
1986 stub_print_pwr_temp_stats(a, prev, curr, FALSE);
1990 ***************************************************************************
1991 * Display average temperature statistics.
1994 * @a Activity structure with statistics.
1995 * @prev Index in array where stats used as reference are.
1996 * @curr Index in array for current sample statistics.
1997 * @itv Interval of time in jiffies.
1998 ***************************************************************************
2000 __print_funct_t print_avg_pwr_temp_stats(struct activity *a, int prev, int curr,
2001 unsigned long long itv)
2003 stub_print_pwr_temp_stats(a, prev, curr, TRUE);
2007 ***************************************************************************
2008 * Display voltage inputs statistics. This function is used to display
2009 * instantaneous and average statistics.
2012 * @a Activity structure with statistics.
2013 * @prev Index in array where stats used as reference are.
2014 * @curr Index in array for current sample statistics.
2015 * @dispavg True if displaying average statistics.
2016 ***************************************************************************
2018 void stub_print_pwr_in_stats(struct activity *a, int prev, int curr, int dispavg)
2021 struct stats_pwr_in *spc;
2022 static double *avg_in = NULL;
2023 static double *avg_in_min = NULL, *avg_in_max = NULL;
2025 /* Allocate arrays of voltage inputs */
2027 if ((avg_in = (double *) malloc(sizeof(double) * a->nr)) == NULL) {
2031 memset(avg_in, 0, sizeof(double) * a->nr);
2034 if ((avg_in_min = (double *) malloc(sizeof(double) * a->nr)) == NULL) {
2038 memset(avg_in_min, 0, sizeof(double) * a->nr);
2041 if ((avg_in_max = (double *) malloc(sizeof(double) * a->nr)) == NULL) {
2045 memset(avg_in_max, 0, sizeof(double) * a->nr);
2049 printf("\n%-11s IN inV %%in %*s\n",
2050 timestamp[!curr], MAX_SENSORS_DEV_LEN, "DEVICE");
2053 for (i = 0; i < a->nr; i++) {
2054 spc = (struct stats_pwr_in *) ((char *) a->buf[curr] + i * a->msize);
2056 printf("%-11s %3d", timestamp[curr], i);
2059 /* Display average values */
2060 printf(" %9.2f %9.2f",
2061 (double) avg_in[i] / avg_count,
2062 (avg_in_max[i] - avg_in_min[i]) ?
2063 ((double) (avg_in[i] / avg_count) - avg_in_min[i]) / (avg_in_max[i] - avg_in_min[i]) * 100 :
2067 /* Display instantaneous values */
2068 printf(" %9.2f %9.2f",
2070 (spc->in_max - spc->in_min) ?
2071 (spc->in - spc->in_min) / (spc->in_max - spc->in_min) * 100 :
2073 avg_in[i] += spc->in;
2074 /* Assume that min and max voltage inputs cannot vary */
2075 avg_in_min[i] = spc->in_min;
2076 avg_in_max[i] = spc->in_max;
2079 printf(" %*s\n", MAX_SENSORS_DEV_LEN, spc->device);
2099 ***************************************************************************
2100 * Display voltage inputs statistics.
2103 * @a Activity structure with statistics.
2104 * @prev Index in array where stats used as reference are.
2105 * @curr Index in array for current sample statistics.
2106 * @itv Interval of time in jiffies.
2107 ***************************************************************************
2109 __print_funct_t print_pwr_in_stats(struct activity *a, int prev, int curr,
2110 unsigned long long itv)
2112 stub_print_pwr_in_stats(a, prev, curr, FALSE);
2116 ***************************************************************************
2117 * Display average voltage inputs statistics.
2120 * @a Activity structure with statistics.
2121 * @prev Index in array where stats used as reference are.
2122 * @curr Index in array for current sample statistics.
2123 * @itv Interval of time in jiffies.
2124 ***************************************************************************
2126 __print_funct_t print_avg_pwr_in_stats(struct activity *a, int prev, int curr,
2127 unsigned long long itv)
2129 stub_print_pwr_in_stats(a, prev, curr, TRUE);
2133 ***************************************************************************
2134 * Display huge pages statistics. This function is used to
2135 * display instantaneous and average statistics.
2138 * @a Activity structure with statistics.
2139 * @prev Index in array where stats used as reference are.
2140 * @curr Index in array for current sample statistics.
2141 * @itv Interval of time in jiffies.
2142 * @dispavg TRUE if displaying average statistics.
2143 ***************************************************************************
2145 void stub_print_huge_stats(struct activity *a, int prev, int curr,
2146 unsigned long long itv, int dispavg)
2149 *smc = (struct stats_huge *) a->buf[curr];
2150 static unsigned long long
2155 printf("\n%-11s kbhugfree kbhugused %%hugused\n",
2160 /* Display instantaneous values */
2161 printf("%-11s %9lu %9lu %6.2f\n",
2164 smc->tlhkb - smc->frhkb,
2166 SP_VALUE(smc->frhkb, smc->tlhkb, smc->tlhkb) : 0.0);
2168 /* Will be used to compute the average */
2169 avg_frhkb += smc->frhkb;
2170 avg_tlhkb += smc->tlhkb;
2173 /* Display average values */
2174 printf("%-11s %9.0f %9.0f %6.2f\n",
2176 (double) avg_frhkb / avg_count,
2177 ((double) avg_tlhkb / avg_count) -
2178 ((double) avg_frhkb / avg_count),
2179 ((double) (avg_tlhkb / avg_count)) ?
2180 SP_VALUE((double) (avg_frhkb / avg_count),
2181 (double) (avg_tlhkb / avg_count),
2182 (double) (avg_tlhkb / avg_count)) :
2185 /* Reset average counters */
2186 avg_frhkb = avg_tlhkb = 0;
2191 ***************************************************************************
2192 * Display huge pages statistics.
2195 * @a Activity structure with statistics.
2196 * @prev Index in array where stats used as reference are.
2197 * @curr Index in array for current sample statistics.
2198 * @itv Interval of time in jiffies.
2199 ***************************************************************************
2201 __print_funct_t print_huge_stats(struct activity *a, int prev, int curr,
2202 unsigned long long itv)
2204 stub_print_huge_stats(a, prev, curr, itv, FALSE);
2208 ***************************************************************************
2209 * Display huge pages statistics.
2212 * @a Activity structure with statistics.
2213 * @prev Index in array where stats used as reference are.
2214 * @curr Index in array for current sample statistics.
2215 * @itv Interval of time in jiffies.
2216 ***************************************************************************
2218 __print_funct_t print_avg_huge_stats(struct activity *a, int prev, int curr,
2219 unsigned long long itv)
2221 stub_print_huge_stats(a, prev, curr, itv, TRUE);
2225 ***************************************************************************
2226 * Display CPU weighted frequency statistics. This function is used to
2227 * display instantaneous and average statistics.
2230 * @a Activity structure with statistics.
2231 * @prev Index in array where stats used as reference are.
2232 * @curr Index in array for current sample statistics.
2233 * @dispavg True if displaying average statistics.
2234 ***************************************************************************
2236 void print_pwr_wghfreq_stats(struct activity *a, int prev, int curr,
2237 unsigned long long itv)
2240 struct stats_pwr_wghfreq *spc, *spp, *spc_k, *spp_k;
2241 unsigned long long tis, tisfreq;
2244 printf("\n%-11s CPU wghMHz\n",
2248 for (i = 0; (i < a->nr) && (i < a->bitmap->b_size + 1); i++) {
2251 * The size of a->buf[...] CPU structure may be different from the default
2252 * sizeof(struct stats_pwr_wghfreq) value if data have been read from a file!
2253 * That's why we don't use a syntax like:
2254 * spc = (struct stats_pwr_wghfreq *) a->buf[...] + i;
2256 spc = (struct stats_pwr_wghfreq *) ((char *) a->buf[curr] + i * a->msize * a->nr2);
2257 spp = (struct stats_pwr_wghfreq *) ((char *) a->buf[prev] + i * a->msize * a->nr2);
2260 * Note: a->nr is in [1, NR_CPUS + 1].
2261 * Bitmap size is provided for (NR_CPUS + 1) CPUs.
2262 * Anyway, NR_CPUS may vary between the version of sysstat
2263 * used by sadc to create a file, and the version of sysstat
2264 * used by sar to read it...
2267 /* Should current CPU (including CPU "all") be displayed? */
2268 if (a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))) {
2270 /* Yes: Display it */
2271 printf("%-11s", timestamp[curr]);
2274 /* This is CPU "all" */
2278 printf(" %3d", i - 1);
2284 for (k = 0; k < a->nr2; k++) {
2286 spc_k = (struct stats_pwr_wghfreq *) ((char *) spc + k * a->msize);
2289 spp_k = (struct stats_pwr_wghfreq *) ((char *) spp + k * a->msize);
2291 tisfreq += (spc_k->freq / 1000) *
2292 (spc_k->time_in_state - spp_k->time_in_state);
2293 tis += (spc_k->time_in_state - spp_k->time_in_state);
2296 /* Display weighted frequency for current CPU */
2297 printf(" %9.2f\n", tis ? ((double) tisfreq) / tis : 0.0);