2 * pr_stats.c: Functions used by sar to display statistics
3 * (C) 1999-2014 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"
72 " %%guest %%gnice %%idle\n",
77 for (i = 0; (i < a->nr) && (i < a->bitmap->b_size + 1); i++) {
80 * The size of a->buf[...] CPU structure may be different from the default
81 * sizeof(struct stats_cpu) value if data have been read from a file!
82 * That's why we don't use a syntax like:
83 * scc = (struct stats_cpu *) a->buf[...] + i;
85 scc = (struct stats_cpu *) ((char *) a->buf[curr] + i * a->msize);
86 scp = (struct stats_cpu *) ((char *) a->buf[prev] + i * a->msize);
89 * Note: a->nr is in [1, NR_CPUS + 1].
90 * Bitmap size is provided for (NR_CPUS + 1) CPUs.
91 * Anyway, NR_CPUS may vary between the version of sysstat
92 * used by sadc to create a file, and the version of sysstat
93 * used by sar to read it...
96 /* Should current CPU (including CPU "all") be displayed? */
97 if (a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))) {
100 printf("%-11s", timestamp[curr]);
103 /* This is CPU "all" */
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/guest_nice times are already included in
115 if ((scc->cpu_user + scc->cpu_nice + scc->cpu_sys +
116 scc->cpu_iowait + scc->cpu_idle + scc->cpu_steal +
117 scc->cpu_hardirq + scc->cpu_softirq) == 0) {
119 * Set current struct fields (which have been set to zero)
120 * to values from previous iteration. Hence their values won't
121 * jump from zero when the CPU comes back online.
125 /* %user, %nice, %system, %iowait, %steal, ..., %idle */
126 printf(" %6.2f %6.2f %6.2f"
127 " %6.2f %6.2f %6.2f",
128 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
130 if (DISPLAY_CPU_ALL(a->opt_flags)) {
132 * Four additional fields to display:
133 * %irq, %soft, %guest, %gnice.
135 printf(" %6.2f %6.2f %6.2f %6.2f",
142 /* Recalculate interval for current proc */
143 g_itv = get_per_cpu_interval(scc, scp);
147 * If the CPU is tickless then there is no change in CPU values
148 * but the sum of values is not zero.
149 * %user, %nice, %system, %iowait, %steal, ..., %idle
151 printf(" %6.2f %6.2f %6.2f"
153 0.0, 0.0, 0.0, 0.0, 0.0);
155 if (DISPLAY_CPU_DEF(a->opt_flags)) {
156 printf(" %6.2f\n", 100.0);
159 * Four additional fields to display:
160 * %irq, %soft, %guest, %gnice.
162 else if (DISPLAY_CPU_ALL(a->opt_flags)) {
163 printf(" %6.2f %6.2f %6.2f %6.2f\n",
164 0.0, 0.0, 0.0, 100.0);
170 if (DISPLAY_CPU_DEF(a->opt_flags)) {
171 printf(" %6.2f %6.2f %6.2f %6.2f %6.2f %6.2f\n",
172 ll_sp_value(scp->cpu_user, scc->cpu_user, g_itv),
173 ll_sp_value(scp->cpu_nice, scc->cpu_nice, g_itv),
174 ll_sp_value(scp->cpu_sys + scp->cpu_hardirq + scp->cpu_softirq,
175 scc->cpu_sys + scc->cpu_hardirq + scc->cpu_softirq,
177 ll_sp_value(scp->cpu_iowait, scc->cpu_iowait, g_itv),
178 ll_sp_value(scp->cpu_steal, scc->cpu_steal, g_itv),
179 scc->cpu_idle < scp->cpu_idle ?
181 ll_sp_value(scp->cpu_idle, scc->cpu_idle, g_itv));
183 else if (DISPLAY_CPU_ALL(a->opt_flags)) {
184 printf(" %6.2f %6.2f %6.2f %6.2f %6.2f %6.2f"
185 " %6.2f %6.2f %6.2f %6.2f\n",
186 (scc->cpu_user - scc->cpu_guest) < (scp->cpu_user - scp->cpu_guest) ?
188 ll_sp_value(scp->cpu_user - scp->cpu_guest,
189 scc->cpu_user - scc->cpu_guest, g_itv),
190 (scc->cpu_nice - scc->cpu_guest_nice) < (scp->cpu_nice - scp->cpu_guest_nice) ?
192 ll_sp_value(scp->cpu_nice - scp->cpu_guest_nice,
193 scc->cpu_nice - scc->cpu_guest_nice, g_itv),
194 ll_sp_value(scp->cpu_sys, scc->cpu_sys, g_itv),
195 ll_sp_value(scp->cpu_iowait, scc->cpu_iowait, g_itv),
196 ll_sp_value(scp->cpu_steal, scc->cpu_steal, g_itv),
197 ll_sp_value(scp->cpu_hardirq, scc->cpu_hardirq, g_itv),
198 ll_sp_value(scp->cpu_softirq, scc->cpu_softirq, g_itv),
199 ll_sp_value(scp->cpu_guest, scc->cpu_guest, g_itv),
200 ll_sp_value(scp->cpu_guest_nice, scc->cpu_guest_nice, g_itv),
201 scc->cpu_idle < scp->cpu_idle ?
203 ll_sp_value(scp->cpu_idle, scc->cpu_idle, g_itv));
210 ***************************************************************************
211 * Display tasks creation and context switches statistics.
214 * @a Activity structure with statistics.
215 * @prev Index in array where stats used as reference are.
216 * @curr Index in array for current sample statistics.
217 * @itv Interval of time in jiffies.
218 ***************************************************************************
220 __print_funct_t print_pcsw_stats(struct activity *a, int prev, int curr,
221 unsigned long long itv)
224 *spc = (struct stats_pcsw *) a->buf[curr],
225 *spp = (struct stats_pcsw *) a->buf[prev];
228 printf("\n%-11s proc/s cswch/s\n", timestamp[!curr]);
231 printf("%-11s %9.2f %9.2f\n", timestamp[curr],
232 S_VALUE (spp->processes, spc->processes, itv),
233 S_VALUE(spp->context_switch, spc->context_switch, itv));
237 ***************************************************************************
238 * Display interrupts statistics.
241 * @a Activity structure with statistics.
242 * @prev Index in array where stats used as reference are.
243 * @curr Index in array for current sample statistics.
244 * @itv Interval of time in jiffies.
245 ***************************************************************************
247 __print_funct_t print_irq_stats(struct activity *a, int prev, int curr,
248 unsigned long long itv)
251 struct stats_irq *sic, *sip;
254 printf("\n%-11s INTR intr/s\n", timestamp[!curr]);
257 for (i = 0; (i < a->nr) && (i < a->bitmap->b_size + 1); i++) {
259 sic = (struct stats_irq *) ((char *) a->buf[curr] + i * a->msize);
260 sip = (struct stats_irq *) ((char *) a->buf[prev] + i * a->msize);
263 * Note: a->nr is in [0, NR_IRQS + 1].
264 * Bitmap size is provided for (NR_IRQS + 1) interrupts.
265 * Anyway, NR_IRQS may vary between the version of sysstat
266 * used by sadc to create a file, and the version of sysstat
267 * used by sar to read it...
270 /* Should current interrupt (including int "sum") be displayed? */
271 if (a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))) {
273 /* Yes: Display it */
274 printf("%-11s", timestamp[curr]);
276 /* This is interrupt "sum" */
280 printf(" %3d", i - 1);
284 S_VALUE(sip->irq_nr, sic->irq_nr, itv));
290 ***************************************************************************
291 * Display swapping statistics.
294 * @a Activity structure with statistics.
295 * @prev Index in array where stats used as reference are.
296 * @curr Index in array for current sample statistics.
297 * @itv Interval of time in jiffies.
298 ***************************************************************************
300 __print_funct_t print_swap_stats(struct activity *a, int prev, int curr,
301 unsigned long long itv)
304 *ssc = (struct stats_swap *) a->buf[curr],
305 *ssp = (struct stats_swap *) a->buf[prev];
308 printf("\n%-11s pswpin/s pswpout/s\n", timestamp[!curr]);
311 printf("%-11s %9.2f %9.2f\n", timestamp[curr],
312 S_VALUE(ssp->pswpin, ssc->pswpin, itv),
313 S_VALUE(ssp->pswpout, ssc->pswpout, itv));
317 ***************************************************************************
318 * Display paging statistics.
321 * @a Activity structure with statistics.
322 * @prev Index in array where stats used as reference are.
323 * @curr Index in array for current sample statistics.
324 * @itv Interval of time in jiffies.
325 ***************************************************************************
327 __print_funct_t print_paging_stats(struct activity *a, int prev, int curr,
328 unsigned long long itv)
331 *spc = (struct stats_paging *) a->buf[curr],
332 *spp = (struct stats_paging *) a->buf[prev];
335 printf("\n%-11s pgpgin/s pgpgout/s fault/s majflt/s pgfree/s"
336 " pgscank/s pgscand/s pgsteal/s %%vmeff\n",
340 printf("%-11s %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f\n",
342 S_VALUE(spp->pgpgin, spc->pgpgin, itv),
343 S_VALUE(spp->pgpgout, spc->pgpgout, itv),
344 S_VALUE(spp->pgfault, spc->pgfault, itv),
345 S_VALUE(spp->pgmajfault, spc->pgmajfault, itv),
346 S_VALUE(spp->pgfree, spc->pgfree, itv),
347 S_VALUE(spp->pgscan_kswapd, spc->pgscan_kswapd, itv),
348 S_VALUE(spp->pgscan_direct, spc->pgscan_direct, itv),
349 S_VALUE(spp->pgsteal, spc->pgsteal, itv),
350 (spc->pgscan_kswapd + spc->pgscan_direct -
351 spp->pgscan_kswapd - spp->pgscan_direct) ?
352 SP_VALUE(spp->pgsteal, spc->pgsteal,
353 spc->pgscan_kswapd + spc->pgscan_direct -
354 spp->pgscan_kswapd - spp->pgscan_direct) : 0.0);
358 ***************************************************************************
359 * Display I/O and transfer rate statistics.
362 * @a Activity structure with statistics.
363 * @prev Index in array where stats used as reference are.
364 * @curr Index in array for current sample statistics.
365 * @itv Interval of time in jiffies.
366 ***************************************************************************
368 __print_funct_t print_io_stats(struct activity *a, int prev, int curr,
369 unsigned long long itv)
372 *sic = (struct stats_io *) a->buf[curr],
373 *sip = (struct stats_io *) a->buf[prev];
376 printf("\n%-11s tps rtps wtps bread/s bwrtn/s\n",
380 printf("%-11s %9.2f %9.2f %9.2f %9.2f %9.2f\n", timestamp[curr],
381 S_VALUE(sip->dk_drive, sic->dk_drive, itv),
382 S_VALUE(sip->dk_drive_rio, sic->dk_drive_rio, itv),
383 S_VALUE(sip->dk_drive_wio, sic->dk_drive_wio, itv),
384 S_VALUE(sip->dk_drive_rblk, sic->dk_drive_rblk, itv),
385 S_VALUE(sip->dk_drive_wblk, sic->dk_drive_wblk, itv));
389 ***************************************************************************
390 * Display memory and swap statistics. This function is used to
391 * display instantaneous and average statistics.
394 * @a Activity structure with statistics.
395 * @prev Index in array where stats used as reference are.
396 * @curr Index in array for current sample statistics.
397 * @itv Interval of time in jiffies.
398 * @dispavg TRUE if displaying average statistics.
399 ***************************************************************************
401 void stub_print_memory_stats(struct activity *a, int prev, int curr,
402 unsigned long long itv, int dispavg)
405 *smc = (struct stats_memory *) a->buf[curr],
406 *smp = (struct stats_memory *) a->buf[prev];
407 static unsigned long long
420 static unsigned long long
425 if (DISPLAY_MEMORY(a->opt_flags)) {
427 printf("\n%-11s frmpg/s bufpg/s campg/s\n",
431 printf("%-11s %9.2f %9.2f %9.2f\n", timestamp[curr],
432 S_VALUE((double) KB_TO_PG(smp->frmkb), (double) KB_TO_PG(smc->frmkb), itv),
433 S_VALUE((double) KB_TO_PG(smp->bufkb), (double) KB_TO_PG(smc->bufkb), itv),
434 S_VALUE((double) KB_TO_PG(smp->camkb), (double) KB_TO_PG(smc->camkb), itv));
437 if (DISPLAY_MEM_AMT(a->opt_flags)) {
439 printf("\n%-11s kbmemfree kbmemused %%memused kbbuffers kbcached"
440 " kbcommit %%commit kbactive kbinact kbdirty", timestamp[!curr]);
441 if (DISPLAY_MEM_ALL(a->opt_flags)) {
442 printf(" kbanonpg kbslab kbkstack kbpgtbl kbvmused");
448 /* Display instantaneous values */
449 printf("%-11s %9lu %9lu %6.2f %9lu %9lu %9lu %7.2f %9lu %9lu %9lu",
452 smc->tlmkb - smc->frmkb,
454 SP_VALUE(smc->frmkb, smc->tlmkb, smc->tlmkb) : 0.0,
458 (smc->tlmkb + smc->tlskb) ?
459 SP_VALUE(0, smc->comkb, smc->tlmkb + smc->tlskb) : 0.0,
464 if (DISPLAY_MEM_ALL(a->opt_flags)) {
465 /* Display extended memory statistics */
466 printf(" %9lu %9lu %9lu %9lu %9lu",
477 * Will be used to compute the average.
478 * We assume that the total amount of memory installed can not vary
479 * during the interval given on the command line.
481 avg_frmkb += smc->frmkb;
482 avg_bufkb += smc->bufkb;
483 avg_camkb += smc->camkb;
484 avg_comkb += smc->comkb;
485 avg_activekb += smc->activekb;
486 avg_inactkb += smc->inactkb;
487 avg_dirtykb += smc->dirtykb;
488 avg_anonpgkb += smc->anonpgkb;
489 avg_slabkb += smc->slabkb;
490 avg_kstackkb += smc->kstackkb;
491 avg_pgtblkb += smc->pgtblkb;
492 avg_vmusedkb += smc->vmusedkb;
495 /* Display average values */
496 printf("%-11s %9.0f %9.0f %6.2f %9.0f %9.0f %9.0f %7.2f %9.0f %9.0f %9.0f",
498 (double) avg_frmkb / avg_count,
499 (double) smc->tlmkb - ((double) avg_frmkb / avg_count),
501 SP_VALUE((double) (avg_frmkb / avg_count), smc->tlmkb,
504 (double) avg_bufkb / avg_count,
505 (double) avg_camkb / avg_count,
506 (double) avg_comkb / avg_count,
507 (smc->tlmkb + smc->tlskb) ?
508 SP_VALUE(0.0, (double) (avg_comkb / avg_count),
509 smc->tlmkb + smc->tlskb) : 0.0,
510 (double) avg_activekb / avg_count,
511 (double) avg_inactkb / avg_count,
512 (double) avg_dirtykb / avg_count);
514 if (DISPLAY_MEM_ALL(a->opt_flags)) {
515 printf(" %9.0f %9.0f %9.0f %9.0f %9.0f",
516 (double) avg_anonpgkb / avg_count,
517 (double) avg_slabkb / avg_count,
518 (double) avg_kstackkb / avg_count,
519 (double) avg_pgtblkb / avg_count,
520 (double) avg_vmusedkb / avg_count);
525 /* Reset average counters */
526 avg_frmkb = avg_bufkb = avg_camkb = avg_comkb = 0;
527 avg_activekb = avg_inactkb = avg_dirtykb = 0;
528 avg_anonpgkb = avg_slabkb = avg_kstackkb = 0;
529 avg_pgtblkb = avg_vmusedkb = 0;
533 if (DISPLAY_SWAP(a->opt_flags)) {
535 printf("\n%-11s kbswpfree kbswpused %%swpused kbswpcad %%swpcad\n",
540 /* Display instantaneous values */
541 printf("%-11s %9lu %9lu %6.2f %9lu %6.2f\n",
544 smc->tlskb - smc->frskb,
546 SP_VALUE(smc->frskb, smc->tlskb, smc->tlskb) : 0.0,
548 (smc->tlskb - smc->frskb) ?
549 SP_VALUE(0, smc->caskb, smc->tlskb - smc->frskb) : 0.0);
552 * Will be used to compute the average.
553 * We assume that the total amount of swap space may vary.
555 avg_frskb += smc->frskb;
556 avg_tlskb += smc->tlskb;
557 avg_caskb += smc->caskb;
560 /* Display average values */
561 printf("%-11s %9.0f %9.0f %6.2f %9.0f %6.2f\n",
563 (double) avg_frskb / avg_count,
564 ((double) avg_tlskb / avg_count) -
565 ((double) avg_frskb / avg_count),
566 ((double) (avg_tlskb / avg_count)) ?
567 SP_VALUE((double) (avg_frskb / avg_count),
568 (double) (avg_tlskb / avg_count),
569 (double) (avg_tlskb / avg_count)) :
571 (double) (avg_caskb / avg_count),
572 (((double) avg_tlskb / avg_count) -
573 ((double) avg_frskb / avg_count)) ?
574 SP_VALUE(0.0, (double) (avg_caskb / avg_count),
575 ((double) avg_tlskb / avg_count) -
576 ((double) avg_frskb / avg_count)) :
579 /* Reset average counters */
580 avg_frskb = avg_tlskb = avg_caskb = 0;
586 ***************************************************************************
587 * Display memory and swap statistics.
590 * @a Activity structure with statistics.
591 * @prev Index in array where stats used as reference are.
592 * @curr Index in array for current sample statistics.
593 * @itv Interval of time in jiffies.
594 ***************************************************************************
596 __print_funct_t print_memory_stats(struct activity *a, int prev, int curr,
597 unsigned long long itv)
599 stub_print_memory_stats(a, prev, curr, itv, FALSE);
603 ***************************************************************************
604 * Display average memory statistics.
607 * @a Activity structure with statistics.
608 * @prev Index in array where stats used as reference are.
609 * @curr Index in array for current sample statistics.
610 * @itv Interval of time in jiffies.
611 ***************************************************************************
613 __print_funct_t print_avg_memory_stats(struct activity *a, int prev, int curr,
614 unsigned long long itv)
616 stub_print_memory_stats(a, prev, curr, itv, TRUE);
620 ***************************************************************************
621 * Display kernel tables statistics. This function is used to display
622 * instantaneous and average statistics.
625 * @a Activity structure with statistics.
626 * @curr Index in array for current sample statistics.
627 * @dispavg True if displaying average statistics.
628 ***************************************************************************
630 void stub_print_ktables_stats(struct activity *a, int curr, int dispavg)
633 *skc = (struct stats_ktables *) a->buf[curr];
634 static unsigned long long
642 printf("\n%-11s dentunusd file-nr inode-nr pty-nr\n",
647 /* Display instantaneous values */
648 printf("%-11s %9u %9u %9u %9u\n", timestamp[curr],
655 * Will be used to compute the average.
656 * Note: Overflow unlikely to happen but not impossible...
658 avg_dentry_stat += skc->dentry_stat;
659 avg_file_used += skc->file_used;
660 avg_inode_used += skc->inode_used;
661 avg_pty_nr += skc->pty_nr;
664 /* Display average values */
665 printf("%-11s %9.0f %9.0f %9.0f %9.0f\n",
667 (double) avg_dentry_stat / avg_count,
668 (double) avg_file_used / avg_count,
669 (double) avg_inode_used / avg_count,
670 (double) avg_pty_nr / avg_count);
672 /* Reset average counters */
673 avg_dentry_stat = avg_file_used = avg_inode_used = avg_pty_nr = 0;
678 ***************************************************************************
679 * Display kernel tables statistics.
682 * @a Activity structure with statistics.
683 * @prev Index in array where stats used as reference are.
684 * @curr Index in array for current sample statistics.
685 * @itv Interval of time in jiffies.
686 ***************************************************************************
688 __print_funct_t print_ktables_stats(struct activity *a, int prev, int curr,
689 unsigned long long itv)
691 stub_print_ktables_stats(a, curr, FALSE);
695 ***************************************************************************
696 * Display average kernel tables statistics.
699 * @a Activity structure with statistics.
700 * @prev Index in array where stats used as reference are.
701 * @curr Index in array for current sample statistics.
702 * @itv Interval of time in jiffies.
703 ***************************************************************************
705 __print_funct_t print_avg_ktables_stats(struct activity *a, int prev, int curr,
706 unsigned long long itv)
708 stub_print_ktables_stats(a, curr, TRUE);
712 ***************************************************************************
713 * Display queue and load statistics. This function is used to display
714 * instantaneous and average statistics.
717 * @a Activity structure with statistics.
718 * @curr Index in array for current sample statistics.
719 * @dispavg TRUE if displaying average statistics.
720 ***************************************************************************
722 void stub_print_queue_stats(struct activity *a, int curr, int dispavg)
725 *sqc = (struct stats_queue *) a->buf[curr];
726 static unsigned long long
732 avg_procs_blocked = 0;
735 printf("\n%-11s runq-sz plist-sz ldavg-1 ldavg-5 ldavg-15 blocked\n",
740 /* Display instantaneous values */
741 printf("%-11s %9lu %9u %9.2f %9.2f %9.2f %9lu\n", timestamp[curr],
744 (double) sqc->load_avg_1 / 100,
745 (double) sqc->load_avg_5 / 100,
746 (double) sqc->load_avg_15 / 100,
749 /* Will be used to compute the average */
750 avg_nr_running += sqc->nr_running;
751 avg_nr_threads += sqc->nr_threads;
752 avg_load_avg_1 += sqc->load_avg_1;
753 avg_load_avg_5 += sqc->load_avg_5;
754 avg_load_avg_15 += sqc->load_avg_15;
755 avg_procs_blocked += sqc->procs_blocked;
758 /* Display average values */
759 printf("%-11s %9.0f %9.0f %9.2f %9.2f %9.2f %9.0f\n", timestamp[curr],
760 (double) avg_nr_running / avg_count,
761 (double) avg_nr_threads / avg_count,
762 (double) avg_load_avg_1 / (avg_count * 100),
763 (double) avg_load_avg_5 / (avg_count * 100),
764 (double) avg_load_avg_15 / (avg_count * 100),
765 (double) avg_procs_blocked / avg_count);
767 /* Reset average counters */
768 avg_nr_running = avg_nr_threads = 0;
769 avg_load_avg_1 = avg_load_avg_5 = avg_load_avg_15 = 0;
770 avg_procs_blocked = 0;
775 ***************************************************************************
776 * Display queue and load statistics.
779 * @a Activity structure with statistics.
780 * @prev Index in array where stats used as reference are.
781 * @curr Index in array for current sample statistics.
782 * @itv Interval of time in jiffies.
783 ***************************************************************************
785 __print_funct_t print_queue_stats(struct activity *a, int prev, int curr,
786 unsigned long long itv)
788 stub_print_queue_stats(a, curr, FALSE);
792 ***************************************************************************
793 * Display average queue and load statistics.
796 * @a Activity structure with statistics.
797 * @prev Index in array where stats used as reference are.
798 * @curr Index in array for current sample statistics.
799 * @itv Interval of time in jiffies.
800 ***************************************************************************
802 __print_funct_t print_avg_queue_stats(struct activity *a, int prev, int curr,
803 unsigned long long itv)
805 stub_print_queue_stats(a, curr, TRUE);
809 ***************************************************************************
810 * Display serial lines statistics.
813 * @a Activity structure with statistics.
814 * @prev Index in array where stats used as reference are.
815 * @curr Index in array for current sample statistics.
816 * @itv Interval of time in jiffies.
817 ***************************************************************************
819 __print_funct_t print_serial_stats(struct activity *a, int prev, int curr,
820 unsigned long long itv)
823 struct stats_serial *ssc, *ssp;
826 printf("\n%-11s TTY rcvin/s xmtin/s framerr/s prtyerr/s"
827 " brk/s ovrun/s\n", timestamp[!curr]);
830 for (i = 0; i < a->nr; i++) {
832 ssc = (struct stats_serial *) ((char *) a->buf[curr] + i * a->msize);
833 ssp = (struct stats_serial *) ((char *) a->buf[prev] + i * a->msize);
838 printf("%-11s %3d", timestamp[curr], ssc->line - 1);
840 if ((ssc->line == ssp->line) || WANT_SINCE_BOOT(flags)) {
841 printf(" %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f\n",
842 S_VALUE(ssp->rx, ssc->rx, itv),
843 S_VALUE(ssp->tx, ssc->tx, itv),
844 S_VALUE(ssp->frame, ssc->frame, itv),
845 S_VALUE(ssp->parity, ssc->parity, itv),
846 S_VALUE(ssp->brk, ssc->brk, itv),
847 S_VALUE(ssp->overrun, ssc->overrun, itv));
850 printf(" N/A N/A N/A N/A"
857 ***************************************************************************
858 * Display disks statistics.
861 * @a Activity structure with statistics.
862 * @prev Index in array where stats used as reference are.
863 * @curr Index in array for current sample statistics.
864 * @itv Interval of time in jiffies.
865 ***************************************************************************
867 __print_funct_t print_disk_stats(struct activity *a, int prev, int curr,
868 unsigned long long itv)
871 struct stats_disk *sdc, *sdp;
872 struct ext_disk_stats xds;
873 char *dev_name, *persist_dev_name;
876 printf("\n%-11s DEV tps rd_sec/s wr_sec/s avgrq-sz"
877 " avgqu-sz await svctm %%util\n",
881 for (i = 0; i < a->nr; i++) {
883 sdc = (struct stats_disk *) ((char *) a->buf[curr] + i * a->msize);
885 if (!(sdc->major + sdc->minor))
888 j = check_disk_reg(a, curr, prev, i);
889 sdp = (struct stats_disk *) ((char *) a->buf[prev] + j * a->msize);
891 /* Compute service time, etc. */
892 compute_ext_disk_stats(sdc, sdp, itv, &xds);
895 persist_dev_name = NULL;
897 if (DISPLAY_PERSIST_NAME_S(flags)) {
898 persist_dev_name = get_persistent_name_from_pretty(get_devname(sdc->major, sdc->minor, TRUE));
901 if (persist_dev_name) {
902 dev_name = persist_dev_name;
905 if ((USE_PRETTY_OPTION(flags)) && (sdc->major == dm_major)) {
906 dev_name = transform_devmapname(sdc->major, sdc->minor);
910 dev_name = get_devname(sdc->major, sdc->minor,
911 USE_PRETTY_OPTION(flags));
915 printf("%-11s %9s %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f\n",
917 /* Confusion possible here between index and minor numbers */
919 S_VALUE(sdp->nr_ios, sdc->nr_ios, itv),
920 S_VALUE(sdp->rd_sect, sdc->rd_sect, itv),
921 S_VALUE(sdp->wr_sect, sdc->wr_sect, itv),
922 /* See iostat for explanations */
924 S_VALUE(sdp->rq_ticks, sdc->rq_ticks, itv) / 1000.0,
932 ***************************************************************************
933 * Display network interfaces statistics.
936 * @a Activity structure with statistics.
937 * @prev Index in array where stats used as reference are.
938 * @curr Index in array for current sample statistics.
939 * @itv Interval of time in jiffies.
940 ***************************************************************************
942 __print_funct_t print_net_dev_stats(struct activity *a, int prev, int curr,
943 unsigned long long itv)
946 struct stats_net_dev *sndc, *sndp;
947 double rxkb, txkb, ifutil;
950 printf("\n%-11s IFACE rxpck/s txpck/s rxkB/s txkB/s"
951 " rxcmp/s txcmp/s rxmcst/s %%ifutil\n", timestamp[!curr]);
954 for (i = 0; i < a->nr; i++) {
956 sndc = (struct stats_net_dev *) ((char *) a->buf[curr] + i * a->msize);
958 if (!strcmp(sndc->interface, ""))
961 j = check_net_dev_reg(a, curr, prev, i);
962 sndp = (struct stats_net_dev *) ((char *) a->buf[prev] + j * a->msize);
964 printf("%-11s %9s", timestamp[curr], sndc->interface);
966 rxkb = S_VALUE(sndp->rx_bytes, sndc->rx_bytes, itv);
967 txkb = S_VALUE(sndp->tx_bytes, sndc->tx_bytes, itv);
969 printf(" %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f",
970 S_VALUE(sndp->rx_packets, sndc->rx_packets, itv),
971 S_VALUE(sndp->tx_packets, sndc->tx_packets, itv),
974 S_VALUE(sndp->rx_compressed, sndc->rx_compressed, itv),
975 S_VALUE(sndp->tx_compressed, sndc->tx_compressed, itv),
976 S_VALUE(sndp->multicast, sndc->multicast, itv));
978 ifutil = compute_ifutil(sndc, rxkb, txkb);
979 printf(" %6.2f\n", ifutil);
984 ***************************************************************************
985 * Display network interface errors statistics.
988 * @a Activity structure with statistics.
989 * @prev Index in array where stats used as reference are.
990 * @curr Index in array for current sample statistics.
991 * @itv Interval of time in jiffies.
992 ***************************************************************************
994 __print_funct_t print_net_edev_stats(struct activity *a, int prev, int curr,
995 unsigned long long itv)
998 struct stats_net_edev *snedc, *snedp;
1001 printf("\n%-11s IFACE rxerr/s txerr/s coll/s rxdrop/s"
1002 " txdrop/s txcarr/s rxfram/s rxfifo/s txfifo/s\n",
1006 for (i = 0; i < a->nr; i++) {
1008 snedc = (struct stats_net_edev *) ((char *) a->buf[curr] + i * a->msize);
1010 if (!strcmp(snedc->interface, ""))
1013 j = check_net_edev_reg(a, curr, prev, i);
1014 snedp = (struct stats_net_edev *) ((char *) a->buf[prev] + j * a->msize);
1016 printf("%-11s %9s", timestamp[curr], snedc->interface);
1018 printf(" %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f\n",
1019 S_VALUE(snedp->rx_errors, snedc->rx_errors, itv),
1020 S_VALUE(snedp->tx_errors, snedc->tx_errors, itv),
1021 S_VALUE(snedp->collisions, snedc->collisions, itv),
1022 S_VALUE(snedp->rx_dropped, snedc->rx_dropped, itv),
1023 S_VALUE(snedp->tx_dropped, snedc->tx_dropped, itv),
1024 S_VALUE(snedp->tx_carrier_errors, snedc->tx_carrier_errors, itv),
1025 S_VALUE(snedp->rx_frame_errors, snedc->rx_frame_errors, itv),
1026 S_VALUE(snedp->rx_fifo_errors, snedc->rx_fifo_errors, itv),
1027 S_VALUE(snedp->tx_fifo_errors, snedc->tx_fifo_errors, itv));
1032 ***************************************************************************
1033 * Display NFS client statistics.
1036 * @a Activity structure with statistics.
1037 * @prev Index in array where stats used as reference are.
1038 * @curr Index in array for current sample statistics.
1039 * @itv Interval of time in jiffies.
1040 ***************************************************************************
1042 __print_funct_t print_net_nfs_stats(struct activity *a, int prev, int curr,
1043 unsigned long long itv)
1045 struct stats_net_nfs
1046 *snnc = (struct stats_net_nfs *) a->buf[curr],
1047 *snnp = (struct stats_net_nfs *) a->buf[prev];
1050 printf("\n%-11s call/s retrans/s read/s write/s access/s"
1051 " getatt/s\n", timestamp[!curr]);
1054 printf("%-11s %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f\n", timestamp[curr],
1055 S_VALUE(snnp->nfs_rpccnt, snnc->nfs_rpccnt, itv),
1056 S_VALUE(snnp->nfs_rpcretrans, snnc->nfs_rpcretrans, itv),
1057 S_VALUE(snnp->nfs_readcnt, snnc->nfs_readcnt, itv),
1058 S_VALUE(snnp->nfs_writecnt, snnc->nfs_writecnt, itv),
1059 S_VALUE(snnp->nfs_accesscnt, snnc->nfs_accesscnt, itv),
1060 S_VALUE(snnp->nfs_getattcnt, snnc->nfs_getattcnt, itv));
1064 ***************************************************************************
1065 * Display NFS server statistics.
1068 * @a Activity structure with statistics.
1069 * @prev Index in array where stats used as reference are.
1070 * @curr Index in array for current sample statistics.
1071 * @itv Interval of time in jiffies.
1072 ***************************************************************************
1074 __print_funct_t print_net_nfsd_stats(struct activity *a, int prev, int curr,
1075 unsigned long long itv)
1077 struct stats_net_nfsd
1078 *snndc = (struct stats_net_nfsd *) a->buf[curr],
1079 *snndp = (struct stats_net_nfsd *) a->buf[prev];
1082 printf("\n%-11s scall/s badcall/s packet/s udp/s tcp/s "
1083 "hit/s miss/s sread/s swrite/s saccess/s sgetatt/s\n",
1087 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",
1089 S_VALUE(snndp->nfsd_rpccnt, snndc->nfsd_rpccnt, itv),
1090 S_VALUE(snndp->nfsd_rpcbad, snndc->nfsd_rpcbad, itv),
1091 S_VALUE(snndp->nfsd_netcnt, snndc->nfsd_netcnt, itv),
1092 S_VALUE(snndp->nfsd_netudpcnt, snndc->nfsd_netudpcnt, itv),
1093 S_VALUE(snndp->nfsd_nettcpcnt, snndc->nfsd_nettcpcnt, itv),
1094 S_VALUE(snndp->nfsd_rchits, snndc->nfsd_rchits, itv),
1095 S_VALUE(snndp->nfsd_rcmisses, snndc->nfsd_rcmisses, itv),
1096 S_VALUE(snndp->nfsd_readcnt, snndc->nfsd_readcnt, itv),
1097 S_VALUE(snndp->nfsd_writecnt, snndc->nfsd_writecnt, itv),
1098 S_VALUE(snndp->nfsd_accesscnt, snndc->nfsd_accesscnt, itv),
1099 S_VALUE(snndp->nfsd_getattcnt, snndc->nfsd_getattcnt, itv));
1103 ***************************************************************************
1104 * Display network sockets statistics. This function is used to display
1105 * instantaneous and average statistics.
1108 * @a Activity structure with statistics.
1109 * @curr Index in array for current sample statistics.
1110 * @dispavg TRUE if displaying average statistics.
1111 ***************************************************************************
1113 void stub_print_net_sock_stats(struct activity *a, int curr, int dispavg)
1115 struct stats_net_sock
1116 *snsc = (struct stats_net_sock *) a->buf[curr];
1117 static unsigned long long
1126 printf("\n%-11s totsck tcpsck udpsck rawsck ip-frag tcp-tw\n",
1131 /* Display instantaneous values */
1132 printf("%-11s %9u %9u %9u %9u %9u %9u\n", timestamp[curr],
1140 /* Will be used to compute the average */
1141 avg_sock_inuse += snsc->sock_inuse;
1142 avg_tcp_inuse += snsc->tcp_inuse;
1143 avg_udp_inuse += snsc->udp_inuse;
1144 avg_raw_inuse += snsc->raw_inuse;
1145 avg_frag_inuse += snsc->frag_inuse;
1146 avg_tcp_tw += snsc->tcp_tw;
1149 /* Display average values */
1150 printf("%-11s %9.0f %9.0f %9.0f %9.0f %9.0f %9.0f\n", timestamp[curr],
1151 (double) avg_sock_inuse / avg_count,
1152 (double) avg_tcp_inuse / avg_count,
1153 (double) avg_udp_inuse / avg_count,
1154 (double) avg_raw_inuse / avg_count,
1155 (double) avg_frag_inuse / avg_count,
1156 (double) avg_tcp_tw / avg_count);
1158 /* Reset average counters */
1159 avg_sock_inuse = avg_tcp_inuse = avg_udp_inuse = 0;
1160 avg_raw_inuse = avg_frag_inuse = avg_tcp_tw = 0;
1165 ***************************************************************************
1166 * Display network sockets statistics.
1169 * @a Activity structure with statistics.
1170 * @prev Index in array where stats used as reference are.
1171 * @curr Index in array for current sample statistics.
1172 * @itv Interval of time in jiffies.
1173 ***************************************************************************
1175 __print_funct_t print_net_sock_stats(struct activity *a, int prev, int curr,
1176 unsigned long long itv)
1178 stub_print_net_sock_stats(a, curr, FALSE);
1182 ***************************************************************************
1183 * Display average network sockets statistics.
1186 * @a Activity structure with statistics.
1187 * @prev Index in array where stats used as reference are.
1188 * @curr Index in array for current sample statistics.
1189 * @itv Interval of time in jiffies.
1190 ***************************************************************************
1192 __print_funct_t print_avg_net_sock_stats(struct activity *a, int prev, int curr,
1193 unsigned long long itv)
1195 stub_print_net_sock_stats(a, curr, TRUE);
1199 ***************************************************************************
1200 * Display IP 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_ip_stats(struct activity *a, int prev, int curr,
1210 unsigned long long itv)
1213 *snic = (struct stats_net_ip *) a->buf[curr],
1214 *snip = (struct stats_net_ip *) a->buf[prev];
1217 printf("\n%-11s irec/s fwddgm/s idel/s orq/s asmrq/s"
1218 " asmok/s fragok/s fragcrt/s\n", timestamp[!curr]);
1221 printf("%-11s %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f\n",
1223 S_VALUE(snip->InReceives, snic->InReceives, itv),
1224 S_VALUE(snip->ForwDatagrams, snic->ForwDatagrams, itv),
1225 S_VALUE(snip->InDelivers, snic->InDelivers, itv),
1226 S_VALUE(snip->OutRequests, snic->OutRequests, itv),
1227 S_VALUE(snip->ReasmReqds, snic->ReasmReqds, itv),
1228 S_VALUE(snip->ReasmOKs, snic->ReasmOKs, itv),
1229 S_VALUE(snip->FragOKs, snic->FragOKs, itv),
1230 S_VALUE(snip->FragCreates, snic->FragCreates, itv));
1234 ***************************************************************************
1235 * Display IP network error statistics.
1238 * @a Activity structure with statistics.
1239 * @prev Index in array where stats used as reference are.
1240 * @curr Index in array for current sample statistics.
1241 * @itv Interval of time in jiffies.
1242 ***************************************************************************
1244 __print_funct_t print_net_eip_stats(struct activity *a, int prev, int curr,
1245 unsigned long long itv)
1247 struct stats_net_eip
1248 *sneic = (struct stats_net_eip *) a->buf[curr],
1249 *sneip = (struct stats_net_eip *) a->buf[prev];
1252 printf("\n%-11s ihdrerr/s iadrerr/s iukwnpr/s idisc/s odisc/s"
1253 " onort/s asmf/s fragf/s\n", timestamp[!curr]);
1256 printf("%-11s %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f\n",
1258 S_VALUE(sneip->InHdrErrors, sneic->InHdrErrors, itv),
1259 S_VALUE(sneip->InAddrErrors, sneic->InAddrErrors, itv),
1260 S_VALUE(sneip->InUnknownProtos, sneic->InUnknownProtos, itv),
1261 S_VALUE(sneip->InDiscards, sneic->InDiscards, itv),
1262 S_VALUE(sneip->OutDiscards, sneic->OutDiscards, itv),
1263 S_VALUE(sneip->OutNoRoutes, sneic->OutNoRoutes, itv),
1264 S_VALUE(sneip->ReasmFails, sneic->ReasmFails, itv),
1265 S_VALUE(sneip->FragFails, sneic->FragFails, itv));
1269 ***************************************************************************
1270 * Display ICMP network traffic statistics.
1273 * @a Activity structure with statistics.
1274 * @prev Index in array where stats used as reference are.
1275 * @curr Index in array for current sample statistics.
1276 * @itv Interval of time in jiffies.
1277 ***************************************************************************
1279 __print_funct_t print_net_icmp_stats(struct activity *a, int prev, int curr,
1280 unsigned long long itv)
1282 struct stats_net_icmp
1283 *snic = (struct stats_net_icmp *) a->buf[curr],
1284 *snip = (struct stats_net_icmp *) a->buf[prev];
1287 printf("\n%-11s imsg/s omsg/s iech/s iechr/s oech/s"
1288 " oechr/s itm/s itmr/s otm/s otmr/s"
1289 " iadrmk/s iadrmkr/s oadrmk/s oadrmkr/s\n", timestamp[!curr]);
1292 printf("%-11s %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f"
1293 " %9.2f %9.2f %9.2f %9.2f\n", timestamp[curr],
1294 S_VALUE(snip->InMsgs, snic->InMsgs, itv),
1295 S_VALUE(snip->OutMsgs, snic->OutMsgs, itv),
1296 S_VALUE(snip->InEchos, snic->InEchos, itv),
1297 S_VALUE(snip->InEchoReps, snic->InEchoReps, itv),
1298 S_VALUE(snip->OutEchos, snic->OutEchos, itv),
1299 S_VALUE(snip->OutEchoReps, snic->OutEchoReps, itv),
1300 S_VALUE(snip->InTimestamps, snic->InTimestamps, itv),
1301 S_VALUE(snip->InTimestampReps, snic->InTimestampReps, itv),
1302 S_VALUE(snip->OutTimestamps, snic->OutTimestamps, itv),
1303 S_VALUE(snip->OutTimestampReps, snic->OutTimestampReps, itv),
1304 S_VALUE(snip->InAddrMasks, snic->InAddrMasks, itv),
1305 S_VALUE(snip->InAddrMaskReps, snic->InAddrMaskReps, itv),
1306 S_VALUE(snip->OutAddrMasks, snic->OutAddrMasks, itv),
1307 S_VALUE(snip->OutAddrMaskReps, snic->OutAddrMaskReps, itv));
1311 ***************************************************************************
1312 * Display ICMP network error statistics.
1315 * @a Activity structure with statistics.
1316 * @prev Index in array where stats used as reference are.
1317 * @curr Index in array for current sample statistics.
1318 * @itv Interval of time in jiffies.
1319 ***************************************************************************
1321 __print_funct_t print_net_eicmp_stats(struct activity *a, int prev, int curr,
1322 unsigned long long itv)
1324 struct stats_net_eicmp
1325 *sneic = (struct stats_net_eicmp *) a->buf[curr],
1326 *sneip = (struct stats_net_eicmp *) a->buf[prev];
1329 printf("\n%-11s ierr/s oerr/s idstunr/s odstunr/s itmex/s"
1330 " otmex/s iparmpb/s oparmpb/s isrcq/s osrcq/s"
1331 " iredir/s oredir/s\n", timestamp[!curr]);
1334 printf("%-11s %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f"
1335 " %9.2f %9.2f\n", timestamp[curr],
1336 S_VALUE(sneip->InErrors, sneic->InErrors, itv),
1337 S_VALUE(sneip->OutErrors, sneic->OutErrors, itv),
1338 S_VALUE(sneip->InDestUnreachs, sneic->InDestUnreachs, itv),
1339 S_VALUE(sneip->OutDestUnreachs, sneic->OutDestUnreachs, itv),
1340 S_VALUE(sneip->InTimeExcds, sneic->InTimeExcds, itv),
1341 S_VALUE(sneip->OutTimeExcds, sneic->OutTimeExcds, itv),
1342 S_VALUE(sneip->InParmProbs, sneic->InParmProbs, itv),
1343 S_VALUE(sneip->OutParmProbs, sneic->OutParmProbs, itv),
1344 S_VALUE(sneip->InSrcQuenchs, sneic->InSrcQuenchs, itv),
1345 S_VALUE(sneip->OutSrcQuenchs, sneic->OutSrcQuenchs, itv),
1346 S_VALUE(sneip->InRedirects, sneic->InRedirects, itv),
1347 S_VALUE(sneip->OutRedirects, sneic->OutRedirects, itv));
1351 ***************************************************************************
1352 * Display TCP network traffic statistics.
1355 * @a Activity structure with statistics.
1356 * @prev Index in array where stats used as reference are.
1357 * @curr Index in array for current sample statistics.
1358 * @itv Interval of time in jiffies.
1359 ***************************************************************************
1361 __print_funct_t print_net_tcp_stats(struct activity *a, int prev, int curr,
1362 unsigned long long itv)
1364 struct stats_net_tcp
1365 *sntc = (struct stats_net_tcp *) a->buf[curr],
1366 *sntp = (struct stats_net_tcp *) a->buf[prev];
1369 printf("\n%-11s active/s passive/s iseg/s oseg/s\n",
1373 printf("%-11s %9.2f %9.2f %9.2f %9.2f\n",
1375 S_VALUE(sntp->ActiveOpens, sntc->ActiveOpens, itv),
1376 S_VALUE(sntp->PassiveOpens, sntc->PassiveOpens, itv),
1377 S_VALUE(sntp->InSegs, sntc->InSegs, itv),
1378 S_VALUE(sntp->OutSegs, sntc->OutSegs, itv));
1382 ***************************************************************************
1383 * Display TCP network error statistics.
1386 * @a Activity structure with statistics.
1387 * @prev Index in array where stats used as reference are.
1388 * @curr Index in array for current sample statistics.
1389 * @itv Interval of time in jiffies.
1390 ***************************************************************************
1392 __print_funct_t print_net_etcp_stats(struct activity *a, int prev, int curr,
1393 unsigned long long itv)
1395 struct stats_net_etcp
1396 *snetc = (struct stats_net_etcp *) a->buf[curr],
1397 *snetp = (struct stats_net_etcp *) a->buf[prev];
1400 printf("\n%-11s atmptf/s estres/s retrans/s isegerr/s orsts/s\n",
1404 printf("%-11s %9.2f %9.2f %9.2f %9.2f %9.2f\n",
1406 S_VALUE(snetp->AttemptFails, snetc->AttemptFails, itv),
1407 S_VALUE(snetp->EstabResets, snetc->EstabResets, itv),
1408 S_VALUE(snetp->RetransSegs, snetc->RetransSegs, itv),
1409 S_VALUE(snetp->InErrs, snetc->InErrs, itv),
1410 S_VALUE(snetp->OutRsts, snetc->OutRsts, itv));
1414 ***************************************************************************
1415 * Display UDP network traffic statistics.
1418 * @a Activity structure with statistics.
1419 * @prev Index in array where stats used as reference are.
1420 * @curr Index in array for current sample statistics.
1421 * @itv Interval of time in jiffies.
1422 ***************************************************************************
1424 __print_funct_t print_net_udp_stats(struct activity *a, int prev, int curr,
1425 unsigned long long itv)
1427 struct stats_net_udp
1428 *snuc = (struct stats_net_udp *) a->buf[curr],
1429 *snup = (struct stats_net_udp *) a->buf[prev];
1432 printf("\n%-11s idgm/s odgm/s noport/s idgmerr/s\n",
1436 printf("%-11s %9.2f %9.2f %9.2f %9.2f\n",
1438 S_VALUE(snup->InDatagrams, snuc->InDatagrams, itv),
1439 S_VALUE(snup->OutDatagrams, snuc->OutDatagrams, itv),
1440 S_VALUE(snup->NoPorts, snuc->NoPorts, itv),
1441 S_VALUE(snup->InErrors, snuc->InErrors, itv));
1445 ***************************************************************************
1446 * Display IPv6 sockets statistics. This function is used to display
1447 * instantaneous and average statistics.
1450 * @a Activity structure with statistics.
1451 * @curr Index in array for current sample statistics.
1452 * @dispavg TRUE if displaying average statistics.
1453 ***************************************************************************
1455 void stub_print_net_sock6_stats(struct activity *a, int curr, int dispavg)
1457 struct stats_net_sock6
1458 *snsc = (struct stats_net_sock6 *) a->buf[curr];
1459 static unsigned long long
1463 avg_frag6_inuse = 0;
1466 printf("\n%-11s tcp6sck udp6sck raw6sck ip6-frag\n",
1471 /* Display instantaneous values */
1472 printf("%-11s %9u %9u %9u %9u\n", timestamp[curr],
1478 /* Will be used to compute the average */
1479 avg_tcp6_inuse += snsc->tcp6_inuse;
1480 avg_udp6_inuse += snsc->udp6_inuse;
1481 avg_raw6_inuse += snsc->raw6_inuse;
1482 avg_frag6_inuse += snsc->frag6_inuse;
1485 /* Display average values */
1486 printf("%-11s %9.0f %9.0f %9.0f %9.0f\n", timestamp[curr],
1487 (double) avg_tcp6_inuse / avg_count,
1488 (double) avg_udp6_inuse / avg_count,
1489 (double) avg_raw6_inuse / avg_count,
1490 (double) avg_frag6_inuse / avg_count);
1492 /* Reset average counters */
1493 avg_tcp6_inuse = avg_udp6_inuse = avg_raw6_inuse = avg_frag6_inuse = 0;
1498 ***************************************************************************
1499 * Display IPv6 sockets statistics.
1502 * @a Activity structure with statistics.
1503 * @prev Index in array where stats used as reference are.
1504 * @curr Index in array for current sample statistics.
1505 * @itv Interval of time in jiffies.
1506 ***************************************************************************
1508 __print_funct_t print_net_sock6_stats(struct activity *a, int prev, int curr,
1509 unsigned long long itv)
1511 stub_print_net_sock6_stats(a, curr, FALSE);
1515 ***************************************************************************
1516 * Display average IPv6 sockets statistics.
1519 * @a Activity structure with statistics.
1520 * @prev Index in array where stats used as reference are.
1521 * @curr Index in array for current sample statistics.
1522 * @itv Interval of time in jiffies.
1523 ***************************************************************************
1525 __print_funct_t print_avg_net_sock6_stats(struct activity *a, int prev, int curr,
1526 unsigned long long itv)
1528 stub_print_net_sock6_stats(a, curr, TRUE);
1532 ***************************************************************************
1533 * Display IPv6 network traffic statistics.
1536 * @a Activity structure with statistics.
1537 * @prev Index in array where stats used as reference are.
1538 * @curr Index in array for current sample statistics.
1539 * @itv Interval of time in jiffies.
1540 ***************************************************************************
1542 __print_funct_t print_net_ip6_stats(struct activity *a, int prev, int curr,
1543 unsigned long long itv)
1545 struct stats_net_ip6
1546 *snic = (struct stats_net_ip6 *) a->buf[curr],
1547 *snip = (struct stats_net_ip6 *) a->buf[prev];
1550 printf("\n%-11s irec6/s fwddgm6/s idel6/s orq6/s asmrq6/s"
1551 " asmok6/s imcpck6/s omcpck6/s fragok6/s fragcr6/s\n",
1555 printf("%-11s %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f\n",
1557 S_VALUE(snip->InReceives6, snic->InReceives6, itv),
1558 S_VALUE(snip->OutForwDatagrams6, snic->OutForwDatagrams6, itv),
1559 S_VALUE(snip->InDelivers6, snic->InDelivers6, itv),
1560 S_VALUE(snip->OutRequests6, snic->OutRequests6, itv),
1561 S_VALUE(snip->ReasmReqds6, snic->ReasmReqds6, itv),
1562 S_VALUE(snip->ReasmOKs6, snic->ReasmOKs6, itv),
1563 S_VALUE(snip->InMcastPkts6, snic->InMcastPkts6, itv),
1564 S_VALUE(snip->OutMcastPkts6, snic->OutMcastPkts6, itv),
1565 S_VALUE(snip->FragOKs6, snic->FragOKs6, itv),
1566 S_VALUE(snip->FragCreates6, snic->FragCreates6, itv));
1570 ***************************************************************************
1571 * Display IPv6 network error statistics.
1574 * @a Activity structure with statistics.
1575 * @prev Index in array where stats used as reference are.
1576 * @curr Index in array for current sample statistics.
1577 * @itv Interval of time in jiffies.
1578 ***************************************************************************
1580 __print_funct_t print_net_eip6_stats(struct activity *a, int prev, int curr,
1581 unsigned long long itv)
1583 struct stats_net_eip6
1584 *sneic = (struct stats_net_eip6 *) a->buf[curr],
1585 *sneip = (struct stats_net_eip6 *) a->buf[prev];
1588 printf("\n%-11s ihdrer6/s iadrer6/s iukwnp6/s i2big6/s idisc6/s odisc6/s"
1589 " inort6/s onort6/s asmf6/s fragf6/s itrpck6/s\n",
1593 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",
1595 S_VALUE(sneip->InHdrErrors6, sneic->InHdrErrors6, itv),
1596 S_VALUE(sneip->InAddrErrors6, sneic->InAddrErrors6, itv),
1597 S_VALUE(sneip->InUnknownProtos6, sneic->InUnknownProtos6, itv),
1598 S_VALUE(sneip->InTooBigErrors6, sneic->InTooBigErrors6, itv),
1599 S_VALUE(sneip->InDiscards6, sneic->InDiscards6, itv),
1600 S_VALUE(sneip->OutDiscards6, sneic->OutDiscards6, itv),
1601 S_VALUE(sneip->InNoRoutes6, sneic->InNoRoutes6, itv),
1602 S_VALUE(sneip->OutNoRoutes6, sneic->OutNoRoutes6, itv),
1603 S_VALUE(sneip->ReasmFails6, sneic->ReasmFails6, itv),
1604 S_VALUE(sneip->FragFails6, sneic->FragFails6, itv),
1605 S_VALUE(sneip->InTruncatedPkts6, sneic->InTruncatedPkts6, itv));
1609 ***************************************************************************
1610 * Display ICMPv6 network traffic statistics.
1613 * @a Activity structure with statistics.
1614 * @prev Index in array where stats used as reference are.
1615 * @curr Index in array for current sample statistics.
1616 * @itv Interval of time in jiffies.
1617 ***************************************************************************
1619 __print_funct_t print_net_icmp6_stats(struct activity *a, int prev, int curr,
1620 unsigned long long itv)
1622 struct stats_net_icmp6
1623 *snic = (struct stats_net_icmp6 *) a->buf[curr],
1624 *snip = (struct stats_net_icmp6 *) a->buf[prev];
1627 printf("\n%-11s imsg6/s omsg6/s iech6/s iechr6/s oechr6/s"
1628 " igmbq6/s igmbr6/s ogmbr6/s igmbrd6/s ogmbrd6/s irtsol6/s ortsol6/s"
1629 " irtad6/s inbsol6/s onbsol6/s inbad6/s onbad6/s\n",
1633 printf("%-11s %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f"
1634 " %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f\n", timestamp[curr],
1635 S_VALUE(snip->InMsgs6, snic->InMsgs6, itv),
1636 S_VALUE(snip->OutMsgs6, snic->OutMsgs6, itv),
1637 S_VALUE(snip->InEchos6, snic->InEchos6, itv),
1638 S_VALUE(snip->InEchoReplies6, snic->InEchoReplies6, itv),
1639 S_VALUE(snip->OutEchoReplies6, snic->OutEchoReplies6, itv),
1640 S_VALUE(snip->InGroupMembQueries6, snic->InGroupMembQueries6, itv),
1641 S_VALUE(snip->InGroupMembResponses6, snic->InGroupMembResponses6, itv),
1642 S_VALUE(snip->OutGroupMembResponses6, snic->OutGroupMembResponses6, itv),
1643 S_VALUE(snip->InGroupMembReductions6, snic->InGroupMembReductions6, itv),
1644 S_VALUE(snip->OutGroupMembReductions6, snic->OutGroupMembReductions6, itv),
1645 S_VALUE(snip->InRouterSolicits6, snic->InRouterSolicits6, itv),
1646 S_VALUE(snip->OutRouterSolicits6, snic->OutRouterSolicits6, itv),
1647 S_VALUE(snip->InRouterAdvertisements6, snic->InRouterAdvertisements6, itv),
1648 S_VALUE(snip->InNeighborSolicits6, snic->InNeighborSolicits6, itv),
1649 S_VALUE(snip->OutNeighborSolicits6, snic->OutNeighborSolicits6, itv),
1650 S_VALUE(snip->InNeighborAdvertisements6, snic->InNeighborAdvertisements6, itv),
1651 S_VALUE(snip->OutNeighborAdvertisements6, snic->OutNeighborAdvertisements6, itv));
1655 ***************************************************************************
1656 * Display ICMPv6 network error statistics.
1659 * @a Activity structure with statistics.
1660 * @prev Index in array where stats used as reference are.
1661 * @curr Index in array for current sample statistics.
1662 * @itv Interval of time in jiffies.
1663 ***************************************************************************
1665 __print_funct_t print_net_eicmp6_stats(struct activity *a, int prev, int curr,
1666 unsigned long long itv)
1668 struct stats_net_eicmp6
1669 *sneic = (struct stats_net_eicmp6 *) a->buf[curr],
1670 *sneip = (struct stats_net_eicmp6 *) a->buf[prev];
1673 printf("\n%-11s ierr6/s idtunr6/s odtunr6/s itmex6/s otmex6/s"
1674 " iprmpb6/s oprmpb6/s iredir6/s oredir6/s ipck2b6/s opck2b6/s\n",
1678 printf("%-11s %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f"
1679 " %9.2f\n", timestamp[curr],
1680 S_VALUE(sneip->InErrors6, sneic->InErrors6, itv),
1681 S_VALUE(sneip->InDestUnreachs6, sneic->InDestUnreachs6, itv),
1682 S_VALUE(sneip->OutDestUnreachs6, sneic->OutDestUnreachs6, itv),
1683 S_VALUE(sneip->InTimeExcds6, sneic->InTimeExcds6, itv),
1684 S_VALUE(sneip->OutTimeExcds6, sneic->OutTimeExcds6, itv),
1685 S_VALUE(sneip->InParmProblems6, sneic->InParmProblems6, itv),
1686 S_VALUE(sneip->OutParmProblems6, sneic->OutParmProblems6, itv),
1687 S_VALUE(sneip->InRedirects6, sneic->InRedirects6, itv),
1688 S_VALUE(sneip->OutRedirects6, sneic->OutRedirects6, itv),
1689 S_VALUE(sneip->InPktTooBigs6, sneic->InPktTooBigs6, itv),
1690 S_VALUE(sneip->OutPktTooBigs6, sneic->OutPktTooBigs6, itv));
1694 ***************************************************************************
1695 * Display UDPv6 network traffic statistics.
1698 * @a Activity structure with statistics.
1699 * @prev Index in array where stats used as reference are.
1700 * @curr Index in array for current sample statistics.
1701 * @itv Interval of time in jiffies.
1702 ***************************************************************************
1704 __print_funct_t print_net_udp6_stats(struct activity *a, int prev, int curr,
1705 unsigned long long itv)
1707 struct stats_net_udp6
1708 *snuc = (struct stats_net_udp6 *) a->buf[curr],
1709 *snup = (struct stats_net_udp6 *) a->buf[prev];
1712 printf("\n%-11s idgm6/s odgm6/s noport6/s idgmer6/s\n",
1716 printf("%-11s %9.2f %9.2f %9.2f %9.2f\n",
1718 S_VALUE(snup->InDatagrams6, snuc->InDatagrams6, itv),
1719 S_VALUE(snup->OutDatagrams6, snuc->OutDatagrams6, itv),
1720 S_VALUE(snup->NoPorts6, snuc->NoPorts6, itv),
1721 S_VALUE(snup->InErrors6, snuc->InErrors6, itv));
1725 ***************************************************************************
1726 * Display CPU frequency statistics. This function is used to display
1727 * instantaneous and average statistics.
1730 * @a Activity structure with statistics.
1731 * @curr Index in array for current sample statistics.
1732 * @dispavg True if displaying average statistics.
1733 ***************************************************************************
1735 void stub_print_pwr_cpufreq_stats(struct activity *a, int curr, int dispavg)
1738 struct stats_pwr_cpufreq *spc;
1739 static unsigned long long
1740 *avg_cpufreq = NULL;
1743 /* Allocate array of CPU frequency */
1744 if ((avg_cpufreq = (unsigned long long *) malloc(sizeof(unsigned long long) * a->nr))
1749 memset(avg_cpufreq, 0, sizeof(unsigned long long) * a->nr);
1753 printf("\n%-11s CPU MHz\n",
1757 for (i = 0; (i < a->nr) && (i < a->bitmap->b_size + 1); i++) {
1760 * The size of a->buf[...] CPU structure may be different from the default
1761 * sizeof(struct stats_pwr_cpufreq) value if data have been read from a file!
1762 * That's why we don't use a syntax like:
1763 * spc = (struct stats_pwr_cpufreq *) a->buf[...] + i;
1765 spc = (struct stats_pwr_cpufreq *) ((char *) a->buf[curr] + i * a->msize);
1768 * Note: a->nr is in [1, NR_CPUS + 1].
1769 * Bitmap size is provided for (NR_CPUS + 1) CPUs.
1770 * Anyway, NR_CPUS may vary between the version of sysstat
1771 * used by sadc to create a file, and the version of sysstat
1772 * used by sar to read it...
1775 /* Should current CPU (including CPU "all") be displayed? */
1776 if (a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))) {
1778 /* Yes: Display it */
1779 printf("%-11s", timestamp[curr]);
1782 /* This is CPU "all" */
1786 printf(" %3d", i - 1);
1790 /* Display instantaneous values */
1792 ((double) spc->cpufreq) / 100);
1794 * Will be used to compute the average.
1795 * Note: overflow unlikely to happen but not impossible...
1797 avg_cpufreq[i] += spc->cpufreq;
1800 /* Display average values */
1802 (double) avg_cpufreq[i] / (100 * avg_count));
1808 /* Array of CPU frequency no longer needed: Free it! */
1817 ***************************************************************************
1818 * Display CPU frequency statistics.
1821 * @a Activity structure with statistics.
1822 * @prev Index in array where stats used as reference are.
1823 * @curr Index in array for current sample statistics.
1824 * @itv Interval of time in jiffies.
1825 ***************************************************************************
1827 __print_funct_t print_pwr_cpufreq_stats(struct activity *a, int prev, int curr,
1828 unsigned long long itv)
1830 stub_print_pwr_cpufreq_stats(a, curr, FALSE);
1834 ***************************************************************************
1835 * Display average CPU frequency statistics.
1838 * @a Activity structure with statistics.
1839 * @prev Index in array where stats used as reference are.
1840 * @curr Index in array for current sample statistics.
1841 * @itv Interval of time in jiffies.
1842 ***************************************************************************
1844 __print_funct_t print_avg_pwr_cpufreq_stats(struct activity *a, int prev, int curr,
1845 unsigned long long itv)
1847 stub_print_pwr_cpufreq_stats(a, curr, TRUE);
1851 ***************************************************************************
1852 * Display fan statistics. This function is used to display
1853 * instantaneous and average statistics.
1856 * @a Activity structure with statistics.
1857 * @curr Index in array for current sample statistics.
1858 * @dispavg True if displaying average statistics.
1859 ***************************************************************************
1861 void stub_print_pwr_fan_stats(struct activity *a, int curr, int dispavg)
1864 struct stats_pwr_fan *spc;
1865 static double *avg_fan = NULL;
1866 static double *avg_fan_min = NULL;
1868 /* Allocate arrays of fan RPMs */
1870 if ((avg_fan = (double *) malloc(sizeof(double) * a->nr)) == NULL) {
1874 memset(avg_fan, 0, sizeof(double) * a->nr);
1877 if ((avg_fan_min = (double *) malloc(sizeof(double) * a->nr)) == NULL) {
1881 memset(avg_fan_min, 0, sizeof(double) * a->nr);
1885 printf("\n%-11s FAN rpm drpm %*s\n",
1886 timestamp[!curr], MAX_SENSORS_DEV_LEN, "DEVICE");
1889 for (i = 0; i < a->nr; i++) {
1890 spc = (struct stats_pwr_fan *) ((char *) a->buf[curr] + i * a->msize);
1892 printf("%-11s %3d", timestamp[curr], i + 1);
1895 /* Display average values */
1896 printf(" %9.2f %9.2f",
1897 (double) avg_fan[i] / avg_count,
1898 (double) (avg_fan[i] - avg_fan_min[i]) / avg_count);
1901 /* Display instantaneous values */
1902 printf(" %9.2f %9.2f",
1904 spc->rpm - spc->rpm_min);
1905 avg_fan[i] += spc->rpm;
1906 avg_fan_min[i] += spc->rpm_min;
1909 printf(" %*s\n", MAX_SENSORS_DEV_LEN, spc->device);
1925 ***************************************************************************
1926 * Display fan statistics.
1929 * @a Activity structure with statistics.
1930 * @prev Index in array where stats used as reference are.
1931 * @curr Index in array for current sample statistics.
1932 * @itv Interval of time in jiffies.
1933 ***************************************************************************
1935 __print_funct_t print_pwr_fan_stats(struct activity *a, int prev, int curr,
1936 unsigned long long itv)
1938 stub_print_pwr_fan_stats(a, curr, FALSE);
1942 ***************************************************************************
1943 * Display average fan statistics.
1946 * @a Activity structure with statistics.
1947 * @prev Index in array where stats used as reference are.
1948 * @curr Index in array for current sample statistics.
1949 * @itv Interval of time in jiffies.
1950 ***************************************************************************
1952 __print_funct_t print_avg_pwr_fan_stats(struct activity *a, int prev, int curr,
1953 unsigned long long itv)
1955 stub_print_pwr_fan_stats(a, curr, TRUE);
1959 ***************************************************************************
1960 * Display device temperature statistics. This function is used to display
1961 * instantaneous and average statistics.
1964 * @a Activity structure with statistics.
1965 * @curr Index in array for current sample statistics.
1966 * @dispavg True if displaying average statistics.
1967 ***************************************************************************
1969 void stub_print_pwr_temp_stats(struct activity *a, int curr, int dispavg)
1972 struct stats_pwr_temp *spc;
1973 static double *avg_temp = NULL;
1974 static double *avg_temp_min = NULL, *avg_temp_max = NULL;
1976 /* Allocate arrays of temperatures */
1978 if ((avg_temp = (double *) malloc(sizeof(double) * a->nr)) == NULL) {
1982 memset(avg_temp, 0, sizeof(double) * a->nr);
1984 if (!avg_temp_min) {
1985 if ((avg_temp_min = (double *) malloc(sizeof(double) * a->nr)) == NULL) {
1989 memset(avg_temp_min, 0, sizeof(double) * a->nr);
1991 if (!avg_temp_max) {
1992 if ((avg_temp_max = (double *) malloc(sizeof(double) * a->nr)) == NULL) {
1996 memset(avg_temp_max, 0, sizeof(double) * a->nr);
2000 printf("\n%-11s TEMP degC %%temp %*s\n",
2001 timestamp[!curr], MAX_SENSORS_DEV_LEN, "DEVICE");
2004 for (i = 0; i < a->nr; i++) {
2005 spc = (struct stats_pwr_temp *) ((char *) a->buf[curr] + i * a->msize);
2007 printf("%-11s %3d", timestamp[curr], i + 1);
2010 /* Display average values */
2011 printf(" %9.2f %9.2f",
2012 (double) avg_temp[i] / avg_count,
2013 (avg_temp_max[i] - avg_temp_min[i]) ?
2014 ((double) (avg_temp[i] / avg_count) - avg_temp_min[i]) / (avg_temp_max[i] - avg_temp_min[i]) * 100 :
2018 /* Display instantaneous values */
2019 printf(" %9.2f %9.2f",
2021 (spc->temp_max - spc->temp_min) ?
2022 (spc->temp - spc->temp_min) / (spc->temp_max - spc->temp_min) * 100 :
2024 avg_temp[i] += spc->temp;
2025 /* Assume that min and max temperatures cannot vary */
2026 avg_temp_min[i] = spc->temp_min;
2027 avg_temp_max[i] = spc->temp_max;
2030 printf(" %*s\n", MAX_SENSORS_DEV_LEN, spc->device);
2040 avg_temp_min = NULL;
2044 avg_temp_max = NULL;
2050 ***************************************************************************
2051 * Display temperature statistics.
2054 * @a Activity structure with statistics.
2055 * @prev Index in array where stats used as reference are.
2056 * @curr Index in array for current sample statistics.
2057 * @itv Interval of time in jiffies.
2058 ***************************************************************************
2060 __print_funct_t print_pwr_temp_stats(struct activity *a, int prev, int curr,
2061 unsigned long long itv)
2063 stub_print_pwr_temp_stats(a, curr, FALSE);
2067 ***************************************************************************
2068 * Display average temperature statistics.
2071 * @a Activity structure with statistics.
2072 * @prev Index in array where stats used as reference are.
2073 * @curr Index in array for current sample statistics.
2074 * @itv Interval of time in jiffies.
2075 ***************************************************************************
2077 __print_funct_t print_avg_pwr_temp_stats(struct activity *a, int prev, int curr,
2078 unsigned long long itv)
2080 stub_print_pwr_temp_stats(a, curr, TRUE);
2084 ***************************************************************************
2085 * Display voltage inputs statistics. This function is used to display
2086 * instantaneous and average statistics.
2089 * @a Activity structure with statistics.
2090 * @curr Index in array for current sample statistics.
2091 * @dispavg True if displaying average statistics.
2092 ***************************************************************************
2094 void stub_print_pwr_in_stats(struct activity *a, int curr, int dispavg)
2097 struct stats_pwr_in *spc;
2098 static double *avg_in = NULL;
2099 static double *avg_in_min = NULL, *avg_in_max = NULL;
2101 /* Allocate arrays of voltage inputs */
2103 if ((avg_in = (double *) malloc(sizeof(double) * a->nr)) == NULL) {
2107 memset(avg_in, 0, sizeof(double) * a->nr);
2110 if ((avg_in_min = (double *) malloc(sizeof(double) * a->nr)) == NULL) {
2114 memset(avg_in_min, 0, sizeof(double) * a->nr);
2117 if ((avg_in_max = (double *) malloc(sizeof(double) * a->nr)) == NULL) {
2121 memset(avg_in_max, 0, sizeof(double) * a->nr);
2125 printf("\n%-11s IN inV %%in %*s\n",
2126 timestamp[!curr], MAX_SENSORS_DEV_LEN, "DEVICE");
2129 for (i = 0; i < a->nr; i++) {
2130 spc = (struct stats_pwr_in *) ((char *) a->buf[curr] + i * a->msize);
2132 printf("%-11s %3d", timestamp[curr], i);
2135 /* Display average values */
2136 printf(" %9.2f %9.2f",
2137 (double) avg_in[i] / avg_count,
2138 (avg_in_max[i] - avg_in_min[i]) ?
2139 ((double) (avg_in[i] / avg_count) - avg_in_min[i]) / (avg_in_max[i] - avg_in_min[i]) * 100 :
2143 /* Display instantaneous values */
2144 printf(" %9.2f %9.2f",
2146 (spc->in_max - spc->in_min) ?
2147 (spc->in - spc->in_min) / (spc->in_max - spc->in_min) * 100 :
2149 avg_in[i] += spc->in;
2150 /* Assume that min and max voltage inputs cannot vary */
2151 avg_in_min[i] = spc->in_min;
2152 avg_in_max[i] = spc->in_max;
2155 printf(" %*s\n", MAX_SENSORS_DEV_LEN, spc->device);
2175 ***************************************************************************
2176 * Display voltage inputs statistics.
2179 * @a Activity structure with statistics.
2180 * @prev Index in array where stats used as reference are.
2181 * @curr Index in array for current sample statistics.
2182 * @itv Interval of time in jiffies.
2183 ***************************************************************************
2185 __print_funct_t print_pwr_in_stats(struct activity *a, int prev, int curr,
2186 unsigned long long itv)
2188 stub_print_pwr_in_stats(a, curr, FALSE);
2192 ***************************************************************************
2193 * Display average voltage inputs statistics.
2196 * @a Activity structure with statistics.
2197 * @prev Index in array where stats used as reference are.
2198 * @curr Index in array for current sample statistics.
2199 * @itv Interval of time in jiffies.
2200 ***************************************************************************
2202 __print_funct_t print_avg_pwr_in_stats(struct activity *a, int prev, int curr,
2203 unsigned long long itv)
2205 stub_print_pwr_in_stats(a, curr, TRUE);
2209 ***************************************************************************
2210 * Display huge pages statistics. This function is used to
2211 * display instantaneous and average statistics.
2214 * @a Activity structure with statistics.
2215 * @curr Index in array for current sample statistics.
2216 * @dispavg TRUE if displaying average statistics.
2217 ***************************************************************************
2219 void stub_print_huge_stats(struct activity *a, int curr, int dispavg)
2222 *smc = (struct stats_huge *) a->buf[curr];
2223 static unsigned long long
2228 printf("\n%-11s kbhugfree kbhugused %%hugused\n",
2233 /* Display instantaneous values */
2234 printf("%-11s %9lu %9lu %6.2f\n",
2237 smc->tlhkb - smc->frhkb,
2239 SP_VALUE(smc->frhkb, smc->tlhkb, smc->tlhkb) : 0.0);
2241 /* Will be used to compute the average */
2242 avg_frhkb += smc->frhkb;
2243 avg_tlhkb += smc->tlhkb;
2246 /* Display average values */
2247 printf("%-11s %9.0f %9.0f %6.2f\n",
2249 (double) avg_frhkb / avg_count,
2250 ((double) avg_tlhkb / avg_count) -
2251 ((double) avg_frhkb / avg_count),
2252 ((double) (avg_tlhkb / avg_count)) ?
2253 SP_VALUE((double) (avg_frhkb / avg_count),
2254 (double) (avg_tlhkb / avg_count),
2255 (double) (avg_tlhkb / avg_count)) :
2258 /* Reset average counters */
2259 avg_frhkb = avg_tlhkb = 0;
2264 ***************************************************************************
2265 * Display huge pages statistics.
2268 * @a Activity structure with statistics.
2269 * @prev Index in array where stats used as reference are.
2270 * @curr Index in array for current sample statistics.
2271 * @itv Interval of time in jiffies.
2272 ***************************************************************************
2274 __print_funct_t print_huge_stats(struct activity *a, int prev, int curr,
2275 unsigned long long itv)
2277 stub_print_huge_stats(a, curr, FALSE);
2281 ***************************************************************************
2282 * Display huge pages statistics.
2285 * @a Activity structure with statistics.
2286 * @prev Index in array where stats used as reference are.
2287 * @curr Index in array for current sample statistics.
2288 * @itv Interval of time in jiffies.
2289 ***************************************************************************
2291 __print_funct_t print_avg_huge_stats(struct activity *a, int prev, int curr,
2292 unsigned long long itv)
2294 stub_print_huge_stats(a, curr, TRUE);
2298 ***************************************************************************
2299 * Display CPU weighted frequency statistics. This function is used to
2300 * display instantaneous and average statistics.
2303 * @a Activity structure with statistics.
2304 * @prev Index in array where stats used as reference are.
2305 * @curr Index in array for current sample statistics.
2306 * @itv Interval of time in jiffies.
2307 ***************************************************************************
2309 void print_pwr_wghfreq_stats(struct activity *a, int prev, int curr,
2310 unsigned long long itv)
2313 struct stats_pwr_wghfreq *spc, *spp, *spc_k, *spp_k;
2314 unsigned long long tis, tisfreq;
2317 printf("\n%-11s CPU wghMHz\n",
2321 for (i = 0; (i < a->nr) && (i < a->bitmap->b_size + 1); i++) {
2324 * The size of a->buf[...] CPU structure may be different from the default
2325 * sizeof(struct stats_pwr_wghfreq) value if data have been read from a file!
2326 * That's why we don't use a syntax like:
2327 * spc = (struct stats_pwr_wghfreq *) a->buf[...] + i;
2329 spc = (struct stats_pwr_wghfreq *) ((char *) a->buf[curr] + i * a->msize * a->nr2);
2330 spp = (struct stats_pwr_wghfreq *) ((char *) a->buf[prev] + i * a->msize * a->nr2);
2333 * Note: a->nr is in [1, NR_CPUS + 1].
2334 * Bitmap size is provided for (NR_CPUS + 1) CPUs.
2335 * Anyway, NR_CPUS may vary between the version of sysstat
2336 * used by sadc to create a file, and the version of sysstat
2337 * used by sar to read it...
2340 /* Should current CPU (including CPU "all") be displayed? */
2341 if (a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))) {
2343 /* Yes: Display it */
2344 printf("%-11s", timestamp[curr]);
2347 /* This is CPU "all" */
2351 printf(" %3d", i - 1);
2357 for (k = 0; k < a->nr2; k++) {
2359 spc_k = (struct stats_pwr_wghfreq *) ((char *) spc + k * a->msize);
2362 spp_k = (struct stats_pwr_wghfreq *) ((char *) spp + k * a->msize);
2364 tisfreq += (spc_k->freq / 1000) *
2365 (spc_k->time_in_state - spp_k->time_in_state);
2366 tis += (spc_k->time_in_state - spp_k->time_in_state);
2369 /* Display weighted frequency for current CPU */
2370 printf(" %9.2f\n", tis ? ((double) tisfreq) / tis : 0.0);
2376 ***************************************************************************
2377 * Display USB devices statistics. This function is used to
2378 * display instantaneous and summary statistics.
2381 * @a Activity structure with statistics.
2382 * @curr Index in array for current sample statistics.
2383 * @itv Interval of time in jiffies.
2384 * @dispavg TRUE if displaying average statistics.
2385 ***************************************************************************
2387 void stub_print_pwr_usb_stats(struct activity *a, int curr, int dispavg)
2390 struct stats_pwr_usb *suc, *sum;
2393 printf("\n%-11s BUS idvendor idprod maxpower",
2394 (dispavg ? _("Summary") : timestamp[!curr]));
2395 printf(" %*s", MAX_MANUF_LEN - 1, "manufact");
2396 printf(" %*s\n", MAX_PROD_LEN - 1, "product");
2399 for (i = 0; i < a->nr; i++) {
2400 suc = (struct stats_pwr_usb *) ((char *) a->buf[curr] + i * a->msize);
2403 /* Bus#0 doesn't exist: We are at the end of the list */
2406 printf("%-11s %6d %9x %9x %9u",
2407 (dispavg ? _("Summary") : timestamp[curr]),
2409 suc->vendor_id, suc->product_id,
2410 /* bMaxPower is expressed in 2 mA units */
2411 suc->bmaxpower << 1);
2413 printf(" %*s", MAX_MANUF_LEN - 1, suc->manufacturer);
2414 printf(" %*s\n", MAX_PROD_LEN - 1, suc->product);
2417 /* Save current USB device in summary list */
2418 for (j = 0; j < a->nr; j++) {
2419 sum = (struct stats_pwr_usb *) ((char *) a->buf[2] + j * a->msize);
2421 if ((sum->bus_nr == suc->bus_nr) &&
2422 (sum->vendor_id == suc->vendor_id) &&
2423 (sum->product_id == suc->product_id))
2424 /* USB device found in summary list */
2428 * Current slot is free:
2429 * Save USB device in summary list.
2434 if (j == a->nr - 1) {
2436 * This is the last slot and
2437 * we still havent't found the device.
2438 * So create a dummy device here.
2441 sum->vendor_id = sum->product_id = 0;
2443 sum->manufacturer[0] = '\0';
2444 snprintf(sum->product, MAX_PROD_LEN, "%s",
2445 _("Other devices not listed here"));
2446 sum->product[MAX_PROD_LEN - 1] = '\0';
2454 ***************************************************************************
2455 * Display USB devices statistics.
2458 * @a Activity structure with statistics.
2459 * @prev Index in array where stats used as reference are.
2460 * @curr Index in array for current sample statistics.
2461 * @itv Interval of time in jiffies.
2462 ***************************************************************************
2464 __print_funct_t print_pwr_usb_stats(struct activity *a, int prev, int curr,
2465 unsigned long long itv)
2467 stub_print_pwr_usb_stats(a, curr, FALSE);
2471 ***************************************************************************
2472 * Display average USB devices statistics.
2475 * @a Activity structure with statistics.
2476 * @prev Index in array where stats used as reference are.
2477 * @curr Index in array for current sample statistics.
2478 * @itv Interval of time in jiffies.
2479 ***************************************************************************
2481 __print_funct_t print_avg_pwr_usb_stats(struct activity *a, int prev, int curr,
2482 unsigned long long itv)
2484 stub_print_pwr_usb_stats(a, 2, TRUE);
2488 ***************************************************************************
2489 * Display filesystems statistics. This function is used to
2490 * display instantaneous and average statistics.
2493 * @a Activity structure with statistics.
2494 * @curr Index in array for current sample statistics.
2495 * @dispavg TRUE if displaying average statistics.
2496 ***************************************************************************
2498 __print_funct_t stub_print_filesystem_stats(struct activity *a, int curr, int dispavg)
2501 struct stats_filesystem *sfc, *sfm;
2505 printf("\n%-11s MBfsfree MBfsused %%fsused %%ufsused"
2506 " Ifree Iused %%Iused FILESYSTEM\n",
2507 (dispavg ? _("Summary") : timestamp[!curr]));
2510 for (i = 0; i < a->nr; i++) {
2511 sfc = (struct stats_filesystem *) ((char *) a->buf[curr] + i * a->msize);
2514 /* Size of filesystem is null: We are at the end of the list */
2517 printf("%-11s %9.0f %9.0f %6.2f %6.2f"
2518 " %9llu %9llu %6.2f %s\n",
2519 (dispavg ? _("Summary") : timestamp[curr]),
2520 (double) sfc->f_bfree / 1024 / 1024,
2521 (double) (sfc->f_blocks - sfc->f_bfree) / 1024 / 1024,
2522 /* f_blocks is not null. But test it anyway ;-) */
2523 sfc->f_blocks ? SP_VALUE(sfc->f_bfree, sfc->f_blocks, sfc->f_blocks)
2525 sfc->f_blocks ? SP_VALUE(sfc->f_bavail, sfc->f_blocks, sfc->f_blocks)
2528 sfc->f_files - sfc->f_ffree,
2529 sfc->f_files ? SP_VALUE(sfc->f_ffree, sfc->f_files, sfc->f_files)
2534 /* Save current filesystem in summary list */
2535 for (j = 0; j < a->nr; j++) {
2536 sfm = (struct stats_filesystem *) ((char *) a->buf[2] + j * a->msize);
2538 if (!strcmp(sfm->fs_name, sfc->fs_name) ||
2541 * Filesystem found in list (then save again its stats)
2542 * or free slot (end of list).
2553 ***************************************************************************
2554 * Display filesystems statistics.
2557 * @a Activity structure with statistics.
2558 * @prev Index in array where stats used as reference are.
2559 * @curr Index in array for current sample statistics.
2560 * @itv Interval of time in jiffies.
2561 ***************************************************************************
2563 __print_funct_t print_filesystem_stats(struct activity *a, int prev, int curr,
2564 unsigned long long itv)
2566 stub_print_filesystem_stats(a, curr, FALSE);
2570 ***************************************************************************
2571 * Display average filesystems statistics.
2574 * @a Activity structure with statistics.
2575 * @prev Index in array where stats used as reference are.
2576 * @curr Index in array for current sample statistics.
2577 * @itv Interval of time in jiffies.
2578 ***************************************************************************
2580 __print_funct_t print_avg_filesystem_stats(struct activity *a, int prev, int curr,
2581 unsigned long long itv)
2583 stub_print_filesystem_stats(a, 2, TRUE);