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
493 static unsigned long long
498 if (DISPLAY_MEMORY(a->opt_flags)) {
500 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
503 printf("%-11s", timestamp[curr]);
505 S_VALUE((double) KB_TO_PG(smp->frmkb), (double) KB_TO_PG(smc->frmkb), itv),
506 S_VALUE((double) KB_TO_PG(smp->bufkb), (double) KB_TO_PG(smc->bufkb), itv),
507 S_VALUE((double) KB_TO_PG(smp->camkb), (double) KB_TO_PG(smc->camkb), itv));
511 if (DISPLAY_MEM_AMT(a->opt_flags)) {
513 print_hdr_line(timestamp[!curr], a, SECOND, 0, 9);
517 /* Display instantaneous values */
518 printf("%-11s", timestamp[curr]);
520 (unsigned long long) smc->frmkb,
521 (unsigned long long) (smc->tlmkb - smc->frmkb));
524 SP_VALUE(smc->frmkb, smc->tlmkb, smc->tlmkb)
527 (unsigned long long) smc->bufkb,
528 (unsigned long long) smc->camkb,
529 (unsigned long long) smc->comkb);
531 (smc->tlmkb + smc->tlskb) ?
532 SP_VALUE(0, smc->comkb, smc->tlmkb + smc->tlskb)
535 (unsigned long long) smc->activekb,
536 (unsigned long long) smc->inactkb,
537 (unsigned long long) smc->dirtykb);
539 if (DISPLAY_MEM_ALL(a->opt_flags)) {
540 /* Display extended memory statistics */
542 (unsigned long long) smc->anonpgkb,
543 (unsigned long long) smc->slabkb,
544 (unsigned long long) smc->kstackkb,
545 (unsigned long long) smc->pgtblkb,
546 (unsigned long long) smc->vmusedkb,
547 (unsigned long long) smc->availablekb);
553 * Will be used to compute the average.
554 * We assume that the total amount of memory installed can not vary
555 * during the interval given on the command line.
557 avg_frmkb += smc->frmkb;
558 avg_bufkb += smc->bufkb;
559 avg_camkb += smc->camkb;
560 avg_comkb += smc->comkb;
561 avg_activekb += smc->activekb;
562 avg_inactkb += smc->inactkb;
563 avg_dirtykb += smc->dirtykb;
564 avg_anonpgkb += smc->anonpgkb;
565 avg_slabkb += smc->slabkb;
566 avg_kstackkb += smc->kstackkb;
567 avg_pgtblkb += smc->pgtblkb;
568 avg_vmusedkb += smc->vmusedkb;
569 avg_availablekb += smc->availablekb;
572 /* Display average values */
573 printf("%-11s", timestamp[curr]);
575 (double) avg_frmkb / avg_count,
576 (double) smc->tlmkb - ((double) avg_frmkb / avg_count));
579 SP_VALUE((double) (avg_frmkb / avg_count), smc->tlmkb, smc->tlmkb)
582 (double) avg_bufkb / avg_count,
583 (double) avg_camkb / avg_count,
584 (double) avg_comkb / avg_count);
586 (smc->tlmkb + smc->tlskb) ?
587 SP_VALUE(0.0, (double) (avg_comkb / avg_count), smc->tlmkb + smc->tlskb)
590 (double) avg_activekb / avg_count,
591 (double) avg_inactkb / avg_count,
592 (double) avg_dirtykb / avg_count);
594 if (DISPLAY_MEM_ALL(a->opt_flags)) {
596 (double) avg_anonpgkb / avg_count,
597 (double) avg_slabkb / avg_count,
598 (double) avg_kstackkb / avg_count,
599 (double) avg_pgtblkb / avg_count,
600 (double) avg_vmusedkb / avg_count,
601 (double) avg_availablekb / avg_count);
606 /* Reset average counters */
607 avg_frmkb = avg_bufkb = avg_camkb = avg_comkb = 0;
608 avg_activekb = avg_inactkb = avg_dirtykb = 0;
609 avg_anonpgkb = avg_slabkb = avg_kstackkb = 0;
610 avg_pgtblkb = avg_vmusedkb = avg_availablekb = 0;
614 if (DISPLAY_SWAP(a->opt_flags)) {
616 print_hdr_line(timestamp[!curr], a, THIRD, 0, 9);
620 /* Display instantaneous values */
621 printf("%-11s", timestamp[curr]);
623 (unsigned long long) smc->frskb,
624 (unsigned long long) (smc->tlskb - smc->frskb));
627 SP_VALUE(smc->frskb, smc->tlskb, smc->tlskb)
630 (unsigned long long) smc->caskb);
632 (smc->tlskb - smc->frskb) ?
633 SP_VALUE(0, smc->caskb, smc->tlskb - smc->frskb)
639 * Will be used to compute the average.
640 * We assume that the total amount of swap space may vary.
642 avg_frskb += smc->frskb;
643 avg_tlskb += smc->tlskb;
644 avg_caskb += smc->caskb;
647 /* Display average values */
648 printf("%-11s", timestamp[curr]);
650 (double) avg_frskb / avg_count,
651 ((double) avg_tlskb / avg_count) -
652 ((double) avg_frskb / avg_count));
655 SP_VALUE((double) avg_frskb / avg_count,
656 (double) avg_tlskb / avg_count,
657 (double) avg_tlskb / avg_count)
660 (double) avg_caskb / avg_count);
662 (avg_tlskb != avg_frskb) ?
663 SP_VALUE(0.0, (double) avg_caskb / avg_count,
664 ((double) avg_tlskb / avg_count) -
665 ((double) avg_frskb / avg_count))
669 /* Reset average counters */
670 avg_frskb = avg_tlskb = avg_caskb = 0;
676 ***************************************************************************
677 * Display memory and swap statistics.
680 * @a Activity structure with statistics.
681 * @prev Index in array where stats used as reference are.
682 * @curr Index in array for current sample statistics.
683 * @itv Interval of time in jiffies.
684 ***************************************************************************
686 __print_funct_t print_memory_stats(struct activity *a, int prev, int curr,
687 unsigned long long itv)
689 stub_print_memory_stats(a, prev, curr, itv, FALSE);
693 ***************************************************************************
694 * Display average memory statistics.
697 * @a Activity structure with statistics.
698 * @prev Index in array where stats used as reference are.
699 * @curr Index in array for current sample statistics.
700 * @itv Interval of time in jiffies.
701 ***************************************************************************
703 __print_funct_t print_avg_memory_stats(struct activity *a, int prev, int curr,
704 unsigned long long itv)
706 stub_print_memory_stats(a, prev, curr, itv, TRUE);
710 ***************************************************************************
711 * Display kernel tables statistics. This function is used to display
712 * instantaneous and average statistics.
715 * @a Activity structure with statistics.
716 * @curr Index in array for current sample statistics.
717 * @dispavg True if displaying average statistics.
718 ***************************************************************************
720 void stub_print_ktables_stats(struct activity *a, int curr, int dispavg)
723 *skc = (struct stats_ktables *) a->buf[curr];
724 static unsigned long long
732 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
736 /* Display instantaneous values */
737 printf("%-11s", timestamp[curr]);
739 (unsigned long long) skc->dentry_stat,
740 (unsigned long long) skc->file_used,
741 (unsigned long long) skc->inode_used,
742 (unsigned long long) skc->pty_nr);
746 * Will be used to compute the average.
747 * Note: Overflow unlikely to happen but not impossible...
749 avg_dentry_stat += skc->dentry_stat;
750 avg_file_used += skc->file_used;
751 avg_inode_used += skc->inode_used;
752 avg_pty_nr += skc->pty_nr;
755 /* Display average values */
756 printf("%-11s", timestamp[curr]);
758 (double) avg_dentry_stat / avg_count,
759 (double) avg_file_used / avg_count,
760 (double) avg_inode_used / avg_count,
761 (double) avg_pty_nr / avg_count);
764 /* Reset average counters */
765 avg_dentry_stat = avg_file_used = avg_inode_used = avg_pty_nr = 0;
770 ***************************************************************************
771 * Display kernel tables statistics.
774 * @a Activity structure with statistics.
775 * @prev Index in array where stats used as reference are.
776 * @curr Index in array for current sample statistics.
777 * @itv Interval of time in jiffies.
778 ***************************************************************************
780 __print_funct_t print_ktables_stats(struct activity *a, int prev, int curr,
781 unsigned long long itv)
783 stub_print_ktables_stats(a, curr, FALSE);
787 ***************************************************************************
788 * Display average kernel tables statistics.
791 * @a Activity structure with statistics.
792 * @prev Index in array where stats used as reference are.
793 * @curr Index in array for current sample statistics.
794 * @itv Interval of time in jiffies.
795 ***************************************************************************
797 __print_funct_t print_avg_ktables_stats(struct activity *a, int prev, int curr,
798 unsigned long long itv)
800 stub_print_ktables_stats(a, curr, TRUE);
804 ***************************************************************************
805 * Display queue and load statistics. This function is used to display
806 * instantaneous and average statistics.
809 * @a Activity structure with statistics.
810 * @curr Index in array for current sample statistics.
811 * @dispavg TRUE if displaying average statistics.
812 ***************************************************************************
814 void stub_print_queue_stats(struct activity *a, int curr, int dispavg)
817 *sqc = (struct stats_queue *) a->buf[curr];
818 static unsigned long long
824 avg_procs_blocked = 0;
827 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
831 /* Display instantaneous values */
832 printf("%-11s", timestamp[curr]);
834 (unsigned long long) sqc->nr_running,
835 (unsigned long long) sqc->nr_threads);
837 (double) sqc->load_avg_1 / 100,
838 (double) sqc->load_avg_5 / 100,
839 (double) sqc->load_avg_15 / 100);
841 (unsigned long long) sqc->procs_blocked);
844 /* Will be used to compute the average */
845 avg_nr_running += sqc->nr_running;
846 avg_nr_threads += sqc->nr_threads;
847 avg_load_avg_1 += sqc->load_avg_1;
848 avg_load_avg_5 += sqc->load_avg_5;
849 avg_load_avg_15 += sqc->load_avg_15;
850 avg_procs_blocked += sqc->procs_blocked;
853 /* Display average values */
854 printf("%-11s", timestamp[curr]);
856 (double) avg_nr_running / avg_count,
857 (double) avg_nr_threads / avg_count);
859 (double) avg_load_avg_1 / (avg_count * 100),
860 (double) avg_load_avg_5 / (avg_count * 100),
861 (double) avg_load_avg_15 / (avg_count * 100));
863 (double) avg_procs_blocked / avg_count);
866 /* Reset average counters */
867 avg_nr_running = avg_nr_threads = 0;
868 avg_load_avg_1 = avg_load_avg_5 = avg_load_avg_15 = 0;
869 avg_procs_blocked = 0;
874 ***************************************************************************
875 * Display queue and load statistics.
878 * @a Activity structure with statistics.
879 * @prev Index in array where stats used as reference are.
880 * @curr Index in array for current sample statistics.
881 * @itv Interval of time in jiffies.
882 ***************************************************************************
884 __print_funct_t print_queue_stats(struct activity *a, int prev, int curr,
885 unsigned long long itv)
887 stub_print_queue_stats(a, curr, FALSE);
891 ***************************************************************************
892 * Display average queue and load statistics.
895 * @a Activity structure with statistics.
896 * @prev Index in array where stats used as reference are.
897 * @curr Index in array for current sample statistics.
898 * @itv Interval of time in jiffies.
899 ***************************************************************************
901 __print_funct_t print_avg_queue_stats(struct activity *a, int prev, int curr,
902 unsigned long long itv)
904 stub_print_queue_stats(a, curr, TRUE);
908 ***************************************************************************
909 * Display serial lines statistics.
912 * @a Activity structure with statistics.
913 * @prev Index in array where stats used as reference are.
914 * @curr Index in array for current sample statistics.
915 * @itv Interval of time in jiffies.
916 ***************************************************************************
918 __print_funct_t print_serial_stats(struct activity *a, int prev, int curr,
919 unsigned long long itv)
922 struct stats_serial *ssc, *ssp;
925 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
928 for (i = 0; i < a->nr; i++) {
930 ssc = (struct stats_serial *) ((char *) a->buf[curr] + i * a->msize);
931 ssp = (struct stats_serial *) ((char *) a->buf[prev] + i * a->msize);
936 printf("%-11s", timestamp[curr]);
937 cprintf_in(IS_INT, " %3d", "", ssc->line - 1);
939 if ((ssc->line == ssp->line) || WANT_SINCE_BOOT(flags)) {
941 S_VALUE(ssp->rx, ssc->rx, itv),
942 S_VALUE(ssp->tx, ssc->tx, itv),
943 S_VALUE(ssp->frame, ssc->frame, itv),
944 S_VALUE(ssp->parity, ssc->parity, itv),
945 S_VALUE(ssp->brk, ssc->brk, itv),
946 S_VALUE(ssp->overrun, ssc->overrun, itv));
950 printf(" N/A N/A N/A N/A"
957 ***************************************************************************
958 * Display disks statistics.
961 * @a Activity structure with statistics.
962 * @prev Index in array where stats used as reference are.
963 * @curr Index in array for current sample statistics.
964 * @itv Interval of time in jiffies.
965 ***************************************************************************
967 __print_funct_t print_disk_stats(struct activity *a, int prev, int curr,
968 unsigned long long itv)
971 struct stats_disk *sdc, *sdp;
972 struct ext_disk_stats xds;
973 char *dev_name, *persist_dev_name;
976 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
979 for (i = 0; i < a->nr; i++) {
981 sdc = (struct stats_disk *) ((char *) a->buf[curr] + i * a->msize);
983 if (!(sdc->major + sdc->minor))
986 j = check_disk_reg(a, curr, prev, i);
987 sdp = (struct stats_disk *) ((char *) a->buf[prev] + j * a->msize);
989 /* Compute service time, etc. */
990 compute_ext_disk_stats(sdc, sdp, itv, &xds);
993 persist_dev_name = NULL;
995 if (DISPLAY_PERSIST_NAME_S(flags)) {
996 persist_dev_name = get_persistent_name_from_pretty(get_devname(sdc->major, sdc->minor, TRUE));
999 if (persist_dev_name) {
1000 dev_name = persist_dev_name;
1003 if ((USE_PRETTY_OPTION(flags)) && (sdc->major == dm_major)) {
1004 dev_name = transform_devmapname(sdc->major, sdc->minor);
1008 dev_name = get_devname(sdc->major, sdc->minor,
1009 USE_PRETTY_OPTION(flags));
1013 printf("%-11s", timestamp[curr]);
1015 cprintf_in(IS_STR, " %9s", dev_name, 0);
1017 S_VALUE(sdp->nr_ios, sdc->nr_ios, itv),
1018 S_VALUE(sdp->rd_sect, sdc->rd_sect, itv),
1019 S_VALUE(sdp->wr_sect, sdc->wr_sect, itv),
1020 /* See iostat for explanations */
1022 S_VALUE(sdp->rq_ticks, sdc->rq_ticks, itv) / 1000.0,
1032 ***************************************************************************
1033 * Display network interfaces statistics.
1036 * @a Activity structure with statistics.
1037 * @prev Index in array where stats used as reference are.
1038 * @curr Index in array for current sample statistics.
1039 * @itv Interval of time in jiffies.
1040 ***************************************************************************
1042 __print_funct_t print_net_dev_stats(struct activity *a, int prev, int curr,
1043 unsigned long long itv)
1046 struct stats_net_dev *sndc, *sndp;
1047 double rxkb, txkb, ifutil;
1050 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
1053 for (i = 0; i < a->nr; i++) {
1055 sndc = (struct stats_net_dev *) ((char *) a->buf[curr] + i * a->msize);
1057 if (!strcmp(sndc->interface, ""))
1060 j = check_net_dev_reg(a, curr, prev, i);
1061 sndp = (struct stats_net_dev *) ((char *) a->buf[prev] + j * a->msize);
1063 printf("%-11s", timestamp[curr]);
1064 cprintf_in(IS_STR, " %9s", sndc->interface, 0);
1066 rxkb = S_VALUE(sndp->rx_bytes, sndc->rx_bytes, itv);
1067 txkb = S_VALUE(sndp->tx_bytes, sndc->tx_bytes, itv);
1070 S_VALUE(sndp->rx_packets, sndc->rx_packets, itv),
1071 S_VALUE(sndp->tx_packets, sndc->tx_packets, itv),
1074 S_VALUE(sndp->rx_compressed, sndc->rx_compressed, itv),
1075 S_VALUE(sndp->tx_compressed, sndc->tx_compressed, itv),
1076 S_VALUE(sndp->multicast, sndc->multicast, itv));
1077 ifutil = compute_ifutil(sndc, rxkb, txkb);
1078 cprintf_pc(1, 9, 2, ifutil);
1084 ***************************************************************************
1085 * Display network interface errors statistics.
1088 * @a Activity structure with statistics.
1089 * @prev Index in array where stats used as reference are.
1090 * @curr Index in array for current sample statistics.
1091 * @itv Interval of time in jiffies.
1092 ***************************************************************************
1094 __print_funct_t print_net_edev_stats(struct activity *a, int prev, int curr,
1095 unsigned long long itv)
1098 struct stats_net_edev *snedc, *snedp;
1101 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
1104 for (i = 0; i < a->nr; i++) {
1106 snedc = (struct stats_net_edev *) ((char *) a->buf[curr] + i * a->msize);
1108 if (!strcmp(snedc->interface, ""))
1111 j = check_net_edev_reg(a, curr, prev, i);
1112 snedp = (struct stats_net_edev *) ((char *) a->buf[prev] + j * a->msize);
1114 printf("%-11s", timestamp[curr]);
1115 cprintf_in(IS_STR, " %9s", snedc->interface, 0);
1118 S_VALUE(snedp->rx_errors, snedc->rx_errors, itv),
1119 S_VALUE(snedp->tx_errors, snedc->tx_errors, itv),
1120 S_VALUE(snedp->collisions, snedc->collisions, itv),
1121 S_VALUE(snedp->rx_dropped, snedc->rx_dropped, itv),
1122 S_VALUE(snedp->tx_dropped, snedc->tx_dropped, itv),
1123 S_VALUE(snedp->tx_carrier_errors, snedc->tx_carrier_errors, itv),
1124 S_VALUE(snedp->rx_frame_errors, snedc->rx_frame_errors, itv),
1125 S_VALUE(snedp->rx_fifo_errors, snedc->rx_fifo_errors, itv),
1126 S_VALUE(snedp->tx_fifo_errors, snedc->tx_fifo_errors, itv));
1132 ***************************************************************************
1133 * Display NFS client statistics.
1136 * @a Activity structure with statistics.
1137 * @prev Index in array where stats used as reference are.
1138 * @curr Index in array for current sample statistics.
1139 * @itv Interval of time in jiffies.
1140 ***************************************************************************
1142 __print_funct_t print_net_nfs_stats(struct activity *a, int prev, int curr,
1143 unsigned long long itv)
1145 struct stats_net_nfs
1146 *snnc = (struct stats_net_nfs *) a->buf[curr],
1147 *snnp = (struct stats_net_nfs *) a->buf[prev];
1150 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
1153 printf("%-11s", timestamp[curr]);
1155 S_VALUE(snnp->nfs_rpccnt, snnc->nfs_rpccnt, itv),
1156 S_VALUE(snnp->nfs_rpcretrans, snnc->nfs_rpcretrans, itv),
1157 S_VALUE(snnp->nfs_readcnt, snnc->nfs_readcnt, itv),
1158 S_VALUE(snnp->nfs_writecnt, snnc->nfs_writecnt, itv),
1159 S_VALUE(snnp->nfs_accesscnt, snnc->nfs_accesscnt, itv),
1160 S_VALUE(snnp->nfs_getattcnt, snnc->nfs_getattcnt, itv));
1165 ***************************************************************************
1166 * Display NFS server statistics.
1169 * @a Activity structure with statistics.
1170 * @prev Index in array where stats used as reference are.
1171 * @curr Index in array for current sample statistics.
1172 * @itv Interval of time in jiffies.
1173 ***************************************************************************
1175 __print_funct_t print_net_nfsd_stats(struct activity *a, int prev, int curr,
1176 unsigned long long itv)
1178 struct stats_net_nfsd
1179 *snndc = (struct stats_net_nfsd *) a->buf[curr],
1180 *snndp = (struct stats_net_nfsd *) a->buf[prev];
1183 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
1186 printf("%-11s", timestamp[curr]);
1188 S_VALUE(snndp->nfsd_rpccnt, snndc->nfsd_rpccnt, itv),
1189 S_VALUE(snndp->nfsd_rpcbad, snndc->nfsd_rpcbad, itv),
1190 S_VALUE(snndp->nfsd_netcnt, snndc->nfsd_netcnt, itv),
1191 S_VALUE(snndp->nfsd_netudpcnt, snndc->nfsd_netudpcnt, itv),
1192 S_VALUE(snndp->nfsd_nettcpcnt, snndc->nfsd_nettcpcnt, itv),
1193 S_VALUE(snndp->nfsd_rchits, snndc->nfsd_rchits, itv),
1194 S_VALUE(snndp->nfsd_rcmisses, snndc->nfsd_rcmisses, itv),
1195 S_VALUE(snndp->nfsd_readcnt, snndc->nfsd_readcnt, itv),
1196 S_VALUE(snndp->nfsd_writecnt, snndc->nfsd_writecnt, itv),
1197 S_VALUE(snndp->nfsd_accesscnt, snndc->nfsd_accesscnt, itv),
1198 S_VALUE(snndp->nfsd_getattcnt, snndc->nfsd_getattcnt, itv));
1203 ***************************************************************************
1204 * Display network sockets statistics. This function is used to display
1205 * instantaneous and average statistics.
1208 * @a Activity structure with statistics.
1209 * @curr Index in array for current sample statistics.
1210 * @dispavg TRUE if displaying average statistics.
1211 ***************************************************************************
1213 void stub_print_net_sock_stats(struct activity *a, int curr, int dispavg)
1215 struct stats_net_sock
1216 *snsc = (struct stats_net_sock *) a->buf[curr];
1217 static unsigned long long
1226 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
1230 /* Display instantaneous values */
1231 printf("%-11s", timestamp[curr]);
1233 (unsigned long long) snsc->sock_inuse,
1234 (unsigned long long) snsc->tcp_inuse,
1235 (unsigned long long) snsc->udp_inuse,
1236 (unsigned long long) snsc->raw_inuse,
1237 (unsigned long long) snsc->frag_inuse,
1238 (unsigned long long) snsc->tcp_tw);
1241 /* Will be used to compute the average */
1242 avg_sock_inuse += snsc->sock_inuse;
1243 avg_tcp_inuse += snsc->tcp_inuse;
1244 avg_udp_inuse += snsc->udp_inuse;
1245 avg_raw_inuse += snsc->raw_inuse;
1246 avg_frag_inuse += snsc->frag_inuse;
1247 avg_tcp_tw += snsc->tcp_tw;
1250 /* Display average values */
1251 printf("%-11s", timestamp[curr]);
1253 (double) avg_sock_inuse / avg_count,
1254 (double) avg_tcp_inuse / avg_count,
1255 (double) avg_udp_inuse / avg_count,
1256 (double) avg_raw_inuse / avg_count,
1257 (double) avg_frag_inuse / avg_count,
1258 (double) avg_tcp_tw / avg_count);
1261 /* Reset average counters */
1262 avg_sock_inuse = avg_tcp_inuse = avg_udp_inuse = 0;
1263 avg_raw_inuse = avg_frag_inuse = avg_tcp_tw = 0;
1268 ***************************************************************************
1269 * Display network sockets statistics.
1272 * @a Activity structure with statistics.
1273 * @prev Index in array where stats used as reference are.
1274 * @curr Index in array for current sample statistics.
1275 * @itv Interval of time in jiffies.
1276 ***************************************************************************
1278 __print_funct_t print_net_sock_stats(struct activity *a, int prev, int curr,
1279 unsigned long long itv)
1281 stub_print_net_sock_stats(a, curr, FALSE);
1285 ***************************************************************************
1286 * Display average network sockets statistics.
1289 * @a Activity structure with statistics.
1290 * @prev Index in array where stats used as reference are.
1291 * @curr Index in array for current sample statistics.
1292 * @itv Interval of time in jiffies.
1293 ***************************************************************************
1295 __print_funct_t print_avg_net_sock_stats(struct activity *a, int prev, int curr,
1296 unsigned long long itv)
1298 stub_print_net_sock_stats(a, curr, TRUE);
1302 ***************************************************************************
1303 * Display IP network traffic statistics.
1306 * @a Activity structure with statistics.
1307 * @prev Index in array where stats used as reference are.
1308 * @curr Index in array for current sample statistics.
1309 * @itv Interval of time in jiffies.
1310 ***************************************************************************
1312 __print_funct_t print_net_ip_stats(struct activity *a, int prev, int curr,
1313 unsigned long long itv)
1316 *snic = (struct stats_net_ip *) a->buf[curr],
1317 *snip = (struct stats_net_ip *) a->buf[prev];
1320 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
1323 printf("%-11s", timestamp[curr]);
1325 S_VALUE(snip->InReceives, snic->InReceives, itv),
1326 S_VALUE(snip->ForwDatagrams, snic->ForwDatagrams, itv),
1327 S_VALUE(snip->InDelivers, snic->InDelivers, itv),
1328 S_VALUE(snip->OutRequests, snic->OutRequests, itv),
1329 S_VALUE(snip->ReasmReqds, snic->ReasmReqds, itv),
1330 S_VALUE(snip->ReasmOKs, snic->ReasmOKs, itv),
1331 S_VALUE(snip->FragOKs, snic->FragOKs, itv),
1332 S_VALUE(snip->FragCreates, snic->FragCreates, itv));
1337 ***************************************************************************
1338 * Display IP network errors statistics.
1341 * @a Activity structure with statistics.
1342 * @prev Index in array where stats used as reference are.
1343 * @curr Index in array for current sample statistics.
1344 * @itv Interval of time in jiffies.
1345 ***************************************************************************
1347 __print_funct_t print_net_eip_stats(struct activity *a, int prev, int curr,
1348 unsigned long long itv)
1350 struct stats_net_eip
1351 *sneic = (struct stats_net_eip *) a->buf[curr],
1352 *sneip = (struct stats_net_eip *) a->buf[prev];
1355 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
1358 printf("%-11s", timestamp[curr]);
1360 S_VALUE(sneip->InHdrErrors, sneic->InHdrErrors, itv),
1361 S_VALUE(sneip->InAddrErrors, sneic->InAddrErrors, itv),
1362 S_VALUE(sneip->InUnknownProtos, sneic->InUnknownProtos, itv),
1363 S_VALUE(sneip->InDiscards, sneic->InDiscards, itv),
1364 S_VALUE(sneip->OutDiscards, sneic->OutDiscards, itv),
1365 S_VALUE(sneip->OutNoRoutes, sneic->OutNoRoutes, itv),
1366 S_VALUE(sneip->ReasmFails, sneic->ReasmFails, itv),
1367 S_VALUE(sneip->FragFails, sneic->FragFails, itv));
1372 ***************************************************************************
1373 * Display ICMP network traffic statistics.
1376 * @a Activity structure with statistics.
1377 * @prev Index in array where stats used as reference are.
1378 * @curr Index in array for current sample statistics.
1379 * @itv Interval of time in jiffies.
1380 ***************************************************************************
1382 __print_funct_t print_net_icmp_stats(struct activity *a, int prev, int curr,
1383 unsigned long long itv)
1385 struct stats_net_icmp
1386 *snic = (struct stats_net_icmp *) a->buf[curr],
1387 *snip = (struct stats_net_icmp *) a->buf[prev];
1390 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
1393 printf("%-11s", timestamp[curr]);
1395 S_VALUE(snip->InMsgs, snic->InMsgs, itv),
1396 S_VALUE(snip->OutMsgs, snic->OutMsgs, itv),
1397 S_VALUE(snip->InEchos, snic->InEchos, itv),
1398 S_VALUE(snip->InEchoReps, snic->InEchoReps, itv),
1399 S_VALUE(snip->OutEchos, snic->OutEchos, itv),
1400 S_VALUE(snip->OutEchoReps, snic->OutEchoReps, itv),
1401 S_VALUE(snip->InTimestamps, snic->InTimestamps, itv),
1402 S_VALUE(snip->InTimestampReps, snic->InTimestampReps, itv),
1403 S_VALUE(snip->OutTimestamps, snic->OutTimestamps, itv),
1404 S_VALUE(snip->OutTimestampReps, snic->OutTimestampReps, itv),
1405 S_VALUE(snip->InAddrMasks, snic->InAddrMasks, itv),
1406 S_VALUE(snip->InAddrMaskReps, snic->InAddrMaskReps, itv),
1407 S_VALUE(snip->OutAddrMasks, snic->OutAddrMasks, itv),
1408 S_VALUE(snip->OutAddrMaskReps, snic->OutAddrMaskReps, itv));
1413 ***************************************************************************
1414 * Display ICMP network errors statistics.
1417 * @a Activity structure with statistics.
1418 * @prev Index in array where stats used as reference are.
1419 * @curr Index in array for current sample statistics.
1420 * @itv Interval of time in jiffies.
1421 ***************************************************************************
1423 __print_funct_t print_net_eicmp_stats(struct activity *a, int prev, int curr,
1424 unsigned long long itv)
1426 struct stats_net_eicmp
1427 *sneic = (struct stats_net_eicmp *) a->buf[curr],
1428 *sneip = (struct stats_net_eicmp *) a->buf[prev];
1431 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
1434 printf("%-11s", timestamp[curr]);
1436 S_VALUE(sneip->InErrors, sneic->InErrors, itv),
1437 S_VALUE(sneip->OutErrors, sneic->OutErrors, itv),
1438 S_VALUE(sneip->InDestUnreachs, sneic->InDestUnreachs, itv),
1439 S_VALUE(sneip->OutDestUnreachs, sneic->OutDestUnreachs, itv),
1440 S_VALUE(sneip->InTimeExcds, sneic->InTimeExcds, itv),
1441 S_VALUE(sneip->OutTimeExcds, sneic->OutTimeExcds, itv),
1442 S_VALUE(sneip->InParmProbs, sneic->InParmProbs, itv),
1443 S_VALUE(sneip->OutParmProbs, sneic->OutParmProbs, itv),
1444 S_VALUE(sneip->InSrcQuenchs, sneic->InSrcQuenchs, itv),
1445 S_VALUE(sneip->OutSrcQuenchs, sneic->OutSrcQuenchs, itv),
1446 S_VALUE(sneip->InRedirects, sneic->InRedirects, itv),
1447 S_VALUE(sneip->OutRedirects, sneic->OutRedirects, itv));
1452 ***************************************************************************
1453 * Display TCP network traffic statistics.
1456 * @a Activity structure with statistics.
1457 * @prev Index in array where stats used as reference are.
1458 * @curr Index in array for current sample statistics.
1459 * @itv Interval of time in jiffies.
1460 ***************************************************************************
1462 __print_funct_t print_net_tcp_stats(struct activity *a, int prev, int curr,
1463 unsigned long long itv)
1465 struct stats_net_tcp
1466 *sntc = (struct stats_net_tcp *) a->buf[curr],
1467 *sntp = (struct stats_net_tcp *) a->buf[prev];
1470 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
1473 printf("%-11s", timestamp[curr]);
1475 S_VALUE(sntp->ActiveOpens, sntc->ActiveOpens, itv),
1476 S_VALUE(sntp->PassiveOpens, sntc->PassiveOpens, itv),
1477 S_VALUE(sntp->InSegs, sntc->InSegs, itv),
1478 S_VALUE(sntp->OutSegs, sntc->OutSegs, itv));
1483 ***************************************************************************
1484 * Display TCP network errors statistics.
1487 * @a Activity structure with statistics.
1488 * @prev Index in array where stats used as reference are.
1489 * @curr Index in array for current sample statistics.
1490 * @itv Interval of time in jiffies.
1491 ***************************************************************************
1493 __print_funct_t print_net_etcp_stats(struct activity *a, int prev, int curr,
1494 unsigned long long itv)
1496 struct stats_net_etcp
1497 *snetc = (struct stats_net_etcp *) a->buf[curr],
1498 *snetp = (struct stats_net_etcp *) a->buf[prev];
1501 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
1504 printf("%-11s", timestamp[curr]);
1506 S_VALUE(snetp->AttemptFails, snetc->AttemptFails, itv),
1507 S_VALUE(snetp->EstabResets, snetc->EstabResets, itv),
1508 S_VALUE(snetp->RetransSegs, snetc->RetransSegs, itv),
1509 S_VALUE(snetp->InErrs, snetc->InErrs, itv),
1510 S_VALUE(snetp->OutRsts, snetc->OutRsts, itv));
1515 ***************************************************************************
1516 * Display UDP network traffic statistics.
1519 * @a Activity structure with statistics.
1520 * @prev Index in array where stats used as reference are.
1521 * @curr Index in array for current sample statistics.
1522 * @itv Interval of time in jiffies.
1523 ***************************************************************************
1525 __print_funct_t print_net_udp_stats(struct activity *a, int prev, int curr,
1526 unsigned long long itv)
1528 struct stats_net_udp
1529 *snuc = (struct stats_net_udp *) a->buf[curr],
1530 *snup = (struct stats_net_udp *) a->buf[prev];
1533 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
1536 printf("%-11s", timestamp[curr]);
1538 S_VALUE(snup->InDatagrams, snuc->InDatagrams, itv),
1539 S_VALUE(snup->OutDatagrams, snuc->OutDatagrams, itv),
1540 S_VALUE(snup->NoPorts, snuc->NoPorts, itv),
1541 S_VALUE(snup->InErrors, snuc->InErrors, itv));
1546 ***************************************************************************
1547 * Display IPv6 sockets statistics. This function is used to display
1548 * instantaneous and average statistics.
1551 * @a Activity structure with statistics.
1552 * @curr Index in array for current sample statistics.
1553 * @dispavg TRUE if displaying average statistics.
1554 ***************************************************************************
1556 void stub_print_net_sock6_stats(struct activity *a, int curr, int dispavg)
1558 struct stats_net_sock6
1559 *snsc = (struct stats_net_sock6 *) a->buf[curr];
1560 static unsigned long long
1564 avg_frag6_inuse = 0;
1567 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
1571 /* Display instantaneous values */
1572 printf("%-11s", timestamp[curr]);
1574 (unsigned long long) snsc->tcp6_inuse,
1575 (unsigned long long) snsc->udp6_inuse,
1576 (unsigned long long) snsc->raw6_inuse,
1577 (unsigned long long) snsc->frag6_inuse);
1580 /* Will be used to compute the average */
1581 avg_tcp6_inuse += snsc->tcp6_inuse;
1582 avg_udp6_inuse += snsc->udp6_inuse;
1583 avg_raw6_inuse += snsc->raw6_inuse;
1584 avg_frag6_inuse += snsc->frag6_inuse;
1587 /* Display average values */
1588 printf("%-11s", timestamp[curr]);
1590 (double) avg_tcp6_inuse / avg_count,
1591 (double) avg_udp6_inuse / avg_count,
1592 (double) avg_raw6_inuse / avg_count,
1593 (double) avg_frag6_inuse / avg_count);
1596 /* Reset average counters */
1597 avg_tcp6_inuse = avg_udp6_inuse = avg_raw6_inuse = avg_frag6_inuse = 0;
1602 ***************************************************************************
1603 * Display IPv6 sockets statistics.
1606 * @a Activity structure with statistics.
1607 * @prev Index in array where stats used as reference are.
1608 * @curr Index in array for current sample statistics.
1609 * @itv Interval of time in jiffies.
1610 ***************************************************************************
1612 __print_funct_t print_net_sock6_stats(struct activity *a, int prev, int curr,
1613 unsigned long long itv)
1615 stub_print_net_sock6_stats(a, curr, FALSE);
1619 ***************************************************************************
1620 * Display average IPv6 sockets statistics.
1623 * @a Activity structure with statistics.
1624 * @prev Index in array where stats used as reference are.
1625 * @curr Index in array for current sample statistics.
1626 * @itv Interval of time in jiffies.
1627 ***************************************************************************
1629 __print_funct_t print_avg_net_sock6_stats(struct activity *a, int prev, int curr,
1630 unsigned long long itv)
1632 stub_print_net_sock6_stats(a, curr, TRUE);
1636 ***************************************************************************
1637 * Display IPv6 network traffic statistics.
1640 * @a Activity structure with statistics.
1641 * @prev Index in array where stats used as reference are.
1642 * @curr Index in array for current sample statistics.
1643 * @itv Interval of time in jiffies.
1644 ***************************************************************************
1646 __print_funct_t print_net_ip6_stats(struct activity *a, int prev, int curr,
1647 unsigned long long itv)
1649 struct stats_net_ip6
1650 *snic = (struct stats_net_ip6 *) a->buf[curr],
1651 *snip = (struct stats_net_ip6 *) a->buf[prev];
1654 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
1657 printf("%-11s", timestamp[curr]);
1659 S_VALUE(snip->InReceives6, snic->InReceives6, itv),
1660 S_VALUE(snip->OutForwDatagrams6, snic->OutForwDatagrams6, itv),
1661 S_VALUE(snip->InDelivers6, snic->InDelivers6, itv),
1662 S_VALUE(snip->OutRequests6, snic->OutRequests6, itv),
1663 S_VALUE(snip->ReasmReqds6, snic->ReasmReqds6, itv),
1664 S_VALUE(snip->ReasmOKs6, snic->ReasmOKs6, itv),
1665 S_VALUE(snip->InMcastPkts6, snic->InMcastPkts6, itv),
1666 S_VALUE(snip->OutMcastPkts6, snic->OutMcastPkts6, itv),
1667 S_VALUE(snip->FragOKs6, snic->FragOKs6, itv),
1668 S_VALUE(snip->FragCreates6, snic->FragCreates6, itv));
1673 ***************************************************************************
1674 * Display IPv6 network errors statistics.
1677 * @a Activity structure with statistics.
1678 * @prev Index in array where stats used as reference are.
1679 * @curr Index in array for current sample statistics.
1680 * @itv Interval of time in jiffies.
1681 ***************************************************************************
1683 __print_funct_t print_net_eip6_stats(struct activity *a, int prev, int curr,
1684 unsigned long long itv)
1686 struct stats_net_eip6
1687 *sneic = (struct stats_net_eip6 *) a->buf[curr],
1688 *sneip = (struct stats_net_eip6 *) a->buf[prev];
1691 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
1694 printf("%-11s", timestamp[curr]);
1696 S_VALUE(sneip->InHdrErrors6, sneic->InHdrErrors6, itv),
1697 S_VALUE(sneip->InAddrErrors6, sneic->InAddrErrors6, itv),
1698 S_VALUE(sneip->InUnknownProtos6, sneic->InUnknownProtos6, itv),
1699 S_VALUE(sneip->InTooBigErrors6, sneic->InTooBigErrors6, itv),
1700 S_VALUE(sneip->InDiscards6, sneic->InDiscards6, itv),
1701 S_VALUE(sneip->OutDiscards6, sneic->OutDiscards6, itv),
1702 S_VALUE(sneip->InNoRoutes6, sneic->InNoRoutes6, itv),
1703 S_VALUE(sneip->OutNoRoutes6, sneic->OutNoRoutes6, itv),
1704 S_VALUE(sneip->ReasmFails6, sneic->ReasmFails6, itv),
1705 S_VALUE(sneip->FragFails6, sneic->FragFails6, itv),
1706 S_VALUE(sneip->InTruncatedPkts6, sneic->InTruncatedPkts6, itv));
1711 ***************************************************************************
1712 * Display ICMPv6 network traffic statistics.
1715 * @a Activity structure with statistics.
1716 * @prev Index in array where stats used as reference are.
1717 * @curr Index in array for current sample statistics.
1718 * @itv Interval of time in jiffies.
1719 ***************************************************************************
1721 __print_funct_t print_net_icmp6_stats(struct activity *a, int prev, int curr,
1722 unsigned long long itv)
1724 struct stats_net_icmp6
1725 *snic = (struct stats_net_icmp6 *) a->buf[curr],
1726 *snip = (struct stats_net_icmp6 *) a->buf[prev];
1729 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
1732 printf("%-11s", timestamp[curr]);
1734 S_VALUE(snip->InMsgs6, snic->InMsgs6, itv),
1735 S_VALUE(snip->OutMsgs6, snic->OutMsgs6, itv),
1736 S_VALUE(snip->InEchos6, snic->InEchos6, itv),
1737 S_VALUE(snip->InEchoReplies6, snic->InEchoReplies6, itv),
1738 S_VALUE(snip->OutEchoReplies6, snic->OutEchoReplies6, itv),
1739 S_VALUE(snip->InGroupMembQueries6, snic->InGroupMembQueries6, itv),
1740 S_VALUE(snip->InGroupMembResponses6, snic->InGroupMembResponses6, itv),
1741 S_VALUE(snip->OutGroupMembResponses6, snic->OutGroupMembResponses6, itv),
1742 S_VALUE(snip->InGroupMembReductions6, snic->InGroupMembReductions6, itv),
1743 S_VALUE(snip->OutGroupMembReductions6, snic->OutGroupMembReductions6, itv),
1744 S_VALUE(snip->InRouterSolicits6, snic->InRouterSolicits6, itv),
1745 S_VALUE(snip->OutRouterSolicits6, snic->OutRouterSolicits6, itv),
1746 S_VALUE(snip->InRouterAdvertisements6, snic->InRouterAdvertisements6, itv),
1747 S_VALUE(snip->InNeighborSolicits6, snic->InNeighborSolicits6, itv),
1748 S_VALUE(snip->OutNeighborSolicits6, snic->OutNeighborSolicits6, itv),
1749 S_VALUE(snip->InNeighborAdvertisements6, snic->InNeighborAdvertisements6, itv),
1750 S_VALUE(snip->OutNeighborAdvertisements6, snic->OutNeighborAdvertisements6, itv));
1755 ***************************************************************************
1756 * Display ICMPv6 network errors statistics.
1759 * @a Activity structure with statistics.
1760 * @prev Index in array where stats used as reference are.
1761 * @curr Index in array for current sample statistics.
1762 * @itv Interval of time in jiffies.
1763 ***************************************************************************
1765 __print_funct_t print_net_eicmp6_stats(struct activity *a, int prev, int curr,
1766 unsigned long long itv)
1768 struct stats_net_eicmp6
1769 *sneic = (struct stats_net_eicmp6 *) a->buf[curr],
1770 *sneip = (struct stats_net_eicmp6 *) a->buf[prev];
1773 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
1776 printf("%-11s", timestamp[curr]);
1778 S_VALUE(sneip->InErrors6, sneic->InErrors6, itv),
1779 S_VALUE(sneip->InDestUnreachs6, sneic->InDestUnreachs6, itv),
1780 S_VALUE(sneip->OutDestUnreachs6, sneic->OutDestUnreachs6, itv),
1781 S_VALUE(sneip->InTimeExcds6, sneic->InTimeExcds6, itv),
1782 S_VALUE(sneip->OutTimeExcds6, sneic->OutTimeExcds6, itv),
1783 S_VALUE(sneip->InParmProblems6, sneic->InParmProblems6, itv),
1784 S_VALUE(sneip->OutParmProblems6, sneic->OutParmProblems6, itv),
1785 S_VALUE(sneip->InRedirects6, sneic->InRedirects6, itv),
1786 S_VALUE(sneip->OutRedirects6, sneic->OutRedirects6, itv),
1787 S_VALUE(sneip->InPktTooBigs6, sneic->InPktTooBigs6, itv),
1788 S_VALUE(sneip->OutPktTooBigs6, sneic->OutPktTooBigs6, itv));
1793 ***************************************************************************
1794 * Display UDPv6 network traffic statistics.
1797 * @a Activity structure with statistics.
1798 * @prev Index in array where stats used as reference are.
1799 * @curr Index in array for current sample statistics.
1800 * @itv Interval of time in jiffies.
1801 ***************************************************************************
1803 __print_funct_t print_net_udp6_stats(struct activity *a, int prev, int curr,
1804 unsigned long long itv)
1806 struct stats_net_udp6
1807 *snuc = (struct stats_net_udp6 *) a->buf[curr],
1808 *snup = (struct stats_net_udp6 *) a->buf[prev];
1811 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
1814 printf("%-11s", timestamp[curr]);
1816 S_VALUE(snup->InDatagrams6, snuc->InDatagrams6, itv),
1817 S_VALUE(snup->OutDatagrams6, snuc->OutDatagrams6, itv),
1818 S_VALUE(snup->NoPorts6, snuc->NoPorts6, itv),
1819 S_VALUE(snup->InErrors6, snuc->InErrors6, itv));
1824 ***************************************************************************
1825 * Display CPU frequency statistics. This function is used to display
1826 * instantaneous and average statistics.
1829 * @a Activity structure with statistics.
1830 * @curr Index in array for current sample statistics.
1831 * @dispavg True if displaying average statistics.
1832 ***************************************************************************
1834 void stub_print_pwr_cpufreq_stats(struct activity *a, int curr, int dispavg)
1837 struct stats_pwr_cpufreq *spc;
1838 static unsigned long long
1839 *avg_cpufreq = NULL;
1842 /* Allocate array of CPU frequency */
1843 if ((avg_cpufreq = (unsigned long long *) malloc(sizeof(unsigned long long) * a->nr))
1848 memset(avg_cpufreq, 0, sizeof(unsigned long long) * a->nr);
1852 print_hdr_line(timestamp[!curr], a, FIRST, 7, 9);
1855 for (i = 0; (i < a->nr) && (i < a->bitmap->b_size + 1); i++) {
1858 * The size of a->buf[...] CPU structure may be different from the default
1859 * sizeof(struct stats_pwr_cpufreq) value if data have been read from a file!
1860 * That's why we don't use a syntax like:
1861 * spc = (struct stats_pwr_cpufreq *) a->buf[...] + i;
1863 spc = (struct stats_pwr_cpufreq *) ((char *) a->buf[curr] + i * a->msize);
1866 * Note: a->nr is in [1, NR_CPUS + 1].
1867 * Bitmap size is provided for (NR_CPUS + 1) CPUs.
1868 * Anyway, NR_CPUS may vary between the version of sysstat
1869 * used by sadc to create a file, and the version of sysstat
1870 * used by sar to read it...
1873 /* Should current CPU (including CPU "all") be displayed? */
1874 if (a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))) {
1876 /* Yes: Display it */
1877 printf("%-11s", timestamp[curr]);
1880 /* This is CPU "all" */
1881 cprintf_in(IS_STR, "%s", " all", 0);
1884 cprintf_in(IS_INT, " %3d", "", i - 1);
1888 /* Display instantaneous values */
1890 ((double) spc->cpufreq) / 100);
1893 * Will be used to compute the average.
1894 * Note: overflow unlikely to happen but not impossible...
1896 avg_cpufreq[i] += spc->cpufreq;
1899 /* Display average values */
1901 (double) avg_cpufreq[i] / (100 * avg_count));
1908 /* Array of CPU frequency no longer needed: Free it! */
1917 ***************************************************************************
1918 * Display CPU frequency statistics.
1921 * @a Activity structure with statistics.
1922 * @prev Index in array where stats used as reference are.
1923 * @curr Index in array for current sample statistics.
1924 * @itv Interval of time in jiffies.
1925 ***************************************************************************
1927 __print_funct_t print_pwr_cpufreq_stats(struct activity *a, int prev, int curr,
1928 unsigned long long itv)
1930 stub_print_pwr_cpufreq_stats(a, curr, FALSE);
1934 ***************************************************************************
1935 * Display average CPU frequency statistics.
1938 * @a Activity structure with statistics.
1939 * @prev Index in array where stats used as reference are.
1940 * @curr Index in array for current sample statistics.
1941 * @itv Interval of time in jiffies.
1942 ***************************************************************************
1944 __print_funct_t print_avg_pwr_cpufreq_stats(struct activity *a, int prev, int curr,
1945 unsigned long long itv)
1947 stub_print_pwr_cpufreq_stats(a, curr, TRUE);
1951 ***************************************************************************
1952 * Display fan statistics. This function is used to display
1953 * instantaneous and average statistics.
1956 * @a Activity structure with statistics.
1957 * @curr Index in array for current sample statistics.
1958 * @dispavg True if displaying average statistics.
1959 ***************************************************************************
1961 void stub_print_pwr_fan_stats(struct activity *a, int curr, int dispavg)
1964 struct stats_pwr_fan *spc;
1965 static double *avg_fan = NULL;
1966 static double *avg_fan_min = NULL;
1968 /* Allocate arrays of fan RPMs */
1970 if ((avg_fan = (double *) malloc(sizeof(double) * a->nr)) == NULL) {
1974 memset(avg_fan, 0, sizeof(double) * a->nr);
1977 if ((avg_fan_min = (double *) malloc(sizeof(double) * a->nr)) == NULL) {
1981 memset(avg_fan_min, 0, sizeof(double) * a->nr);
1985 print_hdr_line(timestamp[!curr], a, FIRST, -2, 9);
1988 for (i = 0; i < a->nr; i++) {
1989 spc = (struct stats_pwr_fan *) ((char *) a->buf[curr] + i * a->msize);
1991 printf("%-11s", timestamp[curr]);
1992 cprintf_in(IS_INT, " %5d", "", i + 1);
1995 /* Display average values */
1997 (double) avg_fan[i] / avg_count,
1998 (double) (avg_fan[i] - avg_fan_min[i]) / avg_count);
2001 /* Display instantaneous values */
2004 spc->rpm - spc->rpm_min);
2005 avg_fan[i] += spc->rpm;
2006 avg_fan_min[i] += spc->rpm_min;
2009 cprintf_in(IS_STR, " %s\n", spc->device, 0);
2025 ***************************************************************************
2026 * Display fan statistics.
2029 * @a Activity structure with statistics.
2030 * @prev Index in array where stats used as reference are.
2031 * @curr Index in array for current sample statistics.
2032 * @itv Interval of time in jiffies.
2033 ***************************************************************************
2035 __print_funct_t print_pwr_fan_stats(struct activity *a, int prev, int curr,
2036 unsigned long long itv)
2038 stub_print_pwr_fan_stats(a, curr, FALSE);
2042 ***************************************************************************
2043 * Display average fan statistics.
2046 * @a Activity structure with statistics.
2047 * @prev Index in array where stats used as reference are.
2048 * @curr Index in array for current sample statistics.
2049 * @itv Interval of time in jiffies.
2050 ***************************************************************************
2052 __print_funct_t print_avg_pwr_fan_stats(struct activity *a, int prev, int curr,
2053 unsigned long long itv)
2055 stub_print_pwr_fan_stats(a, curr, TRUE);
2059 ***************************************************************************
2060 * Display device temperature statistics. This function is used to display
2061 * instantaneous and average statistics.
2064 * @a Activity structure with statistics.
2065 * @curr Index in array for current sample statistics.
2066 * @dispavg True if displaying average statistics.
2067 ***************************************************************************
2069 void stub_print_pwr_temp_stats(struct activity *a, int curr, int dispavg)
2072 struct stats_pwr_temp *spc;
2073 static double *avg_temp = NULL;
2074 static double *avg_temp_min = NULL, *avg_temp_max = NULL;
2076 /* Allocate arrays of temperatures */
2078 if ((avg_temp = (double *) malloc(sizeof(double) * a->nr)) == NULL) {
2082 memset(avg_temp, 0, sizeof(double) * a->nr);
2084 if (!avg_temp_min) {
2085 if ((avg_temp_min = (double *) malloc(sizeof(double) * a->nr)) == NULL) {
2089 memset(avg_temp_min, 0, sizeof(double) * a->nr);
2091 if (!avg_temp_max) {
2092 if ((avg_temp_max = (double *) malloc(sizeof(double) * a->nr)) == NULL) {
2096 memset(avg_temp_max, 0, sizeof(double) * a->nr);
2100 print_hdr_line(timestamp[!curr], a, FIRST, -2, 9);
2103 for (i = 0; i < a->nr; i++) {
2104 spc = (struct stats_pwr_temp *) ((char *) a->buf[curr] + i * a->msize);
2106 printf("%-11s", timestamp[curr]);
2107 cprintf_in(IS_INT, " %5d", "", i + 1);
2110 /* Display average values */
2111 cprintf_f(1, 9, 2, (double) avg_temp[i] / avg_count);
2113 (avg_temp_max[i] - avg_temp_min[i]) ?
2114 ((double) (avg_temp[i] / avg_count) - avg_temp_min[i]) / (avg_temp_max[i] - avg_temp_min[i]) * 100
2118 /* Display instantaneous values */
2119 cprintf_f(1, 9, 2, spc->temp);
2121 (spc->temp_max - spc->temp_min) ?
2122 (spc->temp - spc->temp_min) / (spc->temp_max - spc->temp_min) * 100
2124 avg_temp[i] += spc->temp;
2125 /* Assume that min and max temperatures cannot vary */
2126 avg_temp_min[i] = spc->temp_min;
2127 avg_temp_max[i] = spc->temp_max;
2130 cprintf_in(IS_STR, " %s\n", spc->device, 0);
2140 avg_temp_min = NULL;
2144 avg_temp_max = NULL;
2150 ***************************************************************************
2151 * Display temperature statistics.
2154 * @a Activity structure with statistics.
2155 * @prev Index in array where stats used as reference are.
2156 * @curr Index in array for current sample statistics.
2157 * @itv Interval of time in jiffies.
2158 ***************************************************************************
2160 __print_funct_t print_pwr_temp_stats(struct activity *a, int prev, int curr,
2161 unsigned long long itv)
2163 stub_print_pwr_temp_stats(a, curr, FALSE);
2167 ***************************************************************************
2168 * Display average temperature statistics.
2171 * @a Activity structure with statistics.
2172 * @prev Index in array where stats used as reference are.
2173 * @curr Index in array for current sample statistics.
2174 * @itv Interval of time in jiffies.
2175 ***************************************************************************
2177 __print_funct_t print_avg_pwr_temp_stats(struct activity *a, int prev, int curr,
2178 unsigned long long itv)
2180 stub_print_pwr_temp_stats(a, curr, TRUE);
2184 ***************************************************************************
2185 * Display voltage inputs statistics. This function is used to display
2186 * instantaneous and average statistics.
2189 * @a Activity structure with statistics.
2190 * @curr Index in array for current sample statistics.
2191 * @dispavg True if displaying average statistics.
2192 ***************************************************************************
2194 void stub_print_pwr_in_stats(struct activity *a, int curr, int dispavg)
2197 struct stats_pwr_in *spc;
2198 static double *avg_in = NULL;
2199 static double *avg_in_min = NULL, *avg_in_max = NULL;
2201 /* Allocate arrays of voltage inputs */
2203 if ((avg_in = (double *) malloc(sizeof(double) * a->nr)) == NULL) {
2207 memset(avg_in, 0, sizeof(double) * a->nr);
2210 if ((avg_in_min = (double *) malloc(sizeof(double) * a->nr)) == NULL) {
2214 memset(avg_in_min, 0, sizeof(double) * a->nr);
2217 if ((avg_in_max = (double *) malloc(sizeof(double) * a->nr)) == NULL) {
2221 memset(avg_in_max, 0, sizeof(double) * a->nr);
2225 print_hdr_line(timestamp[!curr], a, FIRST, -2, 9);
2228 for (i = 0; i < a->nr; i++) {
2229 spc = (struct stats_pwr_in *) ((char *) a->buf[curr] + i * a->msize);
2231 printf("%-11s", timestamp[curr]);
2232 cprintf_in(IS_INT, " %5d", "", i);
2235 /* Display average values */
2236 cprintf_f(1, 9, 2, (double) avg_in[i] / avg_count);
2238 (avg_in_max[i] - avg_in_min[i]) ?
2239 ((double) (avg_in[i] / avg_count) - avg_in_min[i]) / (avg_in_max[i] - avg_in_min[i]) * 100
2243 /* Display instantaneous values */
2244 cprintf_f(1, 9, 2, spc->in);
2246 (spc->in_max - spc->in_min) ?
2247 (spc->in - spc->in_min) / (spc->in_max - spc->in_min) * 100
2249 avg_in[i] += spc->in;
2250 /* Assume that min and max voltage inputs cannot vary */
2251 avg_in_min[i] = spc->in_min;
2252 avg_in_max[i] = spc->in_max;
2255 cprintf_in(IS_STR, " %s\n", spc->device, 0);
2275 ***************************************************************************
2276 * Display voltage inputs statistics.
2279 * @a Activity structure with statistics.
2280 * @prev Index in array where stats used as reference are.
2281 * @curr Index in array for current sample statistics.
2282 * @itv Interval of time in jiffies.
2283 ***************************************************************************
2285 __print_funct_t print_pwr_in_stats(struct activity *a, int prev, int curr,
2286 unsigned long long itv)
2288 stub_print_pwr_in_stats(a, curr, FALSE);
2292 ***************************************************************************
2293 * Display average voltage inputs statistics.
2296 * @a Activity structure with statistics.
2297 * @prev Index in array where stats used as reference are.
2298 * @curr Index in array for current sample statistics.
2299 * @itv Interval of time in jiffies.
2300 ***************************************************************************
2302 __print_funct_t print_avg_pwr_in_stats(struct activity *a, int prev, int curr,
2303 unsigned long long itv)
2305 stub_print_pwr_in_stats(a, curr, TRUE);
2309 ***************************************************************************
2310 * Display huge pages statistics. This function is used to
2311 * display instantaneous and average statistics.
2314 * @a Activity structure with statistics.
2315 * @curr Index in array for current sample statistics.
2316 * @dispavg TRUE if displaying average statistics.
2317 ***************************************************************************
2319 void stub_print_huge_stats(struct activity *a, int curr, int dispavg)
2322 *smc = (struct stats_huge *) a->buf[curr];
2323 static unsigned long long
2328 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
2332 /* Display instantaneous values */
2333 printf("%-11s", timestamp[curr]);
2335 (unsigned long long) smc->frhkb,
2336 (unsigned long long) (smc->tlhkb - smc->frhkb));
2339 SP_VALUE(smc->frhkb, smc->tlhkb, smc->tlhkb) : 0.0);
2342 /* Will be used to compute the average */
2343 avg_frhkb += smc->frhkb;
2344 avg_tlhkb += smc->tlhkb;
2347 /* Display average values */
2348 printf("%-11s", timestamp[curr]);
2350 (double) avg_frhkb / avg_count,
2351 ((double) avg_tlhkb / avg_count) -
2352 ((double) avg_frhkb / avg_count));
2355 SP_VALUE((double) avg_frhkb / avg_count,
2356 (double) avg_tlhkb / avg_count,
2357 (double) avg_tlhkb / avg_count) : 0.0);
2360 /* Reset average counters */
2361 avg_frhkb = avg_tlhkb = 0;
2366 ***************************************************************************
2367 * Display huge pages statistics.
2370 * @a Activity structure with statistics.
2371 * @prev Index in array where stats used as reference are.
2372 * @curr Index in array for current sample statistics.
2373 * @itv Interval of time in jiffies.
2374 ***************************************************************************
2376 __print_funct_t print_huge_stats(struct activity *a, int prev, int curr,
2377 unsigned long long itv)
2379 stub_print_huge_stats(a, curr, FALSE);
2383 ***************************************************************************
2384 * Display huge pages statistics.
2387 * @a Activity structure with statistics.
2388 * @prev Index in array where stats used as reference are.
2389 * @curr Index in array for current sample statistics.
2390 * @itv Interval of time in jiffies.
2391 ***************************************************************************
2393 __print_funct_t print_avg_huge_stats(struct activity *a, int prev, int curr,
2394 unsigned long long itv)
2396 stub_print_huge_stats(a, curr, TRUE);
2400 ***************************************************************************
2401 * Display CPU weighted frequency statistics. This function is used to
2402 * display instantaneous and average statistics.
2405 * @a Activity structure with statistics.
2406 * @prev Index in array where stats used as reference are.
2407 * @curr Index in array for current sample statistics.
2408 * @itv Interval of time in jiffies.
2409 ***************************************************************************
2411 void print_pwr_wghfreq_stats(struct activity *a, int prev, int curr,
2412 unsigned long long itv)
2415 struct stats_pwr_wghfreq *spc, *spp, *spc_k, *spp_k;
2416 unsigned long long tis, tisfreq;
2419 print_hdr_line(timestamp[!curr], a, FIRST, 7, 9);
2422 for (i = 0; (i < a->nr) && (i < a->bitmap->b_size + 1); i++) {
2425 * The size of a->buf[...] CPU structure may be different from the default
2426 * sizeof(struct stats_pwr_wghfreq) value if data have been read from a file!
2427 * That's why we don't use a syntax like:
2428 * spc = (struct stats_pwr_wghfreq *) a->buf[...] + i;
2430 spc = (struct stats_pwr_wghfreq *) ((char *) a->buf[curr] + i * a->msize * a->nr2);
2431 spp = (struct stats_pwr_wghfreq *) ((char *) a->buf[prev] + i * a->msize * a->nr2);
2434 * Note: a->nr is in [1, NR_CPUS + 1].
2435 * Bitmap size is provided for (NR_CPUS + 1) CPUs.
2436 * Anyway, NR_CPUS may vary between the version of sysstat
2437 * used by sadc to create a file, and the version of sysstat
2438 * used by sar to read it...
2441 /* Should current CPU (including CPU "all") be displayed? */
2442 if (a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))) {
2444 /* Yes: Display it */
2445 printf("%-11s", timestamp[curr]);
2448 /* This is CPU "all" */
2449 cprintf_in(IS_STR, "%s", " all", 0);
2452 cprintf_in(IS_INT, " %3d", "", i - 1);
2458 for (k = 0; k < a->nr2; k++) {
2460 spc_k = (struct stats_pwr_wghfreq *) ((char *) spc + k * a->msize);
2463 spp_k = (struct stats_pwr_wghfreq *) ((char *) spp + k * a->msize);
2465 tisfreq += (spc_k->freq / 1000) *
2466 (spc_k->time_in_state - spp_k->time_in_state);
2467 tis += (spc_k->time_in_state - spp_k->time_in_state);
2470 /* Display weighted frequency for current CPU */
2472 tis ? ((double) tisfreq) / tis : 0.0);
2479 ***************************************************************************
2480 * Display USB devices statistics. This function is used to
2481 * display instantaneous and summary statistics.
2484 * @a Activity structure with statistics.
2485 * @curr Index in array for current sample statistics.
2486 * @itv Interval of time in jiffies.
2487 * @dispavg TRUE if displaying average statistics.
2488 ***************************************************************************
2490 void stub_print_pwr_usb_stats(struct activity *a, int curr, int dispavg)
2494 struct stats_pwr_usb *suc, *sum;
2497 printf("\n%-11s BUS idvendor idprod maxpower",
2498 (dispavg ? _("Summary:") : timestamp[!curr]));
2499 printf(" %-*s product\n", MAX_MANUF_LEN - 1, "manufact");
2502 for (i = 0; i < a->nr; i++) {
2503 suc = (struct stats_pwr_usb *) ((char *) a->buf[curr] + i * a->msize);
2506 /* Bus#0 doesn't exist: We are at the end of the list */
2509 printf("%-11s", (dispavg ? _("Summary:") : timestamp[curr]));
2510 cprintf_in(IS_INT, " %6d", "", suc->bus_nr);
2515 /* bMaxPower is expressed in 2 mA units */
2516 (unsigned long long) (suc->bmaxpower << 1));
2518 snprintf(fmt, 16, " %%-%ds", MAX_MANUF_LEN - 1);
2519 cprintf_s(IS_STR, fmt, suc->manufacturer);
2520 cprintf_s(IS_STR, " %s\n", suc->product);
2523 /* Save current USB device in summary list */
2524 for (j = 0; j < a->nr; j++) {
2525 sum = (struct stats_pwr_usb *) ((char *) a->buf[2] + j * a->msize);
2527 if ((sum->bus_nr == suc->bus_nr) &&
2528 (sum->vendor_id == suc->vendor_id) &&
2529 (sum->product_id == suc->product_id))
2530 /* USB device found in summary list */
2534 * Current slot is free:
2535 * Save USB device in summary list.
2540 if (j == a->nr - 1) {
2542 * This is the last slot and
2543 * we still havent't found the device.
2544 * So create a dummy device here.
2547 sum->vendor_id = sum->product_id = 0;
2549 sum->manufacturer[0] = '\0';
2550 snprintf(sum->product, MAX_PROD_LEN, "%s",
2551 _("Other devices not listed here"));
2552 sum->product[MAX_PROD_LEN - 1] = '\0';
2560 ***************************************************************************
2561 * Display USB devices statistics.
2564 * @a Activity structure with statistics.
2565 * @prev Index in array where stats used as reference are.
2566 * @curr Index in array for current sample statistics.
2567 * @itv Interval of time in jiffies.
2568 ***************************************************************************
2570 __print_funct_t print_pwr_usb_stats(struct activity *a, int prev, int curr,
2571 unsigned long long itv)
2573 stub_print_pwr_usb_stats(a, curr, FALSE);
2577 ***************************************************************************
2578 * Display average USB devices statistics.
2581 * @a Activity structure with statistics.
2582 * @prev Index in array where stats used as reference are.
2583 * @curr Index in array for current sample statistics.
2584 * @itv Interval of time in jiffies.
2585 ***************************************************************************
2587 __print_funct_t print_avg_pwr_usb_stats(struct activity *a, int prev, int curr,
2588 unsigned long long itv)
2590 stub_print_pwr_usb_stats(a, 2, TRUE);
2594 ***************************************************************************
2595 * Display filesystems statistics. This function is used to
2596 * display instantaneous and average statistics.
2599 * @a Activity structure with statistics.
2600 * @curr Index in array for current sample statistics.
2601 * @dispavg TRUE if displaying average statistics.
2602 ***************************************************************************
2604 __print_funct_t stub_print_filesystem_stats(struct activity *a, int curr, int dispavg)
2607 struct stats_filesystem *sfc, *sfm;
2610 print_hdr_line((dispavg ? _("Summary:") : timestamp[!curr]),
2611 a, FIRST + DISPLAY_MOUNT(a->opt_flags), -1, 9);
2614 for (i = 0; i < a->nr; i++) {
2615 sfc = (struct stats_filesystem *) ((char *) a->buf[curr] + i * a->msize);
2618 /* Size of filesystem is zero: We are at the end of the list */
2621 printf("%-11s", (dispavg ? _("Summary:") : timestamp[curr]));
2623 (double) sfc->f_bfree / 1024 / 1024,
2624 (double) (sfc->f_blocks - sfc->f_bfree) / 1024 / 1024);
2626 /* f_blocks is not zero. But test it anyway ;-) */
2627 sfc->f_blocks ? SP_VALUE(sfc->f_bfree, sfc->f_blocks, sfc->f_blocks)
2629 sfc->f_blocks ? SP_VALUE(sfc->f_bavail, sfc->f_blocks, sfc->f_blocks)
2632 (unsigned long long) sfc->f_ffree,
2633 (unsigned long long) (sfc->f_files - sfc->f_ffree));
2635 sfc->f_files ? SP_VALUE(sfc->f_ffree, sfc->f_files, sfc->f_files)
2637 cprintf_in(IS_STR, " %s\n",
2638 DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name, 0);
2641 /* Save current filesystem in summary list */
2642 for (j = 0; j < a->nr; j++) {
2643 sfm = (struct stats_filesystem *) ((char *) a->buf[2] + j * a->msize);
2645 if (!strcmp(sfm->fs_name, sfc->fs_name) ||
2648 * Filesystem found in list (then save again its stats)
2649 * or free slot (end of list).
2660 ***************************************************************************
2661 * Display filesystems statistics.
2664 * @a Activity structure with statistics.
2665 * @prev Index in array where stats used as reference are.
2666 * @curr Index in array for current sample statistics.
2667 * @itv Interval of time in jiffies.
2668 ***************************************************************************
2670 __print_funct_t print_filesystem_stats(struct activity *a, int prev, int curr,
2671 unsigned long long itv)
2673 stub_print_filesystem_stats(a, curr, FALSE);
2677 ***************************************************************************
2678 * Display average filesystems statistics.
2681 * @a Activity structure with statistics.
2682 * @prev Index in array where stats used as reference are.
2683 * @curr Index in array for current sample statistics.
2684 * @itv Interval of time in jiffies.
2685 ***************************************************************************
2687 __print_funct_t print_avg_filesystem_stats(struct activity *a, int prev, int curr,
2688 unsigned long long itv)
2690 stub_print_filesystem_stats(a, 2, TRUE);
2694 ***************************************************************************
2695 * Display Fibre Channel HBA statistics.
2698 * @a Activity structure with statistics.
2699 * @prev Index in array where stats used as reference are.
2700 * @curr Index in array for current sample statistics.
2701 * @itv Interval of time in jiffies.
2702 ***************************************************************************
2704 __print_funct_t print_fchost_stats(struct activity *a, int prev, int curr,
2705 unsigned long long itv)
2708 struct stats_fchost *sfcc,*sfcp;
2711 print_hdr_line(timestamp[!curr], a, FIRST, -1, 9);
2714 for (i = 0; i < a->nr; i++) {
2716 sfcc = (struct stats_fchost *) ((char *) a->buf[curr] + i * a->msize);
2717 sfcp = (struct stats_fchost *) ((char *) a->buf[prev] + i * a->msize);
2719 if (!sfcc->fchost_name[0])
2720 /* We are at the end of the list */
2723 printf("%-11s", timestamp[curr]);
2725 S_VALUE(sfcp->f_rxframes, sfcc->f_rxframes, itv),
2726 S_VALUE(sfcp->f_txframes, sfcc->f_txframes, itv),
2727 S_VALUE(sfcp->f_rxwords, sfcc->f_rxwords, itv),
2728 S_VALUE(sfcp->f_txwords, sfcc->f_txwords, itv));
2729 cprintf_in(IS_STR, " %s\n", sfcc->fchost_name, 0);
2734 ***************************************************************************
2735 * Display softnet statistics.
2738 * @a Activity structure with statistics.
2739 * @prev Index in array where stats used as reference are.
2740 * @curr Index in array for current sample statistics.
2741 * @itv Interval of time in jiffies.
2742 ***************************************************************************
2744 __print_funct_t print_softnet_stats(struct activity *a, int prev, int curr,
2745 unsigned long long itv)
2747 struct stats_softnet
2748 *ssnc = (struct stats_softnet *) a->buf[curr],
2749 *ssnp = (struct stats_softnet *) a->buf[prev];
2753 print_hdr_line(timestamp[!curr], a, FIRST, 7, 9);
2756 for (i = 0; (i < a->nr) && (i < a->bitmap->b_size + 1); i++) {
2759 * The size of a->buf[...] CPU structure may be different from the default
2760 * sizeof(struct stats_pwr_cpufreq) value if data have been read from a file!
2761 * That's why we don't use a syntax like:
2762 * ssnc = (struct stats_softnet *) a->buf[...] + i;
2764 ssnc = (struct stats_softnet *) ((char *) a->buf[curr] + i * a->msize);
2765 ssnp = (struct stats_softnet *) ((char *) a->buf[prev] + i * a->msize);
2768 * Note: a->nr is in [1, NR_CPUS + 1].
2769 * Bitmap size is provided for (NR_CPUS + 1) CPUs.
2770 * Anyway, NR_CPUS may vary between the version of sysstat
2771 * used by sadc to create a file, and the version of sysstat
2772 * used by sar to read it...
2775 /* Should current CPU (including CPU "all") be displayed? */
2776 if (a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))) {
2778 /* Yes: Display it */
2779 printf("%-11s", timestamp[curr]);
2782 /* This is CPU "all" */
2783 cprintf_in(IS_STR, " %s", " all", 0);
2786 cprintf_in(IS_INT, " %7d", "", i - 1);
2790 S_VALUE(ssnp->processed, ssnc->processed, itv),
2791 S_VALUE(ssnp->dropped, ssnc->dropped, itv),
2792 S_VALUE(ssnp->time_squeeze, ssnc->time_squeeze, itv),
2793 S_VALUE(ssnp->received_rps, ssnc->received_rps, itv),
2794 S_VALUE(ssnp->flow_limit, ssnc->flow_limit, itv));