2 * pr_stats.c: Functions used by sar to display statistics
3 * (C) 1999-2016 by Sebastien GODARD (sysstat <at> orange.fr)
5 ***************************************************************************
6 * This program is free software; you can redistribute it and/or modify it *
7 * under the terms of the GNU General Public License as published by the *
8 * Free Software Foundation; either version 2 of the License, or (at your *
9 * option) any later version. *
11 * This program is distributed in the hope that it will be useful, but *
12 * WITHOUT ANY WARRANTY; without the implied warranty of MERCHANTABILITY *
13 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License *
16 * You should have received a copy of the GNU General Public License along *
17 * with this program; if not, write to the Free Software Foundation, Inc., *
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA *
19 ***************************************************************************
34 #define _(string) gettext(string)
36 #define _(string) (string)
39 extern unsigned int flags;
40 extern unsigned int dm_major;
42 extern char timestamp[][TIMESTAMP_LEN];
43 extern unsigned long avg_count;
47 ***************************************************************************
48 * Display current activity header line.
51 * @timestamp Timestamp for previous stat sample.
52 * @a Activity structure.
53 * @pos Index in @.hdr_line string, 0 being the first one (header
54 * are delimited by the '|' character).
55 * @iwidth First column width (generally this is the item name). A
56 * negative value means that the corresponding field shall be
57 * displayed at the end of the line, with no indication of width.
58 * @vwidth Column width for stats values.
59 ***************************************************************************
61 void print_hdr_line(char *timestamp, struct activity *a, int pos, int iwidth, int vwidth)
63 char hline[HEADER_LINE_LEN] = "";
64 char *hl, *tk, *it = NULL;
68 strncpy(hline, a->hdr_line, HEADER_LINE_LEN - 1);
69 hline[HEADER_LINE_LEN - 1] = '\0';
70 for (hl = strtok(hline, "|"); hl && (pos > 0); hl = strtok(NULL, "|"), pos--);
72 /* Bad @pos arg given to function */
75 printf("\n%-11s", timestamp);
77 if (strchr(hl, '&')) {
79 if ((a->opt_flags & 0xff00) & (1 << (8 + p))) {
80 /* Display whole header line */
84 /* Display only the first part of the header line */
88 /* Display each field */
89 for (tk = strtok(hl, ";"); tk; tk = strtok(NULL, ";"), i--) {
91 printf(" %*s", iwidth, tk);
95 if ((iwidth < 0) && (iwidth == i)) {
100 printf(" %*s", vwidth, tk);
110 ***************************************************************************
111 * Display CPU statistics.
114 * @a Activity structure with statistics.
115 * @prev Index in array where stats used as reference are.
116 * @curr Index in array for current sample statistics.
117 * @g_itv Interval of time in jiffies multiplied by the number
119 ***************************************************************************
121 __print_funct_t print_cpu_stats(struct activity *a, int prev, int curr,
122 unsigned long long g_itv)
125 struct stats_cpu *scc, *scp;
128 print_hdr_line(timestamp[!curr], a, FIRST + DISPLAY_CPU_ALL(a->opt_flags), 7, 9);
131 for (i = 0; (i < a->nr) && (i < a->bitmap->b_size + 1); i++) {
134 * The size of a->buf[...] CPU structure may be different from the default
135 * sizeof(struct stats_cpu) value if data have been read from a file!
136 * That's why we don't use a syntax like:
137 * scc = (struct stats_cpu *) a->buf[...] + i;
139 scc = (struct stats_cpu *) ((char *) a->buf[curr] + i * a->msize);
140 scp = (struct stats_cpu *) ((char *) a->buf[prev] + i * a->msize);
143 * Note: a->nr is in [1, NR_CPUS + 1].
144 * Bitmap size is provided for (NR_CPUS + 1) CPUs.
145 * Anyway, NR_CPUS may vary between the version of sysstat
146 * used by sadc to create a file, and the version of sysstat
147 * used by sar to read it...
150 /* Should current CPU (including CPU "all") be displayed? */
151 if (!(a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))))
155 /* Yes: Display it */
156 printf("%-11s", timestamp[curr]);
159 /* This is CPU "all" */
160 cprintf_in(IS_STR, " %s", " all", 0);
163 cprintf_in(IS_INT, " %7d", "", i - 1);
166 * If the CPU is offline then it is omited from /proc/stat:
167 * All the fields couldn't have been read and the sum of them is zero.
168 * (Remember that guest/guest_nice times are already included in
171 if ((scc->cpu_user + scc->cpu_nice + scc->cpu_sys +
172 scc->cpu_iowait + scc->cpu_idle + scc->cpu_steal +
173 scc->cpu_hardirq + scc->cpu_softirq) == 0) {
175 * Set current struct fields (which have been set to zero)
176 * to values from previous iteration. Hence their values won't
177 * jump from zero when the CPU comes back online.
181 /* %user, %nice, %system, %iowait, %steal, ..., %idle */
183 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
185 if (DISPLAY_CPU_ALL(a->opt_flags)) {
187 * Four additional fields to display:
188 * %irq, %soft, %guest, %gnice.
197 /* Recalculate interval for current proc */
198 g_itv = get_per_cpu_interval(scc, scp);
202 * If the CPU is tickless then there is no change in CPU values
203 * but the sum of values is not zero.
204 * %user, %nice, %system, %iowait, %steal, ..., %idle
207 0.0, 0.0, 0.0, 0.0, 0.0);
209 if (DISPLAY_CPU_DEF(a->opt_flags)) {
210 cprintf_pc(1, 9, 2, 100.0);
214 * Four additional fields to display:
215 * %irq, %soft, %guest, %gnice.
217 else if (DISPLAY_CPU_ALL(a->opt_flags)) {
219 0.0, 0.0, 0.0, 100.0);
226 if (DISPLAY_CPU_DEF(a->opt_flags)) {
228 ll_sp_value(scp->cpu_user, scc->cpu_user, g_itv),
229 ll_sp_value(scp->cpu_nice, scc->cpu_nice, g_itv),
230 ll_sp_value(scp->cpu_sys + scp->cpu_hardirq + scp->cpu_softirq,
231 scc->cpu_sys + scc->cpu_hardirq + scc->cpu_softirq,
233 ll_sp_value(scp->cpu_iowait, scc->cpu_iowait, g_itv),
234 ll_sp_value(scp->cpu_steal, scc->cpu_steal, g_itv),
235 scc->cpu_idle < scp->cpu_idle ?
237 ll_sp_value(scp->cpu_idle, scc->cpu_idle, g_itv));
240 else if (DISPLAY_CPU_ALL(a->opt_flags)) {
242 (scc->cpu_user - scc->cpu_guest) < (scp->cpu_user - scp->cpu_guest) ?
244 ll_sp_value(scp->cpu_user - scp->cpu_guest,
245 scc->cpu_user - scc->cpu_guest, g_itv),
246 (scc->cpu_nice - scc->cpu_guest_nice) < (scp->cpu_nice - scp->cpu_guest_nice) ?
248 ll_sp_value(scp->cpu_nice - scp->cpu_guest_nice,
249 scc->cpu_nice - scc->cpu_guest_nice, g_itv),
250 ll_sp_value(scp->cpu_sys, scc->cpu_sys, g_itv),
251 ll_sp_value(scp->cpu_iowait, scc->cpu_iowait, g_itv),
252 ll_sp_value(scp->cpu_steal, scc->cpu_steal, g_itv),
253 ll_sp_value(scp->cpu_hardirq, scc->cpu_hardirq, g_itv),
254 ll_sp_value(scp->cpu_softirq, scc->cpu_softirq, g_itv),
255 ll_sp_value(scp->cpu_guest, scc->cpu_guest, g_itv),
256 ll_sp_value(scp->cpu_guest_nice, scc->cpu_guest_nice, g_itv),
257 scc->cpu_idle < scp->cpu_idle ?
259 ll_sp_value(scp->cpu_idle, scc->cpu_idle, g_itv));
266 ***************************************************************************
267 * Display tasks creation and context switches statistics.
270 * @a Activity structure with statistics.
271 * @prev Index in array where stats used as reference are.
272 * @curr Index in array for current sample statistics.
273 * @itv Interval of time in jiffies.
274 ***************************************************************************
276 __print_funct_t print_pcsw_stats(struct activity *a, int prev, int curr,
277 unsigned long long itv)
280 *spc = (struct stats_pcsw *) a->buf[curr],
281 *spp = (struct stats_pcsw *) a->buf[prev];
284 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
287 printf("%-11s", timestamp[curr]);
288 cprintf_f(-1, 2, 9, 2,
289 S_VALUE(spp->processes, spc->processes, itv),
290 S_VALUE(spp->context_switch, spc->context_switch, itv));
295 ***************************************************************************
296 * Display interrupts statistics.
299 * @a Activity structure with statistics.
300 * @prev Index in array where stats used as reference are.
301 * @curr Index in array for current sample statistics.
302 * @itv Interval of time in jiffies.
303 ***************************************************************************
305 __print_funct_t print_irq_stats(struct activity *a, int prev, int curr,
306 unsigned long long itv)
309 struct stats_irq *sic, *sip;
312 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
315 for (i = 0; (i < a->nr) && (i < a->bitmap->b_size + 1); i++) {
317 sic = (struct stats_irq *) ((char *) a->buf[curr] + i * a->msize);
318 sip = (struct stats_irq *) ((char *) a->buf[prev] + i * a->msize);
321 * Note: a->nr is in [0, NR_IRQS + 1].
322 * Bitmap size is provided for (NR_IRQS + 1) interrupts.
323 * Anyway, NR_IRQS may vary between the version of sysstat
324 * used by sadc to create a file, and the version of sysstat
325 * used by sar to read it...
328 /* Should current interrupt (including int "sum") be displayed? */
329 if (a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))) {
331 /* Yes: Display it */
332 printf("%-11s", timestamp[curr]);
334 /* This is interrupt "sum" */
335 cprintf_in(IS_STR, " %s", " sum", 0);
338 cprintf_in(IS_INT, " %9d", "", i -1);
341 cprintf_f(-1, 1, 9, 2, S_VALUE(sip->irq_nr, sic->irq_nr, itv));
348 ***************************************************************************
349 * Display swapping statistics.
352 * @a Activity structure with statistics.
353 * @prev Index in array where stats used as reference are.
354 * @curr Index in array for current sample statistics.
355 * @itv Interval of time in jiffies.
356 ***************************************************************************
358 __print_funct_t print_swap_stats(struct activity *a, int prev, int curr,
359 unsigned long long itv)
362 *ssc = (struct stats_swap *) a->buf[curr],
363 *ssp = (struct stats_swap *) a->buf[prev];
366 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
369 printf("%-11s", timestamp[curr]);
370 cprintf_f(-1, 2, 9, 2,
371 S_VALUE(ssp->pswpin, ssc->pswpin, itv),
372 S_VALUE(ssp->pswpout, ssc->pswpout, itv));
377 ***************************************************************************
378 * Display paging statistics.
381 * @a Activity structure with statistics.
382 * @prev Index in array where stats used as reference are.
383 * @curr Index in array for current sample statistics.
384 * @itv Interval of time in jiffies.
385 ***************************************************************************
387 __print_funct_t print_paging_stats(struct activity *a, int prev, int curr,
388 unsigned long long itv)
391 *spc = (struct stats_paging *) a->buf[curr],
392 *spp = (struct stats_paging *) a->buf[prev];
395 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
398 printf("%-11s", timestamp[curr]);
399 cprintf_f(-1, 8, 9, 2,
400 S_VALUE(spp->pgpgin, spc->pgpgin, itv),
401 S_VALUE(spp->pgpgout, spc->pgpgout, itv),
402 S_VALUE(spp->pgfault, spc->pgfault, itv),
403 S_VALUE(spp->pgmajfault, spc->pgmajfault, itv),
404 S_VALUE(spp->pgfree, spc->pgfree, itv),
405 S_VALUE(spp->pgscan_kswapd, spc->pgscan_kswapd, itv),
406 S_VALUE(spp->pgscan_direct, spc->pgscan_direct, itv),
407 S_VALUE(spp->pgsteal, spc->pgsteal, itv));
409 (spc->pgscan_kswapd + spc->pgscan_direct -
410 spp->pgscan_kswapd - spp->pgscan_direct) ?
411 SP_VALUE(spp->pgsteal, spc->pgsteal,
412 spc->pgscan_kswapd + spc->pgscan_direct -
413 spp->pgscan_kswapd - spp->pgscan_direct)
419 ***************************************************************************
420 * Display I/O and transfer rate statistics.
423 * @a Activity structure with statistics.
424 * @prev Index in array where stats used as reference are.
425 * @curr Index in array for current sample statistics.
426 * @itv Interval of time in jiffies.
427 ***************************************************************************
429 __print_funct_t print_io_stats(struct activity *a, int prev, int curr,
430 unsigned long long itv)
433 *sic = (struct stats_io *) a->buf[curr],
434 *sip = (struct stats_io *) a->buf[prev];
437 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
440 printf("%-11s", timestamp[curr]);
442 * If we get negative values, this is probably because
443 * one or more devices/filesystems have been unmounted.
444 * We display 0.0 in this case though we should rather tell
445 * the user that the value cannot be calculated here.
447 cprintf_f(-1, 5, 9, 2,
448 sic->dk_drive < sip->dk_drive ? 0.0 :
449 S_VALUE(sip->dk_drive, sic->dk_drive, itv),
450 sic->dk_drive_rio < sip->dk_drive_rio ? 0.0 :
451 S_VALUE(sip->dk_drive_rio, sic->dk_drive_rio, itv),
452 sic->dk_drive_wio < sip->dk_drive_wio ? 0.0 :
453 S_VALUE(sip->dk_drive_wio, sic->dk_drive_wio, itv),
454 sic->dk_drive_rblk < sip->dk_drive_rblk ? 0.0 :
455 S_VALUE(sip->dk_drive_rblk, sic->dk_drive_rblk, itv),
456 sic->dk_drive_wblk < sip->dk_drive_wblk ? 0.0 :
457 S_VALUE(sip->dk_drive_wblk, sic->dk_drive_wblk, itv));
462 ***************************************************************************
463 * Display memory and swap statistics. This function is used to
464 * display instantaneous and average statistics.
467 * @a Activity structure with statistics.
468 * @prev Index in array where stats used as reference are.
469 * @curr Index in array for current sample statistics.
470 * @itv Interval of time in jiffies.
471 * @dispavg TRUE if displaying average statistics.
472 ***************************************************************************
474 void stub_print_memory_stats(struct activity *a, int prev, int curr,
475 unsigned long long itv, int dispavg)
478 *smc = (struct stats_memory *) a->buf[curr],
479 *smp = (struct stats_memory *) a->buf[prev];
480 static unsigned long long
494 static unsigned long long
500 if (DISPLAY_UNIT(flags)) {
501 /* Default values unit is kB */
505 if (DISPLAY_MEMORY(a->opt_flags)) {
507 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
510 printf("%-11s", timestamp[curr]);
511 cprintf_f(-1, 3, 9, 2,
512 S_VALUE((double) KB_TO_PG(smp->frmkb), (double) KB_TO_PG(smc->frmkb), itv),
513 S_VALUE((double) KB_TO_PG(smp->bufkb), (double) KB_TO_PG(smc->bufkb), itv),
514 S_VALUE((double) KB_TO_PG(smp->camkb), (double) KB_TO_PG(smc->camkb), itv));
518 if (DISPLAY_MEM_AMT(a->opt_flags)) {
520 print_hdr_line(timestamp[!curr], a, SECOND, 0, 9);
524 /* Display instantaneous values */
525 printf("%-11s", timestamp[curr]);
526 cprintf_u64(unit, 3, 9,
527 (unsigned long long) smc->frmkb,
528 (unsigned long long) smc->availablekb,
529 (unsigned long long) (smc->tlmkb - smc->frmkb));
532 SP_VALUE(smc->frmkb, smc->tlmkb, smc->tlmkb)
534 cprintf_u64(unit, 3, 9,
535 (unsigned long long) smc->bufkb,
536 (unsigned long long) smc->camkb,
537 (unsigned long long) smc->comkb);
539 (smc->tlmkb + smc->tlskb) ?
540 SP_VALUE(0, smc->comkb, smc->tlmkb + smc->tlskb)
542 cprintf_u64(unit, 3, 9,
543 (unsigned long long) smc->activekb,
544 (unsigned long long) smc->inactkb,
545 (unsigned long long) smc->dirtykb);
547 if (DISPLAY_MEM_ALL(a->opt_flags)) {
548 /* Display extended memory statistics */
549 cprintf_u64(unit, 5, 9,
550 (unsigned long long) smc->anonpgkb,
551 (unsigned long long) smc->slabkb,
552 (unsigned long long) smc->kstackkb,
553 (unsigned long long) smc->pgtblkb,
554 (unsigned long long) smc->vmusedkb);
560 * Will be used to compute the average.
561 * We assume that the total amount of memory installed can not vary
562 * during the interval given on the command line.
564 avg_frmkb += smc->frmkb;
565 avg_bufkb += smc->bufkb;
566 avg_camkb += smc->camkb;
567 avg_comkb += smc->comkb;
568 avg_activekb += smc->activekb;
569 avg_inactkb += smc->inactkb;
570 avg_dirtykb += smc->dirtykb;
571 avg_anonpgkb += smc->anonpgkb;
572 avg_slabkb += smc->slabkb;
573 avg_kstackkb += smc->kstackkb;
574 avg_pgtblkb += smc->pgtblkb;
575 avg_vmusedkb += smc->vmusedkb;
576 avg_availablekb += smc->availablekb;
579 /* Display average values */
580 printf("%-11s", timestamp[curr]);
581 cprintf_f(unit, 3, 9, 0,
582 (double) avg_frmkb / avg_count,
583 (double) avg_availablekb / avg_count,
584 (double) smc->tlmkb - ((double) avg_frmkb / avg_count));
587 SP_VALUE((double) (avg_frmkb / avg_count), smc->tlmkb, smc->tlmkb)
589 cprintf_f(unit, 3, 9, 0,
590 (double) avg_bufkb / avg_count,
591 (double) avg_camkb / avg_count,
592 (double) avg_comkb / avg_count);
594 (smc->tlmkb + smc->tlskb) ?
595 SP_VALUE(0.0, (double) (avg_comkb / avg_count), smc->tlmkb + smc->tlskb)
597 cprintf_f(unit, 3, 9, 0,
598 (double) avg_activekb / avg_count,
599 (double) avg_inactkb / avg_count,
600 (double) avg_dirtykb / avg_count);
602 if (DISPLAY_MEM_ALL(a->opt_flags)) {
603 cprintf_f(unit, 5, 9, 0,
604 (double) avg_anonpgkb / avg_count,
605 (double) avg_slabkb / avg_count,
606 (double) avg_kstackkb / avg_count,
607 (double) avg_pgtblkb / avg_count,
608 (double) avg_vmusedkb / avg_count);
613 /* Reset average counters */
614 avg_frmkb = avg_bufkb = avg_camkb = avg_comkb = 0;
615 avg_activekb = avg_inactkb = avg_dirtykb = 0;
616 avg_anonpgkb = avg_slabkb = avg_kstackkb = 0;
617 avg_pgtblkb = avg_vmusedkb = avg_availablekb = 0;
621 if (DISPLAY_SWAP(a->opt_flags)) {
623 print_hdr_line(timestamp[!curr], a, THIRD, 0, 9);
627 /* Display instantaneous values */
628 printf("%-11s", timestamp[curr]);
629 cprintf_u64(unit, 2, 9,
630 (unsigned long long) smc->frskb,
631 (unsigned long long) (smc->tlskb - smc->frskb));
634 SP_VALUE(smc->frskb, smc->tlskb, smc->tlskb)
636 cprintf_u64(unit, 1, 9,
637 (unsigned long long) smc->caskb);
639 (smc->tlskb - smc->frskb) ?
640 SP_VALUE(0, smc->caskb, smc->tlskb - smc->frskb)
646 * Will be used to compute the average.
647 * We assume that the total amount of swap space may vary.
649 avg_frskb += smc->frskb;
650 avg_tlskb += smc->tlskb;
651 avg_caskb += smc->caskb;
654 /* Display average values */
655 printf("%-11s", timestamp[curr]);
656 cprintf_f(unit, 2, 9, 0,
657 (double) avg_frskb / avg_count,
658 ((double) avg_tlskb / avg_count) -
659 ((double) avg_frskb / avg_count));
662 SP_VALUE((double) avg_frskb / avg_count,
663 (double) avg_tlskb / avg_count,
664 (double) avg_tlskb / avg_count)
666 cprintf_f(unit, 1, 9, 0,
667 (double) avg_caskb / avg_count);
669 (avg_tlskb != avg_frskb) ?
670 SP_VALUE(0.0, (double) avg_caskb / avg_count,
671 ((double) avg_tlskb / avg_count) -
672 ((double) avg_frskb / avg_count))
676 /* Reset average counters */
677 avg_frskb = avg_tlskb = avg_caskb = 0;
683 ***************************************************************************
684 * Display memory and swap statistics.
687 * @a Activity structure with statistics.
688 * @prev Index in array where stats used as reference are.
689 * @curr Index in array for current sample statistics.
690 * @itv Interval of time in jiffies.
691 ***************************************************************************
693 __print_funct_t print_memory_stats(struct activity *a, int prev, int curr,
694 unsigned long long itv)
696 stub_print_memory_stats(a, prev, curr, itv, FALSE);
700 ***************************************************************************
701 * Display average memory statistics.
704 * @a Activity structure with statistics.
705 * @prev Index in array where stats used as reference are.
706 * @curr Index in array for current sample statistics.
707 * @itv Interval of time in jiffies.
708 ***************************************************************************
710 __print_funct_t print_avg_memory_stats(struct activity *a, int prev, int curr,
711 unsigned long long itv)
713 stub_print_memory_stats(a, prev, curr, itv, TRUE);
717 ***************************************************************************
718 * Display kernel tables statistics. This function is used to display
719 * instantaneous and average statistics.
722 * @a Activity structure with statistics.
723 * @curr Index in array for current sample statistics.
724 * @dispavg True if displaying average statistics.
725 ***************************************************************************
727 void stub_print_ktables_stats(struct activity *a, int curr, int dispavg)
730 *skc = (struct stats_ktables *) a->buf[curr];
731 static unsigned long long
739 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
743 /* Display instantaneous values */
744 printf("%-11s", timestamp[curr]);
745 cprintf_u64(-1, 4, 9,
746 (unsigned long long) skc->dentry_stat,
747 (unsigned long long) skc->file_used,
748 (unsigned long long) skc->inode_used,
749 (unsigned long long) skc->pty_nr);
753 * Will be used to compute the average.
754 * Note: Overflow unlikely to happen but not impossible...
756 avg_dentry_stat += skc->dentry_stat;
757 avg_file_used += skc->file_used;
758 avg_inode_used += skc->inode_used;
759 avg_pty_nr += skc->pty_nr;
762 /* Display average values */
763 printf("%-11s", timestamp[curr]);
764 cprintf_f(-1, 4, 9, 0,
765 (double) avg_dentry_stat / avg_count,
766 (double) avg_file_used / avg_count,
767 (double) avg_inode_used / avg_count,
768 (double) avg_pty_nr / avg_count);
771 /* Reset average counters */
772 avg_dentry_stat = avg_file_used = avg_inode_used = avg_pty_nr = 0;
777 ***************************************************************************
778 * Display kernel tables statistics.
781 * @a Activity structure with statistics.
782 * @prev Index in array where stats used as reference are.
783 * @curr Index in array for current sample statistics.
784 * @itv Interval of time in jiffies.
785 ***************************************************************************
787 __print_funct_t print_ktables_stats(struct activity *a, int prev, int curr,
788 unsigned long long itv)
790 stub_print_ktables_stats(a, curr, FALSE);
794 ***************************************************************************
795 * Display average kernel tables statistics.
798 * @a Activity structure with statistics.
799 * @prev Index in array where stats used as reference are.
800 * @curr Index in array for current sample statistics.
801 * @itv Interval of time in jiffies.
802 ***************************************************************************
804 __print_funct_t print_avg_ktables_stats(struct activity *a, int prev, int curr,
805 unsigned long long itv)
807 stub_print_ktables_stats(a, curr, TRUE);
811 ***************************************************************************
812 * Display queue and load statistics. This function is used to display
813 * instantaneous and average statistics.
816 * @a Activity structure with statistics.
817 * @curr Index in array for current sample statistics.
818 * @dispavg TRUE if displaying average statistics.
819 ***************************************************************************
821 void stub_print_queue_stats(struct activity *a, int curr, int dispavg)
824 *sqc = (struct stats_queue *) a->buf[curr];
825 static unsigned long long
831 avg_procs_blocked = 0;
834 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
838 /* Display instantaneous values */
839 printf("%-11s", timestamp[curr]);
840 cprintf_u64(-1, 2, 9,
841 (unsigned long long) sqc->nr_running,
842 (unsigned long long) sqc->nr_threads);
843 cprintf_f(-1, 3, 9, 2,
844 (double) sqc->load_avg_1 / 100,
845 (double) sqc->load_avg_5 / 100,
846 (double) sqc->load_avg_15 / 100);
847 cprintf_u64(-1, 1, 9,
848 (unsigned long long) sqc->procs_blocked);
851 /* Will be used to compute the average */
852 avg_nr_running += sqc->nr_running;
853 avg_nr_threads += sqc->nr_threads;
854 avg_load_avg_1 += sqc->load_avg_1;
855 avg_load_avg_5 += sqc->load_avg_5;
856 avg_load_avg_15 += sqc->load_avg_15;
857 avg_procs_blocked += sqc->procs_blocked;
860 /* Display average values */
861 printf("%-11s", timestamp[curr]);
862 cprintf_f(-1, 2, 9, 0,
863 (double) avg_nr_running / avg_count,
864 (double) avg_nr_threads / avg_count);
865 cprintf_f(-1, 3, 9, 2,
866 (double) avg_load_avg_1 / (avg_count * 100),
867 (double) avg_load_avg_5 / (avg_count * 100),
868 (double) avg_load_avg_15 / (avg_count * 100));
869 cprintf_f(-1, 1, 9, 0,
870 (double) avg_procs_blocked / avg_count);
873 /* Reset average counters */
874 avg_nr_running = avg_nr_threads = 0;
875 avg_load_avg_1 = avg_load_avg_5 = avg_load_avg_15 = 0;
876 avg_procs_blocked = 0;
881 ***************************************************************************
882 * Display queue and load statistics.
885 * @a Activity structure with statistics.
886 * @prev Index in array where stats used as reference are.
887 * @curr Index in array for current sample statistics.
888 * @itv Interval of time in jiffies.
889 ***************************************************************************
891 __print_funct_t print_queue_stats(struct activity *a, int prev, int curr,
892 unsigned long long itv)
894 stub_print_queue_stats(a, curr, FALSE);
898 ***************************************************************************
899 * Display average queue and load statistics.
902 * @a Activity structure with statistics.
903 * @prev Index in array where stats used as reference are.
904 * @curr Index in array for current sample statistics.
905 * @itv Interval of time in jiffies.
906 ***************************************************************************
908 __print_funct_t print_avg_queue_stats(struct activity *a, int prev, int curr,
909 unsigned long long itv)
911 stub_print_queue_stats(a, curr, TRUE);
915 ***************************************************************************
916 * Display serial lines statistics.
919 * @a Activity structure with statistics.
920 * @prev Index in array where stats used as reference are.
921 * @curr Index in array for current sample statistics.
922 * @itv Interval of time in jiffies.
923 ***************************************************************************
925 __print_funct_t print_serial_stats(struct activity *a, int prev, int curr,
926 unsigned long long itv)
929 struct stats_serial *ssc, *ssp;
932 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
935 for (i = 0; i < a->nr; i++) {
937 ssc = (struct stats_serial *) ((char *) a->buf[curr] + i * a->msize);
938 ssp = (struct stats_serial *) ((char *) a->buf[prev] + i * a->msize);
943 printf("%-11s", timestamp[curr]);
944 cprintf_in(IS_INT, " %3d", "", ssc->line - 1);
946 if ((ssc->line == ssp->line) || WANT_SINCE_BOOT(flags)) {
947 cprintf_f(-1, 6, 9, 2,
948 S_VALUE(ssp->rx, ssc->rx, itv),
949 S_VALUE(ssp->tx, ssc->tx, itv),
950 S_VALUE(ssp->frame, ssc->frame, itv),
951 S_VALUE(ssp->parity, ssc->parity, itv),
952 S_VALUE(ssp->brk, ssc->brk, itv),
953 S_VALUE(ssp->overrun, ssc->overrun, itv));
957 printf(" N/A N/A N/A N/A"
964 ***************************************************************************
965 * Display disks statistics.
968 * @a Activity structure with statistics.
969 * @prev Index in array where stats used as reference are.
970 * @curr Index in array for current sample statistics.
971 * @itv Interval of time in jiffies.
972 ***************************************************************************
974 __print_funct_t print_disk_stats(struct activity *a, int prev, int curr,
975 unsigned long long itv)
978 struct stats_disk *sdc, *sdp;
979 struct ext_disk_stats xds;
980 char *dev_name, *persist_dev_name;
983 if (DISPLAY_UNIT(flags)) {
984 /* Default values unit is sectors */
989 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
992 for (i = 0; i < a->nr; i++) {
994 sdc = (struct stats_disk *) ((char *) a->buf[curr] + i * a->msize);
996 if (!(sdc->major + sdc->minor))
999 j = check_disk_reg(a, curr, prev, i);
1000 sdp = (struct stats_disk *) ((char *) a->buf[prev] + j * a->msize);
1002 /* Compute service time, etc. */
1003 compute_ext_disk_stats(sdc, sdp, itv, &xds);
1006 persist_dev_name = NULL;
1008 if (DISPLAY_PERSIST_NAME_S(flags)) {
1009 persist_dev_name = get_persistent_name_from_pretty(get_devname(sdc->major, sdc->minor, TRUE));
1012 if (persist_dev_name) {
1013 dev_name = persist_dev_name;
1016 if ((USE_PRETTY_OPTION(flags)) && (sdc->major == dm_major)) {
1017 dev_name = transform_devmapname(sdc->major, sdc->minor);
1021 dev_name = get_devname(sdc->major, sdc->minor,
1022 USE_PRETTY_OPTION(flags));
1026 printf("%-11s", timestamp[curr]);
1028 cprintf_in(IS_STR, " %9s", dev_name, 0);
1029 cprintf_f(-1, 1, 9, 2,
1030 S_VALUE(sdp->nr_ios, sdc->nr_ios, itv));
1031 cprintf_f(unit, 2, 9, 2,
1032 S_VALUE(sdp->rd_sect, sdc->rd_sect, itv),
1033 S_VALUE(sdp->wr_sect, sdc->wr_sect, itv));
1034 cprintf_f(-1, 4, 9, 2,
1035 /* See iostat for explanations */
1037 S_VALUE(sdp->rq_ticks, sdc->rq_ticks, itv) / 1000.0,
1047 ***************************************************************************
1048 * Display network interfaces statistics.
1051 * @a Activity structure with statistics.
1052 * @prev Index in array where stats used as reference are.
1053 * @curr Index in array for current sample statistics.
1054 * @itv Interval of time in jiffies.
1055 ***************************************************************************
1057 __print_funct_t print_net_dev_stats(struct activity *a, int prev, int curr,
1058 unsigned long long itv)
1061 struct stats_net_dev *sndc, *sndp;
1062 double rxkb, txkb, ifutil;
1065 if (DISPLAY_UNIT(flags)) {
1066 /* Default values unit is bytes */
1071 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
1074 for (i = 0; i < a->nr; i++) {
1076 sndc = (struct stats_net_dev *) ((char *) a->buf[curr] + i * a->msize);
1078 if (!strcmp(sndc->interface, ""))
1081 j = check_net_dev_reg(a, curr, prev, i);
1082 sndp = (struct stats_net_dev *) ((char *) a->buf[prev] + j * a->msize);
1084 printf("%-11s", timestamp[curr]);
1085 cprintf_in(IS_STR, " %9s", sndc->interface, 0);
1087 rxkb = S_VALUE(sndp->rx_bytes, sndc->rx_bytes, itv);
1088 txkb = S_VALUE(sndp->tx_bytes, sndc->tx_bytes, itv);
1090 cprintf_f(-1, 2, 9, 2,
1091 S_VALUE(sndp->rx_packets, sndc->rx_packets, itv),
1092 S_VALUE(sndp->tx_packets, sndc->tx_packets, itv));
1093 cprintf_f(unit, 2, 9, 2,
1094 unit < 0 ? rxkb / 1024 : rxkb,
1095 unit < 0 ? txkb / 1024 : txkb);
1096 cprintf_f(-1, 3, 9, 2,
1097 S_VALUE(sndp->rx_compressed, sndc->rx_compressed, itv),
1098 S_VALUE(sndp->tx_compressed, sndc->tx_compressed, itv),
1099 S_VALUE(sndp->multicast, sndc->multicast, itv));
1100 ifutil = compute_ifutil(sndc, rxkb, txkb);
1101 cprintf_pc(1, 9, 2, ifutil);
1107 ***************************************************************************
1108 * Display network interface errors statistics.
1111 * @a Activity structure with statistics.
1112 * @prev Index in array where stats used as reference are.
1113 * @curr Index in array for current sample statistics.
1114 * @itv Interval of time in jiffies.
1115 ***************************************************************************
1117 __print_funct_t print_net_edev_stats(struct activity *a, int prev, int curr,
1118 unsigned long long itv)
1121 struct stats_net_edev *snedc, *snedp;
1124 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
1127 for (i = 0; i < a->nr; i++) {
1129 snedc = (struct stats_net_edev *) ((char *) a->buf[curr] + i * a->msize);
1131 if (!strcmp(snedc->interface, ""))
1134 j = check_net_edev_reg(a, curr, prev, i);
1135 snedp = (struct stats_net_edev *) ((char *) a->buf[prev] + j * a->msize);
1137 printf("%-11s", timestamp[curr]);
1138 cprintf_in(IS_STR, " %9s", snedc->interface, 0);
1140 cprintf_f(-1, 9, 9, 2,
1141 S_VALUE(snedp->rx_errors, snedc->rx_errors, itv),
1142 S_VALUE(snedp->tx_errors, snedc->tx_errors, itv),
1143 S_VALUE(snedp->collisions, snedc->collisions, itv),
1144 S_VALUE(snedp->rx_dropped, snedc->rx_dropped, itv),
1145 S_VALUE(snedp->tx_dropped, snedc->tx_dropped, itv),
1146 S_VALUE(snedp->tx_carrier_errors, snedc->tx_carrier_errors, itv),
1147 S_VALUE(snedp->rx_frame_errors, snedc->rx_frame_errors, itv),
1148 S_VALUE(snedp->rx_fifo_errors, snedc->rx_fifo_errors, itv),
1149 S_VALUE(snedp->tx_fifo_errors, snedc->tx_fifo_errors, itv));
1155 ***************************************************************************
1156 * Display NFS client statistics.
1159 * @a Activity structure with statistics.
1160 * @prev Index in array where stats used as reference are.
1161 * @curr Index in array for current sample statistics.
1162 * @itv Interval of time in jiffies.
1163 ***************************************************************************
1165 __print_funct_t print_net_nfs_stats(struct activity *a, int prev, int curr,
1166 unsigned long long itv)
1168 struct stats_net_nfs
1169 *snnc = (struct stats_net_nfs *) a->buf[curr],
1170 *snnp = (struct stats_net_nfs *) a->buf[prev];
1173 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
1176 printf("%-11s", timestamp[curr]);
1177 cprintf_f(-1, 6, 9, 2,
1178 S_VALUE(snnp->nfs_rpccnt, snnc->nfs_rpccnt, itv),
1179 S_VALUE(snnp->nfs_rpcretrans, snnc->nfs_rpcretrans, itv),
1180 S_VALUE(snnp->nfs_readcnt, snnc->nfs_readcnt, itv),
1181 S_VALUE(snnp->nfs_writecnt, snnc->nfs_writecnt, itv),
1182 S_VALUE(snnp->nfs_accesscnt, snnc->nfs_accesscnt, itv),
1183 S_VALUE(snnp->nfs_getattcnt, snnc->nfs_getattcnt, itv));
1188 ***************************************************************************
1189 * Display NFS server statistics.
1192 * @a Activity structure with statistics.
1193 * @prev Index in array where stats used as reference are.
1194 * @curr Index in array for current sample statistics.
1195 * @itv Interval of time in jiffies.
1196 ***************************************************************************
1198 __print_funct_t print_net_nfsd_stats(struct activity *a, int prev, int curr,
1199 unsigned long long itv)
1201 struct stats_net_nfsd
1202 *snndc = (struct stats_net_nfsd *) a->buf[curr],
1203 *snndp = (struct stats_net_nfsd *) a->buf[prev];
1206 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
1209 printf("%-11s", timestamp[curr]);
1210 cprintf_f(-1, 11, 9, 2,
1211 S_VALUE(snndp->nfsd_rpccnt, snndc->nfsd_rpccnt, itv),
1212 S_VALUE(snndp->nfsd_rpcbad, snndc->nfsd_rpcbad, itv),
1213 S_VALUE(snndp->nfsd_netcnt, snndc->nfsd_netcnt, itv),
1214 S_VALUE(snndp->nfsd_netudpcnt, snndc->nfsd_netudpcnt, itv),
1215 S_VALUE(snndp->nfsd_nettcpcnt, snndc->nfsd_nettcpcnt, itv),
1216 S_VALUE(snndp->nfsd_rchits, snndc->nfsd_rchits, itv),
1217 S_VALUE(snndp->nfsd_rcmisses, snndc->nfsd_rcmisses, itv),
1218 S_VALUE(snndp->nfsd_readcnt, snndc->nfsd_readcnt, itv),
1219 S_VALUE(snndp->nfsd_writecnt, snndc->nfsd_writecnt, itv),
1220 S_VALUE(snndp->nfsd_accesscnt, snndc->nfsd_accesscnt, itv),
1221 S_VALUE(snndp->nfsd_getattcnt, snndc->nfsd_getattcnt, itv));
1226 ***************************************************************************
1227 * Display network sockets statistics. This function is used to display
1228 * instantaneous and average statistics.
1231 * @a Activity structure with statistics.
1232 * @curr Index in array for current sample statistics.
1233 * @dispavg TRUE if displaying average statistics.
1234 ***************************************************************************
1236 void stub_print_net_sock_stats(struct activity *a, int curr, int dispavg)
1238 struct stats_net_sock
1239 *snsc = (struct stats_net_sock *) a->buf[curr];
1240 static unsigned long long
1249 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
1253 /* Display instantaneous values */
1254 printf("%-11s", timestamp[curr]);
1255 cprintf_u64(-1, 6, 9,
1256 (unsigned long long) snsc->sock_inuse,
1257 (unsigned long long) snsc->tcp_inuse,
1258 (unsigned long long) snsc->udp_inuse,
1259 (unsigned long long) snsc->raw_inuse,
1260 (unsigned long long) snsc->frag_inuse,
1261 (unsigned long long) snsc->tcp_tw);
1264 /* Will be used to compute the average */
1265 avg_sock_inuse += snsc->sock_inuse;
1266 avg_tcp_inuse += snsc->tcp_inuse;
1267 avg_udp_inuse += snsc->udp_inuse;
1268 avg_raw_inuse += snsc->raw_inuse;
1269 avg_frag_inuse += snsc->frag_inuse;
1270 avg_tcp_tw += snsc->tcp_tw;
1273 /* Display average values */
1274 printf("%-11s", timestamp[curr]);
1275 cprintf_f(-1, 6, 9, 0,
1276 (double) avg_sock_inuse / avg_count,
1277 (double) avg_tcp_inuse / avg_count,
1278 (double) avg_udp_inuse / avg_count,
1279 (double) avg_raw_inuse / avg_count,
1280 (double) avg_frag_inuse / avg_count,
1281 (double) avg_tcp_tw / avg_count);
1284 /* Reset average counters */
1285 avg_sock_inuse = avg_tcp_inuse = avg_udp_inuse = 0;
1286 avg_raw_inuse = avg_frag_inuse = avg_tcp_tw = 0;
1291 ***************************************************************************
1292 * Display network sockets statistics.
1295 * @a Activity structure with statistics.
1296 * @prev Index in array where stats used as reference are.
1297 * @curr Index in array for current sample statistics.
1298 * @itv Interval of time in jiffies.
1299 ***************************************************************************
1301 __print_funct_t print_net_sock_stats(struct activity *a, int prev, int curr,
1302 unsigned long long itv)
1304 stub_print_net_sock_stats(a, curr, FALSE);
1308 ***************************************************************************
1309 * Display average network sockets statistics.
1312 * @a Activity structure with statistics.
1313 * @prev Index in array where stats used as reference are.
1314 * @curr Index in array for current sample statistics.
1315 * @itv Interval of time in jiffies.
1316 ***************************************************************************
1318 __print_funct_t print_avg_net_sock_stats(struct activity *a, int prev, int curr,
1319 unsigned long long itv)
1321 stub_print_net_sock_stats(a, curr, TRUE);
1325 ***************************************************************************
1326 * Display IP network traffic statistics.
1329 * @a Activity structure with statistics.
1330 * @prev Index in array where stats used as reference are.
1331 * @curr Index in array for current sample statistics.
1332 * @itv Interval of time in jiffies.
1333 ***************************************************************************
1335 __print_funct_t print_net_ip_stats(struct activity *a, int prev, int curr,
1336 unsigned long long itv)
1339 *snic = (struct stats_net_ip *) a->buf[curr],
1340 *snip = (struct stats_net_ip *) a->buf[prev];
1343 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
1346 printf("%-11s", timestamp[curr]);
1347 cprintf_f(-1, 8, 9, 2,
1348 S_VALUE(snip->InReceives, snic->InReceives, itv),
1349 S_VALUE(snip->ForwDatagrams, snic->ForwDatagrams, itv),
1350 S_VALUE(snip->InDelivers, snic->InDelivers, itv),
1351 S_VALUE(snip->OutRequests, snic->OutRequests, itv),
1352 S_VALUE(snip->ReasmReqds, snic->ReasmReqds, itv),
1353 S_VALUE(snip->ReasmOKs, snic->ReasmOKs, itv),
1354 S_VALUE(snip->FragOKs, snic->FragOKs, itv),
1355 S_VALUE(snip->FragCreates, snic->FragCreates, itv));
1360 ***************************************************************************
1361 * Display IP network errors statistics.
1364 * @a Activity structure with statistics.
1365 * @prev Index in array where stats used as reference are.
1366 * @curr Index in array for current sample statistics.
1367 * @itv Interval of time in jiffies.
1368 ***************************************************************************
1370 __print_funct_t print_net_eip_stats(struct activity *a, int prev, int curr,
1371 unsigned long long itv)
1373 struct stats_net_eip
1374 *sneic = (struct stats_net_eip *) a->buf[curr],
1375 *sneip = (struct stats_net_eip *) a->buf[prev];
1378 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
1381 printf("%-11s", timestamp[curr]);
1382 cprintf_f(-1, 8, 9, 2,
1383 S_VALUE(sneip->InHdrErrors, sneic->InHdrErrors, itv),
1384 S_VALUE(sneip->InAddrErrors, sneic->InAddrErrors, itv),
1385 S_VALUE(sneip->InUnknownProtos, sneic->InUnknownProtos, itv),
1386 S_VALUE(sneip->InDiscards, sneic->InDiscards, itv),
1387 S_VALUE(sneip->OutDiscards, sneic->OutDiscards, itv),
1388 S_VALUE(sneip->OutNoRoutes, sneic->OutNoRoutes, itv),
1389 S_VALUE(sneip->ReasmFails, sneic->ReasmFails, itv),
1390 S_VALUE(sneip->FragFails, sneic->FragFails, itv));
1395 ***************************************************************************
1396 * Display ICMP network traffic statistics.
1399 * @a Activity structure with statistics.
1400 * @prev Index in array where stats used as reference are.
1401 * @curr Index in array for current sample statistics.
1402 * @itv Interval of time in jiffies.
1403 ***************************************************************************
1405 __print_funct_t print_net_icmp_stats(struct activity *a, int prev, int curr,
1406 unsigned long long itv)
1408 struct stats_net_icmp
1409 *snic = (struct stats_net_icmp *) a->buf[curr],
1410 *snip = (struct stats_net_icmp *) a->buf[prev];
1413 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
1416 printf("%-11s", timestamp[curr]);
1417 cprintf_f(-1, 14, 9, 2,
1418 S_VALUE(snip->InMsgs, snic->InMsgs, itv),
1419 S_VALUE(snip->OutMsgs, snic->OutMsgs, itv),
1420 S_VALUE(snip->InEchos, snic->InEchos, itv),
1421 S_VALUE(snip->InEchoReps, snic->InEchoReps, itv),
1422 S_VALUE(snip->OutEchos, snic->OutEchos, itv),
1423 S_VALUE(snip->OutEchoReps, snic->OutEchoReps, itv),
1424 S_VALUE(snip->InTimestamps, snic->InTimestamps, itv),
1425 S_VALUE(snip->InTimestampReps, snic->InTimestampReps, itv),
1426 S_VALUE(snip->OutTimestamps, snic->OutTimestamps, itv),
1427 S_VALUE(snip->OutTimestampReps, snic->OutTimestampReps, itv),
1428 S_VALUE(snip->InAddrMasks, snic->InAddrMasks, itv),
1429 S_VALUE(snip->InAddrMaskReps, snic->InAddrMaskReps, itv),
1430 S_VALUE(snip->OutAddrMasks, snic->OutAddrMasks, itv),
1431 S_VALUE(snip->OutAddrMaskReps, snic->OutAddrMaskReps, itv));
1436 ***************************************************************************
1437 * Display ICMP network errors statistics.
1440 * @a Activity structure with statistics.
1441 * @prev Index in array where stats used as reference are.
1442 * @curr Index in array for current sample statistics.
1443 * @itv Interval of time in jiffies.
1444 ***************************************************************************
1446 __print_funct_t print_net_eicmp_stats(struct activity *a, int prev, int curr,
1447 unsigned long long itv)
1449 struct stats_net_eicmp
1450 *sneic = (struct stats_net_eicmp *) a->buf[curr],
1451 *sneip = (struct stats_net_eicmp *) a->buf[prev];
1454 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
1457 printf("%-11s", timestamp[curr]);
1458 cprintf_f(-1, 12, 9, 2,
1459 S_VALUE(sneip->InErrors, sneic->InErrors, itv),
1460 S_VALUE(sneip->OutErrors, sneic->OutErrors, itv),
1461 S_VALUE(sneip->InDestUnreachs, sneic->InDestUnreachs, itv),
1462 S_VALUE(sneip->OutDestUnreachs, sneic->OutDestUnreachs, itv),
1463 S_VALUE(sneip->InTimeExcds, sneic->InTimeExcds, itv),
1464 S_VALUE(sneip->OutTimeExcds, sneic->OutTimeExcds, itv),
1465 S_VALUE(sneip->InParmProbs, sneic->InParmProbs, itv),
1466 S_VALUE(sneip->OutParmProbs, sneic->OutParmProbs, itv),
1467 S_VALUE(sneip->InSrcQuenchs, sneic->InSrcQuenchs, itv),
1468 S_VALUE(sneip->OutSrcQuenchs, sneic->OutSrcQuenchs, itv),
1469 S_VALUE(sneip->InRedirects, sneic->InRedirects, itv),
1470 S_VALUE(sneip->OutRedirects, sneic->OutRedirects, itv));
1475 ***************************************************************************
1476 * Display TCP network traffic statistics.
1479 * @a Activity structure with statistics.
1480 * @prev Index in array where stats used as reference are.
1481 * @curr Index in array for current sample statistics.
1482 * @itv Interval of time in jiffies.
1483 ***************************************************************************
1485 __print_funct_t print_net_tcp_stats(struct activity *a, int prev, int curr,
1486 unsigned long long itv)
1488 struct stats_net_tcp
1489 *sntc = (struct stats_net_tcp *) a->buf[curr],
1490 *sntp = (struct stats_net_tcp *) a->buf[prev];
1493 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
1496 printf("%-11s", timestamp[curr]);
1497 cprintf_f(-1, 4, 9, 2,
1498 S_VALUE(sntp->ActiveOpens, sntc->ActiveOpens, itv),
1499 S_VALUE(sntp->PassiveOpens, sntc->PassiveOpens, itv),
1500 S_VALUE(sntp->InSegs, sntc->InSegs, itv),
1501 S_VALUE(sntp->OutSegs, sntc->OutSegs, itv));
1506 ***************************************************************************
1507 * Display TCP network errors statistics.
1510 * @a Activity structure with statistics.
1511 * @prev Index in array where stats used as reference are.
1512 * @curr Index in array for current sample statistics.
1513 * @itv Interval of time in jiffies.
1514 ***************************************************************************
1516 __print_funct_t print_net_etcp_stats(struct activity *a, int prev, int curr,
1517 unsigned long long itv)
1519 struct stats_net_etcp
1520 *snetc = (struct stats_net_etcp *) a->buf[curr],
1521 *snetp = (struct stats_net_etcp *) a->buf[prev];
1524 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
1527 printf("%-11s", timestamp[curr]);
1528 cprintf_f(-1, 5, 9, 2,
1529 S_VALUE(snetp->AttemptFails, snetc->AttemptFails, itv),
1530 S_VALUE(snetp->EstabResets, snetc->EstabResets, itv),
1531 S_VALUE(snetp->RetransSegs, snetc->RetransSegs, itv),
1532 S_VALUE(snetp->InErrs, snetc->InErrs, itv),
1533 S_VALUE(snetp->OutRsts, snetc->OutRsts, itv));
1538 ***************************************************************************
1539 * Display UDP network traffic statistics.
1542 * @a Activity structure with statistics.
1543 * @prev Index in array where stats used as reference are.
1544 * @curr Index in array for current sample statistics.
1545 * @itv Interval of time in jiffies.
1546 ***************************************************************************
1548 __print_funct_t print_net_udp_stats(struct activity *a, int prev, int curr,
1549 unsigned long long itv)
1551 struct stats_net_udp
1552 *snuc = (struct stats_net_udp *) a->buf[curr],
1553 *snup = (struct stats_net_udp *) a->buf[prev];
1556 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
1559 printf("%-11s", timestamp[curr]);
1560 cprintf_f(-1, 4, 9, 2,
1561 S_VALUE(snup->InDatagrams, snuc->InDatagrams, itv),
1562 S_VALUE(snup->OutDatagrams, snuc->OutDatagrams, itv),
1563 S_VALUE(snup->NoPorts, snuc->NoPorts, itv),
1564 S_VALUE(snup->InErrors, snuc->InErrors, itv));
1569 ***************************************************************************
1570 * Display IPv6 sockets statistics. This function is used to display
1571 * instantaneous and average statistics.
1574 * @a Activity structure with statistics.
1575 * @curr Index in array for current sample statistics.
1576 * @dispavg TRUE if displaying average statistics.
1577 ***************************************************************************
1579 void stub_print_net_sock6_stats(struct activity *a, int curr, int dispavg)
1581 struct stats_net_sock6
1582 *snsc = (struct stats_net_sock6 *) a->buf[curr];
1583 static unsigned long long
1587 avg_frag6_inuse = 0;
1590 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
1594 /* Display instantaneous values */
1595 printf("%-11s", timestamp[curr]);
1596 cprintf_u64(-1, 4, 9,
1597 (unsigned long long) snsc->tcp6_inuse,
1598 (unsigned long long) snsc->udp6_inuse,
1599 (unsigned long long) snsc->raw6_inuse,
1600 (unsigned long long) snsc->frag6_inuse);
1603 /* Will be used to compute the average */
1604 avg_tcp6_inuse += snsc->tcp6_inuse;
1605 avg_udp6_inuse += snsc->udp6_inuse;
1606 avg_raw6_inuse += snsc->raw6_inuse;
1607 avg_frag6_inuse += snsc->frag6_inuse;
1610 /* Display average values */
1611 printf("%-11s", timestamp[curr]);
1612 cprintf_f(-1, 4, 9, 0,
1613 (double) avg_tcp6_inuse / avg_count,
1614 (double) avg_udp6_inuse / avg_count,
1615 (double) avg_raw6_inuse / avg_count,
1616 (double) avg_frag6_inuse / avg_count);
1619 /* Reset average counters */
1620 avg_tcp6_inuse = avg_udp6_inuse = avg_raw6_inuse = avg_frag6_inuse = 0;
1625 ***************************************************************************
1626 * Display IPv6 sockets statistics.
1629 * @a Activity structure with statistics.
1630 * @prev Index in array where stats used as reference are.
1631 * @curr Index in array for current sample statistics.
1632 * @itv Interval of time in jiffies.
1633 ***************************************************************************
1635 __print_funct_t print_net_sock6_stats(struct activity *a, int prev, int curr,
1636 unsigned long long itv)
1638 stub_print_net_sock6_stats(a, curr, FALSE);
1642 ***************************************************************************
1643 * Display average IPv6 sockets statistics.
1646 * @a Activity structure with statistics.
1647 * @prev Index in array where stats used as reference are.
1648 * @curr Index in array for current sample statistics.
1649 * @itv Interval of time in jiffies.
1650 ***************************************************************************
1652 __print_funct_t print_avg_net_sock6_stats(struct activity *a, int prev, int curr,
1653 unsigned long long itv)
1655 stub_print_net_sock6_stats(a, curr, TRUE);
1659 ***************************************************************************
1660 * Display IPv6 network traffic 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 * @itv Interval of time in jiffies.
1667 ***************************************************************************
1669 __print_funct_t print_net_ip6_stats(struct activity *a, int prev, int curr,
1670 unsigned long long itv)
1672 struct stats_net_ip6
1673 *snic = (struct stats_net_ip6 *) a->buf[curr],
1674 *snip = (struct stats_net_ip6 *) a->buf[prev];
1677 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
1680 printf("%-11s", timestamp[curr]);
1681 cprintf_f(-1, 10, 9, 2,
1682 S_VALUE(snip->InReceives6, snic->InReceives6, itv),
1683 S_VALUE(snip->OutForwDatagrams6, snic->OutForwDatagrams6, itv),
1684 S_VALUE(snip->InDelivers6, snic->InDelivers6, itv),
1685 S_VALUE(snip->OutRequests6, snic->OutRequests6, itv),
1686 S_VALUE(snip->ReasmReqds6, snic->ReasmReqds6, itv),
1687 S_VALUE(snip->ReasmOKs6, snic->ReasmOKs6, itv),
1688 S_VALUE(snip->InMcastPkts6, snic->InMcastPkts6, itv),
1689 S_VALUE(snip->OutMcastPkts6, snic->OutMcastPkts6, itv),
1690 S_VALUE(snip->FragOKs6, snic->FragOKs6, itv),
1691 S_VALUE(snip->FragCreates6, snic->FragCreates6, itv));
1696 ***************************************************************************
1697 * Display IPv6 network errors statistics.
1700 * @a Activity structure with statistics.
1701 * @prev Index in array where stats used as reference are.
1702 * @curr Index in array for current sample statistics.
1703 * @itv Interval of time in jiffies.
1704 ***************************************************************************
1706 __print_funct_t print_net_eip6_stats(struct activity *a, int prev, int curr,
1707 unsigned long long itv)
1709 struct stats_net_eip6
1710 *sneic = (struct stats_net_eip6 *) a->buf[curr],
1711 *sneip = (struct stats_net_eip6 *) a->buf[prev];
1714 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
1717 printf("%-11s", timestamp[curr]);
1718 cprintf_f(-1, 11, 9, 2,
1719 S_VALUE(sneip->InHdrErrors6, sneic->InHdrErrors6, itv),
1720 S_VALUE(sneip->InAddrErrors6, sneic->InAddrErrors6, itv),
1721 S_VALUE(sneip->InUnknownProtos6, sneic->InUnknownProtos6, itv),
1722 S_VALUE(sneip->InTooBigErrors6, sneic->InTooBigErrors6, itv),
1723 S_VALUE(sneip->InDiscards6, sneic->InDiscards6, itv),
1724 S_VALUE(sneip->OutDiscards6, sneic->OutDiscards6, itv),
1725 S_VALUE(sneip->InNoRoutes6, sneic->InNoRoutes6, itv),
1726 S_VALUE(sneip->OutNoRoutes6, sneic->OutNoRoutes6, itv),
1727 S_VALUE(sneip->ReasmFails6, sneic->ReasmFails6, itv),
1728 S_VALUE(sneip->FragFails6, sneic->FragFails6, itv),
1729 S_VALUE(sneip->InTruncatedPkts6, sneic->InTruncatedPkts6, itv));
1734 ***************************************************************************
1735 * Display ICMPv6 network traffic statistics.
1738 * @a Activity structure with statistics.
1739 * @prev Index in array where stats used as reference are.
1740 * @curr Index in array for current sample statistics.
1741 * @itv Interval of time in jiffies.
1742 ***************************************************************************
1744 __print_funct_t print_net_icmp6_stats(struct activity *a, int prev, int curr,
1745 unsigned long long itv)
1747 struct stats_net_icmp6
1748 *snic = (struct stats_net_icmp6 *) a->buf[curr],
1749 *snip = (struct stats_net_icmp6 *) a->buf[prev];
1752 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
1755 printf("%-11s", timestamp[curr]);
1756 cprintf_f(-1, 17, 9, 2,
1757 S_VALUE(snip->InMsgs6, snic->InMsgs6, itv),
1758 S_VALUE(snip->OutMsgs6, snic->OutMsgs6, itv),
1759 S_VALUE(snip->InEchos6, snic->InEchos6, itv),
1760 S_VALUE(snip->InEchoReplies6, snic->InEchoReplies6, itv),
1761 S_VALUE(snip->OutEchoReplies6, snic->OutEchoReplies6, itv),
1762 S_VALUE(snip->InGroupMembQueries6, snic->InGroupMembQueries6, itv),
1763 S_VALUE(snip->InGroupMembResponses6, snic->InGroupMembResponses6, itv),
1764 S_VALUE(snip->OutGroupMembResponses6, snic->OutGroupMembResponses6, itv),
1765 S_VALUE(snip->InGroupMembReductions6, snic->InGroupMembReductions6, itv),
1766 S_VALUE(snip->OutGroupMembReductions6, snic->OutGroupMembReductions6, itv),
1767 S_VALUE(snip->InRouterSolicits6, snic->InRouterSolicits6, itv),
1768 S_VALUE(snip->OutRouterSolicits6, snic->OutRouterSolicits6, itv),
1769 S_VALUE(snip->InRouterAdvertisements6, snic->InRouterAdvertisements6, itv),
1770 S_VALUE(snip->InNeighborSolicits6, snic->InNeighborSolicits6, itv),
1771 S_VALUE(snip->OutNeighborSolicits6, snic->OutNeighborSolicits6, itv),
1772 S_VALUE(snip->InNeighborAdvertisements6, snic->InNeighborAdvertisements6, itv),
1773 S_VALUE(snip->OutNeighborAdvertisements6, snic->OutNeighborAdvertisements6, itv));
1778 ***************************************************************************
1779 * Display ICMPv6 network errors statistics.
1782 * @a Activity structure with statistics.
1783 * @prev Index in array where stats used as reference are.
1784 * @curr Index in array for current sample statistics.
1785 * @itv Interval of time in jiffies.
1786 ***************************************************************************
1788 __print_funct_t print_net_eicmp6_stats(struct activity *a, int prev, int curr,
1789 unsigned long long itv)
1791 struct stats_net_eicmp6
1792 *sneic = (struct stats_net_eicmp6 *) a->buf[curr],
1793 *sneip = (struct stats_net_eicmp6 *) a->buf[prev];
1796 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
1799 printf("%-11s", timestamp[curr]);
1800 cprintf_f(-1, 11, 9, 2,
1801 S_VALUE(sneip->InErrors6, sneic->InErrors6, itv),
1802 S_VALUE(sneip->InDestUnreachs6, sneic->InDestUnreachs6, itv),
1803 S_VALUE(sneip->OutDestUnreachs6, sneic->OutDestUnreachs6, itv),
1804 S_VALUE(sneip->InTimeExcds6, sneic->InTimeExcds6, itv),
1805 S_VALUE(sneip->OutTimeExcds6, sneic->OutTimeExcds6, itv),
1806 S_VALUE(sneip->InParmProblems6, sneic->InParmProblems6, itv),
1807 S_VALUE(sneip->OutParmProblems6, sneic->OutParmProblems6, itv),
1808 S_VALUE(sneip->InRedirects6, sneic->InRedirects6, itv),
1809 S_VALUE(sneip->OutRedirects6, sneic->OutRedirects6, itv),
1810 S_VALUE(sneip->InPktTooBigs6, sneic->InPktTooBigs6, itv),
1811 S_VALUE(sneip->OutPktTooBigs6, sneic->OutPktTooBigs6, itv));
1816 ***************************************************************************
1817 * Display UDPv6 network traffic statistics.
1820 * @a Activity structure with statistics.
1821 * @prev Index in array where stats used as reference are.
1822 * @curr Index in array for current sample statistics.
1823 * @itv Interval of time in jiffies.
1824 ***************************************************************************
1826 __print_funct_t print_net_udp6_stats(struct activity *a, int prev, int curr,
1827 unsigned long long itv)
1829 struct stats_net_udp6
1830 *snuc = (struct stats_net_udp6 *) a->buf[curr],
1831 *snup = (struct stats_net_udp6 *) a->buf[prev];
1834 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
1837 printf("%-11s", timestamp[curr]);
1838 cprintf_f(-1, 4, 9, 2,
1839 S_VALUE(snup->InDatagrams6, snuc->InDatagrams6, itv),
1840 S_VALUE(snup->OutDatagrams6, snuc->OutDatagrams6, itv),
1841 S_VALUE(snup->NoPorts6, snuc->NoPorts6, itv),
1842 S_VALUE(snup->InErrors6, snuc->InErrors6, itv));
1847 ***************************************************************************
1848 * Display CPU frequency statistics. This function is used to display
1849 * instantaneous and average statistics.
1852 * @a Activity structure with statistics.
1853 * @curr Index in array for current sample statistics.
1854 * @dispavg True if displaying average statistics.
1855 ***************************************************************************
1857 void stub_print_pwr_cpufreq_stats(struct activity *a, int curr, int dispavg)
1860 struct stats_pwr_cpufreq *spc;
1861 static unsigned long long
1862 *avg_cpufreq = NULL;
1865 /* Allocate array of CPU frequency */
1866 if ((avg_cpufreq = (unsigned long long *) malloc(sizeof(unsigned long long) * a->nr))
1871 memset(avg_cpufreq, 0, sizeof(unsigned long long) * a->nr);
1875 print_hdr_line(timestamp[!curr], a, FIRST, 7, 9);
1878 for (i = 0; (i < a->nr) && (i < a->bitmap->b_size + 1); i++) {
1881 * The size of a->buf[...] CPU structure may be different from the default
1882 * sizeof(struct stats_pwr_cpufreq) value if data have been read from a file!
1883 * That's why we don't use a syntax like:
1884 * spc = (struct stats_pwr_cpufreq *) a->buf[...] + i;
1886 spc = (struct stats_pwr_cpufreq *) ((char *) a->buf[curr] + i * a->msize);
1889 * Note: a->nr is in [1, NR_CPUS + 1].
1890 * Bitmap size is provided for (NR_CPUS + 1) CPUs.
1891 * Anyway, NR_CPUS may vary between the version of sysstat
1892 * used by sadc to create a file, and the version of sysstat
1893 * used by sar to read it...
1896 /* Should current CPU (including CPU "all") be displayed? */
1897 if (a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))) {
1899 /* Yes: Display it */
1900 printf("%-11s", timestamp[curr]);
1903 /* This is CPU "all" */
1904 cprintf_in(IS_STR, "%s", " all", 0);
1907 cprintf_in(IS_INT, " %3d", "", i - 1);
1911 /* Display instantaneous values */
1912 cprintf_f(-1, 1, 9, 2,
1913 ((double) spc->cpufreq) / 100);
1916 * Will be used to compute the average.
1917 * Note: overflow unlikely to happen but not impossible...
1919 avg_cpufreq[i] += spc->cpufreq;
1922 /* Display average values */
1923 cprintf_f(-1, 1, 9, 2,
1924 (double) avg_cpufreq[i] / (100 * avg_count));
1931 /* Array of CPU frequency no longer needed: Free it! */
1940 ***************************************************************************
1941 * Display CPU frequency statistics.
1944 * @a Activity structure with statistics.
1945 * @prev Index in array where stats used as reference are.
1946 * @curr Index in array for current sample statistics.
1947 * @itv Interval of time in jiffies.
1948 ***************************************************************************
1950 __print_funct_t print_pwr_cpufreq_stats(struct activity *a, int prev, int curr,
1951 unsigned long long itv)
1953 stub_print_pwr_cpufreq_stats(a, curr, FALSE);
1957 ***************************************************************************
1958 * Display average CPU frequency statistics.
1961 * @a Activity structure with statistics.
1962 * @prev Index in array where stats used as reference are.
1963 * @curr Index in array for current sample statistics.
1964 * @itv Interval of time in jiffies.
1965 ***************************************************************************
1967 __print_funct_t print_avg_pwr_cpufreq_stats(struct activity *a, int prev, int curr,
1968 unsigned long long itv)
1970 stub_print_pwr_cpufreq_stats(a, curr, TRUE);
1974 ***************************************************************************
1975 * Display fan statistics. This function is used to display
1976 * instantaneous and average statistics.
1979 * @a Activity structure with statistics.
1980 * @curr Index in array for current sample statistics.
1981 * @dispavg True if displaying average statistics.
1982 ***************************************************************************
1984 void stub_print_pwr_fan_stats(struct activity *a, int curr, int dispavg)
1987 struct stats_pwr_fan *spc;
1988 static double *avg_fan = NULL;
1989 static double *avg_fan_min = NULL;
1991 /* Allocate arrays of fan RPMs */
1993 if ((avg_fan = (double *) malloc(sizeof(double) * a->nr)) == NULL) {
1997 memset(avg_fan, 0, sizeof(double) * a->nr);
2000 if ((avg_fan_min = (double *) malloc(sizeof(double) * a->nr)) == NULL) {
2004 memset(avg_fan_min, 0, sizeof(double) * a->nr);
2008 print_hdr_line(timestamp[!curr], a, FIRST, -2, 9);
2011 for (i = 0; i < a->nr; i++) {
2012 spc = (struct stats_pwr_fan *) ((char *) a->buf[curr] + i * a->msize);
2014 printf("%-11s", timestamp[curr]);
2015 cprintf_in(IS_INT, " %5d", "", i + 1);
2018 /* Display average values */
2019 cprintf_f(-1, 2, 9, 2,
2020 (double) avg_fan[i] / avg_count,
2021 (double) (avg_fan[i] - avg_fan_min[i]) / avg_count);
2024 /* Display instantaneous values */
2025 cprintf_f(-1, 2, 9, 2,
2027 spc->rpm - spc->rpm_min);
2028 avg_fan[i] += spc->rpm;
2029 avg_fan_min[i] += spc->rpm_min;
2032 cprintf_in(IS_STR, " %s\n", spc->device, 0);
2048 ***************************************************************************
2049 * Display fan statistics.
2052 * @a Activity structure with statistics.
2053 * @prev Index in array where stats used as reference are.
2054 * @curr Index in array for current sample statistics.
2055 * @itv Interval of time in jiffies.
2056 ***************************************************************************
2058 __print_funct_t print_pwr_fan_stats(struct activity *a, int prev, int curr,
2059 unsigned long long itv)
2061 stub_print_pwr_fan_stats(a, curr, FALSE);
2065 ***************************************************************************
2066 * Display average fan statistics.
2069 * @a Activity structure with statistics.
2070 * @prev Index in array where stats used as reference are.
2071 * @curr Index in array for current sample statistics.
2072 * @itv Interval of time in jiffies.
2073 ***************************************************************************
2075 __print_funct_t print_avg_pwr_fan_stats(struct activity *a, int prev, int curr,
2076 unsigned long long itv)
2078 stub_print_pwr_fan_stats(a, curr, TRUE);
2082 ***************************************************************************
2083 * Display device temperature statistics. This function is used to display
2084 * instantaneous and average statistics.
2087 * @a Activity structure with statistics.
2088 * @curr Index in array for current sample statistics.
2089 * @dispavg True if displaying average statistics.
2090 ***************************************************************************
2092 void stub_print_pwr_temp_stats(struct activity *a, int curr, int dispavg)
2095 struct stats_pwr_temp *spc;
2096 static double *avg_temp = NULL;
2097 static double *avg_temp_min = NULL, *avg_temp_max = NULL;
2099 /* Allocate arrays of temperatures */
2101 if ((avg_temp = (double *) malloc(sizeof(double) * a->nr)) == NULL) {
2105 memset(avg_temp, 0, sizeof(double) * a->nr);
2107 if (!avg_temp_min) {
2108 if ((avg_temp_min = (double *) malloc(sizeof(double) * a->nr)) == NULL) {
2112 memset(avg_temp_min, 0, sizeof(double) * a->nr);
2114 if (!avg_temp_max) {
2115 if ((avg_temp_max = (double *) malloc(sizeof(double) * a->nr)) == NULL) {
2119 memset(avg_temp_max, 0, sizeof(double) * a->nr);
2123 print_hdr_line(timestamp[!curr], a, FIRST, -2, 9);
2126 for (i = 0; i < a->nr; i++) {
2127 spc = (struct stats_pwr_temp *) ((char *) a->buf[curr] + i * a->msize);
2129 printf("%-11s", timestamp[curr]);
2130 cprintf_in(IS_INT, " %5d", "", i + 1);
2133 /* Display average values */
2134 cprintf_f(-1, 1, 9, 2, (double) avg_temp[i] / avg_count);
2136 (avg_temp_max[i] - avg_temp_min[i]) ?
2137 ((double) (avg_temp[i] / avg_count) - avg_temp_min[i]) / (avg_temp_max[i] - avg_temp_min[i]) * 100
2141 /* Display instantaneous values */
2142 cprintf_f(-1, 1, 9, 2, spc->temp);
2144 (spc->temp_max - spc->temp_min) ?
2145 (spc->temp - spc->temp_min) / (spc->temp_max - spc->temp_min) * 100
2147 avg_temp[i] += spc->temp;
2148 /* Assume that min and max temperatures cannot vary */
2149 avg_temp_min[i] = spc->temp_min;
2150 avg_temp_max[i] = spc->temp_max;
2153 cprintf_in(IS_STR, " %s\n", spc->device, 0);
2163 avg_temp_min = NULL;
2167 avg_temp_max = NULL;
2173 ***************************************************************************
2174 * Display temperature statistics.
2177 * @a Activity structure with statistics.
2178 * @prev Index in array where stats used as reference are.
2179 * @curr Index in array for current sample statistics.
2180 * @itv Interval of time in jiffies.
2181 ***************************************************************************
2183 __print_funct_t print_pwr_temp_stats(struct activity *a, int prev, int curr,
2184 unsigned long long itv)
2186 stub_print_pwr_temp_stats(a, curr, FALSE);
2190 ***************************************************************************
2191 * Display average temperature statistics.
2194 * @a Activity structure with statistics.
2195 * @prev Index in array where stats used as reference are.
2196 * @curr Index in array for current sample statistics.
2197 * @itv Interval of time in jiffies.
2198 ***************************************************************************
2200 __print_funct_t print_avg_pwr_temp_stats(struct activity *a, int prev, int curr,
2201 unsigned long long itv)
2203 stub_print_pwr_temp_stats(a, curr, TRUE);
2207 ***************************************************************************
2208 * Display voltage inputs statistics. This function is used to display
2209 * instantaneous and average statistics.
2212 * @a Activity structure with statistics.
2213 * @curr Index in array for current sample statistics.
2214 * @dispavg True if displaying average statistics.
2215 ***************************************************************************
2217 void stub_print_pwr_in_stats(struct activity *a, int curr, int dispavg)
2220 struct stats_pwr_in *spc;
2221 static double *avg_in = NULL;
2222 static double *avg_in_min = NULL, *avg_in_max = NULL;
2224 /* Allocate arrays of voltage inputs */
2226 if ((avg_in = (double *) malloc(sizeof(double) * a->nr)) == NULL) {
2230 memset(avg_in, 0, sizeof(double) * a->nr);
2233 if ((avg_in_min = (double *) malloc(sizeof(double) * a->nr)) == NULL) {
2237 memset(avg_in_min, 0, sizeof(double) * a->nr);
2240 if ((avg_in_max = (double *) malloc(sizeof(double) * a->nr)) == NULL) {
2244 memset(avg_in_max, 0, sizeof(double) * a->nr);
2248 print_hdr_line(timestamp[!curr], a, FIRST, -2, 9);
2251 for (i = 0; i < a->nr; i++) {
2252 spc = (struct stats_pwr_in *) ((char *) a->buf[curr] + i * a->msize);
2254 printf("%-11s", timestamp[curr]);
2255 cprintf_in(IS_INT, " %5d", "", i);
2258 /* Display average values */
2259 cprintf_f(-1, 1, 9, 2, (double) avg_in[i] / avg_count);
2261 (avg_in_max[i] - avg_in_min[i]) ?
2262 ((double) (avg_in[i] / avg_count) - avg_in_min[i]) / (avg_in_max[i] - avg_in_min[i]) * 100
2266 /* Display instantaneous values */
2267 cprintf_f(-1, 1, 9, 2, spc->in);
2269 (spc->in_max - spc->in_min) ?
2270 (spc->in - spc->in_min) / (spc->in_max - spc->in_min) * 100
2272 avg_in[i] += spc->in;
2273 /* Assume that min and max voltage inputs cannot vary */
2274 avg_in_min[i] = spc->in_min;
2275 avg_in_max[i] = spc->in_max;
2278 cprintf_in(IS_STR, " %s\n", spc->device, 0);
2298 ***************************************************************************
2299 * Display voltage inputs statistics.
2302 * @a Activity structure with statistics.
2303 * @prev Index in array where stats used as reference are.
2304 * @curr Index in array for current sample statistics.
2305 * @itv Interval of time in jiffies.
2306 ***************************************************************************
2308 __print_funct_t print_pwr_in_stats(struct activity *a, int prev, int curr,
2309 unsigned long long itv)
2311 stub_print_pwr_in_stats(a, curr, FALSE);
2315 ***************************************************************************
2316 * Display average voltage inputs statistics.
2319 * @a Activity structure with statistics.
2320 * @prev Index in array where stats used as reference are.
2321 * @curr Index in array for current sample statistics.
2322 * @itv Interval of time in jiffies.
2323 ***************************************************************************
2325 __print_funct_t print_avg_pwr_in_stats(struct activity *a, int prev, int curr,
2326 unsigned long long itv)
2328 stub_print_pwr_in_stats(a, curr, TRUE);
2332 ***************************************************************************
2333 * Display huge pages statistics. This function is used to
2334 * display instantaneous and average statistics.
2337 * @a Activity structure with statistics.
2338 * @curr Index in array for current sample statistics.
2339 * @dispavg TRUE if displaying average statistics.
2340 ***************************************************************************
2342 void stub_print_huge_stats(struct activity *a, int curr, int dispavg)
2345 *smc = (struct stats_huge *) a->buf[curr];
2346 static unsigned long long
2351 if (DISPLAY_UNIT(flags)) {
2352 /* Default values unit is kB */
2357 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
2361 /* Display instantaneous values */
2362 printf("%-11s", timestamp[curr]);
2363 cprintf_u64(unit, 2, 9,
2364 (unsigned long long) smc->frhkb,
2365 (unsigned long long) (smc->tlhkb - smc->frhkb));
2368 SP_VALUE(smc->frhkb, smc->tlhkb, smc->tlhkb) : 0.0);
2371 /* Will be used to compute the average */
2372 avg_frhkb += smc->frhkb;
2373 avg_tlhkb += smc->tlhkb;
2376 /* Display average values */
2377 printf("%-11s", timestamp[curr]);
2378 cprintf_f(unit, 2, 9, 0,
2379 (double) avg_frhkb / avg_count,
2380 ((double) avg_tlhkb / avg_count) -
2381 ((double) avg_frhkb / avg_count));
2384 SP_VALUE((double) avg_frhkb / avg_count,
2385 (double) avg_tlhkb / avg_count,
2386 (double) avg_tlhkb / avg_count) : 0.0);
2389 /* Reset average counters */
2390 avg_frhkb = avg_tlhkb = 0;
2395 ***************************************************************************
2396 * Display huge pages statistics.
2399 * @a Activity structure with statistics.
2400 * @prev Index in array where stats used as reference are.
2401 * @curr Index in array for current sample statistics.
2402 * @itv Interval of time in jiffies.
2403 ***************************************************************************
2405 __print_funct_t print_huge_stats(struct activity *a, int prev, int curr,
2406 unsigned long long itv)
2408 stub_print_huge_stats(a, curr, FALSE);
2412 ***************************************************************************
2413 * Display huge pages statistics.
2416 * @a Activity structure with statistics.
2417 * @prev Index in array where stats used as reference are.
2418 * @curr Index in array for current sample statistics.
2419 * @itv Interval of time in jiffies.
2420 ***************************************************************************
2422 __print_funct_t print_avg_huge_stats(struct activity *a, int prev, int curr,
2423 unsigned long long itv)
2425 stub_print_huge_stats(a, curr, TRUE);
2429 ***************************************************************************
2430 * Display CPU weighted frequency statistics. This function is used to
2431 * display instantaneous and average statistics.
2434 * @a Activity structure with statistics.
2435 * @prev Index in array where stats used as reference are.
2436 * @curr Index in array for current sample statistics.
2437 * @itv Interval of time in jiffies.
2438 ***************************************************************************
2440 void print_pwr_wghfreq_stats(struct activity *a, int prev, int curr,
2441 unsigned long long itv)
2444 struct stats_pwr_wghfreq *spc, *spp, *spc_k, *spp_k;
2445 unsigned long long tis, tisfreq;
2448 print_hdr_line(timestamp[!curr], a, FIRST, 7, 9);
2451 for (i = 0; (i < a->nr) && (i < a->bitmap->b_size + 1); i++) {
2454 * The size of a->buf[...] CPU structure may be different from the default
2455 * sizeof(struct stats_pwr_wghfreq) value if data have been read from a file!
2456 * That's why we don't use a syntax like:
2457 * spc = (struct stats_pwr_wghfreq *) a->buf[...] + i;
2459 spc = (struct stats_pwr_wghfreq *) ((char *) a->buf[curr] + i * a->msize * a->nr2);
2460 spp = (struct stats_pwr_wghfreq *) ((char *) a->buf[prev] + i * a->msize * a->nr2);
2463 * Note: a->nr is in [1, NR_CPUS + 1].
2464 * Bitmap size is provided for (NR_CPUS + 1) CPUs.
2465 * Anyway, NR_CPUS may vary between the version of sysstat
2466 * used by sadc to create a file, and the version of sysstat
2467 * used by sar to read it...
2470 /* Should current CPU (including CPU "all") be displayed? */
2471 if (a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))) {
2473 /* Yes: Display it */
2474 printf("%-11s", timestamp[curr]);
2477 /* This is CPU "all" */
2478 cprintf_in(IS_STR, "%s", " all", 0);
2481 cprintf_in(IS_INT, " %3d", "", i - 1);
2487 for (k = 0; k < a->nr2; k++) {
2489 spc_k = (struct stats_pwr_wghfreq *) ((char *) spc + k * a->msize);
2492 spp_k = (struct stats_pwr_wghfreq *) ((char *) spp + k * a->msize);
2494 tisfreq += (spc_k->freq / 1000) *
2495 (spc_k->time_in_state - spp_k->time_in_state);
2496 tis += (spc_k->time_in_state - spp_k->time_in_state);
2499 /* Display weighted frequency for current CPU */
2500 cprintf_f(-1, 1, 9, 2,
2501 tis ? ((double) tisfreq) / tis : 0.0);
2508 ***************************************************************************
2509 * Display USB devices statistics. This function is used to
2510 * display instantaneous and summary statistics.
2513 * @a Activity structure with statistics.
2514 * @curr Index in array for current sample statistics.
2515 * @itv Interval of time in jiffies.
2516 * @dispavg TRUE if displaying average statistics.
2517 ***************************************************************************
2519 void stub_print_pwr_usb_stats(struct activity *a, int curr, int dispavg)
2523 struct stats_pwr_usb *suc, *sum;
2526 printf("\n%-11s BUS idvendor idprod maxpower",
2527 (dispavg ? _("Summary:") : timestamp[!curr]));
2528 printf(" %-*s product\n", MAX_MANUF_LEN - 1, "manufact");
2531 for (i = 0; i < a->nr; i++) {
2532 suc = (struct stats_pwr_usb *) ((char *) a->buf[curr] + i * a->msize);
2535 /* Bus#0 doesn't exist: We are at the end of the list */
2538 printf("%-11s", (dispavg ? _("Summary:") : timestamp[curr]));
2539 cprintf_in(IS_INT, " %6d", "", suc->bus_nr);
2543 cprintf_u64(-1, 1, 9,
2544 /* bMaxPower is expressed in 2 mA units */
2545 (unsigned long long) (suc->bmaxpower << 1));
2547 snprintf(fmt, 16, " %%-%ds", MAX_MANUF_LEN - 1);
2548 cprintf_s(IS_STR, fmt, suc->manufacturer);
2549 cprintf_s(IS_STR, " %s\n", suc->product);
2552 /* Save current USB device in summary list */
2553 for (j = 0; j < a->nr; j++) {
2554 sum = (struct stats_pwr_usb *) ((char *) a->buf[2] + j * a->msize);
2556 if ((sum->bus_nr == suc->bus_nr) &&
2557 (sum->vendor_id == suc->vendor_id) &&
2558 (sum->product_id == suc->product_id))
2559 /* USB device found in summary list */
2563 * Current slot is free:
2564 * Save USB device in summary list.
2569 if (j == a->nr - 1) {
2571 * This is the last slot and
2572 * we still havent't found the device.
2573 * So create a dummy device here.
2576 sum->vendor_id = sum->product_id = 0;
2578 sum->manufacturer[0] = '\0';
2579 snprintf(sum->product, MAX_PROD_LEN, "%s",
2580 _("Other devices not listed here"));
2581 sum->product[MAX_PROD_LEN - 1] = '\0';
2589 ***************************************************************************
2590 * Display USB devices statistics.
2593 * @a Activity structure with statistics.
2594 * @prev Index in array where stats used as reference are.
2595 * @curr Index in array for current sample statistics.
2596 * @itv Interval of time in jiffies.
2597 ***************************************************************************
2599 __print_funct_t print_pwr_usb_stats(struct activity *a, int prev, int curr,
2600 unsigned long long itv)
2602 stub_print_pwr_usb_stats(a, curr, FALSE);
2606 ***************************************************************************
2607 * Display average USB devices statistics.
2610 * @a Activity structure with statistics.
2611 * @prev Index in array where stats used as reference are.
2612 * @curr Index in array for current sample statistics.
2613 * @itv Interval of time in jiffies.
2614 ***************************************************************************
2616 __print_funct_t print_avg_pwr_usb_stats(struct activity *a, int prev, int curr,
2617 unsigned long long itv)
2619 stub_print_pwr_usb_stats(a, 2, TRUE);
2623 ***************************************************************************
2624 * Display filesystems statistics. This function is used to
2625 * display instantaneous and average statistics.
2628 * @a Activity structure with statistics.
2629 * @curr Index in array for current sample statistics.
2630 * @dispavg TRUE if displaying average statistics.
2631 ***************************************************************************
2633 __print_funct_t stub_print_filesystem_stats(struct activity *a, int curr, int dispavg)
2636 struct stats_filesystem *sfc, *sfm;
2639 if (DISPLAY_UNIT(flags)) {
2640 /* Default values unit is B */
2645 print_hdr_line((dispavg ? _("Summary:") : timestamp[!curr]),
2646 a, FIRST + DISPLAY_MOUNT(a->opt_flags), -1, 9);
2649 for (i = 0; i < a->nr; i++) {
2650 sfc = (struct stats_filesystem *) ((char *) a->buf[curr] + i * a->msize);
2653 /* Size of filesystem is zero: We are at the end of the list */
2656 printf("%-11s", (dispavg ? _("Summary:") : timestamp[curr]));
2657 cprintf_f(unit, 2, 9, 0,
2658 unit < 0 ? (double) sfc->f_bfree / 1024 / 1024 : (double) sfc->f_bfree,
2659 unit < 0 ? (double) (sfc->f_blocks - sfc->f_bfree) / 1024 / 1024 :
2660 (double) (sfc->f_blocks - sfc->f_bfree));
2662 /* f_blocks is not zero. But test it anyway ;-) */
2663 sfc->f_blocks ? SP_VALUE(sfc->f_bfree, sfc->f_blocks, sfc->f_blocks)
2665 sfc->f_blocks ? SP_VALUE(sfc->f_bavail, sfc->f_blocks, sfc->f_blocks)
2667 cprintf_u64(-1, 2, 9,
2668 (unsigned long long) sfc->f_ffree,
2669 (unsigned long long) (sfc->f_files - sfc->f_ffree));
2671 sfc->f_files ? SP_VALUE(sfc->f_ffree, sfc->f_files, sfc->f_files)
2673 cprintf_in(IS_STR, " %s\n",
2674 DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name, 0);
2677 /* Save current filesystem in summary list */
2678 for (j = 0; j < a->nr; j++) {
2679 sfm = (struct stats_filesystem *) ((char *) a->buf[2] + j * a->msize);
2681 if (!strcmp(sfm->fs_name, sfc->fs_name) ||
2684 * Filesystem found in list (then save again its stats)
2685 * or free slot (end of list).
2696 ***************************************************************************
2697 * Display filesystems statistics.
2700 * @a Activity structure with statistics.
2701 * @prev Index in array where stats used as reference are.
2702 * @curr Index in array for current sample statistics.
2703 * @itv Interval of time in jiffies.
2704 ***************************************************************************
2706 __print_funct_t print_filesystem_stats(struct activity *a, int prev, int curr,
2707 unsigned long long itv)
2709 stub_print_filesystem_stats(a, curr, FALSE);
2713 ***************************************************************************
2714 * Display average filesystems statistics.
2717 * @a Activity structure with statistics.
2718 * @prev Index in array where stats used as reference are.
2719 * @curr Index in array for current sample statistics.
2720 * @itv Interval of time in jiffies.
2721 ***************************************************************************
2723 __print_funct_t print_avg_filesystem_stats(struct activity *a, int prev, int curr,
2724 unsigned long long itv)
2726 stub_print_filesystem_stats(a, 2, TRUE);
2730 ***************************************************************************
2731 * Display Fibre Channel HBA statistics.
2734 * @a Activity structure with statistics.
2735 * @prev Index in array where stats used as reference are.
2736 * @curr Index in array for current sample statistics.
2737 * @itv Interval of time in jiffies.
2738 ***************************************************************************
2740 __print_funct_t print_fchost_stats(struct activity *a, int prev, int curr,
2741 unsigned long long itv)
2744 struct stats_fchost *sfcc,*sfcp;
2747 print_hdr_line(timestamp[!curr], a, FIRST, -1, 9);
2750 for (i = 0; i < a->nr; i++) {
2752 sfcc = (struct stats_fchost *) ((char *) a->buf[curr] + i * a->msize);
2753 sfcp = (struct stats_fchost *) ((char *) a->buf[prev] + i * a->msize);
2755 if (!sfcc->fchost_name[0])
2756 /* We are at the end of the list */
2759 printf("%-11s", timestamp[curr]);
2760 cprintf_f(-1, 4, 9, 2,
2761 S_VALUE(sfcp->f_rxframes, sfcc->f_rxframes, itv),
2762 S_VALUE(sfcp->f_txframes, sfcc->f_txframes, itv),
2763 S_VALUE(sfcp->f_rxwords, sfcc->f_rxwords, itv),
2764 S_VALUE(sfcp->f_txwords, sfcc->f_txwords, itv));
2765 cprintf_in(IS_STR, " %s\n", sfcc->fchost_name, 0);
2770 ***************************************************************************
2771 * Display softnet statistics.
2774 * @a Activity structure with statistics.
2775 * @prev Index in array where stats used as reference are.
2776 * @curr Index in array for current sample statistics.
2777 * @itv Interval of time in jiffies.
2778 ***************************************************************************
2780 __print_funct_t print_softnet_stats(struct activity *a, int prev, int curr,
2781 unsigned long long itv)
2783 struct stats_softnet
2784 *ssnc = (struct stats_softnet *) a->buf[curr],
2785 *ssnp = (struct stats_softnet *) a->buf[prev];
2789 print_hdr_line(timestamp[!curr], a, FIRST, 7, 9);
2792 for (i = 0; (i < a->nr) && (i < a->bitmap->b_size + 1); i++) {
2795 * The size of a->buf[...] CPU structure may be different from the default
2796 * sizeof(struct stats_pwr_cpufreq) value if data have been read from a file!
2797 * That's why we don't use a syntax like:
2798 * ssnc = (struct stats_softnet *) a->buf[...] + i;
2800 ssnc = (struct stats_softnet *) ((char *) a->buf[curr] + i * a->msize);
2801 ssnp = (struct stats_softnet *) ((char *) a->buf[prev] + i * a->msize);
2804 * Note: a->nr is in [1, NR_CPUS + 1].
2805 * Bitmap size is provided for (NR_CPUS + 1) CPUs.
2806 * Anyway, NR_CPUS may vary between the version of sysstat
2807 * used by sadc to create a file, and the version of sysstat
2808 * used by sar to read it...
2811 /* Should current CPU (including CPU "all") be displayed? */
2812 if (a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))) {
2814 /* Yes: Display it */
2815 printf("%-11s", timestamp[curr]);
2818 /* This is CPU "all" */
2819 cprintf_in(IS_STR, " %s", " all", 0);
2822 cprintf_in(IS_INT, " %7d", "", i - 1);
2825 cprintf_f(-1, 5, 9, 2,
2826 S_VALUE(ssnp->processed, ssnc->processed, itv),
2827 S_VALUE(ssnp->dropped, ssnc->dropped, itv),
2828 S_VALUE(ssnp->time_squeeze, ssnc->time_squeeze, itv),
2829 S_VALUE(ssnp->received_rps, ssnc->received_rps, itv),
2830 S_VALUE(ssnp->flow_limit, ssnc->flow_limit, itv));