2 * pr_stats.c: Functions used by sar to display statistics
3 * (C) 1999-2011 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
399 static unsigned long long
404 if (DISPLAY_MEMORY(a->opt_flags)) {
406 printf("\n%-11s frmpg/s bufpg/s campg/s\n",
410 printf("%-11s %9.2f %9.2f %9.2f\n", timestamp[curr],
411 S_VALUE((double) KB_TO_PG(smp->frmkb), (double) KB_TO_PG(smc->frmkb), itv),
412 S_VALUE((double) KB_TO_PG(smp->bufkb), (double) KB_TO_PG(smc->bufkb), itv),
413 S_VALUE((double) KB_TO_PG(smp->camkb), (double) KB_TO_PG(smc->camkb), itv));
416 if (DISPLAY_MEM_AMT(a->opt_flags)) {
418 printf("\n%-11s kbmemfree kbmemused %%memused kbbuffers kbcached"
419 " kbcommit %%commit kbactive kbinact\n", timestamp[!curr]);
423 /* Display instantaneous values */
424 printf("%-11s %9lu %9lu %6.2f %9lu %9lu %9lu %7.2f %9lu %9lu\n",
427 smc->tlmkb - smc->frmkb,
429 SP_VALUE(smc->frmkb, smc->tlmkb, smc->tlmkb) : 0.0,
433 (smc->tlmkb + smc->tlskb) ?
434 SP_VALUE(0, smc->comkb, smc->tlmkb + smc->tlskb) : 0.0,
439 * Will be used to compute the average.
440 * We assume that the total amount of memory installed can not vary
441 * during the interval given on the command line.
443 avg_frmkb += smc->frmkb;
444 avg_bufkb += smc->bufkb;
445 avg_camkb += smc->camkb;
446 avg_comkb += smc->comkb;
447 avg_activekb += smc->activekb;
448 avg_inactkb += smc->inactkb;
451 /* Display average values */
452 printf("%-11s %9.0f %9.0f %6.2f %9.0f %9.0f %9.0f %7.2f %9.0f %9.0f\n",
454 (double) avg_frmkb / avg_count,
455 (double) smc->tlmkb - ((double) avg_frmkb / avg_count),
457 SP_VALUE((double) (avg_frmkb / avg_count), smc->tlmkb,
460 (double) avg_bufkb / avg_count,
461 (double) avg_camkb / avg_count,
462 (double) avg_comkb / avg_count,
463 (smc->tlmkb + smc->tlskb) ?
464 SP_VALUE(0.0, (double) (avg_comkb / avg_count),
465 smc->tlmkb + smc->tlskb) : 0.0,
466 (double) avg_activekb / avg_count,
467 (double) avg_inactkb / avg_count);
469 /* Reset average counters */
470 avg_frmkb = avg_bufkb = avg_camkb = avg_comkb = 0;
471 avg_activekb = avg_inactkb = 0;
475 if (DISPLAY_SWAP(a->opt_flags)) {
477 printf("\n%-11s kbswpfree kbswpused %%swpused kbswpcad %%swpcad\n",
482 /* Display instantaneous values */
483 printf("%-11s %9lu %9lu %6.2f %9lu %6.2f\n",
486 smc->tlskb - smc->frskb,
488 SP_VALUE(smc->frskb, smc->tlskb, smc->tlskb) : 0.0,
490 (smc->tlskb - smc->frskb) ?
491 SP_VALUE(0, smc->caskb, smc->tlskb - smc->frskb) : 0.0);
494 * Will be used to compute the average.
495 * We assume that the total amount of swap space may vary.
497 avg_frskb += smc->frskb;
498 avg_tlskb += smc->tlskb;
499 avg_caskb += smc->caskb;
502 /* Display average values */
503 printf("%-11s %9.0f %9.0f %6.2f %9.0f %6.2f\n",
505 (double) avg_frskb / avg_count,
506 ((double) avg_tlskb / avg_count) -
507 ((double) avg_frskb / avg_count),
508 ((double) (avg_tlskb / avg_count)) ?
509 SP_VALUE((double) (avg_frskb / avg_count),
510 (double) (avg_tlskb / avg_count),
511 (double) (avg_tlskb / avg_count)) :
513 (double) (avg_caskb / avg_count),
514 (((double) avg_tlskb / avg_count) -
515 ((double) avg_frskb / avg_count)) ?
516 SP_VALUE(0.0, (double) (avg_caskb / avg_count),
517 ((double) avg_tlskb / avg_count) -
518 ((double) avg_frskb / avg_count)) :
521 /* Reset average counters */
522 avg_frskb = avg_tlskb = avg_caskb = 0;
528 ***************************************************************************
529 * Display memory and swap statistics.
532 * @a Activity structure with statistics.
533 * @prev Index in array where stats used as reference are.
534 * @curr Index in array for current sample statistics.
535 * @itv Interval of time in jiffies.
536 ***************************************************************************
538 __print_funct_t print_memory_stats(struct activity *a, int prev, int curr,
539 unsigned long long itv)
541 stub_print_memory_stats(a, prev, curr, itv, FALSE);
545 ***************************************************************************
546 * Display average memory statistics.
549 * @a Activity structure with statistics.
550 * @prev Index in array where stats used as reference are.
551 * @curr Index in array for current sample statistics.
552 * @itv Interval of time in jiffies.
553 ***************************************************************************
555 __print_funct_t print_avg_memory_stats(struct activity *a, int prev, int curr,
556 unsigned long long itv)
558 stub_print_memory_stats(a, prev, curr, itv, TRUE);
562 ***************************************************************************
563 * Display kernel tables statistics. This function is used to display
564 * instantaneous and average statistics.
567 * @a Activity structure with statistics.
568 * @prev Index in array where stats used as reference are.
569 * @curr Index in array for current sample statistics.
570 * @dispavg True if displaying average statistics.
571 ***************************************************************************
573 void stub_print_ktables_stats(struct activity *a, int prev, int curr, int dispavg)
576 *skc = (struct stats_ktables *) a->buf[curr];
577 static unsigned long long
585 printf("\n%-11s dentunusd file-nr inode-nr pty-nr\n",
590 /* Display instantaneous values */
591 printf("%-11s %9u %9u %9u %9u\n", timestamp[curr],
598 * Will be used to compute the average.
599 * Note: Overflow unlikely to happen but not impossible...
601 avg_dentry_stat += skc->dentry_stat;
602 avg_file_used += skc->file_used;
603 avg_inode_used += skc->inode_used;
604 avg_pty_nr += skc->pty_nr;
607 /* Display average values */
608 printf("%-11s %9.0f %9.0f %9.0f %9.0f\n",
610 (double) avg_dentry_stat / avg_count,
611 (double) avg_file_used / avg_count,
612 (double) avg_inode_used / avg_count,
613 (double) avg_pty_nr / avg_count);
615 /* Reset average counters */
616 avg_dentry_stat = avg_file_used = avg_inode_used = avg_pty_nr = 0;
621 ***************************************************************************
622 * Display kernel tables statistics.
625 * @a Activity structure with statistics.
626 * @prev Index in array where stats used as reference are.
627 * @curr Index in array for current sample statistics.
628 * @itv Interval of time in jiffies.
629 ***************************************************************************
631 __print_funct_t print_ktables_stats(struct activity *a, int prev, int curr,
632 unsigned long long itv)
634 stub_print_ktables_stats(a, prev, curr, FALSE);
638 ***************************************************************************
639 * Display average kernel tables statistics.
642 * @a Activity structure with statistics.
643 * @prev Index in array where stats used as reference are.
644 * @curr Index in array for current sample statistics.
645 * @itv Interval of time in jiffies.
646 ***************************************************************************
648 __print_funct_t print_avg_ktables_stats(struct activity *a, int prev, int curr,
649 unsigned long long itv)
651 stub_print_ktables_stats(a, prev, curr, TRUE);
655 ***************************************************************************
656 * Display queue and load statistics. This function is used to display
657 * instantaneous and average statistics.
660 * @a Activity structure with statistics.
661 * @prev Index in array where stats used as reference are.
662 * @curr Index in array for current sample statistics.
663 * @dispavg TRUE if displaying average statistics.
664 ***************************************************************************
666 void stub_print_queue_stats(struct activity *a, int prev, int curr, int dispavg)
669 *sqc = (struct stats_queue *) a->buf[curr];
670 static unsigned long long
676 avg_procs_blocked = 0;
679 printf("\n%-11s runq-sz plist-sz ldavg-1 ldavg-5 ldavg-15 blocked\n",
684 /* Display instantaneous values */
685 printf("%-11s %9lu %9u %9.2f %9.2f %9.2f %9lu\n", timestamp[curr],
688 (double) sqc->load_avg_1 / 100,
689 (double) sqc->load_avg_5 / 100,
690 (double) sqc->load_avg_15 / 100,
693 /* Will be used to compute the average */
694 avg_nr_running += sqc->nr_running;
695 avg_nr_threads += sqc->nr_threads;
696 avg_load_avg_1 += sqc->load_avg_1;
697 avg_load_avg_5 += sqc->load_avg_5;
698 avg_load_avg_15 += sqc->load_avg_15;
699 avg_procs_blocked += sqc->procs_blocked;
702 /* Display average values */
703 printf("%-11s %9.0f %9.0f %9.2f %9.2f %9.2f %9.0f\n", timestamp[curr],
704 (double) avg_nr_running / avg_count,
705 (double) avg_nr_threads / avg_count,
706 (double) avg_load_avg_1 / (avg_count * 100),
707 (double) avg_load_avg_5 / (avg_count * 100),
708 (double) avg_load_avg_15 / (avg_count * 100),
709 (double) avg_procs_blocked / avg_count);
711 /* Reset average counters */
712 avg_nr_running = avg_nr_threads = 0;
713 avg_load_avg_1 = avg_load_avg_5 = avg_load_avg_15 = 0;
714 avg_procs_blocked = 0;
719 ***************************************************************************
720 * Display queue and load statistics.
723 * @a Activity structure with statistics.
724 * @prev Index in array where stats used as reference are.
725 * @curr Index in array for current sample statistics.
726 * @itv Interval of time in jiffies.
727 ***************************************************************************
729 __print_funct_t print_queue_stats(struct activity *a, int prev, int curr,
730 unsigned long long itv)
732 stub_print_queue_stats(a, prev, curr, FALSE);
736 ***************************************************************************
737 * Display average queue and load statistics.
740 * @a Activity structure with statistics.
741 * @prev Index in array where stats used as reference are.
742 * @curr Index in array for current sample statistics.
743 * @itv Interval of time in jiffies.
744 ***************************************************************************
746 __print_funct_t print_avg_queue_stats(struct activity *a, int prev, int curr,
747 unsigned long long itv)
749 stub_print_queue_stats(a, prev, curr, TRUE);
753 ***************************************************************************
754 * Display serial lines statistics.
757 * @a Activity structure with statistics.
758 * @prev Index in array where stats used as reference are.
759 * @curr Index in array for current sample statistics.
760 * @itv Interval of time in jiffies.
761 ***************************************************************************
763 __print_funct_t print_serial_stats(struct activity *a, int prev, int curr,
764 unsigned long long itv)
767 struct stats_serial *ssc, *ssp;
770 printf("\n%-11s TTY rcvin/s xmtin/s framerr/s prtyerr/s"
771 " brk/s ovrun/s\n", timestamp[!curr]);
774 for (i = 0; i < a->nr; i++) {
776 ssc = (struct stats_serial *) ((char *) a->buf[curr] + i * a->msize);
777 ssp = (struct stats_serial *) ((char *) a->buf[prev] + i * a->msize);
782 printf("%-11s %3d", timestamp[curr], ssc->line - 1);
784 if ((ssc->line == ssp->line) || WANT_SINCE_BOOT(flags)) {
785 printf(" %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f\n",
786 S_VALUE(ssp->rx, ssc->rx, itv),
787 S_VALUE(ssp->tx, ssc->tx, itv),
788 S_VALUE(ssp->frame, ssc->frame, itv),
789 S_VALUE(ssp->parity, ssc->parity, itv),
790 S_VALUE(ssp->brk, ssc->brk, itv),
791 S_VALUE(ssp->overrun, ssc->overrun, itv));
794 printf(" N/A N/A N/A N/A"
801 ***************************************************************************
802 * Display disks statistics.
805 * @a Activity structure with statistics.
806 * @prev Index in array where stats used as reference are.
807 * @curr Index in array for current sample statistics.
808 * @itv Interval of time in jiffies.
809 ***************************************************************************
811 __print_funct_t print_disk_stats(struct activity *a, int prev, int curr,
812 unsigned long long itv)
815 struct stats_disk *sdc, *sdp;
816 struct ext_disk_stats xds;
820 printf("\n%-11s DEV tps rd_sec/s wr_sec/s avgrq-sz"
821 " avgqu-sz await svctm %%util\n",
825 for (i = 0; i < a->nr; i++) {
827 sdc = (struct stats_disk *) ((char *) a->buf[curr] + i * a->msize);
829 if (!(sdc->major + sdc->minor))
832 j = check_disk_reg(a, curr, prev, i);
833 sdp = (struct stats_disk *) ((char *) a->buf[prev] + j * a->msize);
835 /* Compute service time, etc. */
836 compute_ext_disk_stats(sdc, sdp, itv, &xds);
840 if ((USE_PRETTY_OPTION(flags)) && (sdc->major == dm_major)) {
841 dev_name = transform_devmapname(sdc->major, sdc->minor);
845 dev_name = get_devname(sdc->major, sdc->minor,
846 USE_PRETTY_OPTION(flags));
849 printf("%-11s %9s %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f\n",
851 /* Confusion possible here between index and minor numbers */
853 S_VALUE(sdp->nr_ios, sdc->nr_ios, itv),
854 ll_s_value(sdp->rd_sect, sdc->rd_sect, itv),
855 ll_s_value(sdp->wr_sect, sdc->wr_sect, itv),
856 /* See iostat for explanations */
858 S_VALUE(sdp->rq_ticks, sdc->rq_ticks, itv) / 1000.0,
866 ***************************************************************************
867 * Display network interfaces statistics.
870 * @a Activity structure with statistics.
871 * @prev Index in array where stats used as reference are.
872 * @curr Index in array for current sample statistics.
873 * @itv Interval of time in jiffies.
874 ***************************************************************************
876 __print_funct_t print_net_dev_stats(struct activity *a, int prev, int curr,
877 unsigned long long itv)
880 struct stats_net_dev *sndc, *sndp;
883 printf("\n%-11s IFACE rxpck/s txpck/s rxkB/s txkB/s"
884 " rxcmp/s txcmp/s rxmcst/s\n", timestamp[!curr]);
887 for (i = 0; i < a->nr; i++) {
889 sndc = (struct stats_net_dev *) ((char *) a->buf[curr] + i * a->msize);
891 if (!strcmp(sndc->interface, ""))
894 j = check_net_dev_reg(a, curr, prev, i);
895 sndp = (struct stats_net_dev *) ((char *) a->buf[prev] + j * a->msize);
897 printf("%-11s %9s", timestamp[curr], sndc->interface);
899 printf(" %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f\n",
900 S_VALUE(sndp->rx_packets, sndc->rx_packets, itv),
901 S_VALUE(sndp->tx_packets, sndc->tx_packets, itv),
902 S_VALUE(sndp->rx_bytes, sndc->rx_bytes, itv) / 1024,
903 S_VALUE(sndp->tx_bytes, sndc->tx_bytes, itv) / 1024,
904 S_VALUE(sndp->rx_compressed, sndc->rx_compressed, itv),
905 S_VALUE(sndp->tx_compressed, sndc->tx_compressed, itv),
906 S_VALUE(sndp->multicast, sndc->multicast, itv));
911 ***************************************************************************
912 * Display network interface errors statistics.
915 * @a Activity structure with statistics.
916 * @prev Index in array where stats used as reference are.
917 * @curr Index in array for current sample statistics.
918 * @itv Interval of time in jiffies.
919 ***************************************************************************
921 __print_funct_t print_net_edev_stats(struct activity *a, int prev, int curr,
922 unsigned long long itv)
925 struct stats_net_edev *snedc, *snedp;
928 printf("\n%-11s IFACE rxerr/s txerr/s coll/s rxdrop/s"
929 " txdrop/s txcarr/s rxfram/s rxfifo/s txfifo/s\n",
933 for (i = 0; i < a->nr; i++) {
935 snedc = (struct stats_net_edev *) ((char *) a->buf[curr] + i * a->msize);
937 if (!strcmp(snedc->interface, ""))
940 j = check_net_edev_reg(a, curr, prev, i);
941 snedp = (struct stats_net_edev *) ((char *) a->buf[prev] + j * a->msize);
943 printf("%-11s %9s", timestamp[curr], snedc->interface);
945 printf(" %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f\n",
946 S_VALUE(snedp->rx_errors, snedc->rx_errors, itv),
947 S_VALUE(snedp->tx_errors, snedc->tx_errors, itv),
948 S_VALUE(snedp->collisions, snedc->collisions, itv),
949 S_VALUE(snedp->rx_dropped, snedc->rx_dropped, itv),
950 S_VALUE(snedp->tx_dropped, snedc->tx_dropped, itv),
951 S_VALUE(snedp->tx_carrier_errors, snedc->tx_carrier_errors, itv),
952 S_VALUE(snedp->rx_frame_errors, snedc->rx_frame_errors, itv),
953 S_VALUE(snedp->rx_fifo_errors, snedc->rx_fifo_errors, itv),
954 S_VALUE(snedp->tx_fifo_errors, snedc->tx_fifo_errors, itv));
959 ***************************************************************************
960 * Display NFS client statistics.
963 * @a Activity structure with statistics.
964 * @prev Index in array where stats used as reference are.
965 * @curr Index in array for current sample statistics.
966 * @itv Interval of time in jiffies.
967 ***************************************************************************
969 __print_funct_t print_net_nfs_stats(struct activity *a, int prev, int curr,
970 unsigned long long itv)
973 *snnc = (struct stats_net_nfs *) a->buf[curr],
974 *snnp = (struct stats_net_nfs *) a->buf[prev];
977 printf("\n%-11s call/s retrans/s read/s write/s access/s"
978 " getatt/s\n", timestamp[!curr]);
981 printf("%-11s %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f\n", timestamp[curr],
982 S_VALUE(snnp->nfs_rpccnt, snnc->nfs_rpccnt, itv),
983 S_VALUE(snnp->nfs_rpcretrans, snnc->nfs_rpcretrans, itv),
984 S_VALUE(snnp->nfs_readcnt, snnc->nfs_readcnt, itv),
985 S_VALUE(snnp->nfs_writecnt, snnc->nfs_writecnt, itv),
986 S_VALUE(snnp->nfs_accesscnt, snnc->nfs_accesscnt, itv),
987 S_VALUE(snnp->nfs_getattcnt, snnc->nfs_getattcnt, itv));
991 ***************************************************************************
992 * Display NFS server statistics.
995 * @a Activity structure with statistics.
996 * @prev Index in array where stats used as reference are.
997 * @curr Index in array for current sample statistics.
998 * @itv Interval of time in jiffies.
999 ***************************************************************************
1001 __print_funct_t print_net_nfsd_stats(struct activity *a, int prev, int curr,
1002 unsigned long long itv)
1004 struct stats_net_nfsd
1005 *snndc = (struct stats_net_nfsd *) a->buf[curr],
1006 *snndp = (struct stats_net_nfsd *) a->buf[prev];
1009 printf("\n%-11s scall/s badcall/s packet/s udp/s tcp/s "
1010 "hit/s miss/s sread/s swrite/s saccess/s sgetatt/s\n",
1014 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",
1016 S_VALUE(snndp->nfsd_rpccnt, snndc->nfsd_rpccnt, itv),
1017 S_VALUE(snndp->nfsd_rpcbad, snndc->nfsd_rpcbad, itv),
1018 S_VALUE(snndp->nfsd_netcnt, snndc->nfsd_netcnt, itv),
1019 S_VALUE(snndp->nfsd_netudpcnt, snndc->nfsd_netudpcnt, itv),
1020 S_VALUE(snndp->nfsd_nettcpcnt, snndc->nfsd_nettcpcnt, itv),
1021 S_VALUE(snndp->nfsd_rchits, snndc->nfsd_rchits, itv),
1022 S_VALUE(snndp->nfsd_rcmisses, snndc->nfsd_rcmisses, itv),
1023 S_VALUE(snndp->nfsd_readcnt, snndc->nfsd_readcnt, itv),
1024 S_VALUE(snndp->nfsd_writecnt, snndc->nfsd_writecnt, itv),
1025 S_VALUE(snndp->nfsd_accesscnt, snndc->nfsd_accesscnt, itv),
1026 S_VALUE(snndp->nfsd_getattcnt, snndc->nfsd_getattcnt, itv));
1030 ***************************************************************************
1031 * Display network sockets statistics. This function is used to display
1032 * instantaneous and average statistics.
1035 * @a Activity structure with statistics.
1036 * @prev Index in array where stats used as reference are.
1037 * @curr Index in array for current sample statistics.
1038 * @itv Interval of time in jiffies.
1039 * @dispavg TRUE if displaying average statistics.
1040 ***************************************************************************
1042 void stub_print_net_sock_stats(struct activity *a, int prev, int curr,
1043 unsigned long long itv, int dispavg)
1045 struct stats_net_sock
1046 *snsc = (struct stats_net_sock *) a->buf[curr];
1047 static unsigned long long
1056 printf("\n%-11s totsck tcpsck udpsck rawsck ip-frag tcp-tw\n",
1061 /* Display instantaneous values */
1062 printf("%-11s %9u %9u %9u %9u %9u %9u\n", timestamp[curr],
1070 /* Will be used to compute the average */
1071 avg_sock_inuse += snsc->sock_inuse;
1072 avg_tcp_inuse += snsc->tcp_inuse;
1073 avg_udp_inuse += snsc->udp_inuse;
1074 avg_raw_inuse += snsc->raw_inuse;
1075 avg_frag_inuse += snsc->frag_inuse;
1076 avg_tcp_tw += snsc->tcp_tw;
1079 /* Display average values */
1080 printf("%-11s %9.0f %9.0f %9.0f %9.0f %9.0f %9.0f\n", timestamp[curr],
1081 (double) avg_sock_inuse / avg_count,
1082 (double) avg_tcp_inuse / avg_count,
1083 (double) avg_udp_inuse / avg_count,
1084 (double) avg_raw_inuse / avg_count,
1085 (double) avg_frag_inuse / avg_count,
1086 (double) avg_tcp_tw / avg_count);
1088 /* Reset average counters */
1089 avg_sock_inuse = avg_tcp_inuse = avg_udp_inuse = 0;
1090 avg_raw_inuse = avg_frag_inuse = avg_tcp_tw = 0;
1095 ***************************************************************************
1096 * Display network sockets statistics.
1099 * @a Activity structure with statistics.
1100 * @prev Index in array where stats used as reference are.
1101 * @curr Index in array for current sample statistics.
1102 * @itv Interval of time in jiffies.
1103 ***************************************************************************
1105 __print_funct_t print_net_sock_stats(struct activity *a, int prev, int curr,
1106 unsigned long long itv)
1108 stub_print_net_sock_stats(a, prev, curr, itv, FALSE);
1112 ***************************************************************************
1113 * Display average network sockets statistics.
1116 * @a Activity structure with statistics.
1117 * @prev Index in array where stats used as reference are.
1118 * @curr Index in array for current sample statistics.
1119 * @itv Interval of time in jiffies.
1120 ***************************************************************************
1122 __print_funct_t print_avg_net_sock_stats(struct activity *a, int prev, int curr,
1123 unsigned long long itv)
1125 stub_print_net_sock_stats(a, prev, curr, itv, TRUE);
1129 ***************************************************************************
1130 * Display IP network traffic statistics.
1133 * @a Activity structure with statistics.
1134 * @prev Index in array where stats used as reference are.
1135 * @curr Index in array for current sample statistics.
1136 * @itv Interval of time in jiffies.
1137 ***************************************************************************
1139 __print_funct_t print_net_ip_stats(struct activity *a, int prev, int curr,
1140 unsigned long long itv)
1143 *snic = (struct stats_net_ip *) a->buf[curr],
1144 *snip = (struct stats_net_ip *) a->buf[prev];
1147 printf("\n%-11s irec/s fwddgm/s idel/s orq/s asmrq/s"
1148 " asmok/s fragok/s fragcrt/s\n", timestamp[!curr]);
1151 printf("%-11s %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f\n",
1153 S_VALUE(snip->InReceives, snic->InReceives, itv),
1154 S_VALUE(snip->ForwDatagrams, snic->ForwDatagrams, itv),
1155 S_VALUE(snip->InDelivers, snic->InDelivers, itv),
1156 S_VALUE(snip->OutRequests, snic->OutRequests, itv),
1157 S_VALUE(snip->ReasmReqds, snic->ReasmReqds, itv),
1158 S_VALUE(snip->ReasmOKs, snic->ReasmOKs, itv),
1159 S_VALUE(snip->FragOKs, snic->FragOKs, itv),
1160 S_VALUE(snip->FragCreates, snic->FragCreates, itv));
1164 ***************************************************************************
1165 * Display IP network error statistics.
1168 * @a Activity structure with statistics.
1169 * @prev Index in array where stats used as reference are.
1170 * @curr Index in array for current sample statistics.
1171 * @itv Interval of time in jiffies.
1172 ***************************************************************************
1174 __print_funct_t print_net_eip_stats(struct activity *a, int prev, int curr,
1175 unsigned long long itv)
1177 struct stats_net_eip
1178 *sneic = (struct stats_net_eip *) a->buf[curr],
1179 *sneip = (struct stats_net_eip *) a->buf[prev];
1182 printf("\n%-11s ihdrerr/s iadrerr/s iukwnpr/s idisc/s odisc/s"
1183 " onort/s asmf/s fragf/s\n", timestamp[!curr]);
1186 printf("%-11s %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f\n",
1188 S_VALUE(sneip->InHdrErrors, sneic->InHdrErrors, itv),
1189 S_VALUE(sneip->InAddrErrors, sneic->InAddrErrors, itv),
1190 S_VALUE(sneip->InUnknownProtos, sneic->InUnknownProtos, itv),
1191 S_VALUE(sneip->InDiscards, sneic->InDiscards, itv),
1192 S_VALUE(sneip->OutDiscards, sneic->OutDiscards, itv),
1193 S_VALUE(sneip->OutNoRoutes, sneic->OutNoRoutes, itv),
1194 S_VALUE(sneip->ReasmFails, sneic->ReasmFails, itv),
1195 S_VALUE(sneip->FragFails, sneic->FragFails, itv));
1199 ***************************************************************************
1200 * Display ICMP network traffic statistics.
1203 * @a Activity structure with statistics.
1204 * @prev Index in array where stats used as reference are.
1205 * @curr Index in array for current sample statistics.
1206 * @itv Interval of time in jiffies.
1207 ***************************************************************************
1209 __print_funct_t print_net_icmp_stats(struct activity *a, int prev, int curr,
1210 unsigned long long itv)
1212 struct stats_net_icmp
1213 *snic = (struct stats_net_icmp *) a->buf[curr],
1214 *snip = (struct stats_net_icmp *) a->buf[prev];
1217 printf("\n%-11s imsg/s omsg/s iech/s iechr/s oech/s"
1218 " oechr/s itm/s itmr/s otm/s otmr/s"
1219 " iadrmk/s iadrmkr/s oadrmk/s oadrmkr/s\n", timestamp[!curr]);
1222 printf("%-11s %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f"
1223 " %9.2f %9.2f %9.2f %9.2f\n", timestamp[curr],
1224 S_VALUE(snip->InMsgs, snic->InMsgs, itv),
1225 S_VALUE(snip->OutMsgs, snic->OutMsgs, itv),
1226 S_VALUE(snip->InEchos, snic->InEchos, itv),
1227 S_VALUE(snip->InEchoReps, snic->InEchoReps, itv),
1228 S_VALUE(snip->OutEchos, snic->OutEchos, itv),
1229 S_VALUE(snip->OutEchoReps, snic->OutEchoReps, itv),
1230 S_VALUE(snip->InTimestamps, snic->InTimestamps, itv),
1231 S_VALUE(snip->InTimestampReps, snic->InTimestampReps, itv),
1232 S_VALUE(snip->OutTimestamps, snic->OutTimestamps, itv),
1233 S_VALUE(snip->OutTimestampReps, snic->OutTimestampReps, itv),
1234 S_VALUE(snip->InAddrMasks, snic->InAddrMasks, itv),
1235 S_VALUE(snip->InAddrMaskReps, snic->InAddrMaskReps, itv),
1236 S_VALUE(snip->OutAddrMasks, snic->OutAddrMasks, itv),
1237 S_VALUE(snip->OutAddrMaskReps, snic->OutAddrMaskReps, itv));
1241 ***************************************************************************
1242 * Display ICMP network error statistics.
1245 * @a Activity structure with statistics.
1246 * @prev Index in array where stats used as reference are.
1247 * @curr Index in array for current sample statistics.
1248 * @itv Interval of time in jiffies.
1249 ***************************************************************************
1251 __print_funct_t print_net_eicmp_stats(struct activity *a, int prev, int curr,
1252 unsigned long long itv)
1254 struct stats_net_eicmp
1255 *sneic = (struct stats_net_eicmp *) a->buf[curr],
1256 *sneip = (struct stats_net_eicmp *) a->buf[prev];
1259 printf("\n%-11s ierr/s oerr/s idstunr/s odstunr/s itmex/s"
1260 " otmex/s iparmpb/s oparmpb/s isrcq/s osrcq/s"
1261 " iredir/s oredir/s\n", timestamp[!curr]);
1264 printf("%-11s %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f"
1265 " %9.2f %9.2f\n", timestamp[curr],
1266 S_VALUE(sneip->InErrors, sneic->InErrors, itv),
1267 S_VALUE(sneip->OutErrors, sneic->OutErrors, itv),
1268 S_VALUE(sneip->InDestUnreachs, sneic->InDestUnreachs, itv),
1269 S_VALUE(sneip->OutDestUnreachs, sneic->OutDestUnreachs, itv),
1270 S_VALUE(sneip->InTimeExcds, sneic->InTimeExcds, itv),
1271 S_VALUE(sneip->OutTimeExcds, sneic->OutTimeExcds, itv),
1272 S_VALUE(sneip->InParmProbs, sneic->InParmProbs, itv),
1273 S_VALUE(sneip->OutParmProbs, sneic->OutParmProbs, itv),
1274 S_VALUE(sneip->InSrcQuenchs, sneic->InSrcQuenchs, itv),
1275 S_VALUE(sneip->OutSrcQuenchs, sneic->OutSrcQuenchs, itv),
1276 S_VALUE(sneip->InRedirects, sneic->InRedirects, itv),
1277 S_VALUE(sneip->OutRedirects, sneic->OutRedirects, itv));
1281 ***************************************************************************
1282 * Display TCP network traffic statistics.
1285 * @a Activity structure with statistics.
1286 * @prev Index in array where stats used as reference are.
1287 * @curr Index in array for current sample statistics.
1288 * @itv Interval of time in jiffies.
1289 ***************************************************************************
1291 __print_funct_t print_net_tcp_stats(struct activity *a, int prev, int curr,
1292 unsigned long long itv)
1294 struct stats_net_tcp
1295 *sntc = (struct stats_net_tcp *) a->buf[curr],
1296 *sntp = (struct stats_net_tcp *) a->buf[prev];
1299 printf("\n%-11s active/s passive/s iseg/s oseg/s\n",
1303 printf("%-11s %9.2f %9.2f %9.2f %9.2f\n",
1305 S_VALUE(sntp->ActiveOpens, sntc->ActiveOpens, itv),
1306 S_VALUE(sntp->PassiveOpens, sntc->PassiveOpens, itv),
1307 S_VALUE(sntp->InSegs, sntc->InSegs, itv),
1308 S_VALUE(sntp->OutSegs, sntc->OutSegs, itv));
1312 ***************************************************************************
1313 * Display TCP network error statistics.
1316 * @a Activity structure with statistics.
1317 * @prev Index in array where stats used as reference are.
1318 * @curr Index in array for current sample statistics.
1319 * @itv Interval of time in jiffies.
1320 ***************************************************************************
1322 __print_funct_t print_net_etcp_stats(struct activity *a, int prev, int curr,
1323 unsigned long long itv)
1325 struct stats_net_etcp
1326 *snetc = (struct stats_net_etcp *) a->buf[curr],
1327 *snetp = (struct stats_net_etcp *) a->buf[prev];
1330 printf("\n%-11s atmptf/s estres/s retrans/s isegerr/s orsts/s\n",
1334 printf("%-11s %9.2f %9.2f %9.2f %9.2f %9.2f\n",
1336 S_VALUE(snetp->AttemptFails, snetc->AttemptFails, itv),
1337 S_VALUE(snetp->EstabResets, snetc->EstabResets, itv),
1338 S_VALUE(snetp->RetransSegs, snetc->RetransSegs, itv),
1339 S_VALUE(snetp->InErrs, snetc->InErrs, itv),
1340 S_VALUE(snetp->OutRsts, snetc->OutRsts, itv));
1344 ***************************************************************************
1345 * Display UDP network traffic statistics.
1348 * @a Activity structure with statistics.
1349 * @prev Index in array where stats used as reference are.
1350 * @curr Index in array for current sample statistics.
1351 * @itv Interval of time in jiffies.
1352 ***************************************************************************
1354 __print_funct_t print_net_udp_stats(struct activity *a, int prev, int curr,
1355 unsigned long long itv)
1357 struct stats_net_udp
1358 *snuc = (struct stats_net_udp *) a->buf[curr],
1359 *snup = (struct stats_net_udp *) a->buf[prev];
1362 printf("\n%-11s idgm/s odgm/s noport/s idgmerr/s\n",
1366 printf("%-11s %9.2f %9.2f %9.2f %9.2f\n",
1368 S_VALUE(snup->InDatagrams, snuc->InDatagrams, itv),
1369 S_VALUE(snup->OutDatagrams, snuc->OutDatagrams, itv),
1370 S_VALUE(snup->NoPorts, snuc->NoPorts, itv),
1371 S_VALUE(snup->InErrors, snuc->InErrors, itv));
1375 ***************************************************************************
1376 * Display IPv6 sockets statistics. This function is used to display
1377 * instantaneous and average statistics.
1380 * @a Activity structure with statistics.
1381 * @prev Index in array where stats used as reference are.
1382 * @curr Index in array for current sample statistics.
1383 * @itv Interval of time in jiffies.
1384 * @dispavg TRUE if displaying average statistics.
1385 ***************************************************************************
1387 void stub_print_net_sock6_stats(struct activity *a, int prev, int curr,
1388 unsigned long long itv, int dispavg)
1390 struct stats_net_sock6
1391 *snsc = (struct stats_net_sock6 *) a->buf[curr];
1392 static unsigned long long
1396 avg_frag6_inuse = 0;
1399 printf("\n%-11s tcp6sck udp6sck raw6sck ip6-frag\n",
1404 /* Display instantaneous values */
1405 printf("%-11s %9u %9u %9u %9u\n", timestamp[curr],
1411 /* Will be used to compute the average */
1412 avg_tcp6_inuse += snsc->tcp6_inuse;
1413 avg_udp6_inuse += snsc->udp6_inuse;
1414 avg_raw6_inuse += snsc->raw6_inuse;
1415 avg_frag6_inuse += snsc->frag6_inuse;
1418 /* Display average values */
1419 printf("%-11s %9.0f %9.0f %9.0f %9.0f\n", timestamp[curr],
1420 (double) avg_tcp6_inuse / avg_count,
1421 (double) avg_udp6_inuse / avg_count,
1422 (double) avg_raw6_inuse / avg_count,
1423 (double) avg_frag6_inuse / avg_count);
1425 /* Reset average counters */
1426 avg_tcp6_inuse = avg_udp6_inuse = avg_raw6_inuse = avg_frag6_inuse = 0;
1431 ***************************************************************************
1432 * Display IPv6 sockets statistics.
1435 * @a Activity structure with statistics.
1436 * @prev Index in array where stats used as reference are.
1437 * @curr Index in array for current sample statistics.
1438 * @itv Interval of time in jiffies.
1439 ***************************************************************************
1441 __print_funct_t print_net_sock6_stats(struct activity *a, int prev, int curr,
1442 unsigned long long itv)
1444 stub_print_net_sock6_stats(a, prev, curr, itv, FALSE);
1448 ***************************************************************************
1449 * Display average IPv6 sockets statistics.
1452 * @a Activity structure with statistics.
1453 * @prev Index in array where stats used as reference are.
1454 * @curr Index in array for current sample statistics.
1455 * @itv Interval of time in jiffies.
1456 ***************************************************************************
1458 __print_funct_t print_avg_net_sock6_stats(struct activity *a, int prev, int curr,
1459 unsigned long long itv)
1461 stub_print_net_sock6_stats(a, prev, curr, itv, TRUE);
1465 ***************************************************************************
1466 * Display IPv6 network traffic statistics.
1469 * @a Activity structure with statistics.
1470 * @prev Index in array where stats used as reference are.
1471 * @curr Index in array for current sample statistics.
1472 * @itv Interval of time in jiffies.
1473 ***************************************************************************
1475 __print_funct_t print_net_ip6_stats(struct activity *a, int prev, int curr,
1476 unsigned long long itv)
1478 struct stats_net_ip6
1479 *snic = (struct stats_net_ip6 *) a->buf[curr],
1480 *snip = (struct stats_net_ip6 *) a->buf[prev];
1483 printf("\n%-11s irec6/s fwddgm6/s idel6/s orq6/s asmrq6/s"
1484 " asmok6/s imcpck6/s omcpck6/s fragok6/s fragcr6/s\n",
1488 printf("%-11s %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f\n",
1490 S_VALUE(snip->InReceives6, snic->InReceives6, itv),
1491 S_VALUE(snip->OutForwDatagrams6, snic->OutForwDatagrams6, itv),
1492 S_VALUE(snip->InDelivers6, snic->InDelivers6, itv),
1493 S_VALUE(snip->OutRequests6, snic->OutRequests6, itv),
1494 S_VALUE(snip->ReasmReqds6, snic->ReasmReqds6, itv),
1495 S_VALUE(snip->ReasmOKs6, snic->ReasmOKs6, itv),
1496 S_VALUE(snip->InMcastPkts6, snic->InMcastPkts6, itv),
1497 S_VALUE(snip->OutMcastPkts6, snic->OutMcastPkts6, itv),
1498 S_VALUE(snip->FragOKs6, snic->FragOKs6, itv),
1499 S_VALUE(snip->FragCreates6, snic->FragCreates6, itv));
1503 ***************************************************************************
1504 * Display IPv6 network error statistics.
1507 * @a Activity structure with statistics.
1508 * @prev Index in array where stats used as reference are.
1509 * @curr Index in array for current sample statistics.
1510 * @itv Interval of time in jiffies.
1511 ***************************************************************************
1513 __print_funct_t print_net_eip6_stats(struct activity *a, int prev, int curr,
1514 unsigned long long itv)
1516 struct stats_net_eip6
1517 *sneic = (struct stats_net_eip6 *) a->buf[curr],
1518 *sneip = (struct stats_net_eip6 *) a->buf[prev];
1521 printf("\n%-11s ihdrer6/s iadrer6/s iukwnp6/s i2big6/s idisc6/s odisc6/s"
1522 " inort6/s onort6/s asmf6/s fragf6/s itrpck6/s\n",
1526 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",
1528 S_VALUE(sneip->InHdrErrors6, sneic->InHdrErrors6, itv),
1529 S_VALUE(sneip->InAddrErrors6, sneic->InAddrErrors6, itv),
1530 S_VALUE(sneip->InUnknownProtos6, sneic->InUnknownProtos6, itv),
1531 S_VALUE(sneip->InTooBigErrors6, sneic->InTooBigErrors6, itv),
1532 S_VALUE(sneip->InDiscards6, sneic->InDiscards6, itv),
1533 S_VALUE(sneip->OutDiscards6, sneic->OutDiscards6, itv),
1534 S_VALUE(sneip->InNoRoutes6, sneic->InNoRoutes6, itv),
1535 S_VALUE(sneip->OutNoRoutes6, sneic->OutNoRoutes6, itv),
1536 S_VALUE(sneip->ReasmFails6, sneic->ReasmFails6, itv),
1537 S_VALUE(sneip->FragFails6, sneic->FragFails6, itv),
1538 S_VALUE(sneip->InTruncatedPkts6, sneic->InTruncatedPkts6, itv));
1542 ***************************************************************************
1543 * Display ICMPv6 network traffic statistics.
1546 * @a Activity structure with statistics.
1547 * @prev Index in array where stats used as reference are.
1548 * @curr Index in array for current sample statistics.
1549 * @itv Interval of time in jiffies.
1550 ***************************************************************************
1552 __print_funct_t print_net_icmp6_stats(struct activity *a, int prev, int curr,
1553 unsigned long long itv)
1555 struct stats_net_icmp6
1556 *snic = (struct stats_net_icmp6 *) a->buf[curr],
1557 *snip = (struct stats_net_icmp6 *) a->buf[prev];
1560 printf("\n%-11s imsg6/s omsg6/s iech6/s iechr6/s oechr6/s"
1561 " igmbq6/s igmbr6/s ogmbr6/s igmbrd6/s ogmbrd6/s irtsol6/s ortsol6/s"
1562 " irtad6/s inbsol6/s onbsol6/s inbad6/s onbad6/s\n",
1566 printf("%-11s %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f"
1567 " %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f\n", timestamp[curr],
1568 S_VALUE(snip->InMsgs6, snic->InMsgs6, itv),
1569 S_VALUE(snip->OutMsgs6, snic->OutMsgs6, itv),
1570 S_VALUE(snip->InEchos6, snic->InEchos6, itv),
1571 S_VALUE(snip->InEchoReplies6, snic->InEchoReplies6, itv),
1572 S_VALUE(snip->OutEchoReplies6, snic->OutEchoReplies6, itv),
1573 S_VALUE(snip->InGroupMembQueries6, snic->InGroupMembQueries6, itv),
1574 S_VALUE(snip->InGroupMembResponses6, snic->InGroupMembResponses6, itv),
1575 S_VALUE(snip->OutGroupMembResponses6, snic->OutGroupMembResponses6, itv),
1576 S_VALUE(snip->InGroupMembReductions6, snic->InGroupMembReductions6, itv),
1577 S_VALUE(snip->OutGroupMembReductions6, snic->OutGroupMembReductions6, itv),
1578 S_VALUE(snip->InRouterSolicits6, snic->InRouterSolicits6, itv),
1579 S_VALUE(snip->OutRouterSolicits6, snic->OutRouterSolicits6, itv),
1580 S_VALUE(snip->InRouterAdvertisements6, snic->InRouterAdvertisements6, itv),
1581 S_VALUE(snip->InNeighborSolicits6, snic->InNeighborSolicits6, itv),
1582 S_VALUE(snip->OutNeighborSolicits6, snic->OutNeighborSolicits6, itv),
1583 S_VALUE(snip->InNeighborAdvertisements6, snic->InNeighborAdvertisements6, itv),
1584 S_VALUE(snip->OutNeighborAdvertisements6, snic->OutNeighborAdvertisements6, itv));
1588 ***************************************************************************
1589 * Display ICMPv6 network error statistics.
1592 * @a Activity structure with statistics.
1593 * @prev Index in array where stats used as reference are.
1594 * @curr Index in array for current sample statistics.
1595 * @itv Interval of time in jiffies.
1596 ***************************************************************************
1598 __print_funct_t print_net_eicmp6_stats(struct activity *a, int prev, int curr,
1599 unsigned long long itv)
1601 struct stats_net_eicmp6
1602 *sneic = (struct stats_net_eicmp6 *) a->buf[curr],
1603 *sneip = (struct stats_net_eicmp6 *) a->buf[prev];
1606 printf("\n%-11s ierr6/s idtunr6/s odtunr6/s itmex6/s otmex6/s"
1607 " iprmpb6/s oprmpb6/s iredir6/s oredir6/s ipck2b6/s opck2b6/s\n",
1611 printf("%-11s %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f"
1612 " %9.2f\n", timestamp[curr],
1613 S_VALUE(sneip->InErrors6, sneic->InErrors6, itv),
1614 S_VALUE(sneip->InDestUnreachs6, sneic->InDestUnreachs6, itv),
1615 S_VALUE(sneip->OutDestUnreachs6, sneic->OutDestUnreachs6, itv),
1616 S_VALUE(sneip->InTimeExcds6, sneic->InTimeExcds6, itv),
1617 S_VALUE(sneip->OutTimeExcds6, sneic->OutTimeExcds6, itv),
1618 S_VALUE(sneip->InParmProblems6, sneic->InParmProblems6, itv),
1619 S_VALUE(sneip->OutParmProblems6, sneic->OutParmProblems6, itv),
1620 S_VALUE(sneip->InRedirects6, sneic->InRedirects6, itv),
1621 S_VALUE(sneip->OutRedirects6, sneic->OutRedirects6, itv),
1622 S_VALUE(sneip->InPktTooBigs6, sneic->InPktTooBigs6, itv),
1623 S_VALUE(sneip->OutPktTooBigs6, sneic->OutPktTooBigs6, itv));
1627 ***************************************************************************
1628 * Display UDPv6 network traffic statistics.
1631 * @a Activity structure with statistics.
1632 * @prev Index in array where stats used as reference are.
1633 * @curr Index in array for current sample statistics.
1634 * @itv Interval of time in jiffies.
1635 ***************************************************************************
1637 __print_funct_t print_net_udp6_stats(struct activity *a, int prev, int curr,
1638 unsigned long long itv)
1640 struct stats_net_udp6
1641 *snuc = (struct stats_net_udp6 *) a->buf[curr],
1642 *snup = (struct stats_net_udp6 *) a->buf[prev];
1645 printf("\n%-11s idgm6/s odgm6/s noport6/s idgmer6/s\n",
1649 printf("%-11s %9.2f %9.2f %9.2f %9.2f\n",
1651 S_VALUE(snup->InDatagrams6, snuc->InDatagrams6, itv),
1652 S_VALUE(snup->OutDatagrams6, snuc->OutDatagrams6, itv),
1653 S_VALUE(snup->NoPorts6, snuc->NoPorts6, itv),
1654 S_VALUE(snup->InErrors6, snuc->InErrors6, itv));
1658 ***************************************************************************
1659 * Display CPU frequency statistics. This function is used to display
1660 * instantaneous and average statistics.
1663 * @a Activity structure with statistics.
1664 * @prev Index in array where stats used as reference are.
1665 * @curr Index in array for current sample statistics.
1666 * @dispavg True if displaying average statistics.
1667 ***************************************************************************
1669 void stub_print_pwr_cpufreq_stats(struct activity *a, int prev, int curr, int dispavg)
1672 struct stats_pwr_cpufreq *spc;
1673 static unsigned long long
1674 *avg_cpufreq = NULL;
1677 /* Allocate array of CPU frequency */
1678 if ((avg_cpufreq = (unsigned long long *) malloc(sizeof(unsigned long long) * a->nr))
1683 memset(avg_cpufreq, 0, sizeof(unsigned long long) * a->nr);
1687 printf("\n%-11s CPU MHz\n",
1691 for (i = 0; (i < a->nr) && (i < a->bitmap->b_size + 1); i++) {
1694 * The size of a->buf[...] CPU structure may be different from the default
1695 * sizeof(struct stats_pwr_cpufreq) value if data have been read from a file!
1696 * That's why we don't use a syntax like:
1697 * spc = (struct stats_pwr_cpufreq *) a->buf[...] + i;
1699 spc = (struct stats_pwr_cpufreq *) ((char *) a->buf[curr] + i * a->msize);
1702 * Note: a->nr is in [1, NR_CPUS + 1].
1703 * Bitmap size is provided for (NR_CPUS + 1) CPUs.
1704 * Anyway, NR_CPUS may vary between the version of sysstat
1705 * used by sadc to create a file, and the version of sysstat
1706 * used by sar to read it...
1709 /* Should current CPU (including CPU "all") be displayed? */
1710 if (a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))) {
1712 /* Yes: Display it */
1713 printf("%-11s", timestamp[curr]);
1716 /* This is CPU "all" */
1720 printf(" %3d", i - 1);
1724 /* Display instantaneous values */
1726 ((double) spc->cpufreq) / 100);
1728 * Will be used to compute the average.
1729 * Note: overflow unlikely to happen but not impossible...
1731 avg_cpufreq[i] += spc->cpufreq;
1734 /* Display average values */
1736 (double) avg_cpufreq[i] / (100 * avg_count));
1742 /* Array of CPU frequency no longer needed: Free it! */
1751 ***************************************************************************
1752 * Display CPU frequency statistics.
1755 * @a Activity structure with statistics.
1756 * @prev Index in array where stats used as reference are.
1757 * @curr Index in array for current sample statistics.
1758 * @itv Interval of time in jiffies.
1759 ***************************************************************************
1761 __print_funct_t print_pwr_cpufreq_stats(struct activity *a, int prev, int curr,
1762 unsigned long long itv)
1764 stub_print_pwr_cpufreq_stats(a, prev, curr, FALSE);
1768 ***************************************************************************
1769 * Display average CPU frequency statistics.
1772 * @a Activity structure with statistics.
1773 * @prev Index in array where stats used as reference are.
1774 * @curr Index in array for current sample statistics.
1775 * @itv Interval of time in jiffies.
1776 ***************************************************************************
1778 __print_funct_t print_avg_pwr_cpufreq_stats(struct activity *a, int prev, int curr,
1779 unsigned long long itv)
1781 stub_print_pwr_cpufreq_stats(a, prev, curr, TRUE);
1785 ***************************************************************************
1786 * Display fan statistics. This function is used to display
1787 * instantaneous and average statistics.
1790 * @a Activity structure with statistics.
1791 * @prev Index in array where stats used as reference are.
1792 * @curr Index in array for current sample statistics.
1793 * @dispavg True if displaying average statistics.
1794 ***************************************************************************
1796 void stub_print_pwr_fan_stats(struct activity *a, int prev, int curr, int dispavg)
1799 struct stats_pwr_fan *spc;
1800 static double *avg_fan = NULL;
1801 static double *avg_fan_min = NULL;
1803 /* Allocate arrays of fan RPMs */
1805 if ((avg_fan = (double *) malloc(sizeof(double) * a->nr)) == NULL) {
1809 memset(avg_fan, 0, sizeof(double) * a->nr);
1812 if ((avg_fan_min = (double *) malloc(sizeof(double) * a->nr)) == NULL) {
1816 memset(avg_fan_min, 0, sizeof(double) * a->nr);
1820 printf("\n%-11s FAN rpm drpm %*s\n",
1821 timestamp[!curr], MAX_SENSORS_DEV_LEN, "DEVICE");
1824 for (i = 0; i < a->nr; i++) {
1825 spc = (struct stats_pwr_fan *) ((char *) a->buf[curr] + i * a->msize);
1827 printf("%-11s %3d", timestamp[curr], i + 1);
1830 /* Display average values */
1831 printf(" %9.2f %9.2f",
1832 (double) avg_fan[i] / avg_count,
1833 (double) (avg_fan[i] - avg_fan_min[i]) / avg_count);
1836 /* Display instantaneous values */
1837 printf(" %9.2f %9.2f",
1839 spc->rpm - spc->rpm_min);
1840 avg_fan[i] += spc->rpm;
1841 avg_fan_min[i] += spc->rpm_min;
1844 printf(" %*s\n", MAX_SENSORS_DEV_LEN, spc->device);
1860 ***************************************************************************
1861 * Display fan statistics.
1864 * @a Activity structure with statistics.
1865 * @prev Index in array where stats used as reference are.
1866 * @curr Index in array for current sample statistics.
1867 * @itv Interval of time in jiffies.
1868 ***************************************************************************
1870 __print_funct_t print_pwr_fan_stats(struct activity *a, int prev, int curr,
1871 unsigned long long itv)
1873 stub_print_pwr_fan_stats(a, prev, curr, FALSE);
1877 ***************************************************************************
1878 * Display average fan statistics.
1881 * @a Activity structure with statistics.
1882 * @prev Index in array where stats used as reference are.
1883 * @curr Index in array for current sample statistics.
1884 * @itv Interval of time in jiffies.
1885 ***************************************************************************
1887 __print_funct_t print_avg_pwr_fan_stats(struct activity *a, int prev, int curr,
1888 unsigned long long itv)
1890 stub_print_pwr_fan_stats(a, prev, curr, TRUE);
1894 ***************************************************************************
1895 * Display device temperature statistics. This function is used to display
1896 * instantaneous and average statistics.
1899 * @a Activity structure with statistics.
1900 * @prev Index in array where stats used as reference are.
1901 * @curr Index in array for current sample statistics.
1902 * @dispavg True if displaying average statistics.
1903 ***************************************************************************
1905 void stub_print_pwr_temp_stats(struct activity *a, int prev, int curr, int dispavg)
1908 struct stats_pwr_temp *spc;
1909 static double *avg_temp = NULL;
1910 static double *avg_temp_min = NULL, *avg_temp_max = NULL;
1912 /* Allocate arrays of temperatures */
1914 if ((avg_temp = (double *) malloc(sizeof(double) * a->nr)) == NULL) {
1918 memset(avg_temp, 0, sizeof(double) * a->nr);
1920 if (!avg_temp_min) {
1921 if ((avg_temp_min = (double *) malloc(sizeof(double) * a->nr)) == NULL) {
1925 memset(avg_temp_min, 0, sizeof(double) * a->nr);
1927 if (!avg_temp_max) {
1928 if ((avg_temp_max = (double *) malloc(sizeof(double) * a->nr)) == NULL) {
1932 memset(avg_temp_max, 0, sizeof(double) * a->nr);
1936 printf("\n%-11s TEMP degC %%temp %*s\n",
1937 timestamp[!curr], MAX_SENSORS_DEV_LEN, "DEVICE");
1940 for (i = 0; i < a->nr; i++) {
1941 spc = (struct stats_pwr_temp *) ((char *) a->buf[curr] + i * a->msize);
1943 printf("%-11s %3d", timestamp[curr], i + 1);
1946 /* Display average values */
1947 printf(" %9.2f %9.2f",
1948 (double) avg_temp[i] / avg_count,
1949 (avg_temp_max[i] - avg_temp_min[i]) ?
1950 ((double) (avg_temp[i] / avg_count) - avg_temp_min[i]) / (avg_temp_max[i] - avg_temp_min[i]) * 100 :
1954 /* Display instantaneous values */
1955 printf(" %9.2f %9.2f",
1957 (spc->temp_max - spc->temp_min) ?
1958 (spc->temp - spc->temp_min) / (spc->temp_max - spc->temp_min) * 100 :
1960 avg_temp[i] += spc->temp;
1961 /* Assume that min and max temperatures cannot vary */
1962 avg_temp_min[i] = spc->temp_min;
1963 avg_temp_max[i] = spc->temp_max;
1966 printf(" %*s\n", MAX_SENSORS_DEV_LEN, spc->device);
1976 avg_temp_min = NULL;
1980 avg_temp_max = NULL;
1986 ***************************************************************************
1987 * Display temperature statistics.
1990 * @a Activity structure with statistics.
1991 * @prev Index in array where stats used as reference are.
1992 * @curr Index in array for current sample statistics.
1993 * @itv Interval of time in jiffies.
1994 ***************************************************************************
1996 __print_funct_t print_pwr_temp_stats(struct activity *a, int prev, int curr,
1997 unsigned long long itv)
1999 stub_print_pwr_temp_stats(a, prev, curr, FALSE);
2003 ***************************************************************************
2004 * Display average temperature statistics.
2007 * @a Activity structure with statistics.
2008 * @prev Index in array where stats used as reference are.
2009 * @curr Index in array for current sample statistics.
2010 * @itv Interval of time in jiffies.
2011 ***************************************************************************
2013 __print_funct_t print_avg_pwr_temp_stats(struct activity *a, int prev, int curr,
2014 unsigned long long itv)
2016 stub_print_pwr_temp_stats(a, prev, curr, TRUE);
2020 ***************************************************************************
2021 * Display voltage inputs statistics. This function is used to display
2022 * instantaneous and average statistics.
2025 * @a Activity structure with statistics.
2026 * @prev Index in array where stats used as reference are.
2027 * @curr Index in array for current sample statistics.
2028 * @dispavg True if displaying average statistics.
2029 ***************************************************************************
2031 void stub_print_pwr_in_stats(struct activity *a, int prev, int curr, int dispavg)
2034 struct stats_pwr_in *spc;
2035 static double *avg_in = NULL;
2036 static double *avg_in_min = NULL, *avg_in_max = NULL;
2038 /* Allocate arrays of voltage inputs */
2040 if ((avg_in = (double *) malloc(sizeof(double) * a->nr)) == NULL) {
2044 memset(avg_in, 0, sizeof(double) * a->nr);
2047 if ((avg_in_min = (double *) malloc(sizeof(double) * a->nr)) == NULL) {
2051 memset(avg_in_min, 0, sizeof(double) * a->nr);
2054 if ((avg_in_max = (double *) malloc(sizeof(double) * a->nr)) == NULL) {
2058 memset(avg_in_max, 0, sizeof(double) * a->nr);
2062 printf("\n%-11s IN inV %%in %*s\n",
2063 timestamp[!curr], MAX_SENSORS_DEV_LEN, "DEVICE");
2066 for (i = 0; i < a->nr; i++) {
2067 spc = (struct stats_pwr_in *) ((char *) a->buf[curr] + i * a->msize);
2069 printf("%-11s %3d", timestamp[curr], i);
2072 /* Display average values */
2073 printf(" %9.2f %9.2f",
2074 (double) avg_in[i] / avg_count,
2075 (avg_in_max[i] - avg_in_min[i]) ?
2076 ((double) (avg_in[i] / avg_count) - avg_in_min[i]) / (avg_in_max[i] - avg_in_min[i]) * 100 :
2080 /* Display instantaneous values */
2081 printf(" %9.2f %9.2f",
2083 (spc->in_max - spc->in_min) ?
2084 (spc->in - spc->in_min) / (spc->in_max - spc->in_min) * 100 :
2086 avg_in[i] += spc->in;
2087 /* Assume that min and max voltage inputs cannot vary */
2088 avg_in_min[i] = spc->in_min;
2089 avg_in_max[i] = spc->in_max;
2092 printf(" %*s\n", MAX_SENSORS_DEV_LEN, spc->device);
2112 ***************************************************************************
2113 * Display voltage inputs statistics.
2116 * @a Activity structure with statistics.
2117 * @prev Index in array where stats used as reference are.
2118 * @curr Index in array for current sample statistics.
2119 * @itv Interval of time in jiffies.
2120 ***************************************************************************
2122 __print_funct_t print_pwr_in_stats(struct activity *a, int prev, int curr,
2123 unsigned long long itv)
2125 stub_print_pwr_in_stats(a, prev, curr, FALSE);
2129 ***************************************************************************
2130 * Display average voltage inputs statistics.
2133 * @a Activity structure with statistics.
2134 * @prev Index in array where stats used as reference are.
2135 * @curr Index in array for current sample statistics.
2136 * @itv Interval of time in jiffies.
2137 ***************************************************************************
2139 __print_funct_t print_avg_pwr_in_stats(struct activity *a, int prev, int curr,
2140 unsigned long long itv)
2142 stub_print_pwr_in_stats(a, prev, curr, TRUE);
2146 ***************************************************************************
2147 * Display huge pages statistics. This function is used to
2148 * display instantaneous and average statistics.
2151 * @a Activity structure with statistics.
2152 * @prev Index in array where stats used as reference are.
2153 * @curr Index in array for current sample statistics.
2154 * @itv Interval of time in jiffies.
2155 * @dispavg TRUE if displaying average statistics.
2156 ***************************************************************************
2158 void stub_print_huge_stats(struct activity *a, int prev, int curr,
2159 unsigned long long itv, int dispavg)
2162 *smc = (struct stats_huge *) a->buf[curr];
2163 static unsigned long long
2168 printf("\n%-11s kbhugfree kbhugused %%hugused\n",
2173 /* Display instantaneous values */
2174 printf("%-11s %9lu %9lu %6.2f\n",
2177 smc->tlhkb - smc->frhkb,
2179 SP_VALUE(smc->frhkb, smc->tlhkb, smc->tlhkb) : 0.0);
2181 /* Will be used to compute the average */
2182 avg_frhkb += smc->frhkb;
2183 avg_tlhkb += smc->tlhkb;
2186 /* Display average values */
2187 printf("%-11s %9.0f %9.0f %6.2f\n",
2189 (double) avg_frhkb / avg_count,
2190 ((double) avg_tlhkb / avg_count) -
2191 ((double) avg_frhkb / avg_count),
2192 ((double) (avg_tlhkb / avg_count)) ?
2193 SP_VALUE((double) (avg_frhkb / avg_count),
2194 (double) (avg_tlhkb / avg_count),
2195 (double) (avg_tlhkb / avg_count)) :
2198 /* Reset average counters */
2199 avg_frhkb = avg_tlhkb = 0;
2204 ***************************************************************************
2205 * Display huge pages statistics.
2208 * @a Activity structure with statistics.
2209 * @prev Index in array where stats used as reference are.
2210 * @curr Index in array for current sample statistics.
2211 * @itv Interval of time in jiffies.
2212 ***************************************************************************
2214 __print_funct_t print_huge_stats(struct activity *a, int prev, int curr,
2215 unsigned long long itv)
2217 stub_print_huge_stats(a, prev, curr, itv, FALSE);
2221 ***************************************************************************
2222 * Display huge pages statistics.
2225 * @a Activity structure with statistics.
2226 * @prev Index in array where stats used as reference are.
2227 * @curr Index in array for current sample statistics.
2228 * @itv Interval of time in jiffies.
2229 ***************************************************************************
2231 __print_funct_t print_avg_huge_stats(struct activity *a, int prev, int curr,
2232 unsigned long long itv)
2234 stub_print_huge_stats(a, prev, curr, itv, TRUE);
2238 ***************************************************************************
2239 * Display CPU weighted frequency statistics. This function is used to
2240 * display instantaneous and average statistics.
2243 * @a Activity structure with statistics.
2244 * @prev Index in array where stats used as reference are.
2245 * @curr Index in array for current sample statistics.
2246 * @dispavg True if displaying average statistics.
2247 ***************************************************************************
2249 void print_pwr_wghfreq_stats(struct activity *a, int prev, int curr,
2250 unsigned long long itv)
2253 struct stats_pwr_wghfreq *spc, *spp, *spc_k, *spp_k;
2254 unsigned long long tis, tisfreq;
2257 printf("\n%-11s CPU wghMHz\n",
2261 for (i = 0; (i < a->nr) && (i < a->bitmap->b_size + 1); i++) {
2264 * The size of a->buf[...] CPU structure may be different from the default
2265 * sizeof(struct stats_pwr_wghfreq) value if data have been read from a file!
2266 * That's why we don't use a syntax like:
2267 * spc = (struct stats_pwr_wghfreq *) a->buf[...] + i;
2269 spc = (struct stats_pwr_wghfreq *) ((char *) a->buf[curr] + i * a->msize * a->nr2);
2270 spp = (struct stats_pwr_wghfreq *) ((char *) a->buf[prev] + i * a->msize * a->nr2);
2273 * Note: a->nr is in [1, NR_CPUS + 1].
2274 * Bitmap size is provided for (NR_CPUS + 1) CPUs.
2275 * Anyway, NR_CPUS may vary between the version of sysstat
2276 * used by sadc to create a file, and the version of sysstat
2277 * used by sar to read it...
2280 /* Should current CPU (including CPU "all") be displayed? */
2281 if (a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))) {
2283 /* Yes: Display it */
2284 printf("%-11s", timestamp[curr]);
2287 /* This is CPU "all" */
2291 printf(" %3d", i - 1);
2297 for (k = 0; k < a->nr2; k++) {
2299 spc_k = (struct stats_pwr_wghfreq *) ((char *) spc + k * a->msize);
2302 spp_k = (struct stats_pwr_wghfreq *) ((char *) spp + k * a->msize);
2304 tisfreq += (spc_k->freq / 1000) *
2305 (spc_k->time_in_state - spp_k->time_in_state);
2306 tis += (spc_k->time_in_state - spp_k->time_in_state);
2309 /* Display weighted frequency for current CPU */
2310 printf(" %9.2f\n", tis ? ((double) tisfreq) / tis : 0.0);
2316 ***************************************************************************
2317 * Display USB devices statistics. This function is used to
2318 * display instantaneous and summary statistics.
2321 * @a Activity structure with statistics.
2322 * @curr Index in array for current sample statistics.
2323 * @itv Interval of time in jiffies.
2324 * @dispavg TRUE if displaying average statistics.
2325 ***************************************************************************
2327 void stub_print_pwr_usb_stats(struct activity *a, int curr, int dispavg)
2330 struct stats_pwr_usb *suc, *sum;
2333 printf("\n%-11s BUS idvendor idprod maxpower",
2334 (dispavg ? _("Summary") : timestamp[!curr]));
2335 printf(" %*s", MAX_MANUF_LEN - 1, "manufact");
2336 printf(" %*s\n", MAX_PROD_LEN - 1, "product");
2339 for (i = 0; i < a->nr; i++) {
2340 suc = (struct stats_pwr_usb *) ((char *) a->buf[curr] + i * a->msize);
2343 /* Bus#0 doesn't exist: We are at the end of the list */
2346 printf("%-11s %6d %9x %9x %9u",
2347 (dispavg ? _("Summary") : timestamp[curr]),
2349 suc->vendor_id, suc->product_id,
2350 /* bMaxPower is expressed in 2 mA units */
2351 suc->bmaxpower << 1);
2353 printf(" %*s", MAX_MANUF_LEN - 1, suc->manufacturer);
2354 printf(" %*s\n", MAX_PROD_LEN - 1, suc->product);
2357 /* Save current USB device in summary list */
2358 for (j = 0; j < a->nr; j++) {
2359 sum = (struct stats_pwr_usb *) ((char *) a->buf[2] + j * a->msize);
2361 if ((sum->bus_nr == suc->bus_nr) &&
2362 (sum->vendor_id == suc->vendor_id) &&
2363 (sum->product_id == suc->product_id))
2364 /* USB device found in summary list */
2368 * Current slot is free:
2369 * Save USB device in summary list.
2374 if (j == a->nr - 1) {
2376 * This is the last slot and
2377 * we still havent't found the device.
2378 * So create a dummy device here.
2381 sum->vendor_id = sum->product_id = 0;
2383 sum->manufacturer[0] = '\0';
2384 snprintf(sum->product, MAX_PROD_LEN, "%s",
2385 _("Other devices not listed here"));
2386 sum->product[MAX_PROD_LEN - 1] = '\0';
2394 ***************************************************************************
2395 * Display memory and swap statistics.
2398 * @a Activity structure with statistics.
2399 * @prev Index in array where stats used as reference are.
2400 * @curr Index in array for current sample statistics.
2401 * @itv Interval of time in jiffies.
2402 ***************************************************************************
2404 __print_funct_t print_pwr_usb_stats(struct activity *a, int prev, int curr,
2405 unsigned long long itv)
2407 stub_print_pwr_usb_stats(a, curr, FALSE);
2411 ***************************************************************************
2412 * Display average memory statistics.
2415 * @a Activity structure with statistics.
2416 * @prev Index in array where stats used as reference are.
2417 * @curr Index in array for current sample statistics.
2418 * @itv Interval of time in jiffies.
2419 ***************************************************************************
2421 __print_funct_t print_avg_pwr_usb_stats(struct activity *a, int prev, int curr,
2422 unsigned long long itv)
2424 stub_print_pwr_usb_stats(a, 2, TRUE);