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))) {
153 /* Yes: Display it */
154 printf("%-11s", timestamp[curr]);
157 /* This is CPU "all" */
158 cprintf_in(IS_STR, " %s", " all", 0);
161 cprintf_in(IS_INT, " %7d", "", i - 1);
164 * If the CPU is offline then it is omited from /proc/stat:
165 * All the fields couldn't have been read and the sum of them is zero.
166 * (Remember that guest/guest_nice times are already included in
169 if ((scc->cpu_user + scc->cpu_nice + scc->cpu_sys +
170 scc->cpu_iowait + scc->cpu_idle + scc->cpu_steal +
171 scc->cpu_hardirq + scc->cpu_softirq) == 0) {
173 * Set current struct fields (which have been set to zero)
174 * to values from previous iteration. Hence their values won't
175 * jump from zero when the CPU comes back online.
179 /* %user, %nice, %system, %iowait, %steal, ..., %idle */
181 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
183 if (DISPLAY_CPU_ALL(a->opt_flags)) {
185 * Four additional fields to display:
186 * %irq, %soft, %guest, %gnice.
195 /* Recalculate interval for current proc */
196 g_itv = get_per_cpu_interval(scc, scp);
200 * If the CPU is tickless then there is no change in CPU values
201 * but the sum of values is not zero.
202 * %user, %nice, %system, %iowait, %steal, ..., %idle
205 0.0, 0.0, 0.0, 0.0, 0.0);
207 if (DISPLAY_CPU_DEF(a->opt_flags)) {
208 cprintf_pc(1, 9, 2, 100.0);
212 * Four additional fields to display:
213 * %irq, %soft, %guest, %gnice.
215 else if (DISPLAY_CPU_ALL(a->opt_flags)) {
217 0.0, 0.0, 0.0, 100.0);
224 if (DISPLAY_CPU_DEF(a->opt_flags)) {
226 ll_sp_value(scp->cpu_user, scc->cpu_user, g_itv),
227 ll_sp_value(scp->cpu_nice, scc->cpu_nice, g_itv),
228 ll_sp_value(scp->cpu_sys + scp->cpu_hardirq + scp->cpu_softirq,
229 scc->cpu_sys + scc->cpu_hardirq + scc->cpu_softirq,
231 ll_sp_value(scp->cpu_iowait, scc->cpu_iowait, g_itv),
232 ll_sp_value(scp->cpu_steal, scc->cpu_steal, g_itv),
233 scc->cpu_idle < scp->cpu_idle ?
235 ll_sp_value(scp->cpu_idle, scc->cpu_idle, g_itv));
238 else if (DISPLAY_CPU_ALL(a->opt_flags)) {
240 (scc->cpu_user - scc->cpu_guest) < (scp->cpu_user - scp->cpu_guest) ?
242 ll_sp_value(scp->cpu_user - scp->cpu_guest,
243 scc->cpu_user - scc->cpu_guest, g_itv),
244 (scc->cpu_nice - scc->cpu_guest_nice) < (scp->cpu_nice - scp->cpu_guest_nice) ?
246 ll_sp_value(scp->cpu_nice - scp->cpu_guest_nice,
247 scc->cpu_nice - scc->cpu_guest_nice, g_itv),
248 ll_sp_value(scp->cpu_sys, scc->cpu_sys, g_itv),
249 ll_sp_value(scp->cpu_iowait, scc->cpu_iowait, g_itv),
250 ll_sp_value(scp->cpu_steal, scc->cpu_steal, g_itv),
251 ll_sp_value(scp->cpu_hardirq, scc->cpu_hardirq, g_itv),
252 ll_sp_value(scp->cpu_softirq, scc->cpu_softirq, g_itv),
253 ll_sp_value(scp->cpu_guest, scc->cpu_guest, g_itv),
254 ll_sp_value(scp->cpu_guest_nice, scc->cpu_guest_nice, g_itv),
255 scc->cpu_idle < scp->cpu_idle ?
257 ll_sp_value(scp->cpu_idle, scc->cpu_idle, g_itv));
265 ***************************************************************************
266 * Display tasks creation and context switches statistics.
269 * @a Activity structure with statistics.
270 * @prev Index in array where stats used as reference are.
271 * @curr Index in array for current sample statistics.
272 * @itv Interval of time in jiffies.
273 ***************************************************************************
275 __print_funct_t print_pcsw_stats(struct activity *a, int prev, int curr,
276 unsigned long long itv)
279 *spc = (struct stats_pcsw *) a->buf[curr],
280 *spp = (struct stats_pcsw *) a->buf[prev];
283 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
286 printf("%-11s", timestamp[curr]);
288 S_VALUE(spp->processes, spc->processes, itv),
289 S_VALUE(spp->context_switch, spc->context_switch, itv));
294 ***************************************************************************
295 * Display interrupts statistics.
298 * @a Activity structure with statistics.
299 * @prev Index in array where stats used as reference are.
300 * @curr Index in array for current sample statistics.
301 * @itv Interval of time in jiffies.
302 ***************************************************************************
304 __print_funct_t print_irq_stats(struct activity *a, int prev, int curr,
305 unsigned long long itv)
308 struct stats_irq *sic, *sip;
311 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
314 for (i = 0; (i < a->nr) && (i < a->bitmap->b_size + 1); i++) {
316 sic = (struct stats_irq *) ((char *) a->buf[curr] + i * a->msize);
317 sip = (struct stats_irq *) ((char *) a->buf[prev] + i * a->msize);
320 * Note: a->nr is in [0, NR_IRQS + 1].
321 * Bitmap size is provided for (NR_IRQS + 1) interrupts.
322 * Anyway, NR_IRQS may vary between the version of sysstat
323 * used by sadc to create a file, and the version of sysstat
324 * used by sar to read it...
327 /* Should current interrupt (including int "sum") be displayed? */
328 if (a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))) {
330 /* Yes: Display it */
331 printf("%-11s", timestamp[curr]);
333 /* This is interrupt "sum" */
334 cprintf_in(IS_STR, " %s", " sum", 0);
337 cprintf_in(IS_INT, " %9d", "", i -1);
340 cprintf_f(1, 9, 2, S_VALUE(sip->irq_nr, sic->irq_nr, itv));
347 ***************************************************************************
348 * Display swapping statistics.
351 * @a Activity structure with statistics.
352 * @prev Index in array where stats used as reference are.
353 * @curr Index in array for current sample statistics.
354 * @itv Interval of time in jiffies.
355 ***************************************************************************
357 __print_funct_t print_swap_stats(struct activity *a, int prev, int curr,
358 unsigned long long itv)
361 *ssc = (struct stats_swap *) a->buf[curr],
362 *ssp = (struct stats_swap *) a->buf[prev];
365 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
368 printf("%-11s", timestamp[curr]);
370 S_VALUE(ssp->pswpin, ssc->pswpin, itv),
371 S_VALUE(ssp->pswpout, ssc->pswpout, itv));
376 ***************************************************************************
377 * Display paging statistics.
380 * @a Activity structure with statistics.
381 * @prev Index in array where stats used as reference are.
382 * @curr Index in array for current sample statistics.
383 * @itv Interval of time in jiffies.
384 ***************************************************************************
386 __print_funct_t print_paging_stats(struct activity *a, int prev, int curr,
387 unsigned long long itv)
390 *spc = (struct stats_paging *) a->buf[curr],
391 *spp = (struct stats_paging *) a->buf[prev];
394 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
397 printf("%-11s", timestamp[curr]);
399 S_VALUE(spp->pgpgin, spc->pgpgin, itv),
400 S_VALUE(spp->pgpgout, spc->pgpgout, itv),
401 S_VALUE(spp->pgfault, spc->pgfault, itv),
402 S_VALUE(spp->pgmajfault, spc->pgmajfault, itv),
403 S_VALUE(spp->pgfree, spc->pgfree, itv),
404 S_VALUE(spp->pgscan_kswapd, spc->pgscan_kswapd, itv),
405 S_VALUE(spp->pgscan_direct, spc->pgscan_direct, itv),
406 S_VALUE(spp->pgsteal, spc->pgsteal, itv));
408 (spc->pgscan_kswapd + spc->pgscan_direct -
409 spp->pgscan_kswapd - spp->pgscan_direct) ?
410 SP_VALUE(spp->pgsteal, spc->pgsteal,
411 spc->pgscan_kswapd + spc->pgscan_direct -
412 spp->pgscan_kswapd - spp->pgscan_direct)
418 ***************************************************************************
419 * Display I/O and transfer rate statistics.
422 * @a Activity structure with statistics.
423 * @prev Index in array where stats used as reference are.
424 * @curr Index in array for current sample statistics.
425 * @itv Interval of time in jiffies.
426 ***************************************************************************
428 __print_funct_t print_io_stats(struct activity *a, int prev, int curr,
429 unsigned long long itv)
432 *sic = (struct stats_io *) a->buf[curr],
433 *sip = (struct stats_io *) a->buf[prev];
436 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
439 printf("%-11s", timestamp[curr]);
441 * If we get negative values, this is probably because
442 * one or more devices/filesystems have been unmounted.
443 * We display 0.0 in this case though we should rather tell
444 * the user that the value cannot be calculated here.
447 sic->dk_drive < sip->dk_drive ? 0.0 :
448 S_VALUE(sip->dk_drive, sic->dk_drive, itv),
449 sic->dk_drive_rio < sip->dk_drive_rio ? 0.0 :
450 S_VALUE(sip->dk_drive_rio, sic->dk_drive_rio, itv),
451 sic->dk_drive_wio < sip->dk_drive_wio ? 0.0 :
452 S_VALUE(sip->dk_drive_wio, sic->dk_drive_wio, itv),
453 sic->dk_drive_rblk < sip->dk_drive_rblk ? 0.0 :
454 S_VALUE(sip->dk_drive_rblk, sic->dk_drive_rblk, itv),
455 sic->dk_drive_wblk < sip->dk_drive_wblk ? 0.0 :
456 S_VALUE(sip->dk_drive_wblk, sic->dk_drive_wblk, itv));
461 ***************************************************************************
462 * Display memory and swap statistics. This function is used to
463 * display instantaneous and average statistics.
466 * @a Activity structure with statistics.
467 * @prev Index in array where stats used as reference are.
468 * @curr Index in array for current sample statistics.
469 * @itv Interval of time in jiffies.
470 * @dispavg TRUE if displaying average statistics.
471 ***************************************************************************
473 void stub_print_memory_stats(struct activity *a, int prev, int curr,
474 unsigned long long itv, int dispavg)
477 *smc = (struct stats_memory *) a->buf[curr],
478 *smp = (struct stats_memory *) a->buf[prev];
479 static unsigned long long
492 static unsigned long long
497 if (DISPLAY_MEMORY(a->opt_flags)) {
499 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
502 printf("%-11s", timestamp[curr]);
504 S_VALUE((double) KB_TO_PG(smp->frmkb), (double) KB_TO_PG(smc->frmkb), itv),
505 S_VALUE((double) KB_TO_PG(smp->bufkb), (double) KB_TO_PG(smc->bufkb), itv),
506 S_VALUE((double) KB_TO_PG(smp->camkb), (double) KB_TO_PG(smc->camkb), itv));
510 if (DISPLAY_MEM_AMT(a->opt_flags)) {
512 print_hdr_line(timestamp[!curr], a, SECOND, 0, 9);
516 /* Display instantaneous values */
517 printf("%-11s", timestamp[curr]);
519 (unsigned long long) smc->frmkb,
520 (unsigned long long) (smc->tlmkb - smc->frmkb));
523 SP_VALUE(smc->frmkb, smc->tlmkb, smc->tlmkb)
526 (unsigned long long) smc->bufkb,
527 (unsigned long long) smc->camkb,
528 (unsigned long long) smc->comkb);
530 (smc->tlmkb + smc->tlskb) ?
531 SP_VALUE(0, smc->comkb, smc->tlmkb + smc->tlskb)
534 (unsigned long long) smc->activekb,
535 (unsigned long long) smc->inactkb,
536 (unsigned long long) smc->dirtykb);
538 if (DISPLAY_MEM_ALL(a->opt_flags)) {
539 /* Display extended memory statistics */
541 (unsigned long long) smc->anonpgkb,
542 (unsigned long long) smc->slabkb,
543 (unsigned long long) smc->kstackkb,
544 (unsigned long long) smc->pgtblkb,
545 (unsigned long long) smc->vmusedkb);
551 * Will be used to compute the average.
552 * We assume that the total amount of memory installed can not vary
553 * during the interval given on the command line.
555 avg_frmkb += smc->frmkb;
556 avg_bufkb += smc->bufkb;
557 avg_camkb += smc->camkb;
558 avg_comkb += smc->comkb;
559 avg_activekb += smc->activekb;
560 avg_inactkb += smc->inactkb;
561 avg_dirtykb += smc->dirtykb;
562 avg_anonpgkb += smc->anonpgkb;
563 avg_slabkb += smc->slabkb;
564 avg_kstackkb += smc->kstackkb;
565 avg_pgtblkb += smc->pgtblkb;
566 avg_vmusedkb += smc->vmusedkb;
569 /* Display average values */
570 printf("%-11s", timestamp[curr]);
572 (double) avg_frmkb / avg_count,
573 (double) smc->tlmkb - ((double) avg_frmkb / avg_count));
576 SP_VALUE((double) (avg_frmkb / avg_count), smc->tlmkb, smc->tlmkb)
579 (double) avg_bufkb / avg_count,
580 (double) avg_camkb / avg_count,
581 (double) avg_comkb / avg_count);
583 (smc->tlmkb + smc->tlskb) ?
584 SP_VALUE(0.0, (double) (avg_comkb / avg_count), smc->tlmkb + smc->tlskb)
587 (double) avg_activekb / avg_count,
588 (double) avg_inactkb / avg_count,
589 (double) avg_dirtykb / avg_count);
591 if (DISPLAY_MEM_ALL(a->opt_flags)) {
593 (double) avg_anonpgkb / avg_count,
594 (double) avg_slabkb / avg_count,
595 (double) avg_kstackkb / avg_count,
596 (double) avg_pgtblkb / avg_count,
597 (double) avg_vmusedkb / avg_count);
602 /* Reset average counters */
603 avg_frmkb = avg_bufkb = avg_camkb = avg_comkb = 0;
604 avg_activekb = avg_inactkb = avg_dirtykb = 0;
605 avg_anonpgkb = avg_slabkb = avg_kstackkb = 0;
606 avg_pgtblkb = avg_vmusedkb = 0;
610 if (DISPLAY_SWAP(a->opt_flags)) {
612 print_hdr_line(timestamp[!curr], a, THIRD, 0, 9);
616 /* Display instantaneous values */
617 printf("%-11s", timestamp[curr]);
619 (unsigned long long) smc->frskb,
620 (unsigned long long) (smc->tlskb - smc->frskb));
623 SP_VALUE(smc->frskb, smc->tlskb, smc->tlskb)
626 (unsigned long long) smc->caskb);
628 (smc->tlskb - smc->frskb) ?
629 SP_VALUE(0, smc->caskb, smc->tlskb - smc->frskb)
635 * Will be used to compute the average.
636 * We assume that the total amount of swap space may vary.
638 avg_frskb += smc->frskb;
639 avg_tlskb += smc->tlskb;
640 avg_caskb += smc->caskb;
643 /* Display average values */
644 printf("%-11s", timestamp[curr]);
646 (double) avg_frskb / avg_count,
647 ((double) avg_tlskb / avg_count) -
648 ((double) avg_frskb / avg_count));
651 SP_VALUE((double) avg_frskb / avg_count,
652 (double) avg_tlskb / avg_count,
653 (double) avg_tlskb / avg_count)
656 (double) avg_caskb / avg_count);
658 (avg_tlskb != avg_frskb) ?
659 SP_VALUE(0.0, (double) avg_caskb / avg_count,
660 ((double) avg_tlskb / avg_count) -
661 ((double) avg_frskb / avg_count))
665 /* Reset average counters */
666 avg_frskb = avg_tlskb = avg_caskb = 0;
672 ***************************************************************************
673 * Display memory and swap statistics.
676 * @a Activity structure with statistics.
677 * @prev Index in array where stats used as reference are.
678 * @curr Index in array for current sample statistics.
679 * @itv Interval of time in jiffies.
680 ***************************************************************************
682 __print_funct_t print_memory_stats(struct activity *a, int prev, int curr,
683 unsigned long long itv)
685 stub_print_memory_stats(a, prev, curr, itv, FALSE);
689 ***************************************************************************
690 * Display average memory statistics.
693 * @a Activity structure with statistics.
694 * @prev Index in array where stats used as reference are.
695 * @curr Index in array for current sample statistics.
696 * @itv Interval of time in jiffies.
697 ***************************************************************************
699 __print_funct_t print_avg_memory_stats(struct activity *a, int prev, int curr,
700 unsigned long long itv)
702 stub_print_memory_stats(a, prev, curr, itv, TRUE);
706 ***************************************************************************
707 * Display kernel tables statistics. This function is used to display
708 * instantaneous and average statistics.
711 * @a Activity structure with statistics.
712 * @curr Index in array for current sample statistics.
713 * @dispavg True if displaying average statistics.
714 ***************************************************************************
716 void stub_print_ktables_stats(struct activity *a, int curr, int dispavg)
719 *skc = (struct stats_ktables *) a->buf[curr];
720 static unsigned long long
728 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
732 /* Display instantaneous values */
733 printf("%-11s", timestamp[curr]);
735 (unsigned long long) skc->dentry_stat,
736 (unsigned long long) skc->file_used,
737 (unsigned long long) skc->inode_used,
738 (unsigned long long) skc->pty_nr);
742 * Will be used to compute the average.
743 * Note: Overflow unlikely to happen but not impossible...
745 avg_dentry_stat += skc->dentry_stat;
746 avg_file_used += skc->file_used;
747 avg_inode_used += skc->inode_used;
748 avg_pty_nr += skc->pty_nr;
751 /* Display average values */
752 printf("%-11s", timestamp[curr]);
754 (double) avg_dentry_stat / avg_count,
755 (double) avg_file_used / avg_count,
756 (double) avg_inode_used / avg_count,
757 (double) avg_pty_nr / avg_count);
760 /* Reset average counters */
761 avg_dentry_stat = avg_file_used = avg_inode_used = avg_pty_nr = 0;
766 ***************************************************************************
767 * Display kernel tables statistics.
770 * @a Activity structure with statistics.
771 * @prev Index in array where stats used as reference are.
772 * @curr Index in array for current sample statistics.
773 * @itv Interval of time in jiffies.
774 ***************************************************************************
776 __print_funct_t print_ktables_stats(struct activity *a, int prev, int curr,
777 unsigned long long itv)
779 stub_print_ktables_stats(a, curr, FALSE);
783 ***************************************************************************
784 * Display average kernel tables statistics.
787 * @a Activity structure with statistics.
788 * @prev Index in array where stats used as reference are.
789 * @curr Index in array for current sample statistics.
790 * @itv Interval of time in jiffies.
791 ***************************************************************************
793 __print_funct_t print_avg_ktables_stats(struct activity *a, int prev, int curr,
794 unsigned long long itv)
796 stub_print_ktables_stats(a, curr, TRUE);
800 ***************************************************************************
801 * Display queue and load statistics. This function is used to display
802 * instantaneous and average statistics.
805 * @a Activity structure with statistics.
806 * @curr Index in array for current sample statistics.
807 * @dispavg TRUE if displaying average statistics.
808 ***************************************************************************
810 void stub_print_queue_stats(struct activity *a, int curr, int dispavg)
813 *sqc = (struct stats_queue *) a->buf[curr];
814 static unsigned long long
820 avg_procs_blocked = 0;
823 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
827 /* Display instantaneous values */
828 printf("%-11s", timestamp[curr]);
830 (unsigned long long) sqc->nr_running,
831 (unsigned long long) sqc->nr_threads);
833 (double) sqc->load_avg_1 / 100,
834 (double) sqc->load_avg_5 / 100,
835 (double) sqc->load_avg_15 / 100);
837 (unsigned long long) sqc->procs_blocked);
840 /* Will be used to compute the average */
841 avg_nr_running += sqc->nr_running;
842 avg_nr_threads += sqc->nr_threads;
843 avg_load_avg_1 += sqc->load_avg_1;
844 avg_load_avg_5 += sqc->load_avg_5;
845 avg_load_avg_15 += sqc->load_avg_15;
846 avg_procs_blocked += sqc->procs_blocked;
849 /* Display average values */
850 printf("%-11s", timestamp[curr]);
852 (double) avg_nr_running / avg_count,
853 (double) avg_nr_threads / avg_count);
855 (double) avg_load_avg_1 / (avg_count * 100),
856 (double) avg_load_avg_5 / (avg_count * 100),
857 (double) avg_load_avg_15 / (avg_count * 100));
859 (double) avg_procs_blocked / avg_count);
862 /* Reset average counters */
863 avg_nr_running = avg_nr_threads = 0;
864 avg_load_avg_1 = avg_load_avg_5 = avg_load_avg_15 = 0;
865 avg_procs_blocked = 0;
870 ***************************************************************************
871 * Display queue and load statistics.
874 * @a Activity structure with statistics.
875 * @prev Index in array where stats used as reference are.
876 * @curr Index in array for current sample statistics.
877 * @itv Interval of time in jiffies.
878 ***************************************************************************
880 __print_funct_t print_queue_stats(struct activity *a, int prev, int curr,
881 unsigned long long itv)
883 stub_print_queue_stats(a, curr, FALSE);
887 ***************************************************************************
888 * Display average queue and load statistics.
891 * @a Activity structure with statistics.
892 * @prev Index in array where stats used as reference are.
893 * @curr Index in array for current sample statistics.
894 * @itv Interval of time in jiffies.
895 ***************************************************************************
897 __print_funct_t print_avg_queue_stats(struct activity *a, int prev, int curr,
898 unsigned long long itv)
900 stub_print_queue_stats(a, curr, TRUE);
904 ***************************************************************************
905 * Display serial lines statistics.
908 * @a Activity structure with statistics.
909 * @prev Index in array where stats used as reference are.
910 * @curr Index in array for current sample statistics.
911 * @itv Interval of time in jiffies.
912 ***************************************************************************
914 __print_funct_t print_serial_stats(struct activity *a, int prev, int curr,
915 unsigned long long itv)
918 struct stats_serial *ssc, *ssp;
921 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
924 for (i = 0; i < a->nr; i++) {
926 ssc = (struct stats_serial *) ((char *) a->buf[curr] + i * a->msize);
927 ssp = (struct stats_serial *) ((char *) a->buf[prev] + i * a->msize);
932 printf("%-11s", timestamp[curr]);
933 cprintf_in(IS_INT, " %3d", "", ssc->line - 1);
935 if ((ssc->line == ssp->line) || WANT_SINCE_BOOT(flags)) {
937 S_VALUE(ssp->rx, ssc->rx, itv),
938 S_VALUE(ssp->tx, ssc->tx, itv),
939 S_VALUE(ssp->frame, ssc->frame, itv),
940 S_VALUE(ssp->parity, ssc->parity, itv),
941 S_VALUE(ssp->brk, ssc->brk, itv),
942 S_VALUE(ssp->overrun, ssc->overrun, itv));
946 printf(" N/A N/A N/A N/A"
953 ***************************************************************************
954 * Display disks statistics.
957 * @a Activity structure with statistics.
958 * @prev Index in array where stats used as reference are.
959 * @curr Index in array for current sample statistics.
960 * @itv Interval of time in jiffies.
961 ***************************************************************************
963 __print_funct_t print_disk_stats(struct activity *a, int prev, int curr,
964 unsigned long long itv)
967 struct stats_disk *sdc, *sdp;
968 struct ext_disk_stats xds;
969 char *dev_name, *persist_dev_name;
972 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
975 for (i = 0; i < a->nr; i++) {
977 sdc = (struct stats_disk *) ((char *) a->buf[curr] + i * a->msize);
979 if (!(sdc->major + sdc->minor))
982 j = check_disk_reg(a, curr, prev, i);
983 sdp = (struct stats_disk *) ((char *) a->buf[prev] + j * a->msize);
985 /* Compute service time, etc. */
986 compute_ext_disk_stats(sdc, sdp, itv, &xds);
989 persist_dev_name = NULL;
991 if (DISPLAY_PERSIST_NAME_S(flags)) {
992 persist_dev_name = get_persistent_name_from_pretty(get_devname(sdc->major, sdc->minor, TRUE));
995 if (persist_dev_name) {
996 dev_name = persist_dev_name;
999 if ((USE_PRETTY_OPTION(flags)) && (sdc->major == dm_major)) {
1000 dev_name = transform_devmapname(sdc->major, sdc->minor);
1004 dev_name = get_devname(sdc->major, sdc->minor,
1005 USE_PRETTY_OPTION(flags));
1009 printf("%-11s", timestamp[curr]);
1011 cprintf_in(IS_STR, " %9s", dev_name, 0);
1013 S_VALUE(sdp->nr_ios, sdc->nr_ios, itv),
1014 S_VALUE(sdp->rd_sect, sdc->rd_sect, itv),
1015 S_VALUE(sdp->wr_sect, sdc->wr_sect, itv),
1016 /* See iostat for explanations */
1018 S_VALUE(sdp->rq_ticks, sdc->rq_ticks, itv) / 1000.0,
1028 ***************************************************************************
1029 * Display network interfaces statistics.
1032 * @a Activity structure with statistics.
1033 * @prev Index in array where stats used as reference are.
1034 * @curr Index in array for current sample statistics.
1035 * @itv Interval of time in jiffies.
1036 ***************************************************************************
1038 __print_funct_t print_net_dev_stats(struct activity *a, int prev, int curr,
1039 unsigned long long itv)
1042 struct stats_net_dev *sndc, *sndp;
1043 double rxkb, txkb, ifutil;
1046 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
1049 for (i = 0; i < a->nr; i++) {
1051 sndc = (struct stats_net_dev *) ((char *) a->buf[curr] + i * a->msize);
1053 if (!strcmp(sndc->interface, ""))
1056 j = check_net_dev_reg(a, curr, prev, i);
1057 sndp = (struct stats_net_dev *) ((char *) a->buf[prev] + j * a->msize);
1059 printf("%-11s", timestamp[curr]);
1060 cprintf_in(IS_STR, " %9s", sndc->interface, 0);
1062 rxkb = S_VALUE(sndp->rx_bytes, sndc->rx_bytes, itv);
1063 txkb = S_VALUE(sndp->tx_bytes, sndc->tx_bytes, itv);
1066 S_VALUE(sndp->rx_packets, sndc->rx_packets, itv),
1067 S_VALUE(sndp->tx_packets, sndc->tx_packets, itv),
1070 S_VALUE(sndp->rx_compressed, sndc->rx_compressed, itv),
1071 S_VALUE(sndp->tx_compressed, sndc->tx_compressed, itv),
1072 S_VALUE(sndp->multicast, sndc->multicast, itv));
1073 ifutil = compute_ifutil(sndc, rxkb, txkb);
1074 cprintf_pc(1, 9, 2, ifutil);
1080 ***************************************************************************
1081 * Display network interface errors statistics.
1084 * @a Activity structure with statistics.
1085 * @prev Index in array where stats used as reference are.
1086 * @curr Index in array for current sample statistics.
1087 * @itv Interval of time in jiffies.
1088 ***************************************************************************
1090 __print_funct_t print_net_edev_stats(struct activity *a, int prev, int curr,
1091 unsigned long long itv)
1094 struct stats_net_edev *snedc, *snedp;
1097 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
1100 for (i = 0; i < a->nr; i++) {
1102 snedc = (struct stats_net_edev *) ((char *) a->buf[curr] + i * a->msize);
1104 if (!strcmp(snedc->interface, ""))
1107 j = check_net_edev_reg(a, curr, prev, i);
1108 snedp = (struct stats_net_edev *) ((char *) a->buf[prev] + j * a->msize);
1110 printf("%-11s", timestamp[curr]);
1111 cprintf_in(IS_STR, " %9s", snedc->interface, 0);
1114 S_VALUE(snedp->rx_errors, snedc->rx_errors, itv),
1115 S_VALUE(snedp->tx_errors, snedc->tx_errors, itv),
1116 S_VALUE(snedp->collisions, snedc->collisions, itv),
1117 S_VALUE(snedp->rx_dropped, snedc->rx_dropped, itv),
1118 S_VALUE(snedp->tx_dropped, snedc->tx_dropped, itv),
1119 S_VALUE(snedp->tx_carrier_errors, snedc->tx_carrier_errors, itv),
1120 S_VALUE(snedp->rx_frame_errors, snedc->rx_frame_errors, itv),
1121 S_VALUE(snedp->rx_fifo_errors, snedc->rx_fifo_errors, itv),
1122 S_VALUE(snedp->tx_fifo_errors, snedc->tx_fifo_errors, itv));
1128 ***************************************************************************
1129 * Display NFS client statistics.
1132 * @a Activity structure with statistics.
1133 * @prev Index in array where stats used as reference are.
1134 * @curr Index in array for current sample statistics.
1135 * @itv Interval of time in jiffies.
1136 ***************************************************************************
1138 __print_funct_t print_net_nfs_stats(struct activity *a, int prev, int curr,
1139 unsigned long long itv)
1141 struct stats_net_nfs
1142 *snnc = (struct stats_net_nfs *) a->buf[curr],
1143 *snnp = (struct stats_net_nfs *) a->buf[prev];
1146 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
1149 printf("%-11s", timestamp[curr]);
1151 S_VALUE(snnp->nfs_rpccnt, snnc->nfs_rpccnt, itv),
1152 S_VALUE(snnp->nfs_rpcretrans, snnc->nfs_rpcretrans, itv),
1153 S_VALUE(snnp->nfs_readcnt, snnc->nfs_readcnt, itv),
1154 S_VALUE(snnp->nfs_writecnt, snnc->nfs_writecnt, itv),
1155 S_VALUE(snnp->nfs_accesscnt, snnc->nfs_accesscnt, itv),
1156 S_VALUE(snnp->nfs_getattcnt, snnc->nfs_getattcnt, itv));
1161 ***************************************************************************
1162 * Display NFS server statistics.
1165 * @a Activity structure with statistics.
1166 * @prev Index in array where stats used as reference are.
1167 * @curr Index in array for current sample statistics.
1168 * @itv Interval of time in jiffies.
1169 ***************************************************************************
1171 __print_funct_t print_net_nfsd_stats(struct activity *a, int prev, int curr,
1172 unsigned long long itv)
1174 struct stats_net_nfsd
1175 *snndc = (struct stats_net_nfsd *) a->buf[curr],
1176 *snndp = (struct stats_net_nfsd *) a->buf[prev];
1179 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
1182 printf("%-11s", timestamp[curr]);
1184 S_VALUE(snndp->nfsd_rpccnt, snndc->nfsd_rpccnt, itv),
1185 S_VALUE(snndp->nfsd_rpcbad, snndc->nfsd_rpcbad, itv),
1186 S_VALUE(snndp->nfsd_netcnt, snndc->nfsd_netcnt, itv),
1187 S_VALUE(snndp->nfsd_netudpcnt, snndc->nfsd_netudpcnt, itv),
1188 S_VALUE(snndp->nfsd_nettcpcnt, snndc->nfsd_nettcpcnt, itv),
1189 S_VALUE(snndp->nfsd_rchits, snndc->nfsd_rchits, itv),
1190 S_VALUE(snndp->nfsd_rcmisses, snndc->nfsd_rcmisses, itv),
1191 S_VALUE(snndp->nfsd_readcnt, snndc->nfsd_readcnt, itv),
1192 S_VALUE(snndp->nfsd_writecnt, snndc->nfsd_writecnt, itv),
1193 S_VALUE(snndp->nfsd_accesscnt, snndc->nfsd_accesscnt, itv),
1194 S_VALUE(snndp->nfsd_getattcnt, snndc->nfsd_getattcnt, itv));
1199 ***************************************************************************
1200 * Display network sockets statistics. This function is used to display
1201 * instantaneous and average statistics.
1204 * @a Activity structure with statistics.
1205 * @curr Index in array for current sample statistics.
1206 * @dispavg TRUE if displaying average statistics.
1207 ***************************************************************************
1209 void stub_print_net_sock_stats(struct activity *a, int curr, int dispavg)
1211 struct stats_net_sock
1212 *snsc = (struct stats_net_sock *) a->buf[curr];
1213 static unsigned long long
1222 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
1226 /* Display instantaneous values */
1227 printf("%-11s", timestamp[curr]);
1229 (unsigned long long) snsc->sock_inuse,
1230 (unsigned long long) snsc->tcp_inuse,
1231 (unsigned long long) snsc->udp_inuse,
1232 (unsigned long long) snsc->raw_inuse,
1233 (unsigned long long) snsc->frag_inuse,
1234 (unsigned long long) snsc->tcp_tw);
1237 /* Will be used to compute the average */
1238 avg_sock_inuse += snsc->sock_inuse;
1239 avg_tcp_inuse += snsc->tcp_inuse;
1240 avg_udp_inuse += snsc->udp_inuse;
1241 avg_raw_inuse += snsc->raw_inuse;
1242 avg_frag_inuse += snsc->frag_inuse;
1243 avg_tcp_tw += snsc->tcp_tw;
1246 /* Display average values */
1247 printf("%-11s", timestamp[curr]);
1249 (double) avg_sock_inuse / avg_count,
1250 (double) avg_tcp_inuse / avg_count,
1251 (double) avg_udp_inuse / avg_count,
1252 (double) avg_raw_inuse / avg_count,
1253 (double) avg_frag_inuse / avg_count,
1254 (double) avg_tcp_tw / avg_count);
1257 /* Reset average counters */
1258 avg_sock_inuse = avg_tcp_inuse = avg_udp_inuse = 0;
1259 avg_raw_inuse = avg_frag_inuse = avg_tcp_tw = 0;
1264 ***************************************************************************
1265 * Display network sockets statistics.
1268 * @a Activity structure with statistics.
1269 * @prev Index in array where stats used as reference are.
1270 * @curr Index in array for current sample statistics.
1271 * @itv Interval of time in jiffies.
1272 ***************************************************************************
1274 __print_funct_t print_net_sock_stats(struct activity *a, int prev, int curr,
1275 unsigned long long itv)
1277 stub_print_net_sock_stats(a, curr, FALSE);
1281 ***************************************************************************
1282 * Display average network sockets statistics.
1285 * @a Activity structure with statistics.
1286 * @prev Index in array where stats used as reference are.
1287 * @curr Index in array for current sample statistics.
1288 * @itv Interval of time in jiffies.
1289 ***************************************************************************
1291 __print_funct_t print_avg_net_sock_stats(struct activity *a, int prev, int curr,
1292 unsigned long long itv)
1294 stub_print_net_sock_stats(a, curr, TRUE);
1298 ***************************************************************************
1299 * Display IP network traffic statistics.
1302 * @a Activity structure with statistics.
1303 * @prev Index in array where stats used as reference are.
1304 * @curr Index in array for current sample statistics.
1305 * @itv Interval of time in jiffies.
1306 ***************************************************************************
1308 __print_funct_t print_net_ip_stats(struct activity *a, int prev, int curr,
1309 unsigned long long itv)
1312 *snic = (struct stats_net_ip *) a->buf[curr],
1313 *snip = (struct stats_net_ip *) a->buf[prev];
1316 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
1319 printf("%-11s", timestamp[curr]);
1321 S_VALUE(snip->InReceives, snic->InReceives, itv),
1322 S_VALUE(snip->ForwDatagrams, snic->ForwDatagrams, itv),
1323 S_VALUE(snip->InDelivers, snic->InDelivers, itv),
1324 S_VALUE(snip->OutRequests, snic->OutRequests, itv),
1325 S_VALUE(snip->ReasmReqds, snic->ReasmReqds, itv),
1326 S_VALUE(snip->ReasmOKs, snic->ReasmOKs, itv),
1327 S_VALUE(snip->FragOKs, snic->FragOKs, itv),
1328 S_VALUE(snip->FragCreates, snic->FragCreates, itv));
1333 ***************************************************************************
1334 * Display IP network errors statistics.
1337 * @a Activity structure with statistics.
1338 * @prev Index in array where stats used as reference are.
1339 * @curr Index in array for current sample statistics.
1340 * @itv Interval of time in jiffies.
1341 ***************************************************************************
1343 __print_funct_t print_net_eip_stats(struct activity *a, int prev, int curr,
1344 unsigned long long itv)
1346 struct stats_net_eip
1347 *sneic = (struct stats_net_eip *) a->buf[curr],
1348 *sneip = (struct stats_net_eip *) a->buf[prev];
1351 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
1354 printf("%-11s", timestamp[curr]);
1356 S_VALUE(sneip->InHdrErrors, sneic->InHdrErrors, itv),
1357 S_VALUE(sneip->InAddrErrors, sneic->InAddrErrors, itv),
1358 S_VALUE(sneip->InUnknownProtos, sneic->InUnknownProtos, itv),
1359 S_VALUE(sneip->InDiscards, sneic->InDiscards, itv),
1360 S_VALUE(sneip->OutDiscards, sneic->OutDiscards, itv),
1361 S_VALUE(sneip->OutNoRoutes, sneic->OutNoRoutes, itv),
1362 S_VALUE(sneip->ReasmFails, sneic->ReasmFails, itv),
1363 S_VALUE(sneip->FragFails, sneic->FragFails, itv));
1368 ***************************************************************************
1369 * Display ICMP network traffic statistics.
1372 * @a Activity structure with statistics.
1373 * @prev Index in array where stats used as reference are.
1374 * @curr Index in array for current sample statistics.
1375 * @itv Interval of time in jiffies.
1376 ***************************************************************************
1378 __print_funct_t print_net_icmp_stats(struct activity *a, int prev, int curr,
1379 unsigned long long itv)
1381 struct stats_net_icmp
1382 *snic = (struct stats_net_icmp *) a->buf[curr],
1383 *snip = (struct stats_net_icmp *) a->buf[prev];
1386 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
1389 printf("%-11s", timestamp[curr]);
1391 S_VALUE(snip->InMsgs, snic->InMsgs, itv),
1392 S_VALUE(snip->OutMsgs, snic->OutMsgs, itv),
1393 S_VALUE(snip->InEchos, snic->InEchos, itv),
1394 S_VALUE(snip->InEchoReps, snic->InEchoReps, itv),
1395 S_VALUE(snip->OutEchos, snic->OutEchos, itv),
1396 S_VALUE(snip->OutEchoReps, snic->OutEchoReps, itv),
1397 S_VALUE(snip->InTimestamps, snic->InTimestamps, itv),
1398 S_VALUE(snip->InTimestampReps, snic->InTimestampReps, itv),
1399 S_VALUE(snip->OutTimestamps, snic->OutTimestamps, itv),
1400 S_VALUE(snip->OutTimestampReps, snic->OutTimestampReps, itv),
1401 S_VALUE(snip->InAddrMasks, snic->InAddrMasks, itv),
1402 S_VALUE(snip->InAddrMaskReps, snic->InAddrMaskReps, itv),
1403 S_VALUE(snip->OutAddrMasks, snic->OutAddrMasks, itv),
1404 S_VALUE(snip->OutAddrMaskReps, snic->OutAddrMaskReps, itv));
1409 ***************************************************************************
1410 * Display ICMP network errors statistics.
1413 * @a Activity structure with statistics.
1414 * @prev Index in array where stats used as reference are.
1415 * @curr Index in array for current sample statistics.
1416 * @itv Interval of time in jiffies.
1417 ***************************************************************************
1419 __print_funct_t print_net_eicmp_stats(struct activity *a, int prev, int curr,
1420 unsigned long long itv)
1422 struct stats_net_eicmp
1423 *sneic = (struct stats_net_eicmp *) a->buf[curr],
1424 *sneip = (struct stats_net_eicmp *) a->buf[prev];
1427 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
1430 printf("%-11s", timestamp[curr]);
1432 S_VALUE(sneip->InErrors, sneic->InErrors, itv),
1433 S_VALUE(sneip->OutErrors, sneic->OutErrors, itv),
1434 S_VALUE(sneip->InDestUnreachs, sneic->InDestUnreachs, itv),
1435 S_VALUE(sneip->OutDestUnreachs, sneic->OutDestUnreachs, itv),
1436 S_VALUE(sneip->InTimeExcds, sneic->InTimeExcds, itv),
1437 S_VALUE(sneip->OutTimeExcds, sneic->OutTimeExcds, itv),
1438 S_VALUE(sneip->InParmProbs, sneic->InParmProbs, itv),
1439 S_VALUE(sneip->OutParmProbs, sneic->OutParmProbs, itv),
1440 S_VALUE(sneip->InSrcQuenchs, sneic->InSrcQuenchs, itv),
1441 S_VALUE(sneip->OutSrcQuenchs, sneic->OutSrcQuenchs, itv),
1442 S_VALUE(sneip->InRedirects, sneic->InRedirects, itv),
1443 S_VALUE(sneip->OutRedirects, sneic->OutRedirects, itv));
1448 ***************************************************************************
1449 * Display TCP network traffic statistics.
1452 * @a Activity structure with statistics.
1453 * @prev Index in array where stats used as reference are.
1454 * @curr Index in array for current sample statistics.
1455 * @itv Interval of time in jiffies.
1456 ***************************************************************************
1458 __print_funct_t print_net_tcp_stats(struct activity *a, int prev, int curr,
1459 unsigned long long itv)
1461 struct stats_net_tcp
1462 *sntc = (struct stats_net_tcp *) a->buf[curr],
1463 *sntp = (struct stats_net_tcp *) a->buf[prev];
1466 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
1469 printf("%-11s", timestamp[curr]);
1471 S_VALUE(sntp->ActiveOpens, sntc->ActiveOpens, itv),
1472 S_VALUE(sntp->PassiveOpens, sntc->PassiveOpens, itv),
1473 S_VALUE(sntp->InSegs, sntc->InSegs, itv),
1474 S_VALUE(sntp->OutSegs, sntc->OutSegs, itv));
1479 ***************************************************************************
1480 * Display TCP network errors statistics.
1483 * @a Activity structure with statistics.
1484 * @prev Index in array where stats used as reference are.
1485 * @curr Index in array for current sample statistics.
1486 * @itv Interval of time in jiffies.
1487 ***************************************************************************
1489 __print_funct_t print_net_etcp_stats(struct activity *a, int prev, int curr,
1490 unsigned long long itv)
1492 struct stats_net_etcp
1493 *snetc = (struct stats_net_etcp *) a->buf[curr],
1494 *snetp = (struct stats_net_etcp *) a->buf[prev];
1497 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
1500 printf("%-11s", timestamp[curr]);
1502 S_VALUE(snetp->AttemptFails, snetc->AttemptFails, itv),
1503 S_VALUE(snetp->EstabResets, snetc->EstabResets, itv),
1504 S_VALUE(snetp->RetransSegs, snetc->RetransSegs, itv),
1505 S_VALUE(snetp->InErrs, snetc->InErrs, itv),
1506 S_VALUE(snetp->OutRsts, snetc->OutRsts, itv));
1511 ***************************************************************************
1512 * Display UDP network traffic statistics.
1515 * @a Activity structure with statistics.
1516 * @prev Index in array where stats used as reference are.
1517 * @curr Index in array for current sample statistics.
1518 * @itv Interval of time in jiffies.
1519 ***************************************************************************
1521 __print_funct_t print_net_udp_stats(struct activity *a, int prev, int curr,
1522 unsigned long long itv)
1524 struct stats_net_udp
1525 *snuc = (struct stats_net_udp *) a->buf[curr],
1526 *snup = (struct stats_net_udp *) a->buf[prev];
1529 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
1532 printf("%-11s", timestamp[curr]);
1534 S_VALUE(snup->InDatagrams, snuc->InDatagrams, itv),
1535 S_VALUE(snup->OutDatagrams, snuc->OutDatagrams, itv),
1536 S_VALUE(snup->NoPorts, snuc->NoPorts, itv),
1537 S_VALUE(snup->InErrors, snuc->InErrors, itv));
1542 ***************************************************************************
1543 * Display IPv6 sockets statistics. This function is used to display
1544 * instantaneous and average statistics.
1547 * @a Activity structure with statistics.
1548 * @curr Index in array for current sample statistics.
1549 * @dispavg TRUE if displaying average statistics.
1550 ***************************************************************************
1552 void stub_print_net_sock6_stats(struct activity *a, int curr, int dispavg)
1554 struct stats_net_sock6
1555 *snsc = (struct stats_net_sock6 *) a->buf[curr];
1556 static unsigned long long
1560 avg_frag6_inuse = 0;
1563 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
1567 /* Display instantaneous values */
1568 printf("%-11s", timestamp[curr]);
1570 (unsigned long long) snsc->tcp6_inuse,
1571 (unsigned long long) snsc->udp6_inuse,
1572 (unsigned long long) snsc->raw6_inuse,
1573 (unsigned long long) snsc->frag6_inuse);
1576 /* Will be used to compute the average */
1577 avg_tcp6_inuse += snsc->tcp6_inuse;
1578 avg_udp6_inuse += snsc->udp6_inuse;
1579 avg_raw6_inuse += snsc->raw6_inuse;
1580 avg_frag6_inuse += snsc->frag6_inuse;
1583 /* Display average values */
1584 printf("%-11s", timestamp[curr]);
1586 (double) avg_tcp6_inuse / avg_count,
1587 (double) avg_udp6_inuse / avg_count,
1588 (double) avg_raw6_inuse / avg_count,
1589 (double) avg_frag6_inuse / avg_count);
1592 /* Reset average counters */
1593 avg_tcp6_inuse = avg_udp6_inuse = avg_raw6_inuse = avg_frag6_inuse = 0;
1598 ***************************************************************************
1599 * Display IPv6 sockets statistics.
1602 * @a Activity structure with statistics.
1603 * @prev Index in array where stats used as reference are.
1604 * @curr Index in array for current sample statistics.
1605 * @itv Interval of time in jiffies.
1606 ***************************************************************************
1608 __print_funct_t print_net_sock6_stats(struct activity *a, int prev, int curr,
1609 unsigned long long itv)
1611 stub_print_net_sock6_stats(a, curr, FALSE);
1615 ***************************************************************************
1616 * Display average IPv6 sockets statistics.
1619 * @a Activity structure with statistics.
1620 * @prev Index in array where stats used as reference are.
1621 * @curr Index in array for current sample statistics.
1622 * @itv Interval of time in jiffies.
1623 ***************************************************************************
1625 __print_funct_t print_avg_net_sock6_stats(struct activity *a, int prev, int curr,
1626 unsigned long long itv)
1628 stub_print_net_sock6_stats(a, curr, TRUE);
1632 ***************************************************************************
1633 * Display IPv6 network traffic statistics.
1636 * @a Activity structure with statistics.
1637 * @prev Index in array where stats used as reference are.
1638 * @curr Index in array for current sample statistics.
1639 * @itv Interval of time in jiffies.
1640 ***************************************************************************
1642 __print_funct_t print_net_ip6_stats(struct activity *a, int prev, int curr,
1643 unsigned long long itv)
1645 struct stats_net_ip6
1646 *snic = (struct stats_net_ip6 *) a->buf[curr],
1647 *snip = (struct stats_net_ip6 *) a->buf[prev];
1650 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
1653 printf("%-11s", timestamp[curr]);
1655 S_VALUE(snip->InReceives6, snic->InReceives6, itv),
1656 S_VALUE(snip->OutForwDatagrams6, snic->OutForwDatagrams6, itv),
1657 S_VALUE(snip->InDelivers6, snic->InDelivers6, itv),
1658 S_VALUE(snip->OutRequests6, snic->OutRequests6, itv),
1659 S_VALUE(snip->ReasmReqds6, snic->ReasmReqds6, itv),
1660 S_VALUE(snip->ReasmOKs6, snic->ReasmOKs6, itv),
1661 S_VALUE(snip->InMcastPkts6, snic->InMcastPkts6, itv),
1662 S_VALUE(snip->OutMcastPkts6, snic->OutMcastPkts6, itv),
1663 S_VALUE(snip->FragOKs6, snic->FragOKs6, itv),
1664 S_VALUE(snip->FragCreates6, snic->FragCreates6, itv));
1669 ***************************************************************************
1670 * Display IPv6 network errors statistics.
1673 * @a Activity structure with statistics.
1674 * @prev Index in array where stats used as reference are.
1675 * @curr Index in array for current sample statistics.
1676 * @itv Interval of time in jiffies.
1677 ***************************************************************************
1679 __print_funct_t print_net_eip6_stats(struct activity *a, int prev, int curr,
1680 unsigned long long itv)
1682 struct stats_net_eip6
1683 *sneic = (struct stats_net_eip6 *) a->buf[curr],
1684 *sneip = (struct stats_net_eip6 *) a->buf[prev];
1687 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
1690 printf("%-11s", timestamp[curr]);
1692 S_VALUE(sneip->InHdrErrors6, sneic->InHdrErrors6, itv),
1693 S_VALUE(sneip->InAddrErrors6, sneic->InAddrErrors6, itv),
1694 S_VALUE(sneip->InUnknownProtos6, sneic->InUnknownProtos6, itv),
1695 S_VALUE(sneip->InTooBigErrors6, sneic->InTooBigErrors6, itv),
1696 S_VALUE(sneip->InDiscards6, sneic->InDiscards6, itv),
1697 S_VALUE(sneip->OutDiscards6, sneic->OutDiscards6, itv),
1698 S_VALUE(sneip->InNoRoutes6, sneic->InNoRoutes6, itv),
1699 S_VALUE(sneip->OutNoRoutes6, sneic->OutNoRoutes6, itv),
1700 S_VALUE(sneip->ReasmFails6, sneic->ReasmFails6, itv),
1701 S_VALUE(sneip->FragFails6, sneic->FragFails6, itv),
1702 S_VALUE(sneip->InTruncatedPkts6, sneic->InTruncatedPkts6, itv));
1707 ***************************************************************************
1708 * Display ICMPv6 network traffic statistics.
1711 * @a Activity structure with statistics.
1712 * @prev Index in array where stats used as reference are.
1713 * @curr Index in array for current sample statistics.
1714 * @itv Interval of time in jiffies.
1715 ***************************************************************************
1717 __print_funct_t print_net_icmp6_stats(struct activity *a, int prev, int curr,
1718 unsigned long long itv)
1720 struct stats_net_icmp6
1721 *snic = (struct stats_net_icmp6 *) a->buf[curr],
1722 *snip = (struct stats_net_icmp6 *) a->buf[prev];
1725 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
1728 printf("%-11s", timestamp[curr]);
1730 S_VALUE(snip->InMsgs6, snic->InMsgs6, itv),
1731 S_VALUE(snip->OutMsgs6, snic->OutMsgs6, itv),
1732 S_VALUE(snip->InEchos6, snic->InEchos6, itv),
1733 S_VALUE(snip->InEchoReplies6, snic->InEchoReplies6, itv),
1734 S_VALUE(snip->OutEchoReplies6, snic->OutEchoReplies6, itv),
1735 S_VALUE(snip->InGroupMembQueries6, snic->InGroupMembQueries6, itv),
1736 S_VALUE(snip->InGroupMembResponses6, snic->InGroupMembResponses6, itv),
1737 S_VALUE(snip->OutGroupMembResponses6, snic->OutGroupMembResponses6, itv),
1738 S_VALUE(snip->InGroupMembReductions6, snic->InGroupMembReductions6, itv),
1739 S_VALUE(snip->OutGroupMembReductions6, snic->OutGroupMembReductions6, itv),
1740 S_VALUE(snip->InRouterSolicits6, snic->InRouterSolicits6, itv),
1741 S_VALUE(snip->OutRouterSolicits6, snic->OutRouterSolicits6, itv),
1742 S_VALUE(snip->InRouterAdvertisements6, snic->InRouterAdvertisements6, itv),
1743 S_VALUE(snip->InNeighborSolicits6, snic->InNeighborSolicits6, itv),
1744 S_VALUE(snip->OutNeighborSolicits6, snic->OutNeighborSolicits6, itv),
1745 S_VALUE(snip->InNeighborAdvertisements6, snic->InNeighborAdvertisements6, itv),
1746 S_VALUE(snip->OutNeighborAdvertisements6, snic->OutNeighborAdvertisements6, itv));
1751 ***************************************************************************
1752 * Display ICMPv6 network errors statistics.
1755 * @a Activity structure with statistics.
1756 * @prev Index in array where stats used as reference are.
1757 * @curr Index in array for current sample statistics.
1758 * @itv Interval of time in jiffies.
1759 ***************************************************************************
1761 __print_funct_t print_net_eicmp6_stats(struct activity *a, int prev, int curr,
1762 unsigned long long itv)
1764 struct stats_net_eicmp6
1765 *sneic = (struct stats_net_eicmp6 *) a->buf[curr],
1766 *sneip = (struct stats_net_eicmp6 *) a->buf[prev];
1769 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
1772 printf("%-11s", timestamp[curr]);
1774 S_VALUE(sneip->InErrors6, sneic->InErrors6, itv),
1775 S_VALUE(sneip->InDestUnreachs6, sneic->InDestUnreachs6, itv),
1776 S_VALUE(sneip->OutDestUnreachs6, sneic->OutDestUnreachs6, itv),
1777 S_VALUE(sneip->InTimeExcds6, sneic->InTimeExcds6, itv),
1778 S_VALUE(sneip->OutTimeExcds6, sneic->OutTimeExcds6, itv),
1779 S_VALUE(sneip->InParmProblems6, sneic->InParmProblems6, itv),
1780 S_VALUE(sneip->OutParmProblems6, sneic->OutParmProblems6, itv),
1781 S_VALUE(sneip->InRedirects6, sneic->InRedirects6, itv),
1782 S_VALUE(sneip->OutRedirects6, sneic->OutRedirects6, itv),
1783 S_VALUE(sneip->InPktTooBigs6, sneic->InPktTooBigs6, itv),
1784 S_VALUE(sneip->OutPktTooBigs6, sneic->OutPktTooBigs6, itv));
1789 ***************************************************************************
1790 * Display UDPv6 network traffic statistics.
1793 * @a Activity structure with statistics.
1794 * @prev Index in array where stats used as reference are.
1795 * @curr Index in array for current sample statistics.
1796 * @itv Interval of time in jiffies.
1797 ***************************************************************************
1799 __print_funct_t print_net_udp6_stats(struct activity *a, int prev, int curr,
1800 unsigned long long itv)
1802 struct stats_net_udp6
1803 *snuc = (struct stats_net_udp6 *) a->buf[curr],
1804 *snup = (struct stats_net_udp6 *) a->buf[prev];
1807 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
1810 printf("%-11s", timestamp[curr]);
1812 S_VALUE(snup->InDatagrams6, snuc->InDatagrams6, itv),
1813 S_VALUE(snup->OutDatagrams6, snuc->OutDatagrams6, itv),
1814 S_VALUE(snup->NoPorts6, snuc->NoPorts6, itv),
1815 S_VALUE(snup->InErrors6, snuc->InErrors6, itv));
1820 ***************************************************************************
1821 * Display CPU frequency statistics. This function is used to display
1822 * instantaneous and average statistics.
1825 * @a Activity structure with statistics.
1826 * @curr Index in array for current sample statistics.
1827 * @dispavg True if displaying average statistics.
1828 ***************************************************************************
1830 void stub_print_pwr_cpufreq_stats(struct activity *a, int curr, int dispavg)
1833 struct stats_pwr_cpufreq *spc;
1834 static unsigned long long
1835 *avg_cpufreq = NULL;
1838 /* Allocate array of CPU frequency */
1839 if ((avg_cpufreq = (unsigned long long *) malloc(sizeof(unsigned long long) * a->nr))
1844 memset(avg_cpufreq, 0, sizeof(unsigned long long) * a->nr);
1848 print_hdr_line(timestamp[!curr], a, FIRST, 7, 9);
1851 for (i = 0; (i < a->nr) && (i < a->bitmap->b_size + 1); i++) {
1854 * The size of a->buf[...] CPU structure may be different from the default
1855 * sizeof(struct stats_pwr_cpufreq) value if data have been read from a file!
1856 * That's why we don't use a syntax like:
1857 * spc = (struct stats_pwr_cpufreq *) a->buf[...] + i;
1859 spc = (struct stats_pwr_cpufreq *) ((char *) a->buf[curr] + i * a->msize);
1862 * Note: a->nr is in [1, NR_CPUS + 1].
1863 * Bitmap size is provided for (NR_CPUS + 1) CPUs.
1864 * Anyway, NR_CPUS may vary between the version of sysstat
1865 * used by sadc to create a file, and the version of sysstat
1866 * used by sar to read it...
1869 /* Should current CPU (including CPU "all") be displayed? */
1870 if (a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))) {
1872 /* Yes: Display it */
1873 printf("%-11s", timestamp[curr]);
1876 /* This is CPU "all" */
1877 cprintf_in(IS_STR, "%s", " all", 0);
1880 cprintf_in(IS_INT, " %3d", "", i - 1);
1884 /* Display instantaneous values */
1886 ((double) spc->cpufreq) / 100);
1889 * Will be used to compute the average.
1890 * Note: overflow unlikely to happen but not impossible...
1892 avg_cpufreq[i] += spc->cpufreq;
1895 /* Display average values */
1897 (double) avg_cpufreq[i] / (100 * avg_count));
1904 /* Array of CPU frequency no longer needed: Free it! */
1913 ***************************************************************************
1914 * Display CPU frequency statistics.
1917 * @a Activity structure with statistics.
1918 * @prev Index in array where stats used as reference are.
1919 * @curr Index in array for current sample statistics.
1920 * @itv Interval of time in jiffies.
1921 ***************************************************************************
1923 __print_funct_t print_pwr_cpufreq_stats(struct activity *a, int prev, int curr,
1924 unsigned long long itv)
1926 stub_print_pwr_cpufreq_stats(a, curr, FALSE);
1930 ***************************************************************************
1931 * Display average CPU frequency statistics.
1934 * @a Activity structure with statistics.
1935 * @prev Index in array where stats used as reference are.
1936 * @curr Index in array for current sample statistics.
1937 * @itv Interval of time in jiffies.
1938 ***************************************************************************
1940 __print_funct_t print_avg_pwr_cpufreq_stats(struct activity *a, int prev, int curr,
1941 unsigned long long itv)
1943 stub_print_pwr_cpufreq_stats(a, curr, TRUE);
1947 ***************************************************************************
1948 * Display fan statistics. This function is used to display
1949 * instantaneous and average statistics.
1952 * @a Activity structure with statistics.
1953 * @curr Index in array for current sample statistics.
1954 * @dispavg True if displaying average statistics.
1955 ***************************************************************************
1957 void stub_print_pwr_fan_stats(struct activity *a, int curr, int dispavg)
1960 struct stats_pwr_fan *spc;
1961 static double *avg_fan = NULL;
1962 static double *avg_fan_min = NULL;
1964 /* Allocate arrays of fan RPMs */
1966 if ((avg_fan = (double *) malloc(sizeof(double) * a->nr)) == NULL) {
1970 memset(avg_fan, 0, sizeof(double) * a->nr);
1973 if ((avg_fan_min = (double *) malloc(sizeof(double) * a->nr)) == NULL) {
1977 memset(avg_fan_min, 0, sizeof(double) * a->nr);
1981 print_hdr_line(timestamp[!curr], a, FIRST, -2, 9);
1984 for (i = 0; i < a->nr; i++) {
1985 spc = (struct stats_pwr_fan *) ((char *) a->buf[curr] + i * a->msize);
1987 printf("%-11s", timestamp[curr]);
1988 cprintf_in(IS_INT, " %5d", "", i + 1);
1991 /* Display average values */
1993 (double) avg_fan[i] / avg_count,
1994 (double) (avg_fan[i] - avg_fan_min[i]) / avg_count);
1997 /* Display instantaneous values */
2000 spc->rpm - spc->rpm_min);
2001 avg_fan[i] += spc->rpm;
2002 avg_fan_min[i] += spc->rpm_min;
2005 cprintf_in(IS_STR, " %s\n", spc->device, 0);
2021 ***************************************************************************
2022 * Display fan statistics.
2025 * @a Activity structure with statistics.
2026 * @prev Index in array where stats used as reference are.
2027 * @curr Index in array for current sample statistics.
2028 * @itv Interval of time in jiffies.
2029 ***************************************************************************
2031 __print_funct_t print_pwr_fan_stats(struct activity *a, int prev, int curr,
2032 unsigned long long itv)
2034 stub_print_pwr_fan_stats(a, curr, FALSE);
2038 ***************************************************************************
2039 * Display average fan statistics.
2042 * @a Activity structure with statistics.
2043 * @prev Index in array where stats used as reference are.
2044 * @curr Index in array for current sample statistics.
2045 * @itv Interval of time in jiffies.
2046 ***************************************************************************
2048 __print_funct_t print_avg_pwr_fan_stats(struct activity *a, int prev, int curr,
2049 unsigned long long itv)
2051 stub_print_pwr_fan_stats(a, curr, TRUE);
2055 ***************************************************************************
2056 * Display device temperature statistics. This function is used to display
2057 * instantaneous and average statistics.
2060 * @a Activity structure with statistics.
2061 * @curr Index in array for current sample statistics.
2062 * @dispavg True if displaying average statistics.
2063 ***************************************************************************
2065 void stub_print_pwr_temp_stats(struct activity *a, int curr, int dispavg)
2068 struct stats_pwr_temp *spc;
2069 static double *avg_temp = NULL;
2070 static double *avg_temp_min = NULL, *avg_temp_max = NULL;
2072 /* Allocate arrays of temperatures */
2074 if ((avg_temp = (double *) malloc(sizeof(double) * a->nr)) == NULL) {
2078 memset(avg_temp, 0, sizeof(double) * a->nr);
2080 if (!avg_temp_min) {
2081 if ((avg_temp_min = (double *) malloc(sizeof(double) * a->nr)) == NULL) {
2085 memset(avg_temp_min, 0, sizeof(double) * a->nr);
2087 if (!avg_temp_max) {
2088 if ((avg_temp_max = (double *) malloc(sizeof(double) * a->nr)) == NULL) {
2092 memset(avg_temp_max, 0, sizeof(double) * a->nr);
2096 print_hdr_line(timestamp[!curr], a, FIRST, -2, 9);
2099 for (i = 0; i < a->nr; i++) {
2100 spc = (struct stats_pwr_temp *) ((char *) a->buf[curr] + i * a->msize);
2102 printf("%-11s", timestamp[curr]);
2103 cprintf_in(IS_INT, " %5d", "", i + 1);
2106 /* Display average values */
2107 cprintf_f(1, 9, 2, (double) avg_temp[i] / avg_count);
2109 (avg_temp_max[i] - avg_temp_min[i]) ?
2110 ((double) (avg_temp[i] / avg_count) - avg_temp_min[i]) / (avg_temp_max[i] - avg_temp_min[i]) * 100
2114 /* Display instantaneous values */
2115 cprintf_f(1, 9, 2, spc->temp);
2117 (spc->temp_max - spc->temp_min) ?
2118 (spc->temp - spc->temp_min) / (spc->temp_max - spc->temp_min) * 100
2120 avg_temp[i] += spc->temp;
2121 /* Assume that min and max temperatures cannot vary */
2122 avg_temp_min[i] = spc->temp_min;
2123 avg_temp_max[i] = spc->temp_max;
2126 cprintf_in(IS_STR, " %s\n", spc->device, 0);
2136 avg_temp_min = NULL;
2140 avg_temp_max = NULL;
2146 ***************************************************************************
2147 * Display temperature statistics.
2150 * @a Activity structure with statistics.
2151 * @prev Index in array where stats used as reference are.
2152 * @curr Index in array for current sample statistics.
2153 * @itv Interval of time in jiffies.
2154 ***************************************************************************
2156 __print_funct_t print_pwr_temp_stats(struct activity *a, int prev, int curr,
2157 unsigned long long itv)
2159 stub_print_pwr_temp_stats(a, curr, FALSE);
2163 ***************************************************************************
2164 * Display average temperature statistics.
2167 * @a Activity structure with statistics.
2168 * @prev Index in array where stats used as reference are.
2169 * @curr Index in array for current sample statistics.
2170 * @itv Interval of time in jiffies.
2171 ***************************************************************************
2173 __print_funct_t print_avg_pwr_temp_stats(struct activity *a, int prev, int curr,
2174 unsigned long long itv)
2176 stub_print_pwr_temp_stats(a, curr, TRUE);
2180 ***************************************************************************
2181 * Display voltage inputs statistics. This function is used to display
2182 * instantaneous and average statistics.
2185 * @a Activity structure with statistics.
2186 * @curr Index in array for current sample statistics.
2187 * @dispavg True if displaying average statistics.
2188 ***************************************************************************
2190 void stub_print_pwr_in_stats(struct activity *a, int curr, int dispavg)
2193 struct stats_pwr_in *spc;
2194 static double *avg_in = NULL;
2195 static double *avg_in_min = NULL, *avg_in_max = NULL;
2197 /* Allocate arrays of voltage inputs */
2199 if ((avg_in = (double *) malloc(sizeof(double) * a->nr)) == NULL) {
2203 memset(avg_in, 0, sizeof(double) * a->nr);
2206 if ((avg_in_min = (double *) malloc(sizeof(double) * a->nr)) == NULL) {
2210 memset(avg_in_min, 0, sizeof(double) * a->nr);
2213 if ((avg_in_max = (double *) malloc(sizeof(double) * a->nr)) == NULL) {
2217 memset(avg_in_max, 0, sizeof(double) * a->nr);
2221 print_hdr_line(timestamp[!curr], a, FIRST, -2, 9);
2224 for (i = 0; i < a->nr; i++) {
2225 spc = (struct stats_pwr_in *) ((char *) a->buf[curr] + i * a->msize);
2227 printf("%-11s", timestamp[curr]);
2228 cprintf_in(IS_INT, " %5d", "", i);
2231 /* Display average values */
2232 cprintf_f(1, 9, 2, (double) avg_in[i] / avg_count);
2234 (avg_in_max[i] - avg_in_min[i]) ?
2235 ((double) (avg_in[i] / avg_count) - avg_in_min[i]) / (avg_in_max[i] - avg_in_min[i]) * 100
2239 /* Display instantaneous values */
2240 cprintf_f(1, 9, 2, spc->in);
2242 (spc->in_max - spc->in_min) ?
2243 (spc->in - spc->in_min) / (spc->in_max - spc->in_min) * 100
2245 avg_in[i] += spc->in;
2246 /* Assume that min and max voltage inputs cannot vary */
2247 avg_in_min[i] = spc->in_min;
2248 avg_in_max[i] = spc->in_max;
2251 cprintf_in(IS_STR, " %s\n", spc->device, 0);
2271 ***************************************************************************
2272 * Display voltage inputs statistics.
2275 * @a Activity structure with statistics.
2276 * @prev Index in array where stats used as reference are.
2277 * @curr Index in array for current sample statistics.
2278 * @itv Interval of time in jiffies.
2279 ***************************************************************************
2281 __print_funct_t print_pwr_in_stats(struct activity *a, int prev, int curr,
2282 unsigned long long itv)
2284 stub_print_pwr_in_stats(a, curr, FALSE);
2288 ***************************************************************************
2289 * Display average voltage inputs statistics.
2292 * @a Activity structure with statistics.
2293 * @prev Index in array where stats used as reference are.
2294 * @curr Index in array for current sample statistics.
2295 * @itv Interval of time in jiffies.
2296 ***************************************************************************
2298 __print_funct_t print_avg_pwr_in_stats(struct activity *a, int prev, int curr,
2299 unsigned long long itv)
2301 stub_print_pwr_in_stats(a, curr, TRUE);
2305 ***************************************************************************
2306 * Display huge pages statistics. This function is used to
2307 * display instantaneous and average statistics.
2310 * @a Activity structure with statistics.
2311 * @curr Index in array for current sample statistics.
2312 * @dispavg TRUE if displaying average statistics.
2313 ***************************************************************************
2315 void stub_print_huge_stats(struct activity *a, int curr, int dispavg)
2318 *smc = (struct stats_huge *) a->buf[curr];
2319 static unsigned long long
2324 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
2328 /* Display instantaneous values */
2329 printf("%-11s", timestamp[curr]);
2331 (unsigned long long) smc->frhkb,
2332 (unsigned long long) (smc->tlhkb - smc->frhkb));
2335 SP_VALUE(smc->frhkb, smc->tlhkb, smc->tlhkb) : 0.0);
2338 /* Will be used to compute the average */
2339 avg_frhkb += smc->frhkb;
2340 avg_tlhkb += smc->tlhkb;
2343 /* Display average values */
2344 printf("%-11s", timestamp[curr]);
2346 (double) avg_frhkb / avg_count,
2347 ((double) avg_tlhkb / avg_count) -
2348 ((double) avg_frhkb / avg_count));
2351 SP_VALUE((double) avg_frhkb / avg_count,
2352 (double) avg_tlhkb / avg_count,
2353 (double) avg_tlhkb / avg_count) : 0.0);
2356 /* Reset average counters */
2357 avg_frhkb = avg_tlhkb = 0;
2362 ***************************************************************************
2363 * Display huge pages statistics.
2366 * @a Activity structure with statistics.
2367 * @prev Index in array where stats used as reference are.
2368 * @curr Index in array for current sample statistics.
2369 * @itv Interval of time in jiffies.
2370 ***************************************************************************
2372 __print_funct_t print_huge_stats(struct activity *a, int prev, int curr,
2373 unsigned long long itv)
2375 stub_print_huge_stats(a, curr, FALSE);
2379 ***************************************************************************
2380 * Display huge pages statistics.
2383 * @a Activity structure with statistics.
2384 * @prev Index in array where stats used as reference are.
2385 * @curr Index in array for current sample statistics.
2386 * @itv Interval of time in jiffies.
2387 ***************************************************************************
2389 __print_funct_t print_avg_huge_stats(struct activity *a, int prev, int curr,
2390 unsigned long long itv)
2392 stub_print_huge_stats(a, curr, TRUE);
2396 ***************************************************************************
2397 * Display CPU weighted frequency statistics. This function is used to
2398 * display instantaneous and average statistics.
2401 * @a Activity structure with statistics.
2402 * @prev Index in array where stats used as reference are.
2403 * @curr Index in array for current sample statistics.
2404 * @itv Interval of time in jiffies.
2405 ***************************************************************************
2407 void print_pwr_wghfreq_stats(struct activity *a, int prev, int curr,
2408 unsigned long long itv)
2411 struct stats_pwr_wghfreq *spc, *spp, *spc_k, *spp_k;
2412 unsigned long long tis, tisfreq;
2415 print_hdr_line(timestamp[!curr], a, FIRST, 7, 9);
2418 for (i = 0; (i < a->nr) && (i < a->bitmap->b_size + 1); i++) {
2421 * The size of a->buf[...] CPU structure may be different from the default
2422 * sizeof(struct stats_pwr_wghfreq) value if data have been read from a file!
2423 * That's why we don't use a syntax like:
2424 * spc = (struct stats_pwr_wghfreq *) a->buf[...] + i;
2426 spc = (struct stats_pwr_wghfreq *) ((char *) a->buf[curr] + i * a->msize * a->nr2);
2427 spp = (struct stats_pwr_wghfreq *) ((char *) a->buf[prev] + i * a->msize * a->nr2);
2430 * Note: a->nr is in [1, NR_CPUS + 1].
2431 * Bitmap size is provided for (NR_CPUS + 1) CPUs.
2432 * Anyway, NR_CPUS may vary between the version of sysstat
2433 * used by sadc to create a file, and the version of sysstat
2434 * used by sar to read it...
2437 /* Should current CPU (including CPU "all") be displayed? */
2438 if (a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))) {
2440 /* Yes: Display it */
2441 printf("%-11s", timestamp[curr]);
2444 /* This is CPU "all" */
2445 cprintf_in(IS_STR, "%s", " all", 0);
2448 cprintf_in(IS_INT, " %3d", "", i - 1);
2454 for (k = 0; k < a->nr2; k++) {
2456 spc_k = (struct stats_pwr_wghfreq *) ((char *) spc + k * a->msize);
2459 spp_k = (struct stats_pwr_wghfreq *) ((char *) spp + k * a->msize);
2461 tisfreq += (spc_k->freq / 1000) *
2462 (spc_k->time_in_state - spp_k->time_in_state);
2463 tis += (spc_k->time_in_state - spp_k->time_in_state);
2466 /* Display weighted frequency for current CPU */
2468 tis ? ((double) tisfreq) / tis : 0.0);
2475 ***************************************************************************
2476 * Display USB devices statistics. This function is used to
2477 * display instantaneous and summary statistics.
2480 * @a Activity structure with statistics.
2481 * @curr Index in array for current sample statistics.
2482 * @itv Interval of time in jiffies.
2483 * @dispavg TRUE if displaying average statistics.
2484 ***************************************************************************
2486 void stub_print_pwr_usb_stats(struct activity *a, int curr, int dispavg)
2490 struct stats_pwr_usb *suc, *sum;
2493 printf("\n%-11s BUS idvendor idprod maxpower",
2494 (dispavg ? _("Summary:") : timestamp[!curr]));
2495 printf(" %-*s product\n", MAX_MANUF_LEN - 1, "manufact");
2498 for (i = 0; i < a->nr; i++) {
2499 suc = (struct stats_pwr_usb *) ((char *) a->buf[curr] + i * a->msize);
2502 /* Bus#0 doesn't exist: We are at the end of the list */
2505 printf("%-11s", (dispavg ? _("Summary:") : timestamp[curr]));
2506 cprintf_in(IS_INT, " %6d", "", suc->bus_nr);
2511 /* bMaxPower is expressed in 2 mA units */
2512 (unsigned long long) (suc->bmaxpower << 1));
2514 snprintf(fmt, 16, " %%-%ds", MAX_MANUF_LEN - 1);
2515 cprintf_s(IS_STR, fmt, suc->manufacturer);
2516 cprintf_s(IS_STR, " %s\n", suc->product);
2519 /* Save current USB device in summary list */
2520 for (j = 0; j < a->nr; j++) {
2521 sum = (struct stats_pwr_usb *) ((char *) a->buf[2] + j * a->msize);
2523 if ((sum->bus_nr == suc->bus_nr) &&
2524 (sum->vendor_id == suc->vendor_id) &&
2525 (sum->product_id == suc->product_id))
2526 /* USB device found in summary list */
2530 * Current slot is free:
2531 * Save USB device in summary list.
2536 if (j == a->nr - 1) {
2538 * This is the last slot and
2539 * we still havent't found the device.
2540 * So create a dummy device here.
2543 sum->vendor_id = sum->product_id = 0;
2545 sum->manufacturer[0] = '\0';
2546 snprintf(sum->product, MAX_PROD_LEN, "%s",
2547 _("Other devices not listed here"));
2548 sum->product[MAX_PROD_LEN - 1] = '\0';
2556 ***************************************************************************
2557 * Display USB devices statistics.
2560 * @a Activity structure with statistics.
2561 * @prev Index in array where stats used as reference are.
2562 * @curr Index in array for current sample statistics.
2563 * @itv Interval of time in jiffies.
2564 ***************************************************************************
2566 __print_funct_t print_pwr_usb_stats(struct activity *a, int prev, int curr,
2567 unsigned long long itv)
2569 stub_print_pwr_usb_stats(a, curr, FALSE);
2573 ***************************************************************************
2574 * Display average USB devices statistics.
2577 * @a Activity structure with statistics.
2578 * @prev Index in array where stats used as reference are.
2579 * @curr Index in array for current sample statistics.
2580 * @itv Interval of time in jiffies.
2581 ***************************************************************************
2583 __print_funct_t print_avg_pwr_usb_stats(struct activity *a, int prev, int curr,
2584 unsigned long long itv)
2586 stub_print_pwr_usb_stats(a, 2, TRUE);
2590 ***************************************************************************
2591 * Display filesystems statistics. This function is used to
2592 * display instantaneous and average statistics.
2595 * @a Activity structure with statistics.
2596 * @curr Index in array for current sample statistics.
2597 * @dispavg TRUE if displaying average statistics.
2598 ***************************************************************************
2600 __print_funct_t stub_print_filesystem_stats(struct activity *a, int curr, int dispavg)
2603 struct stats_filesystem *sfc, *sfm;
2606 print_hdr_line((dispavg ? _("Summary:") : timestamp[!curr]),
2607 a, FIRST + DISPLAY_MOUNT(a->opt_flags), -1, 9);
2610 for (i = 0; i < a->nr; i++) {
2611 sfc = (struct stats_filesystem *) ((char *) a->buf[curr] + i * a->msize);
2614 /* Size of filesystem is zero: We are at the end of the list */
2617 printf("%-11s", (dispavg ? _("Summary:") : timestamp[curr]));
2619 (double) sfc->f_bfree / 1024 / 1024,
2620 (double) (sfc->f_blocks - sfc->f_bfree) / 1024 / 1024);
2622 /* f_blocks is not zero. But test it anyway ;-) */
2623 sfc->f_blocks ? SP_VALUE(sfc->f_bfree, sfc->f_blocks, sfc->f_blocks)
2625 sfc->f_blocks ? SP_VALUE(sfc->f_bavail, sfc->f_blocks, sfc->f_blocks)
2628 (unsigned long long) sfc->f_ffree,
2629 (unsigned long long) (sfc->f_files - sfc->f_ffree));
2631 sfc->f_files ? SP_VALUE(sfc->f_ffree, sfc->f_files, sfc->f_files)
2633 cprintf_in(IS_STR, " %s\n",
2634 DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name, 0);
2637 /* Save current filesystem in summary list */
2638 for (j = 0; j < a->nr; j++) {
2639 sfm = (struct stats_filesystem *) ((char *) a->buf[2] + j * a->msize);
2641 if (!strcmp(sfm->fs_name, sfc->fs_name) ||
2644 * Filesystem found in list (then save again its stats)
2645 * or free slot (end of list).
2656 ***************************************************************************
2657 * Display filesystems statistics.
2660 * @a Activity structure with statistics.
2661 * @prev Index in array where stats used as reference are.
2662 * @curr Index in array for current sample statistics.
2663 * @itv Interval of time in jiffies.
2664 ***************************************************************************
2666 __print_funct_t print_filesystem_stats(struct activity *a, int prev, int curr,
2667 unsigned long long itv)
2669 stub_print_filesystem_stats(a, curr, FALSE);
2673 ***************************************************************************
2674 * Display average filesystems statistics.
2677 * @a Activity structure with statistics.
2678 * @prev Index in array where stats used as reference are.
2679 * @curr Index in array for current sample statistics.
2680 * @itv Interval of time in jiffies.
2681 ***************************************************************************
2683 __print_funct_t print_avg_filesystem_stats(struct activity *a, int prev, int curr,
2684 unsigned long long itv)
2686 stub_print_filesystem_stats(a, 2, TRUE);
2690 ***************************************************************************
2691 * Display Fibre Channel HBA statistics.
2694 * @a Activity structure with statistics.
2695 * @prev Index in array where stats used as reference are.
2696 * @curr Index in array for current sample statistics.
2697 * @itv Interval of time in jiffies.
2698 ***************************************************************************
2700 __print_funct_t print_fchost_stats(struct activity *a, int prev, int curr,
2701 unsigned long long itv)
2704 struct stats_fchost *sfcc,*sfcp;
2707 print_hdr_line(timestamp[!curr], a, FIRST, -1, 9);
2710 for (i = 0; i < a->nr; i++) {
2712 sfcc = (struct stats_fchost *) ((char *) a->buf[curr] + i * a->msize);
2713 sfcp = (struct stats_fchost *) ((char *) a->buf[prev] + i * a->msize);
2715 if (!sfcc->fchost_name[0])
2716 /* We are at the end of the list */
2719 printf("%-11s", timestamp[curr]);
2721 S_VALUE(sfcp->f_rxframes, sfcc->f_rxframes, itv),
2722 S_VALUE(sfcp->f_txframes, sfcc->f_txframes, itv),
2723 S_VALUE(sfcp->f_rxwords, sfcc->f_rxwords, itv),
2724 S_VALUE(sfcp->f_txwords, sfcc->f_txwords, itv));
2725 cprintf_in(IS_STR, " %s\n", sfcc->fchost_name, 0);