2 * pr_stats.c: Functions used by sar to display statistics
3 * (C) 1999-2021 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 uint64_t flags;
41 extern char timestamp[][TIMESTAMP_LEN];
42 extern unsigned long avg_count;
45 ***************************************************************************
46 * Display current activity header line.
49 * @p_timestamp Timestamp for previous stat sample.
50 * @a Activity structure.
51 * @pos Header to display, 0 being the first header (headers
52 * are delimited by the '|' character).
53 * @iwidth First column width (generally this is the item name).
54 * A negative value means that the corresponding field
55 * shall be displayed at the end of the line, with no
56 * indication of width.
57 * @vwidth Column width for stats values.
58 * @offline_bitmap Bitmap for offline items (e.g. CPU).
59 ***************************************************************************
61 void print_hdr_line(char *p_timestamp, struct activity *a, int pos, int iwidth, int vwidth,
62 unsigned char *offline_bitmap)
64 char hline[HEADER_LINE_LEN] = "";
65 char cfld[16], dfld[16];
66 char *hl, *tk, *it = NULL;
70 strncpy(hline, a->hdr_line, sizeof(hline) - 1);
71 hline[sizeof(hline) - 1] = '\0';
72 for (hl = strtok(hline, "|"); hl && (pos > 0); hl = strtok(NULL, "|"), pos--);
74 /* Bad @pos arg given to function */
77 printf("\n%-11s", p_timestamp);
79 if (strchr(hl, '&')) {
81 if ((a->opt_flags & 0xff00) & (1 << (8 + p))) {
82 /* Display whole header line */
86 /* Display only the first part of the header line */
90 /* Display each field */
91 for (tk = strtok(hl, ";"); tk; tk = strtok(NULL, ";"), i--) {
93 if (strchr(tk, '*')) {
94 strncpy(cfld, tk, sizeof(cfld) - 1);
95 k = strcspn(cfld, "*");
96 if (k >= strlen(cfld))
97 continue; /* Should not happen */
99 for (j = 0; (j < a->nr_ini) && (j < a->bitmap->b_size + 1); j++) {
100 if (!(a->bitmap->b_array[j >> 3] & (1 << (j & 0x07))))
101 /* Don't display current item if not selected */
103 if (offline_bitmap && (offline_bitmap[j >> 3] & (1 << (j & 0x07))))
104 /* Don't display current item if offline */
107 printf(" %*s", vwidth, "all");
110 snprintf(dfld, sizeof(dfld), "%s%d%s", cfld, j - 1, cfld + k + 1);
111 dfld[sizeof(dfld) - 1] = '\0';
112 printf(" %*s", vwidth, dfld);
118 printf(" %*s", iwidth, tk);
122 if ((iwidth < 0) && (iwidth == i)) {
127 printf(" %*s", vwidth, tk);
138 ***************************************************************************
139 * Display CPU statistics.
140 * NB: The stats are only calculated over the part of the time interval when
141 * the CPU was online. As a consequence, the sum (%user + %nice + ... + %idle)
142 * will always be 100% on the time interval even if the CPU has been offline
146 * @a Activity structure with statistics.
147 * @prev Index in array where stats used as reference are.
148 * @curr Index in array for current sample statistics.
149 * @itv Interval of time in 1/100th of a second (independent of the
150 * number of processors). Unused here.
151 ***************************************************************************
153 __print_funct_t print_cpu_stats(struct activity *a, int prev, int curr,
154 unsigned long long itv)
157 unsigned long long deltot_jiffies = 1;
158 struct stats_cpu *scc, *scp;
159 unsigned char offline_cpu_bitmap[BITMAP_SIZE(NR_CPUS)] = {0};
162 print_hdr_line(timestamp[!curr], a, FIRST + DISPLAY_CPU_ALL(a->opt_flags), 7, 9, NULL);
166 * @nr[curr] cannot normally be greater than @nr_ini
167 * (since @nr_ini counts up all CPU, even those offline).
168 * If this happens, it may be because the machine has been
169 * restarted with more CPU and no LINUX_RESTART has been
171 * No problem here with @nr_allocated. Having been able to
172 * read @nr[curr] structures shows that buffers are large enough.
174 if (a->nr[curr] > a->nr_ini) {
175 a->nr_ini = a->nr[curr];
179 * Compute CPU "all" as sum of all individual CPU (on SMP machines)
180 * and look for offline CPU.
183 deltot_jiffies = get_global_cpu_statistics(a, prev, curr,
184 flags, offline_cpu_bitmap);
188 * Now display CPU statistics (including CPU "all"),
189 * except for offline CPU or CPU that the user doesn't want to see.
191 for (i = 0; (i < a->nr_ini) && (i < a->bitmap->b_size + 1); i++) {
194 * Should current CPU (including CPU "all") be displayed?
195 * Note: @nr[curr] is in [1, NR_CPUS + 1].
196 * Bitmap size is provided for (NR_CPUS + 1) CPUs.
197 * Anyway, NR_CPUS may vary between the version of sysstat
198 * used by sadc to create a file, and the version of sysstat
199 * used by sar to read it...
201 if (!(a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))) ||
202 offline_cpu_bitmap[i >> 3] & (1 << (i & 0x07)))
203 /* Don't display CPU */
206 scc = (struct stats_cpu *) ((char *) a->buf[curr] + i * a->msize);
207 scp = (struct stats_cpu *) ((char *) a->buf[prev] + i * a->msize);
209 printf("%-11s", timestamp[curr]);
212 /* This is CPU "all" */
213 cprintf_in(IS_STR, " %s", " all", 0);
215 if (a->nr_ini == 1) {
217 * This is a UP machine. In this case
218 * interval has still not been calculated.
220 deltot_jiffies = get_per_cpu_interval(scc, scp);
222 if (!deltot_jiffies) {
223 /* CPU "all" cannot be tickless */
228 cprintf_in(IS_INT, " %7d", "", i - 1);
230 /* Recalculate interval for current proc */
231 deltot_jiffies = get_per_cpu_interval(scc, scp);
233 if (!deltot_jiffies) {
235 * If the CPU is tickless then there is no change in CPU values
236 * but the sum of values is not zero.
237 * %user, %nice, %system, %iowait, %steal, ..., %idle
239 cprintf_pc(DISPLAY_UNIT(flags), 5, 9, 2,
240 0.0, 0.0, 0.0, 0.0, 0.0);
242 if (DISPLAY_CPU_DEF(a->opt_flags)) {
243 cprintf_pc(DISPLAY_UNIT(flags), 1, 9, 2, 100.0);
247 * Four additional fields to display:
248 * %irq, %soft, %guest, %gnice.
250 else if (DISPLAY_CPU_ALL(a->opt_flags)) {
251 cprintf_pc(DISPLAY_UNIT(flags), 5, 9, 2,
252 0.0, 0.0, 0.0, 0.0, 100.0);
259 if (DISPLAY_CPU_DEF(a->opt_flags)) {
260 cprintf_pc(DISPLAY_UNIT(flags), 6, 9, 2,
261 ll_sp_value(scp->cpu_user, scc->cpu_user, deltot_jiffies),
262 ll_sp_value(scp->cpu_nice, scc->cpu_nice, deltot_jiffies),
263 ll_sp_value(scp->cpu_sys + scp->cpu_hardirq + scp->cpu_softirq,
264 scc->cpu_sys + scc->cpu_hardirq + scc->cpu_softirq,
266 ll_sp_value(scp->cpu_iowait, scc->cpu_iowait, deltot_jiffies),
267 ll_sp_value(scp->cpu_steal, scc->cpu_steal, deltot_jiffies),
268 scc->cpu_idle < scp->cpu_idle ?
270 ll_sp_value(scp->cpu_idle, scc->cpu_idle, deltot_jiffies));
273 else if (DISPLAY_CPU_ALL(a->opt_flags)) {
274 cprintf_pc(DISPLAY_UNIT(flags), 10, 9, 2,
275 (scc->cpu_user - scc->cpu_guest) < (scp->cpu_user - scp->cpu_guest) ?
277 ll_sp_value(scp->cpu_user - scp->cpu_guest,
278 scc->cpu_user - scc->cpu_guest, deltot_jiffies),
279 (scc->cpu_nice - scc->cpu_guest_nice) < (scp->cpu_nice - scp->cpu_guest_nice) ?
281 ll_sp_value(scp->cpu_nice - scp->cpu_guest_nice,
282 scc->cpu_nice - scc->cpu_guest_nice, deltot_jiffies),
283 ll_sp_value(scp->cpu_sys, scc->cpu_sys, deltot_jiffies),
284 ll_sp_value(scp->cpu_iowait, scc->cpu_iowait, deltot_jiffies),
285 ll_sp_value(scp->cpu_steal, scc->cpu_steal, deltot_jiffies),
286 ll_sp_value(scp->cpu_hardirq, scc->cpu_hardirq, deltot_jiffies),
287 ll_sp_value(scp->cpu_softirq, scc->cpu_softirq, deltot_jiffies),
288 ll_sp_value(scp->cpu_guest, scc->cpu_guest, deltot_jiffies),
289 ll_sp_value(scp->cpu_guest_nice, scc->cpu_guest_nice, deltot_jiffies),
290 scc->cpu_idle < scp->cpu_idle ?
292 ll_sp_value(scp->cpu_idle, scc->cpu_idle, deltot_jiffies));
299 ***************************************************************************
300 * Display tasks creation and context switches statistics.
303 * @a Activity structure with statistics.
304 * @prev Index in array where stats used as reference are.
305 * @curr Index in array for current sample statistics.
306 * @itv Interval of time in 1/100th of a second.
307 ***************************************************************************
309 __print_funct_t print_pcsw_stats(struct activity *a, int prev, int curr,
310 unsigned long long itv)
313 *spc = (struct stats_pcsw *) a->buf[curr],
314 *spp = (struct stats_pcsw *) a->buf[prev];
317 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9, NULL);
320 printf("%-11s", timestamp[curr]);
321 cprintf_f(NO_UNIT, 2, 9, 2,
322 S_VALUE(spp->processes, spc->processes, itv),
323 S_VALUE(spp->context_switch, spc->context_switch, itv));
328 ***************************************************************************
329 * Display interrupts statistics.
332 * @a Activity structure with statistics.
333 * @prev Index in array where stats used as reference are.
334 * @curr Index in array for current sample statistics.
335 * @itv Interval of time in 1/100th of a second.
336 ***************************************************************************
338 __print_funct_t print_irq_stats(struct activity *a, int prev, int curr,
339 unsigned long long itv)
342 struct stats_irq *sic, *sip;
344 if (dish || DISPLAY_ZERO_OMIT(flags)) {
345 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9, NULL); // TODO: Check for offline CPU
348 for (i = 0; (i < a->nr[curr]) && (i < a->bitmap->b_size + 1); i++) {
351 * If @nr[curr] > @nr[prev] then we consider that previous
352 * interrupt value was 0.
354 sic = (struct stats_irq *) ((char *) a->buf[curr] + i * a->msize);
355 sip = (struct stats_irq *) ((char *) a->buf[prev] + i * a->msize);
358 * Note: @nr[curr] gives the number of interrupts read (1 .. NR_IRQS + 1).
359 * Bitmap size is provided for (NR_IRQS + 1) interrupts.
360 * Anyway, NR_IRQS may vary between the version of sysstat
361 * used by sadc to create a file, and the version of sysstat
362 * used by sar to read it...
365 /* Should current interrupt (including int "sum") be displayed? */
366 if (a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))) {
368 if (DISPLAY_ZERO_OMIT(flags) && !memcmp(sip, sic, STATS_IRQ_SIZE))
371 /* Yes: Display it */
372 printf("%-11s", timestamp[curr]);
374 /* This is interrupt "sum" */
375 cprintf_in(IS_STR, " %s", " sum", 0);
378 cprintf_in(IS_INT, " %9d", "", i -1);
381 cprintf_f(NO_UNIT, 1, 9, 2, S_VALUE(sip->irq_nr, sic->irq_nr, itv));
388 ***************************************************************************
389 * Display swapping statistics.
392 * @a Activity structure with statistics.
393 * @prev Index in array where stats used as reference are.
394 * @curr Index in array for current sample statistics.
395 * @itv Interval of time in 1/100th of a second.
396 ***************************************************************************
398 __print_funct_t print_swap_stats(struct activity *a, int prev, int curr,
399 unsigned long long itv)
402 *ssc = (struct stats_swap *) a->buf[curr],
403 *ssp = (struct stats_swap *) a->buf[prev];
406 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9, NULL);
409 printf("%-11s", timestamp[curr]);
410 cprintf_f(NO_UNIT, 2, 9, 2,
411 S_VALUE(ssp->pswpin, ssc->pswpin, itv),
412 S_VALUE(ssp->pswpout, ssc->pswpout, itv));
417 ***************************************************************************
418 * Display paging statistics.
421 * @a Activity structure with statistics.
422 * @prev Index in array where stats used as reference are.
423 * @curr Index in array for current sample statistics.
424 * @itv Interval of time in 1/100th of a second.
425 ***************************************************************************
427 __print_funct_t print_paging_stats(struct activity *a, int prev, int curr,
428 unsigned long long itv)
431 *spc = (struct stats_paging *) a->buf[curr],
432 *spp = (struct stats_paging *) a->buf[prev];
435 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9, NULL);
438 printf("%-11s", timestamp[curr]);
439 cprintf_f(NO_UNIT, 8, 9, 2,
440 S_VALUE(spp->pgpgin, spc->pgpgin, itv),
441 S_VALUE(spp->pgpgout, spc->pgpgout, itv),
442 S_VALUE(spp->pgfault, spc->pgfault, itv),
443 S_VALUE(spp->pgmajfault, spc->pgmajfault, itv),
444 S_VALUE(spp->pgfree, spc->pgfree, itv),
445 S_VALUE(spp->pgscan_kswapd, spc->pgscan_kswapd, itv),
446 S_VALUE(spp->pgscan_direct, spc->pgscan_direct, itv),
447 S_VALUE(spp->pgsteal, spc->pgsteal, itv));
448 cprintf_pc(DISPLAY_UNIT(flags), 1, 9, 2,
449 (spc->pgscan_kswapd + spc->pgscan_direct -
450 spp->pgscan_kswapd - spp->pgscan_direct) ?
451 SP_VALUE(spp->pgsteal, spc->pgsteal,
452 spc->pgscan_kswapd + spc->pgscan_direct -
453 spp->pgscan_kswapd - spp->pgscan_direct)
459 ***************************************************************************
460 * Display I/O and transfer rate statistics.
463 * @a Activity structure with statistics.
464 * @prev Index in array where stats used as reference are.
465 * @curr Index in array for current sample statistics.
466 * @itv Interval of time in 1/100th of a second.
467 ***************************************************************************
469 __print_funct_t print_io_stats(struct activity *a, int prev, int curr,
470 unsigned long long itv)
473 *sic = (struct stats_io *) a->buf[curr],
474 *sip = (struct stats_io *) a->buf[prev];
477 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9, NULL);
480 printf("%-11s", timestamp[curr]);
482 * If we get negative values, this is probably because
483 * one or more devices/filesystems have been unmounted.
484 * We display 0.0 in this case though we should rather tell
485 * the user that the value cannot be calculated here.
487 cprintf_f(NO_UNIT, 7, 9, 2,
488 sic->dk_drive < sip->dk_drive ? 0.0 :
489 S_VALUE(sip->dk_drive, sic->dk_drive, itv),
490 sic->dk_drive_rio < sip->dk_drive_rio ? 0.0 :
491 S_VALUE(sip->dk_drive_rio, sic->dk_drive_rio, itv),
492 sic->dk_drive_wio < sip->dk_drive_wio ? 0.0 :
493 S_VALUE(sip->dk_drive_wio, sic->dk_drive_wio, itv),
494 sic->dk_drive_dio < sip->dk_drive_dio ? 0.0 :
495 S_VALUE(sip->dk_drive_dio, sic->dk_drive_dio, itv),
496 sic->dk_drive_rblk < sip->dk_drive_rblk ? 0.0 :
497 S_VALUE(sip->dk_drive_rblk, sic->dk_drive_rblk, itv),
498 sic->dk_drive_wblk < sip->dk_drive_wblk ? 0.0 :
499 S_VALUE(sip->dk_drive_wblk, sic->dk_drive_wblk, itv),
500 sic->dk_drive_dblk < sip->dk_drive_dblk ? 0.0 :
501 S_VALUE(sip->dk_drive_dblk, sic->dk_drive_dblk, itv));
506 ***************************************************************************
507 * Display memory and swap statistics. This function is used to
508 * display instantaneous and average statistics.
511 * @a Activity structure with statistics.
512 * @prev Index in array where stats used as reference are.
513 * @curr Index in array for current sample statistics.
514 * @dispavg TRUE if displaying average statistics.
515 ***************************************************************************
517 void stub_print_memory_stats(struct activity *a, int prev, int curr, int dispavg)
520 *smc = (struct stats_memory *) a->buf[curr];
521 static unsigned long long
535 static unsigned long long
540 unsigned long long nousedmem;
542 if (DISPLAY_UNIT(flags)) {
543 /* Default values unit is kB */
544 unit = UNIT_KILOBYTE;
547 if (DISPLAY_MEMORY(a->opt_flags)) {
549 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9, NULL);
551 printf("%-11s", timestamp[curr]);
554 /* Display instantaneous values */
555 nousedmem = smc->frmkb + smc->bufkb + smc->camkb + smc->slabkb;
556 if (nousedmem > smc->tlmkb) {
557 nousedmem = smc->tlmkb;
559 cprintf_u64(unit, 3, 9,
560 (unsigned long long) smc->frmkb,
561 (unsigned long long) smc->availablekb,
562 (unsigned long long) (smc->tlmkb - nousedmem));
563 cprintf_pc(DISPLAY_UNIT(flags), 1, 9, 2,
565 SP_VALUE(nousedmem, smc->tlmkb, smc->tlmkb)
567 cprintf_u64(unit, 3, 9,
568 (unsigned long long) smc->bufkb,
569 (unsigned long long) smc->camkb,
570 (unsigned long long) smc->comkb);
571 cprintf_pc(DISPLAY_UNIT(flags), 1, 9, 2,
572 (smc->tlmkb + smc->tlskb) ?
573 SP_VALUE(0, smc->comkb, smc->tlmkb + smc->tlskb)
575 cprintf_u64(unit, 3, 9,
576 (unsigned long long) smc->activekb,
577 (unsigned long long) smc->inactkb,
578 (unsigned long long) smc->dirtykb);
580 if (DISPLAY_MEM_ALL(a->opt_flags)) {
581 /* Display extended memory statistics */
582 cprintf_u64(unit, 5, 9,
583 (unsigned long long) smc->anonpgkb,
584 (unsigned long long) smc->slabkb,
585 (unsigned long long) smc->kstackkb,
586 (unsigned long long) smc->pgtblkb,
587 (unsigned long long) smc->vmusedkb);
593 * Will be used to compute the average.
594 * We assume that the total amount of memory installed can not vary
595 * during the interval given on the command line.
597 avg_frmkb += smc->frmkb;
598 avg_bufkb += smc->bufkb;
599 avg_camkb += smc->camkb;
600 avg_comkb += smc->comkb;
601 avg_activekb += smc->activekb;
602 avg_inactkb += smc->inactkb;
603 avg_dirtykb += smc->dirtykb;
604 avg_anonpgkb += smc->anonpgkb;
605 avg_slabkb += smc->slabkb;
606 avg_kstackkb += smc->kstackkb;
607 avg_pgtblkb += smc->pgtblkb;
608 avg_vmusedkb += smc->vmusedkb;
609 avg_availablekb += smc->availablekb;
612 /* Display average values */
613 nousedmem = avg_frmkb + avg_bufkb + avg_camkb + avg_slabkb;
614 cprintf_f(unit, 3, 9, 0,
615 (double) avg_frmkb / avg_count,
616 (double) avg_availablekb / avg_count,
617 (double) smc->tlmkb - ((double) nousedmem / avg_count));
618 cprintf_pc(DISPLAY_UNIT(flags), 1, 9, 2,
620 SP_VALUE((double) (nousedmem / avg_count), smc->tlmkb, smc->tlmkb)
622 cprintf_f(unit, 3, 9, 0,
623 (double) avg_bufkb / avg_count,
624 (double) avg_camkb / avg_count,
625 (double) avg_comkb / avg_count);
626 cprintf_pc(DISPLAY_UNIT(flags), 1, 9, 2,
627 (smc->tlmkb + smc->tlskb) ?
628 SP_VALUE(0.0, (double) (avg_comkb / avg_count), smc->tlmkb + smc->tlskb)
630 cprintf_f(unit, 3, 9, 0,
631 (double) avg_activekb / avg_count,
632 (double) avg_inactkb / avg_count,
633 (double) avg_dirtykb / avg_count);
635 if (DISPLAY_MEM_ALL(a->opt_flags)) {
636 cprintf_f(unit, 5, 9, 0,
637 (double) avg_anonpgkb / avg_count,
638 (double) avg_slabkb / avg_count,
639 (double) avg_kstackkb / avg_count,
640 (double) avg_pgtblkb / avg_count,
641 (double) avg_vmusedkb / avg_count);
646 /* Reset average counters */
647 avg_frmkb = avg_bufkb = avg_camkb = avg_comkb = 0;
648 avg_activekb = avg_inactkb = avg_dirtykb = 0;
649 avg_anonpgkb = avg_slabkb = avg_kstackkb = 0;
650 avg_pgtblkb = avg_vmusedkb = avg_availablekb = 0;
654 if (DISPLAY_SWAP(a->opt_flags)) {
656 print_hdr_line(timestamp[!curr], a, SECOND, 0, 9, NULL);
658 printf("%-11s", timestamp[curr]);
661 /* Display instantaneous values */
662 cprintf_u64(unit, 2, 9,
663 (unsigned long long) smc->frskb,
664 (unsigned long long) (smc->tlskb - smc->frskb));
665 cprintf_pc(DISPLAY_UNIT(flags), 1, 9, 2,
667 SP_VALUE(smc->frskb, smc->tlskb, smc->tlskb)
669 cprintf_u64(unit, 1, 9,
670 (unsigned long long) smc->caskb);
671 cprintf_pc(DISPLAY_UNIT(flags), 1, 9, 2,
672 (smc->tlskb - smc->frskb) ?
673 SP_VALUE(0, smc->caskb, smc->tlskb - smc->frskb)
679 * Will be used to compute the average.
680 * We assume that the total amount of swap space may vary.
682 avg_frskb += smc->frskb;
683 avg_tlskb += smc->tlskb;
684 avg_caskb += smc->caskb;
687 /* Display average values */
688 cprintf_f(unit, 2, 9, 0,
689 (double) avg_frskb / avg_count,
690 ((double) avg_tlskb / avg_count) -
691 ((double) avg_frskb / avg_count));
692 cprintf_pc(DISPLAY_UNIT(flags), 1, 9, 2,
694 SP_VALUE((double) avg_frskb / avg_count,
695 (double) avg_tlskb / avg_count,
696 (double) avg_tlskb / avg_count)
698 cprintf_f(unit, 1, 9, 0,
699 (double) avg_caskb / avg_count);
700 cprintf_pc(DISPLAY_UNIT(flags), 1, 9, 2,
701 (avg_tlskb != avg_frskb) ?
702 SP_VALUE(0.0, (double) avg_caskb / avg_count,
703 ((double) avg_tlskb / avg_count) -
704 ((double) avg_frskb / avg_count))
708 /* Reset average counters */
709 avg_frskb = avg_tlskb = avg_caskb = 0;
715 ***************************************************************************
716 * Display memory and swap statistics.
719 * @a Activity structure with statistics.
720 * @prev Index in array where stats used as reference are.
721 * @curr Index in array for current sample statistics.
722 * @itv Interval of time in 1/100th of a second.
723 ***************************************************************************
725 __print_funct_t print_memory_stats(struct activity *a, int prev, int curr,
726 unsigned long long itv)
728 stub_print_memory_stats(a, prev, curr, FALSE);
732 ***************************************************************************
733 * Display average memory statistics.
736 * @a Activity structure with statistics.
737 * @prev Index in array where stats used as reference are.
738 * @curr Index in array for current sample statistics.
739 * @itv Interval of time in 1/100th of a second.
740 ***************************************************************************
742 __print_funct_t print_avg_memory_stats(struct activity *a, int prev, int curr,
743 unsigned long long itv)
745 stub_print_memory_stats(a, prev, curr, TRUE);
749 ***************************************************************************
750 * Display kernel tables statistics. This function is used to display
751 * instantaneous and average statistics.
754 * @a Activity structure with statistics.
755 * @curr Index in array for current sample statistics.
756 * @dispavg True if displaying average statistics.
757 ***************************************************************************
759 void stub_print_ktables_stats(struct activity *a, int curr, int dispavg)
762 *skc = (struct stats_ktables *) a->buf[curr];
763 static unsigned long long
771 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9, NULL);
773 printf("%-11s", timestamp[curr]);
776 /* Display instantaneous values */
777 cprintf_u64(NO_UNIT, 4, 9,
778 (unsigned long long) skc->dentry_stat,
779 (unsigned long long) skc->file_used,
780 (unsigned long long) skc->inode_used,
781 (unsigned long long) skc->pty_nr);
785 * Will be used to compute the average.
786 * Note: Overflow unlikely to happen but not impossible...
788 avg_dentry_stat += skc->dentry_stat;
789 avg_file_used += skc->file_used;
790 avg_inode_used += skc->inode_used;
791 avg_pty_nr += skc->pty_nr;
794 /* Display average values */
795 cprintf_f(NO_UNIT, 4, 9, 0,
796 (double) avg_dentry_stat / avg_count,
797 (double) avg_file_used / avg_count,
798 (double) avg_inode_used / avg_count,
799 (double) avg_pty_nr / avg_count);
802 /* Reset average counters */
803 avg_dentry_stat = avg_file_used = avg_inode_used = avg_pty_nr = 0;
808 ***************************************************************************
809 * Display kernel tables statistics.
812 * @a Activity structure with statistics.
813 * @prev Index in array where stats used as reference are.
814 * @curr Index in array for current sample statistics.
815 * @itv Interval of time in 1/100th of a second.
816 ***************************************************************************
818 __print_funct_t print_ktables_stats(struct activity *a, int prev, int curr,
819 unsigned long long itv)
821 stub_print_ktables_stats(a, curr, FALSE);
825 ***************************************************************************
826 * Display average kernel tables statistics.
829 * @a Activity structure with statistics.
830 * @prev Index in array where stats used as reference are.
831 * @curr Index in array for current sample statistics.
832 * @itv Interval of time in 1/100th of a second.
833 ***************************************************************************
835 __print_funct_t print_avg_ktables_stats(struct activity *a, int prev, int curr,
836 unsigned long long itv)
838 stub_print_ktables_stats(a, curr, TRUE);
842 ***************************************************************************
843 * Display queue and load statistics. This function is used to display
844 * instantaneous and average statistics.
847 * @a Activity structure with statistics.
848 * @curr Index in array for current sample statistics.
849 * @dispavg TRUE if displaying average statistics.
850 ***************************************************************************
852 void stub_print_queue_stats(struct activity *a, int curr, int dispavg)
855 *sqc = (struct stats_queue *) a->buf[curr];
856 static unsigned long long
862 avg_procs_blocked = 0;
865 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9, NULL);
867 printf("%-11s", timestamp[curr]);
870 /* Display instantaneous values */
871 cprintf_u64(NO_UNIT, 2, 9,
872 (unsigned long long) sqc->nr_running,
873 (unsigned long long) sqc->nr_threads);
874 cprintf_f(NO_UNIT, 3, 9, 2,
875 (double) sqc->load_avg_1 / 100,
876 (double) sqc->load_avg_5 / 100,
877 (double) sqc->load_avg_15 / 100);
878 cprintf_u64(NO_UNIT, 1, 9,
879 (unsigned long long) sqc->procs_blocked);
882 /* Will be used to compute the average */
883 avg_nr_running += sqc->nr_running;
884 avg_nr_threads += sqc->nr_threads;
885 avg_load_avg_1 += sqc->load_avg_1;
886 avg_load_avg_5 += sqc->load_avg_5;
887 avg_load_avg_15 += sqc->load_avg_15;
888 avg_procs_blocked += sqc->procs_blocked;
891 /* Display average values */
892 cprintf_f(NO_UNIT, 2, 9, 0,
893 (double) avg_nr_running / avg_count,
894 (double) avg_nr_threads / avg_count);
895 cprintf_f(NO_UNIT, 3, 9, 2,
896 (double) avg_load_avg_1 / (avg_count * 100),
897 (double) avg_load_avg_5 / (avg_count * 100),
898 (double) avg_load_avg_15 / (avg_count * 100));
899 cprintf_f(NO_UNIT, 1, 9, 0,
900 (double) avg_procs_blocked / avg_count);
903 /* Reset average counters */
904 avg_nr_running = avg_nr_threads = 0;
905 avg_load_avg_1 = avg_load_avg_5 = avg_load_avg_15 = 0;
906 avg_procs_blocked = 0;
911 ***************************************************************************
912 * Display queue and load statistics.
915 * @a Activity structure with statistics.
916 * @prev Index in array where stats used as reference are.
917 * @curr Index in array for current sample statistics.
918 * @itv Interval of time in 1/100th of a second.
919 ***************************************************************************
921 __print_funct_t print_queue_stats(struct activity *a, int prev, int curr,
922 unsigned long long itv)
924 stub_print_queue_stats(a, curr, FALSE);
928 ***************************************************************************
929 * Display average queue and load statistics.
932 * @a Activity structure with statistics.
933 * @prev Index in array where stats used as reference are.
934 * @curr Index in array for current sample statistics.
935 * @itv Interval of time in 1/100th of a second.
936 ***************************************************************************
938 __print_funct_t print_avg_queue_stats(struct activity *a, int prev, int curr,
939 unsigned long long itv)
941 stub_print_queue_stats(a, curr, TRUE);
945 ***************************************************************************
946 * Display serial lines statistics.
949 * @a Activity structure with statistics.
950 * @prev Index in array where stats used as reference are.
951 * @curr Index in array for current sample statistics.
952 * @itv Interval of time in 1/100th of a second.
953 ***************************************************************************
955 __print_funct_t print_serial_stats(struct activity *a, int prev, int curr,
956 unsigned long long itv)
959 struct stats_serial *ssc, *ssp;
961 if (dish || DISPLAY_ZERO_OMIT(flags)) {
962 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9, NULL);
965 for (i = 0; i < a->nr[curr]; i++) {
966 ssc = (struct stats_serial *) ((char *) a->buf[curr] + i * a->msize);
968 if (WANT_SINCE_BOOT(flags)) {
970 * We want to display statistics since boot time.
971 * Take the first structure from buf[prev]: This is a
972 * structure that only contains 0 (it has been set to 0
973 * when it has been allocated), and which exists since
974 * there is the same number of allocated structures for
975 * buf[prev] and bur[curr] (even if nothing has been read).
977 ssp = (struct stats_serial *) ((char *) a->buf[prev]);
983 if (a->nr[prev] > 0) {
984 /* Look for corresponding serial line in previous iteration */
987 if (j >= a->nr[prev]) {
994 ssp = (struct stats_serial *) ((char *) a->buf[prev] + j * a->msize);
995 if (ssc->line == ssp->line) {
999 if (++j >= a->nr[prev]) {
1010 if (DISPLAY_ZERO_OMIT(flags) && !memcmp(ssp, ssc, STATS_SERIAL_SIZE))
1013 printf("%-11s", timestamp[curr]);
1014 cprintf_in(IS_INT, " %3d", "", ssc->line);
1016 cprintf_f(NO_UNIT, 6, 9, 2,
1017 S_VALUE(ssp->rx, ssc->rx, itv),
1018 S_VALUE(ssp->tx, ssc->tx, itv),
1019 S_VALUE(ssp->frame, ssc->frame, itv),
1020 S_VALUE(ssp->parity, ssc->parity, itv),
1021 S_VALUE(ssp->brk, ssc->brk, itv),
1022 S_VALUE(ssp->overrun, ssc->overrun, itv));
1028 ***************************************************************************
1029 * Display disks 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 1/100th of a second.
1036 ***************************************************************************
1038 __print_funct_t print_disk_stats(struct activity *a, int prev, int curr,
1039 unsigned long long itv)
1042 struct stats_disk *sdc, *sdp, sdpzero;
1043 struct ext_disk_stats xds;
1047 memset(&sdpzero, 0, STATS_DISK_SIZE);
1049 if (DISPLAY_UNIT(flags)) {
1050 /* Default values unit is kB */
1051 unit = UNIT_KILOBYTE;
1054 if (dish || DISPLAY_ZERO_OMIT(flags)) {
1055 print_hdr_line(timestamp[!curr], a, FIRST, DISPLAY_PRETTY(flags) ? -1 : 0, 9, NULL);
1058 for (i = 0; i < a->nr[curr]; i++) {
1059 sdc = (struct stats_disk *) ((char *) a->buf[curr] + i * a->msize);
1061 if (!WANT_SINCE_BOOT(flags)) {
1062 j = check_disk_reg(a, curr, prev, i);
1069 * This is a newly registered device or we want stats since boot time.
1070 * Previous stats are zero.
1075 sdp = (struct stats_disk *) ((char *) a->buf[prev] + j * a->msize);
1078 if (DISPLAY_ZERO_OMIT(flags) && !memcmp(sdp, sdc, STATS_DISK_SIZE))
1081 /* Get device name */
1082 dev_name = get_device_name(sdc->major, sdc->minor, sdc->wwn, sdc->part_nr,
1083 DISPLAY_PRETTY(flags), DISPLAY_PERSIST_NAME_S(flags),
1084 USE_STABLE_ID(flags), NULL);
1086 if (a->item_list != NULL) {
1087 /* A list of devices has been entered on the command line */
1088 if (!search_list_item(a->item_list, dev_name))
1089 /* Device not found */
1093 /* Compute service time, etc. */
1094 compute_ext_disk_stats(sdc, sdp, itv, &xds);
1096 printf("%-11s", timestamp[curr]);
1098 if (!DISPLAY_PRETTY(flags)) {
1099 cprintf_in(IS_STR, " %9s", dev_name, 0);
1101 cprintf_f(NO_UNIT, 1, 9, 2,
1102 S_VALUE(sdp->nr_ios, sdc->nr_ios, itv));
1103 cprintf_f(unit, 3, 9, 2,
1104 S_VALUE(sdp->rd_sect, sdc->rd_sect, itv) / 2,
1105 S_VALUE(sdp->wr_sect, sdc->wr_sect, itv) / 2,
1106 S_VALUE(sdp->dc_sect, sdc->dc_sect, itv) / 2);
1107 /* See iostat for explanations */
1108 cprintf_f(unit, 1, 9, 2,
1110 cprintf_f(NO_UNIT, 2, 9, 2,
1111 S_VALUE(sdp->rq_ticks, sdc->rq_ticks, itv) / 1000.0,
1113 cprintf_pc(DISPLAY_UNIT(flags), 1, 9, 2,
1115 if (DISPLAY_PRETTY(flags)) {
1116 cprintf_in(IS_STR, " %s", dev_name, 0);
1123 ***************************************************************************
1124 * Display network interfaces statistics.
1127 * @a Activity structure with statistics.
1128 * @prev Index in array where stats used as reference are.
1129 * @curr Index in array for current sample statistics.
1130 * @itv Interval of time in 1/100th of a second.
1131 ***************************************************************************
1133 __print_funct_t print_net_dev_stats(struct activity *a, int prev, int curr,
1134 unsigned long long itv)
1137 struct stats_net_dev *sndc, *sndp, sndzero;
1138 double rxkb, txkb, ifutil;
1141 memset(&sndzero, 0, STATS_NET_DEV_SIZE);
1143 if (DISPLAY_UNIT(flags)) {
1144 /* Default values unit is bytes */
1148 if (dish || DISPLAY_ZERO_OMIT(flags)) {
1149 print_hdr_line(timestamp[!curr], a, FIRST, DISPLAY_PRETTY(flags) ? -1 : 0, 9, NULL);
1152 for (i = 0; i < a->nr[curr]; i++) {
1153 sndc = (struct stats_net_dev *) ((char *) a->buf[curr] + i * a->msize);
1155 if (a->item_list != NULL) {
1156 /* A list of devices has been entered on the command line */
1157 if (!search_list_item(a->item_list, sndc->interface))
1158 /* Device not found */
1162 if (!WANT_SINCE_BOOT(flags)) {
1163 j = check_net_dev_reg(a, curr, prev, i);
1170 * This is a newly registered interface or we want stats since boot time.
1171 * Previous stats are zero.
1176 sndp = (struct stats_net_dev *) ((char *) a->buf[prev] + j * a->msize);
1179 if (DISPLAY_ZERO_OMIT(flags) && !memcmp(sndp, sndc, STATS_NET_DEV_SIZE2CMP))
1182 printf("%-11s", timestamp[curr]);
1184 if (!DISPLAY_PRETTY(flags)) {
1185 cprintf_in(IS_STR, " %9s", sndc->interface, 0);
1187 rxkb = S_VALUE(sndp->rx_bytes, sndc->rx_bytes, itv);
1188 txkb = S_VALUE(sndp->tx_bytes, sndc->tx_bytes, itv);
1190 cprintf_f(NO_UNIT, 2, 9, 2,
1191 S_VALUE(sndp->rx_packets, sndc->rx_packets, itv),
1192 S_VALUE(sndp->tx_packets, sndc->tx_packets, itv));
1193 cprintf_f(unit, 2, 9, 2,
1194 unit < 0 ? rxkb / 1024 : rxkb,
1195 unit < 0 ? txkb / 1024 : txkb);
1196 cprintf_f(NO_UNIT, 3, 9, 2,
1197 S_VALUE(sndp->rx_compressed, sndc->rx_compressed, itv),
1198 S_VALUE(sndp->tx_compressed, sndc->tx_compressed, itv),
1199 S_VALUE(sndp->multicast, sndc->multicast, itv));
1200 ifutil = compute_ifutil(sndc, rxkb, txkb);
1201 cprintf_pc(DISPLAY_UNIT(flags), 1, 9, 2, ifutil);
1202 if (DISPLAY_PRETTY(flags)) {
1203 cprintf_in(IS_STR, " %s", sndc->interface, 0);
1210 ***************************************************************************
1211 * Display network interface errors statistics.
1214 * @a Activity structure with statistics.
1215 * @prev Index in array where stats used as reference are.
1216 * @curr Index in array for current sample statistics.
1217 * @itv Interval of time in 1/100th of a second.
1218 ***************************************************************************
1220 __print_funct_t print_net_edev_stats(struct activity *a, int prev, int curr,
1221 unsigned long long itv)
1224 struct stats_net_edev *snedc, *snedp, snedzero;
1226 memset(&snedzero, 0, STATS_NET_EDEV_SIZE);
1228 if (dish || DISPLAY_ZERO_OMIT(flags)) {
1229 print_hdr_line(timestamp[!curr], a, FIRST, DISPLAY_PRETTY(flags) ? -1 : 0, 9, NULL);
1232 for (i = 0; i < a->nr[curr]; i++) {
1233 snedc = (struct stats_net_edev *) ((char *) a->buf[curr] + i * a->msize);
1235 if (a->item_list != NULL) {
1236 /* A list of devices has been entered on the command line */
1237 if (!search_list_item(a->item_list, snedc->interface))
1238 /* Device not found */
1242 if (!WANT_SINCE_BOOT(flags)) {
1243 j = check_net_edev_reg(a, curr, prev, i);
1250 * This is a newly registered interface or we want stats since boot time.
1251 * Previous stats are zero.
1256 snedp = (struct stats_net_edev *) ((char *) a->buf[prev] + j * a->msize);
1259 if (DISPLAY_ZERO_OMIT(flags) && !memcmp(snedp, snedc, STATS_NET_EDEV_SIZE2CMP))
1262 printf("%-11s", timestamp[curr]);
1264 if (!DISPLAY_PRETTY(flags)) {
1265 cprintf_in(IS_STR, " %9s", snedc->interface, 0);
1267 cprintf_f(NO_UNIT, 9, 9, 2,
1268 S_VALUE(snedp->rx_errors, snedc->rx_errors, itv),
1269 S_VALUE(snedp->tx_errors, snedc->tx_errors, itv),
1270 S_VALUE(snedp->collisions, snedc->collisions, itv),
1271 S_VALUE(snedp->rx_dropped, snedc->rx_dropped, itv),
1272 S_VALUE(snedp->tx_dropped, snedc->tx_dropped, itv),
1273 S_VALUE(snedp->tx_carrier_errors, snedc->tx_carrier_errors, itv),
1274 S_VALUE(snedp->rx_frame_errors, snedc->rx_frame_errors, itv),
1275 S_VALUE(snedp->rx_fifo_errors, snedc->rx_fifo_errors, itv),
1276 S_VALUE(snedp->tx_fifo_errors, snedc->tx_fifo_errors, itv));
1277 if (DISPLAY_PRETTY(flags)) {
1278 cprintf_in(IS_STR, " %s", snedc->interface, 0);
1285 ***************************************************************************
1286 * Display NFS client 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 1/100th of a second.
1293 ***************************************************************************
1295 __print_funct_t print_net_nfs_stats(struct activity *a, int prev, int curr,
1296 unsigned long long itv)
1298 struct stats_net_nfs
1299 *snnc = (struct stats_net_nfs *) a->buf[curr],
1300 *snnp = (struct stats_net_nfs *) a->buf[prev];
1303 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9, NULL);
1306 printf("%-11s", timestamp[curr]);
1307 cprintf_f(NO_UNIT, 6, 9, 2,
1308 S_VALUE(snnp->nfs_rpccnt, snnc->nfs_rpccnt, itv),
1309 S_VALUE(snnp->nfs_rpcretrans, snnc->nfs_rpcretrans, itv),
1310 S_VALUE(snnp->nfs_readcnt, snnc->nfs_readcnt, itv),
1311 S_VALUE(snnp->nfs_writecnt, snnc->nfs_writecnt, itv),
1312 S_VALUE(snnp->nfs_accesscnt, snnc->nfs_accesscnt, itv),
1313 S_VALUE(snnp->nfs_getattcnt, snnc->nfs_getattcnt, itv));
1318 ***************************************************************************
1319 * Display NFS server statistics.
1322 * @a Activity structure with statistics.
1323 * @prev Index in array where stats used as reference are.
1324 * @curr Index in array for current sample statistics.
1325 * @itv Interval of time in 1/100th of a second.
1326 ***************************************************************************
1328 __print_funct_t print_net_nfsd_stats(struct activity *a, int prev, int curr,
1329 unsigned long long itv)
1331 struct stats_net_nfsd
1332 *snndc = (struct stats_net_nfsd *) a->buf[curr],
1333 *snndp = (struct stats_net_nfsd *) a->buf[prev];
1336 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9, NULL);
1339 printf("%-11s", timestamp[curr]);
1340 cprintf_f(NO_UNIT, 11, 9, 2,
1341 S_VALUE(snndp->nfsd_rpccnt, snndc->nfsd_rpccnt, itv),
1342 S_VALUE(snndp->nfsd_rpcbad, snndc->nfsd_rpcbad, itv),
1343 S_VALUE(snndp->nfsd_netcnt, snndc->nfsd_netcnt, itv),
1344 S_VALUE(snndp->nfsd_netudpcnt, snndc->nfsd_netudpcnt, itv),
1345 S_VALUE(snndp->nfsd_nettcpcnt, snndc->nfsd_nettcpcnt, itv),
1346 S_VALUE(snndp->nfsd_rchits, snndc->nfsd_rchits, itv),
1347 S_VALUE(snndp->nfsd_rcmisses, snndc->nfsd_rcmisses, itv),
1348 S_VALUE(snndp->nfsd_readcnt, snndc->nfsd_readcnt, itv),
1349 S_VALUE(snndp->nfsd_writecnt, snndc->nfsd_writecnt, itv),
1350 S_VALUE(snndp->nfsd_accesscnt, snndc->nfsd_accesscnt, itv),
1351 S_VALUE(snndp->nfsd_getattcnt, snndc->nfsd_getattcnt, itv));
1356 ***************************************************************************
1357 * Display network sockets statistics. This function is used to display
1358 * instantaneous and average statistics.
1361 * @a Activity structure with statistics.
1362 * @curr Index in array for current sample statistics.
1363 * @dispavg TRUE if displaying average statistics.
1364 ***************************************************************************
1366 void stub_print_net_sock_stats(struct activity *a, int curr, int dispavg)
1368 struct stats_net_sock
1369 *snsc = (struct stats_net_sock *) a->buf[curr];
1370 static unsigned long long
1379 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9, NULL);
1381 printf("%-11s", timestamp[curr]);
1384 /* Display instantaneous values */
1385 cprintf_u64(NO_UNIT, 6, 9,
1386 (unsigned long long) snsc->sock_inuse,
1387 (unsigned long long) snsc->tcp_inuse,
1388 (unsigned long long) snsc->udp_inuse,
1389 (unsigned long long) snsc->raw_inuse,
1390 (unsigned long long) snsc->frag_inuse,
1391 (unsigned long long) snsc->tcp_tw);
1394 /* Will be used to compute the average */
1395 avg_sock_inuse += snsc->sock_inuse;
1396 avg_tcp_inuse += snsc->tcp_inuse;
1397 avg_udp_inuse += snsc->udp_inuse;
1398 avg_raw_inuse += snsc->raw_inuse;
1399 avg_frag_inuse += snsc->frag_inuse;
1400 avg_tcp_tw += snsc->tcp_tw;
1403 /* Display average values */
1404 cprintf_f(NO_UNIT, 6, 9, 0,
1405 (double) avg_sock_inuse / avg_count,
1406 (double) avg_tcp_inuse / avg_count,
1407 (double) avg_udp_inuse / avg_count,
1408 (double) avg_raw_inuse / avg_count,
1409 (double) avg_frag_inuse / avg_count,
1410 (double) avg_tcp_tw / avg_count);
1413 /* Reset average counters */
1414 avg_sock_inuse = avg_tcp_inuse = avg_udp_inuse = 0;
1415 avg_raw_inuse = avg_frag_inuse = avg_tcp_tw = 0;
1420 ***************************************************************************
1421 * Display network sockets statistics.
1424 * @a Activity structure with statistics.
1425 * @prev Index in array where stats used as reference are.
1426 * @curr Index in array for current sample statistics.
1427 * @itv Interval of time in 1/100th of a second.
1428 ***************************************************************************
1430 __print_funct_t print_net_sock_stats(struct activity *a, int prev, int curr,
1431 unsigned long long itv)
1433 stub_print_net_sock_stats(a, curr, FALSE);
1437 ***************************************************************************
1438 * Display average network sockets statistics.
1441 * @a Activity structure with statistics.
1442 * @prev Index in array where stats used as reference are.
1443 * @curr Index in array for current sample statistics.
1444 * @itv Interval of time in 1/100th of a second.
1445 ***************************************************************************
1447 __print_funct_t print_avg_net_sock_stats(struct activity *a, int prev, int curr,
1448 unsigned long long itv)
1450 stub_print_net_sock_stats(a, curr, TRUE);
1454 ***************************************************************************
1455 * Display IP network traffic statistics.
1458 * @a Activity structure with statistics.
1459 * @prev Index in array where stats used as reference are.
1460 * @curr Index in array for current sample statistics.
1461 * @itv Interval of time in 1/100th of a second.
1462 ***************************************************************************
1464 __print_funct_t print_net_ip_stats(struct activity *a, int prev, int curr,
1465 unsigned long long itv)
1468 *snic = (struct stats_net_ip *) a->buf[curr],
1469 *snip = (struct stats_net_ip *) a->buf[prev];
1472 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9, NULL);
1475 printf("%-11s", timestamp[curr]);
1476 cprintf_f(NO_UNIT, 8, 9, 2,
1477 S_VALUE(snip->InReceives, snic->InReceives, itv),
1478 S_VALUE(snip->ForwDatagrams, snic->ForwDatagrams, itv),
1479 S_VALUE(snip->InDelivers, snic->InDelivers, itv),
1480 S_VALUE(snip->OutRequests, snic->OutRequests, itv),
1481 S_VALUE(snip->ReasmReqds, snic->ReasmReqds, itv),
1482 S_VALUE(snip->ReasmOKs, snic->ReasmOKs, itv),
1483 S_VALUE(snip->FragOKs, snic->FragOKs, itv),
1484 S_VALUE(snip->FragCreates, snic->FragCreates, itv));
1489 ***************************************************************************
1490 * Display IP network errors statistics.
1493 * @a Activity structure with statistics.
1494 * @prev Index in array where stats used as reference are.
1495 * @curr Index in array for current sample statistics.
1496 * @itv Interval of time in 1/100th of a second.
1497 ***************************************************************************
1499 __print_funct_t print_net_eip_stats(struct activity *a, int prev, int curr,
1500 unsigned long long itv)
1502 struct stats_net_eip
1503 *sneic = (struct stats_net_eip *) a->buf[curr],
1504 *sneip = (struct stats_net_eip *) a->buf[prev];
1507 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9, NULL);
1510 printf("%-11s", timestamp[curr]);
1511 cprintf_f(NO_UNIT, 8, 9, 2,
1512 S_VALUE(sneip->InHdrErrors, sneic->InHdrErrors, itv),
1513 S_VALUE(sneip->InAddrErrors, sneic->InAddrErrors, itv),
1514 S_VALUE(sneip->InUnknownProtos, sneic->InUnknownProtos, itv),
1515 S_VALUE(sneip->InDiscards, sneic->InDiscards, itv),
1516 S_VALUE(sneip->OutDiscards, sneic->OutDiscards, itv),
1517 S_VALUE(sneip->OutNoRoutes, sneic->OutNoRoutes, itv),
1518 S_VALUE(sneip->ReasmFails, sneic->ReasmFails, itv),
1519 S_VALUE(sneip->FragFails, sneic->FragFails, itv));
1524 ***************************************************************************
1525 * Display ICMP network traffic statistics.
1528 * @a Activity structure with statistics.
1529 * @prev Index in array where stats used as reference are.
1530 * @curr Index in array for current sample statistics.
1531 * @itv Interval of time in 1/100th of a second.
1532 ***************************************************************************
1534 __print_funct_t print_net_icmp_stats(struct activity *a, int prev, int curr,
1535 unsigned long long itv)
1537 struct stats_net_icmp
1538 *snic = (struct stats_net_icmp *) a->buf[curr],
1539 *snip = (struct stats_net_icmp *) a->buf[prev];
1542 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9, NULL);
1545 printf("%-11s", timestamp[curr]);
1546 cprintf_f(NO_UNIT, 14, 9, 2,
1547 S_VALUE(snip->InMsgs, snic->InMsgs, itv),
1548 S_VALUE(snip->OutMsgs, snic->OutMsgs, itv),
1549 S_VALUE(snip->InEchos, snic->InEchos, itv),
1550 S_VALUE(snip->InEchoReps, snic->InEchoReps, itv),
1551 S_VALUE(snip->OutEchos, snic->OutEchos, itv),
1552 S_VALUE(snip->OutEchoReps, snic->OutEchoReps, itv),
1553 S_VALUE(snip->InTimestamps, snic->InTimestamps, itv),
1554 S_VALUE(snip->InTimestampReps, snic->InTimestampReps, itv),
1555 S_VALUE(snip->OutTimestamps, snic->OutTimestamps, itv),
1556 S_VALUE(snip->OutTimestampReps, snic->OutTimestampReps, itv),
1557 S_VALUE(snip->InAddrMasks, snic->InAddrMasks, itv),
1558 S_VALUE(snip->InAddrMaskReps, snic->InAddrMaskReps, itv),
1559 S_VALUE(snip->OutAddrMasks, snic->OutAddrMasks, itv),
1560 S_VALUE(snip->OutAddrMaskReps, snic->OutAddrMaskReps, itv));
1565 ***************************************************************************
1566 * Display ICMP network errors statistics.
1569 * @a Activity structure with statistics.
1570 * @prev Index in array where stats used as reference are.
1571 * @curr Index in array for current sample statistics.
1572 * @itv Interval of time in 1/100th of a second.
1573 ***************************************************************************
1575 __print_funct_t print_net_eicmp_stats(struct activity *a, int prev, int curr,
1576 unsigned long long itv)
1578 struct stats_net_eicmp
1579 *sneic = (struct stats_net_eicmp *) a->buf[curr],
1580 *sneip = (struct stats_net_eicmp *) a->buf[prev];
1583 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9, NULL);
1586 printf("%-11s", timestamp[curr]);
1587 cprintf_f(NO_UNIT, 12, 9, 2,
1588 S_VALUE(sneip->InErrors, sneic->InErrors, itv),
1589 S_VALUE(sneip->OutErrors, sneic->OutErrors, itv),
1590 S_VALUE(sneip->InDestUnreachs, sneic->InDestUnreachs, itv),
1591 S_VALUE(sneip->OutDestUnreachs, sneic->OutDestUnreachs, itv),
1592 S_VALUE(sneip->InTimeExcds, sneic->InTimeExcds, itv),
1593 S_VALUE(sneip->OutTimeExcds, sneic->OutTimeExcds, itv),
1594 S_VALUE(sneip->InParmProbs, sneic->InParmProbs, itv),
1595 S_VALUE(sneip->OutParmProbs, sneic->OutParmProbs, itv),
1596 S_VALUE(sneip->InSrcQuenchs, sneic->InSrcQuenchs, itv),
1597 S_VALUE(sneip->OutSrcQuenchs, sneic->OutSrcQuenchs, itv),
1598 S_VALUE(sneip->InRedirects, sneic->InRedirects, itv),
1599 S_VALUE(sneip->OutRedirects, sneic->OutRedirects, itv));
1604 ***************************************************************************
1605 * Display TCP network traffic statistics.
1608 * @a Activity structure with statistics.
1609 * @prev Index in array where stats used as reference are.
1610 * @curr Index in array for current sample statistics.
1611 * @itv Interval of time in 1/100th of a second.
1612 ***************************************************************************
1614 __print_funct_t print_net_tcp_stats(struct activity *a, int prev, int curr,
1615 unsigned long long itv)
1617 struct stats_net_tcp
1618 *sntc = (struct stats_net_tcp *) a->buf[curr],
1619 *sntp = (struct stats_net_tcp *) a->buf[prev];
1622 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9, NULL);
1625 printf("%-11s", timestamp[curr]);
1626 cprintf_f(NO_UNIT, 4, 9, 2,
1627 S_VALUE(sntp->ActiveOpens, sntc->ActiveOpens, itv),
1628 S_VALUE(sntp->PassiveOpens, sntc->PassiveOpens, itv),
1629 S_VALUE(sntp->InSegs, sntc->InSegs, itv),
1630 S_VALUE(sntp->OutSegs, sntc->OutSegs, itv));
1635 ***************************************************************************
1636 * Display TCP network errors statistics.
1639 * @a Activity structure with statistics.
1640 * @prev Index in array where stats used as reference are.
1641 * @curr Index in array for current sample statistics.
1642 * @itv Interval of time in 1/100th of a second.
1643 ***************************************************************************
1645 __print_funct_t print_net_etcp_stats(struct activity *a, int prev, int curr,
1646 unsigned long long itv)
1648 struct stats_net_etcp
1649 *snetc = (struct stats_net_etcp *) a->buf[curr],
1650 *snetp = (struct stats_net_etcp *) a->buf[prev];
1653 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9, NULL);
1656 printf("%-11s", timestamp[curr]);
1657 cprintf_f(NO_UNIT, 5, 9, 2,
1658 S_VALUE(snetp->AttemptFails, snetc->AttemptFails, itv),
1659 S_VALUE(snetp->EstabResets, snetc->EstabResets, itv),
1660 S_VALUE(snetp->RetransSegs, snetc->RetransSegs, itv),
1661 S_VALUE(snetp->InErrs, snetc->InErrs, itv),
1662 S_VALUE(snetp->OutRsts, snetc->OutRsts, itv));
1667 ***************************************************************************
1668 * Display UDP network traffic statistics.
1671 * @a Activity structure with statistics.
1672 * @prev Index in array where stats used as reference are.
1673 * @curr Index in array for current sample statistics.
1674 * @itv Interval of time in 1/100th of a second.
1675 ***************************************************************************
1677 __print_funct_t print_net_udp_stats(struct activity *a, int prev, int curr,
1678 unsigned long long itv)
1680 struct stats_net_udp
1681 *snuc = (struct stats_net_udp *) a->buf[curr],
1682 *snup = (struct stats_net_udp *) a->buf[prev];
1685 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9, NULL);
1688 printf("%-11s", timestamp[curr]);
1689 cprintf_f(NO_UNIT, 4, 9, 2,
1690 S_VALUE(snup->InDatagrams, snuc->InDatagrams, itv),
1691 S_VALUE(snup->OutDatagrams, snuc->OutDatagrams, itv),
1692 S_VALUE(snup->NoPorts, snuc->NoPorts, itv),
1693 S_VALUE(snup->InErrors, snuc->InErrors, itv));
1698 ***************************************************************************
1699 * Display IPv6 sockets statistics. This function is used to display
1700 * instantaneous and average statistics.
1703 * @a Activity structure with statistics.
1704 * @curr Index in array for current sample statistics.
1705 * @dispavg TRUE if displaying average statistics.
1706 ***************************************************************************
1708 void stub_print_net_sock6_stats(struct activity *a, int curr, int dispavg)
1710 struct stats_net_sock6
1711 *snsc = (struct stats_net_sock6 *) a->buf[curr];
1712 static unsigned long long
1716 avg_frag6_inuse = 0;
1719 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9, NULL);
1721 printf("%-11s", timestamp[curr]);
1724 /* Display instantaneous values */
1725 cprintf_u64(NO_UNIT, 4, 9,
1726 (unsigned long long) snsc->tcp6_inuse,
1727 (unsigned long long) snsc->udp6_inuse,
1728 (unsigned long long) snsc->raw6_inuse,
1729 (unsigned long long) snsc->frag6_inuse);
1732 /* Will be used to compute the average */
1733 avg_tcp6_inuse += snsc->tcp6_inuse;
1734 avg_udp6_inuse += snsc->udp6_inuse;
1735 avg_raw6_inuse += snsc->raw6_inuse;
1736 avg_frag6_inuse += snsc->frag6_inuse;
1739 /* Display average values */
1740 cprintf_f(NO_UNIT, 4, 9, 0,
1741 (double) avg_tcp6_inuse / avg_count,
1742 (double) avg_udp6_inuse / avg_count,
1743 (double) avg_raw6_inuse / avg_count,
1744 (double) avg_frag6_inuse / avg_count);
1747 /* Reset average counters */
1748 avg_tcp6_inuse = avg_udp6_inuse = avg_raw6_inuse = avg_frag6_inuse = 0;
1753 ***************************************************************************
1754 * Display IPv6 sockets statistics.
1757 * @a Activity structure with statistics.
1758 * @prev Index in array where stats used as reference are.
1759 * @curr Index in array for current sample statistics.
1760 * @itv Interval of time in 1/100th of a second.
1761 ***************************************************************************
1763 __print_funct_t print_net_sock6_stats(struct activity *a, int prev, int curr,
1764 unsigned long long itv)
1766 stub_print_net_sock6_stats(a, curr, FALSE);
1770 ***************************************************************************
1771 * Display average IPv6 sockets statistics.
1774 * @a Activity structure with statistics.
1775 * @prev Index in array where stats used as reference are.
1776 * @curr Index in array for current sample statistics.
1777 * @itv Interval of time in 1/100th of a second.
1778 ***************************************************************************
1780 __print_funct_t print_avg_net_sock6_stats(struct activity *a, int prev, int curr,
1781 unsigned long long itv)
1783 stub_print_net_sock6_stats(a, curr, TRUE);
1787 ***************************************************************************
1788 * Display IPv6 network traffic statistics.
1791 * @a Activity structure with statistics.
1792 * @prev Index in array where stats used as reference are.
1793 * @curr Index in array for current sample statistics.
1794 * @itv Interval of time in 1/100th of a second.
1795 ***************************************************************************
1797 __print_funct_t print_net_ip6_stats(struct activity *a, int prev, int curr,
1798 unsigned long long itv)
1800 struct stats_net_ip6
1801 *snic = (struct stats_net_ip6 *) a->buf[curr],
1802 *snip = (struct stats_net_ip6 *) a->buf[prev];
1805 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9, NULL);
1808 printf("%-11s", timestamp[curr]);
1809 cprintf_f(NO_UNIT, 10, 9, 2,
1810 S_VALUE(snip->InReceives6, snic->InReceives6, itv),
1811 S_VALUE(snip->OutForwDatagrams6, snic->OutForwDatagrams6, itv),
1812 S_VALUE(snip->InDelivers6, snic->InDelivers6, itv),
1813 S_VALUE(snip->OutRequests6, snic->OutRequests6, itv),
1814 S_VALUE(snip->ReasmReqds6, snic->ReasmReqds6, itv),
1815 S_VALUE(snip->ReasmOKs6, snic->ReasmOKs6, itv),
1816 S_VALUE(snip->InMcastPkts6, snic->InMcastPkts6, itv),
1817 S_VALUE(snip->OutMcastPkts6, snic->OutMcastPkts6, itv),
1818 S_VALUE(snip->FragOKs6, snic->FragOKs6, itv),
1819 S_VALUE(snip->FragCreates6, snic->FragCreates6, itv));
1824 ***************************************************************************
1825 * Display IPv6 network errors statistics.
1828 * @a Activity structure with statistics.
1829 * @prev Index in array where stats used as reference are.
1830 * @curr Index in array for current sample statistics.
1831 * @itv Interval of time in 1/100th of a second.
1832 ***************************************************************************
1834 __print_funct_t print_net_eip6_stats(struct activity *a, int prev, int curr,
1835 unsigned long long itv)
1837 struct stats_net_eip6
1838 *sneic = (struct stats_net_eip6 *) a->buf[curr],
1839 *sneip = (struct stats_net_eip6 *) a->buf[prev];
1842 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9, NULL);
1845 printf("%-11s", timestamp[curr]);
1846 cprintf_f(NO_UNIT, 11, 9, 2,
1847 S_VALUE(sneip->InHdrErrors6, sneic->InHdrErrors6, itv),
1848 S_VALUE(sneip->InAddrErrors6, sneic->InAddrErrors6, itv),
1849 S_VALUE(sneip->InUnknownProtos6, sneic->InUnknownProtos6, itv),
1850 S_VALUE(sneip->InTooBigErrors6, sneic->InTooBigErrors6, itv),
1851 S_VALUE(sneip->InDiscards6, sneic->InDiscards6, itv),
1852 S_VALUE(sneip->OutDiscards6, sneic->OutDiscards6, itv),
1853 S_VALUE(sneip->InNoRoutes6, sneic->InNoRoutes6, itv),
1854 S_VALUE(sneip->OutNoRoutes6, sneic->OutNoRoutes6, itv),
1855 S_VALUE(sneip->ReasmFails6, sneic->ReasmFails6, itv),
1856 S_VALUE(sneip->FragFails6, sneic->FragFails6, itv),
1857 S_VALUE(sneip->InTruncatedPkts6, sneic->InTruncatedPkts6, itv));
1862 ***************************************************************************
1863 * Display ICMPv6 network traffic statistics.
1866 * @a Activity structure with statistics.
1867 * @prev Index in array where stats used as reference are.
1868 * @curr Index in array for current sample statistics.
1869 * @itv Interval of time in 1/100th of a second.
1870 ***************************************************************************
1872 __print_funct_t print_net_icmp6_stats(struct activity *a, int prev, int curr,
1873 unsigned long long itv)
1875 struct stats_net_icmp6
1876 *snic = (struct stats_net_icmp6 *) a->buf[curr],
1877 *snip = (struct stats_net_icmp6 *) a->buf[prev];
1880 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9, NULL);
1883 printf("%-11s", timestamp[curr]);
1884 cprintf_f(NO_UNIT, 17, 9, 2,
1885 S_VALUE(snip->InMsgs6, snic->InMsgs6, itv),
1886 S_VALUE(snip->OutMsgs6, snic->OutMsgs6, itv),
1887 S_VALUE(snip->InEchos6, snic->InEchos6, itv),
1888 S_VALUE(snip->InEchoReplies6, snic->InEchoReplies6, itv),
1889 S_VALUE(snip->OutEchoReplies6, snic->OutEchoReplies6, itv),
1890 S_VALUE(snip->InGroupMembQueries6, snic->InGroupMembQueries6, itv),
1891 S_VALUE(snip->InGroupMembResponses6, snic->InGroupMembResponses6, itv),
1892 S_VALUE(snip->OutGroupMembResponses6, snic->OutGroupMembResponses6, itv),
1893 S_VALUE(snip->InGroupMembReductions6, snic->InGroupMembReductions6, itv),
1894 S_VALUE(snip->OutGroupMembReductions6, snic->OutGroupMembReductions6, itv),
1895 S_VALUE(snip->InRouterSolicits6, snic->InRouterSolicits6, itv),
1896 S_VALUE(snip->OutRouterSolicits6, snic->OutRouterSolicits6, itv),
1897 S_VALUE(snip->InRouterAdvertisements6, snic->InRouterAdvertisements6, itv),
1898 S_VALUE(snip->InNeighborSolicits6, snic->InNeighborSolicits6, itv),
1899 S_VALUE(snip->OutNeighborSolicits6, snic->OutNeighborSolicits6, itv),
1900 S_VALUE(snip->InNeighborAdvertisements6, snic->InNeighborAdvertisements6, itv),
1901 S_VALUE(snip->OutNeighborAdvertisements6, snic->OutNeighborAdvertisements6, itv));
1906 ***************************************************************************
1907 * Display ICMPv6 network errors statistics.
1910 * @a Activity structure with statistics.
1911 * @prev Index in array where stats used as reference are.
1912 * @curr Index in array for current sample statistics.
1913 * @itv Interval of time in 1/100th of a second.
1914 ***************************************************************************
1916 __print_funct_t print_net_eicmp6_stats(struct activity *a, int prev, int curr,
1917 unsigned long long itv)
1919 struct stats_net_eicmp6
1920 *sneic = (struct stats_net_eicmp6 *) a->buf[curr],
1921 *sneip = (struct stats_net_eicmp6 *) a->buf[prev];
1924 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9, NULL);
1927 printf("%-11s", timestamp[curr]);
1928 cprintf_f(NO_UNIT, 11, 9, 2,
1929 S_VALUE(sneip->InErrors6, sneic->InErrors6, itv),
1930 S_VALUE(sneip->InDestUnreachs6, sneic->InDestUnreachs6, itv),
1931 S_VALUE(sneip->OutDestUnreachs6, sneic->OutDestUnreachs6, itv),
1932 S_VALUE(sneip->InTimeExcds6, sneic->InTimeExcds6, itv),
1933 S_VALUE(sneip->OutTimeExcds6, sneic->OutTimeExcds6, itv),
1934 S_VALUE(sneip->InParmProblems6, sneic->InParmProblems6, itv),
1935 S_VALUE(sneip->OutParmProblems6, sneic->OutParmProblems6, itv),
1936 S_VALUE(sneip->InRedirects6, sneic->InRedirects6, itv),
1937 S_VALUE(sneip->OutRedirects6, sneic->OutRedirects6, itv),
1938 S_VALUE(sneip->InPktTooBigs6, sneic->InPktTooBigs6, itv),
1939 S_VALUE(sneip->OutPktTooBigs6, sneic->OutPktTooBigs6, itv));
1944 ***************************************************************************
1945 * Display UDPv6 network traffic statistics.
1948 * @a Activity structure with statistics.
1949 * @prev Index in array where stats used as reference are.
1950 * @curr Index in array for current sample statistics.
1951 * @itv Interval of time in 1/100th of a second.
1952 ***************************************************************************
1954 __print_funct_t print_net_udp6_stats(struct activity *a, int prev, int curr,
1955 unsigned long long itv)
1957 struct stats_net_udp6
1958 *snuc = (struct stats_net_udp6 *) a->buf[curr],
1959 *snup = (struct stats_net_udp6 *) a->buf[prev];
1962 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9, NULL);
1965 printf("%-11s", timestamp[curr]);
1966 cprintf_f(NO_UNIT, 4, 9, 2,
1967 S_VALUE(snup->InDatagrams6, snuc->InDatagrams6, itv),
1968 S_VALUE(snup->OutDatagrams6, snuc->OutDatagrams6, itv),
1969 S_VALUE(snup->NoPorts6, snuc->NoPorts6, itv),
1970 S_VALUE(snup->InErrors6, snuc->InErrors6, itv));
1975 ***************************************************************************
1976 * Display CPU frequency statistics. This function is used to display
1977 * instantaneous and average statistics.
1980 * @a Activity structure with statistics.
1981 * @curr Index in array for current sample statistics.
1982 * @dispavg True if displaying average statistics.
1983 ***************************************************************************
1985 void stub_print_pwr_cpufreq_stats(struct activity *a, int curr, int dispavg)
1988 struct stats_pwr_cpufreq *spc;
1989 static __nr_t nr_alloc = 0;
1990 static unsigned long long
1991 *avg_cpufreq = NULL;
1993 if (!avg_cpufreq || (a->nr[curr] > nr_alloc)) {
1994 /* Allocate array of CPU frequency */
1995 SREALLOC(avg_cpufreq, unsigned long long, sizeof(unsigned long long) * a->nr[curr]);
1996 if (a->nr[curr] > nr_alloc) {
1997 /* Init additional space allocated */
1998 memset(avg_cpufreq + nr_alloc, 0,
1999 sizeof(unsigned long long) * (a->nr[curr] - nr_alloc));
2001 nr_alloc = a->nr[curr];
2005 print_hdr_line(timestamp[!curr], a, FIRST, 7, 9, NULL);
2008 for (i = 0; (i < a->nr[curr]) && (i < a->bitmap->b_size + 1); i++) {
2011 * The size of a->buf[...] CPU structure may be different from the default
2012 * sizeof(struct stats_pwr_cpufreq) value if data have been read from a file!
2013 * That's why we don't use a syntax like:
2014 * spc = (struct stats_pwr_cpufreq *) a->buf[...] + i;
2016 spc = (struct stats_pwr_cpufreq *) ((char *) a->buf[curr] + i * a->msize);
2019 /* This CPU is offline: Don't display it */
2023 * Note: @nr[curr] is in [1, NR_CPUS + 1].
2024 * Bitmap size is provided for (NR_CPUS + 1) CPUs.
2025 * Anyway, NR_CPUS may vary between the version of sysstat
2026 * used by sadc to create a file, and the version of sysstat
2027 * used by sar to read it...
2030 /* Should current CPU (including CPU "all") be displayed? */
2031 if (!(a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))))
2035 printf("%-11s", timestamp[curr]);
2038 /* This is CPU "all" */
2039 cprintf_in(IS_STR, "%s", " all", 0);
2042 cprintf_in(IS_INT, " %3d", "", i - 1);
2046 /* Display instantaneous values */
2047 cprintf_f(NO_UNIT, 1, 9, 2,
2048 ((double) spc->cpufreq) / 100);
2051 * Will be used to compute the average.
2052 * Note: Overflow unlikely to happen but not impossible...
2054 avg_cpufreq[i] += spc->cpufreq;
2057 /* Display average values */
2058 cprintf_f(NO_UNIT, 1, 9, 2,
2059 (double) avg_cpufreq[i] / (100 * avg_count));
2064 if (dispavg && avg_cpufreq) {
2065 /* Array of CPU frequency no longer needed: Free it! */
2073 ***************************************************************************
2074 * Display CPU frequency statistics.
2077 * @a Activity structure with statistics.
2078 * @prev Index in array where stats used as reference are.
2079 * @curr Index in array for current sample statistics.
2080 * @itv Interval of time in 1/100th of a second.
2081 ***************************************************************************
2083 __print_funct_t print_pwr_cpufreq_stats(struct activity *a, int prev, int curr,
2084 unsigned long long itv)
2086 stub_print_pwr_cpufreq_stats(a, curr, FALSE);
2090 ***************************************************************************
2091 * Display average CPU frequency statistics.
2094 * @a Activity structure with statistics.
2095 * @prev Index in array where stats used as reference are.
2096 * @curr Index in array for current sample statistics.
2097 * @itv Interval of time in 1/100th of a second.
2098 ***************************************************************************
2100 __print_funct_t print_avg_pwr_cpufreq_stats(struct activity *a, int prev, int curr,
2101 unsigned long long itv)
2103 stub_print_pwr_cpufreq_stats(a, curr, TRUE);
2107 ***************************************************************************
2108 * Display fan statistics. This function is used to display
2109 * instantaneous and average statistics.
2112 * @a Activity structure with statistics.
2113 * @curr Index in array for current sample statistics.
2114 * @dispavg True if displaying average statistics.
2115 ***************************************************************************
2117 void stub_print_pwr_fan_stats(struct activity *a, int curr, int dispavg)
2120 struct stats_pwr_fan *spc;
2121 static __nr_t nr_alloc = 0;
2122 static double *avg_fan = NULL;
2123 static double *avg_fan_min = NULL;
2125 /* Allocate arrays of fan RPMs */
2126 if (!avg_fan || (a->nr[curr] > nr_alloc)) {
2127 SREALLOC(avg_fan, double, sizeof(double) * a->nr[curr]);
2128 SREALLOC(avg_fan_min, double, sizeof(double) * a->nr[curr]);
2130 if (a->nr[curr] > nr_alloc) {
2131 /* Init additional space allocated */
2132 memset(avg_fan + nr_alloc, 0,
2133 sizeof(double) * (a->nr[curr] - nr_alloc));
2134 memset(avg_fan_min + nr_alloc, 0,
2135 sizeof(double) * (a->nr[curr] - nr_alloc));
2137 nr_alloc = a->nr[curr];
2141 print_hdr_line(timestamp[!curr], a, FIRST, -2, 9, NULL);
2144 for (i = 0; i < a->nr[curr]; i++) {
2145 spc = (struct stats_pwr_fan *) ((char *) a->buf[curr] + i * a->msize);
2147 printf("%-11s", timestamp[curr]);
2148 cprintf_in(IS_INT, " %5d", "", i + 1);
2151 /* Display average values */
2152 cprintf_f(NO_UNIT, 2, 9, 2,
2153 (double) avg_fan[i] / avg_count,
2154 (double) (avg_fan[i] - avg_fan_min[i]) / avg_count);
2157 /* Display instantaneous values */
2158 cprintf_f(NO_UNIT, 2, 9, 2,
2160 spc->rpm - spc->rpm_min);
2161 avg_fan[i] += spc->rpm;
2162 avg_fan_min[i] += spc->rpm_min;
2165 cprintf_in(IS_STR, " %s\n", spc->device, 0);
2168 if (dispavg && avg_fan) {
2178 ***************************************************************************
2179 * Display fan statistics.
2182 * @a Activity structure with statistics.
2183 * @prev Index in array where stats used as reference are.
2184 * @curr Index in array for current sample statistics.
2185 * @itv Interval of time in 1/100th of a second.
2186 ***************************************************************************
2188 __print_funct_t print_pwr_fan_stats(struct activity *a, int prev, int curr,
2189 unsigned long long itv)
2191 stub_print_pwr_fan_stats(a, curr, FALSE);
2195 ***************************************************************************
2196 * Display average fan statistics.
2199 * @a Activity structure with statistics.
2200 * @prev Index in array where stats used as reference are.
2201 * @curr Index in array for current sample statistics.
2202 * @itv Interval of time in 1/100th of a second.
2203 ***************************************************************************
2205 __print_funct_t print_avg_pwr_fan_stats(struct activity *a, int prev, int curr,
2206 unsigned long long itv)
2208 stub_print_pwr_fan_stats(a, curr, TRUE);
2212 ***************************************************************************
2213 * Display device temperature statistics. This function is used to display
2214 * instantaneous and average statistics.
2217 * @a Activity structure with statistics.
2218 * @curr Index in array for current sample statistics.
2219 * @dispavg True if displaying average statistics.
2220 ***************************************************************************
2222 void stub_print_pwr_temp_stats(struct activity *a, int curr, int dispavg)
2225 struct stats_pwr_temp *spc;
2226 static __nr_t nr_alloc = 0;
2227 static double *avg_temp = NULL;
2228 static double *avg_temp_min = NULL, *avg_temp_max = NULL;
2230 /* Allocate arrays of temperatures */
2231 if (!avg_temp || (a->nr[curr] > nr_alloc)) {
2232 SREALLOC(avg_temp, double, sizeof(double) * a->nr[curr]);
2233 SREALLOC(avg_temp_min, double, sizeof(double) * a->nr[curr]);
2234 SREALLOC(avg_temp_max, double, sizeof(double) * a->nr[curr]);
2236 if (a->nr[curr] > nr_alloc) {
2237 /* Init additional space allocated */
2238 memset(avg_temp + nr_alloc, 0,
2239 sizeof(double) * (a->nr[curr] - nr_alloc));
2240 memset(avg_temp_min + nr_alloc, 0,
2241 sizeof(double) * (a->nr[curr] - nr_alloc));
2242 memset(avg_temp_max + nr_alloc, 0,
2243 sizeof(double) * (a->nr[curr] - nr_alloc));
2245 nr_alloc = a->nr[curr];
2249 print_hdr_line(timestamp[!curr], a, FIRST, -2, 9, NULL);
2252 for (i = 0; i < a->nr[curr]; i++) {
2253 spc = (struct stats_pwr_temp *) ((char *) a->buf[curr] + i * a->msize);
2255 printf("%-11s", timestamp[curr]);
2256 cprintf_in(IS_INT, " %5d", "", i + 1);
2259 /* Display average values */
2260 cprintf_f(NO_UNIT, 1, 9, 2, (double) avg_temp[i] / avg_count);
2261 cprintf_pc(DISPLAY_UNIT(flags), 1, 9, 2,
2262 (avg_temp_max[i] - avg_temp_min[i]) ?
2263 ((double) (avg_temp[i] / avg_count) - avg_temp_min[i]) / (avg_temp_max[i] - avg_temp_min[i]) * 100
2267 /* Display instantaneous values */
2268 cprintf_f(NO_UNIT, 1, 9, 2, spc->temp);
2269 cprintf_pc(DISPLAY_UNIT(flags), 1, 9, 2,
2270 (spc->temp_max - spc->temp_min) ?
2271 (spc->temp - spc->temp_min) / (spc->temp_max - spc->temp_min) * 100
2273 avg_temp[i] += spc->temp;
2274 /* Assume that min and max temperatures cannot vary */
2275 avg_temp_min[i] = spc->temp_min;
2276 avg_temp_max[i] = spc->temp_max;
2279 cprintf_in(IS_STR, " %s\n", spc->device, 0);
2282 if (dispavg && avg_temp) {
2287 avg_temp_min = NULL;
2288 avg_temp_max = NULL;
2294 ***************************************************************************
2295 * Display temperature statistics.
2298 * @a Activity structure with statistics.
2299 * @prev Index in array where stats used as reference are.
2300 * @curr Index in array for current sample statistics.
2301 * @itv Interval of time in 1/100th of a second.
2302 ***************************************************************************
2304 __print_funct_t print_pwr_temp_stats(struct activity *a, int prev, int curr,
2305 unsigned long long itv)
2307 stub_print_pwr_temp_stats(a, curr, FALSE);
2311 ***************************************************************************
2312 * Display average temperature statistics.
2315 * @a Activity structure with statistics.
2316 * @prev Index in array where stats used as reference are.
2317 * @curr Index in array for current sample statistics.
2318 * @itv Interval of time in 1/100th of a second.
2319 ***************************************************************************
2321 __print_funct_t print_avg_pwr_temp_stats(struct activity *a, int prev, int curr,
2322 unsigned long long itv)
2324 stub_print_pwr_temp_stats(a, curr, TRUE);
2328 ***************************************************************************
2329 * Display voltage inputs statistics. This function is used to display
2330 * instantaneous and average statistics.
2333 * @a Activity structure with statistics.
2334 * @curr Index in array for current sample statistics.
2335 * @dispavg True if displaying average statistics.
2336 ***************************************************************************
2338 void stub_print_pwr_in_stats(struct activity *a, int curr, int dispavg)
2341 struct stats_pwr_in *spc;
2342 static __nr_t nr_alloc = 0;
2343 static double *avg_in = NULL;
2344 static double *avg_in_min = NULL, *avg_in_max = NULL;
2346 /* Allocate arrays of voltage inputs */
2347 if (!avg_in || (a->nr[curr] > nr_alloc)) {
2348 SREALLOC(avg_in, double, sizeof(double) * a->nr[curr]);
2349 SREALLOC(avg_in_min, double, sizeof(double) * a->nr[curr]);
2350 SREALLOC(avg_in_max, double, sizeof(double) * a->nr[curr]);
2352 if (a->nr[curr] > nr_alloc) {
2353 /* Init additional space allocated */
2354 memset(avg_in + nr_alloc, 0,
2355 sizeof(double) * (a->nr[curr] - nr_alloc));
2356 memset(avg_in_min + nr_alloc, 0,
2357 sizeof(double) * (a->nr[curr] - nr_alloc));
2358 memset(avg_in_max + nr_alloc, 0,
2359 sizeof(double) * (a->nr[curr] - nr_alloc));
2361 nr_alloc = a->nr[curr];
2365 print_hdr_line(timestamp[!curr], a, FIRST, -2, 9, NULL);
2368 for (i = 0; i < a->nr[curr]; i++) {
2369 spc = (struct stats_pwr_in *) ((char *) a->buf[curr] + i * a->msize);
2371 printf("%-11s", timestamp[curr]);
2372 cprintf_in(IS_INT, " %5d", "", i);
2375 /* Display average values */
2376 cprintf_f(NO_UNIT, 1, 9, 2, (double) avg_in[i] / avg_count);
2377 cprintf_pc(DISPLAY_UNIT(flags), 1, 9, 2,
2378 (avg_in_max[i] - avg_in_min[i]) ?
2379 ((double) (avg_in[i] / avg_count) - avg_in_min[i]) / (avg_in_max[i] - avg_in_min[i]) * 100
2383 /* Display instantaneous values */
2384 cprintf_f(NO_UNIT, 1, 9, 2, spc->in);
2385 cprintf_pc(DISPLAY_UNIT(flags), 1, 9, 2,
2386 (spc->in_max - spc->in_min) ?
2387 (spc->in - spc->in_min) / (spc->in_max - spc->in_min) * 100
2389 avg_in[i] += spc->in;
2390 /* Assume that min and max voltage inputs cannot vary */
2391 avg_in_min[i] = spc->in_min;
2392 avg_in_max[i] = spc->in_max;
2395 cprintf_in(IS_STR, " %s\n", spc->device, 0);
2398 if (dispavg && avg_in) {
2410 ***************************************************************************
2411 * Display voltage inputs statistics.
2414 * @a Activity structure with statistics.
2415 * @prev Index in array where stats used as reference are.
2416 * @curr Index in array for current sample statistics.
2417 * @itv Interval of time in 1/100th of a second.
2418 ***************************************************************************
2420 __print_funct_t print_pwr_in_stats(struct activity *a, int prev, int curr,
2421 unsigned long long itv)
2423 stub_print_pwr_in_stats(a, curr, FALSE);
2427 ***************************************************************************
2428 * Display average voltage inputs statistics.
2431 * @a Activity structure with statistics.
2432 * @prev Index in array where stats used as reference are.
2433 * @curr Index in array for current sample statistics.
2434 * @itv Interval of time in 1/100th of a second.
2435 ***************************************************************************
2437 __print_funct_t print_avg_pwr_in_stats(struct activity *a, int prev, int curr,
2438 unsigned long long itv)
2440 stub_print_pwr_in_stats(a, curr, TRUE);
2444 ***************************************************************************
2445 * Display huge pages statistics. This function is used to
2446 * display instantaneous and average statistics.
2449 * @a Activity structure with statistics.
2450 * @curr Index in array for current sample statistics.
2451 * @dispavg TRUE if displaying average statistics.
2452 ***************************************************************************
2454 void stub_print_huge_stats(struct activity *a, int curr, int dispavg)
2457 *smc = (struct stats_huge *) a->buf[curr];
2458 static unsigned long long
2465 if (DISPLAY_UNIT(flags)) {
2466 /* Default values unit is kB */
2467 unit = UNIT_KILOBYTE;
2471 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9, NULL);
2473 printf("%-11s", timestamp[curr]);
2476 /* Display instantaneous values */
2477 cprintf_u64(unit, 2, 9,
2478 (unsigned long long) smc->frhkb,
2479 (unsigned long long) (smc->tlhkb - smc->frhkb));
2480 cprintf_pc(DISPLAY_UNIT(flags), 1, 9, 2,
2482 SP_VALUE(smc->frhkb, smc->tlhkb, smc->tlhkb) : 0.0);
2483 cprintf_u64(unit, 2, 9,
2484 (unsigned long long) smc->rsvdhkb,
2485 (unsigned long long) (smc->surphkb));
2488 /* Will be used to compute the average */
2489 avg_frhkb += smc->frhkb;
2490 avg_tlhkb += smc->tlhkb;
2491 avg_rsvdhkb += smc->rsvdhkb;
2492 avg_surphkb += smc->surphkb;
2495 /* Display average values */
2496 cprintf_f(unit, 2, 9, 0,
2497 (double) avg_frhkb / avg_count,
2498 ((double) avg_tlhkb / avg_count) -
2499 ((double) avg_frhkb / avg_count));
2500 cprintf_pc(DISPLAY_UNIT(flags), 1, 9, 2,
2502 SP_VALUE((double) avg_frhkb / avg_count,
2503 (double) avg_tlhkb / avg_count,
2504 (double) avg_tlhkb / avg_count) : 0.0);
2505 cprintf_f(unit, 2, 9, 0,
2506 (double) avg_rsvdhkb / avg_count,
2507 (double) avg_surphkb / avg_count);
2510 /* Reset average counters */
2511 avg_frhkb = avg_tlhkb = avg_rsvdhkb = avg_surphkb = 0;
2516 ***************************************************************************
2517 * Display huge pages statistics.
2520 * @a Activity structure with statistics.
2521 * @prev Index in array where stats used as reference are.
2522 * @curr Index in array for current sample statistics.
2523 * @itv Interval of time in 1/100th of a second.
2524 ***************************************************************************
2526 __print_funct_t print_huge_stats(struct activity *a, int prev, int curr,
2527 unsigned long long itv)
2529 stub_print_huge_stats(a, curr, FALSE);
2533 ***************************************************************************
2534 * Display huge pages statistics.
2537 * @a Activity structure with statistics.
2538 * @prev Index in array where stats used as reference are.
2539 * @curr Index in array for current sample statistics.
2540 * @itv Interval of time in 1/100th of a second.
2541 ***************************************************************************
2543 __print_funct_t print_avg_huge_stats(struct activity *a, int prev, int curr,
2544 unsigned long long itv)
2546 stub_print_huge_stats(a, curr, TRUE);
2550 ***************************************************************************
2551 * Display CPU weighted frequency statistics. This function is used to
2552 * display instantaneous and average statistics.
2555 * @a Activity structure with statistics.
2556 * @prev Index in array where stats used as reference are.
2557 * @curr Index in array for current sample statistics.
2558 * @itv Interval of time in 1/100th of a second.
2559 ***************************************************************************
2561 void print_pwr_wghfreq_stats(struct activity *a, int prev, int curr,
2562 unsigned long long itv)
2565 struct stats_pwr_wghfreq *spc, *spp, *spc_k, *spp_k;
2566 unsigned long long tis, tisfreq;
2569 print_hdr_line(timestamp[!curr], a, FIRST, 7, 9, NULL);
2572 for (i = 0; (i < a->nr[curr]) && (i < a->bitmap->b_size + 1); i++) {
2575 * The size of a->buf[...] CPU structure may be different from the default
2576 * sizeof(struct stats_pwr_wghfreq) value if data have been read from a file!
2577 * That's why we don't use a syntax like:
2578 * spc = (struct stats_pwr_wghfreq *) a->buf[...] + i;
2580 spc = (struct stats_pwr_wghfreq *) ((char *) a->buf[curr] + i * a->msize * a->nr2);
2581 spp = (struct stats_pwr_wghfreq *) ((char *) a->buf[prev] + i * a->msize * a->nr2);
2584 * Note: a->nr is in [1, NR_CPUS + 1].
2585 * Bitmap size is provided for (NR_CPUS + 1) CPUs.
2586 * Anyway, NR_CPUS may vary between the version of sysstat
2587 * used by sadc to create a file, and the version of sysstat
2588 * used by sar to read it...
2591 /* Should current CPU (including CPU "all") be displayed? */
2592 if (!(a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))))
2596 /* Yes: Display it */
2597 printf("%-11s", timestamp[curr]);
2600 /* This is CPU "all" */
2601 cprintf_in(IS_STR, "%s", " all", 0);
2604 cprintf_in(IS_INT, " %3d", "", i - 1);
2610 for (k = 0; k < a->nr2; k++) {
2612 spc_k = (struct stats_pwr_wghfreq *) ((char *) spc + k * a->msize);
2615 spp_k = (struct stats_pwr_wghfreq *) ((char *) spp + k * a->msize);
2617 tisfreq += (spc_k->freq / 1000) *
2618 (spc_k->time_in_state - spp_k->time_in_state);
2619 tis += (spc_k->time_in_state - spp_k->time_in_state);
2622 /* Display weighted frequency for current CPU */
2623 cprintf_f(NO_UNIT, 1, 9, 2,
2624 tis ? ((double) tisfreq) / tis : 0.0);
2630 ***************************************************************************
2631 * Display USB devices statistics. This function is used to
2632 * display instantaneous and summary statistics.
2635 * @a Activity structure with statistics.
2636 * @curr Index in array for current sample statistics.
2637 * @dispavg TRUE if displaying average statistics.
2638 ***************************************************************************
2640 void stub_print_pwr_usb_stats(struct activity *a, int curr, int dispavg)
2644 struct stats_pwr_usb *suc, *sum;
2647 printf("\n%-11s BUS idvendor idprod maxpower",
2648 (dispavg ? _("Summary:") : timestamp[!curr]));
2649 printf(" %-*s product\n", MAX_MANUF_LEN - 1, "manufact");
2652 for (i = 0; i < a->nr[curr]; i++) {
2653 suc = (struct stats_pwr_usb *) ((char *) a->buf[curr] + i * a->msize);
2655 printf("%-11s", (dispavg ? _("Summary:") : timestamp[curr]));
2656 cprintf_in(IS_INT, " %6d", "", suc->bus_nr);
2660 cprintf_u64(NO_UNIT, 1, 9,
2661 /* bMaxPower is expressed in 2 mA units */
2662 (unsigned long long) (suc->bmaxpower << 1));
2664 snprintf(fmt, 16, " %%-%ds", MAX_MANUF_LEN - 1);
2665 cprintf_s(IS_STR, fmt, suc->manufacturer);
2666 cprintf_s(IS_STR, " %s\n", suc->product);
2669 /* Save current USB device in summary list */
2670 for (j = 0; j < a->nr_allocated; j++) {
2671 sum = (struct stats_pwr_usb *) ((char *) a->buf[2] + j * a->msize);
2673 if ((sum->bus_nr == suc->bus_nr) &&
2674 (sum->vendor_id == suc->vendor_id) &&
2675 (sum->product_id == suc->product_id))
2676 /* USB device found in summary list */
2680 * Current slot is free:
2681 * Save USB device in summary list.
2688 if (j == a->nr_allocated) {
2690 * No free slot has been found for current device.
2691 * So enlarge buffers then save device in list.
2693 reallocate_all_buffers(a, j);
2694 sum = (struct stats_pwr_usb *) ((char *) a->buf[2] + j * a->msize);
2703 ***************************************************************************
2704 * Display USB devices statistics.
2707 * @a Activity structure with statistics.
2708 * @prev Index in array where stats used as reference are.
2709 * @curr Index in array for current sample statistics.
2710 * @itv Interval of time in 1/100th of a second.
2711 ***************************************************************************
2713 __print_funct_t print_pwr_usb_stats(struct activity *a, int prev, int curr,
2714 unsigned long long itv)
2716 stub_print_pwr_usb_stats(a, curr, FALSE);
2720 ***************************************************************************
2721 * Display average USB devices statistics.
2724 * @a Activity structure with statistics.
2725 * @prev Index in array where stats used as reference are.
2726 * @curr Index in array for current sample statistics.
2727 * @itv Interval of time in 1/100th of a second.
2728 ***************************************************************************
2730 __print_funct_t print_avg_pwr_usb_stats(struct activity *a, int prev, int curr,
2731 unsigned long long itv)
2733 stub_print_pwr_usb_stats(a, 2, TRUE);
2737 ***************************************************************************
2738 * Display filesystems statistics. This function is used to
2739 * display instantaneous and average statistics.
2742 * @a Activity structure with statistics.
2743 * @prev Index in array where stats used as reference are.
2744 * @curr Index in array for current sample statistics.
2745 * @dispavg TRUE if displaying average statistics.
2746 ***************************************************************************
2748 __print_funct_t stub_print_filesystem_stats(struct activity *a, int prev, int curr, int dispavg)
2750 int i, j, j0, found;
2751 struct stats_filesystem *sfc, *sfp, *sfm;
2755 if (DISPLAY_UNIT(flags)) {
2756 /* Default values unit is B */
2760 if (dish || DISPLAY_ZERO_OMIT(flags)) {
2761 print_hdr_line((dispavg ? _("Summary:") : timestamp[!curr]),
2762 a, FIRST + DISPLAY_MOUNT(a->opt_flags), -1, 9, NULL);
2765 for (i = 0; i < a->nr[curr]; i++) {
2766 sfc = (struct stats_filesystem *) ((char *) a->buf[curr] + i * a->msize);
2768 /* Get name to display (persistent or standard fs name, or mount point) */
2769 dev_name = get_fs_name_to_display(a, flags, sfc);
2771 if (a->item_list != NULL) {
2772 /* A list of devices has been entered on the command line */
2773 if (!search_list_item(a->item_list, dev_name))
2774 /* Device not found */
2779 if (DISPLAY_ZERO_OMIT(flags) && !dispavg) {
2781 if (a->nr[prev] > 0) {
2782 /* Look for corresponding fs in previous iteration */
2785 if (j >= a->nr[prev]) {
2786 j = a->nr[prev] - 1;
2792 sfp = (struct stats_filesystem *) ((char *) a->buf[prev] + j * a->msize);
2793 if (!strcmp(sfp->fs_name, sfc->fs_name)) {
2797 if (++j >= a->nr[prev]) {
2805 if (!DISPLAY_ZERO_OMIT(flags) || dispavg || WANT_SINCE_BOOT(flags) || !found ||
2806 (found && memcmp(sfp, sfc, STATS_FILESYSTEM_SIZE2CMP))) {
2808 printf("%-11s", (dispavg ? _("Summary:") : timestamp[curr]));
2809 cprintf_f(unit, 2, 9, 0,
2810 unit < 0 ? (double) sfc->f_bfree / 1024 / 1024 : (double) sfc->f_bfree,
2811 unit < 0 ? (double) (sfc->f_blocks - sfc->f_bfree) / 1024 / 1024 :
2812 (double) (sfc->f_blocks - sfc->f_bfree));
2813 cprintf_pc(DISPLAY_UNIT(flags), 2, 9, 2,
2814 /* f_blocks is not zero. But test it anyway ;-) */
2815 sfc->f_blocks ? SP_VALUE(sfc->f_bfree, sfc->f_blocks, sfc->f_blocks)
2817 sfc->f_blocks ? SP_VALUE(sfc->f_bavail, sfc->f_blocks, sfc->f_blocks)
2819 cprintf_u64(NO_UNIT, 2, 9,
2820 (unsigned long long) sfc->f_ffree,
2821 (unsigned long long) (sfc->f_files - sfc->f_ffree));
2822 cprintf_pc(DISPLAY_UNIT(flags), 1, 9, 2,
2823 sfc->f_files ? SP_VALUE(sfc->f_ffree, sfc->f_files, sfc->f_files)
2825 cprintf_in(IS_STR, " %s\n", dev_name, 0);
2829 /* Save current filesystem in summary list */
2830 for (j = 0; j < a->nr_allocated; j++) {
2831 sfm = (struct stats_filesystem *) ((char *) a->buf[2] + j * a->msize);
2833 if (!strcmp(sfm->fs_name, sfc->fs_name) ||
2836 * Filesystem found in list (then save again its stats)
2837 * or free slot (end of list).
2840 if (j >= a->nr[2]) {
2846 if (j == a->nr_allocated) {
2848 * No free slot has been found for current filesystem.
2849 * So enlarge buffers then save filesystem in list.
2851 reallocate_all_buffers(a, j);
2852 sfm = (struct stats_filesystem *) ((char *) a->buf[2] + j * a->msize);
2861 ***************************************************************************
2862 * Display filesystems statistics.
2865 * @a Activity structure with statistics.
2866 * @prev Index in array where stats used as reference are.
2867 * @curr Index in array for current sample statistics.
2868 * @itv Interval of time in 1/100th of a second.
2869 ***************************************************************************
2871 __print_funct_t print_filesystem_stats(struct activity *a, int prev, int curr,
2872 unsigned long long itv)
2874 stub_print_filesystem_stats(a, prev, curr, FALSE);
2878 ***************************************************************************
2879 * Display average filesystems statistics.
2882 * @a Activity structure with statistics.
2883 * @prev Index in array where stats used as reference are.
2884 * @curr Index in array for current sample statistics.
2885 * @itv Interval of time in 1/100th of a second.
2886 ***************************************************************************
2888 __print_funct_t print_avg_filesystem_stats(struct activity *a, int prev, int curr,
2889 unsigned long long itv)
2891 stub_print_filesystem_stats(a, prev, 2, TRUE);
2895 ***************************************************************************
2896 * Display Fibre Channel HBA statistics.
2899 * @a Activity structure with statistics.
2900 * @prev Index in array where stats used as reference are.
2901 * @curr Index in array for current sample statistics.
2902 * @itv Interval of time in 1/100th of a second.
2903 ***************************************************************************
2905 __print_funct_t print_fchost_stats(struct activity *a, int prev, int curr,
2906 unsigned long long itv)
2908 int i, j, j0, found;
2909 struct stats_fchost *sfcc, *sfcp, sfczero;
2911 memset(&sfczero, 0, sizeof(struct stats_fchost));
2914 print_hdr_line(timestamp[!curr], a, FIRST, -1, 9, NULL);
2917 for (i = 0; i < a->nr[curr]; i++) {
2918 sfcc = (struct stats_fchost *) ((char *) a->buf[curr] + i * a->msize);
2920 if (WANT_SINCE_BOOT(flags)) {
2921 sfcp = (struct stats_fchost *) ((char *) a->buf[prev]);
2927 if (a->nr[prev] > 0) {
2928 /* Look for corresponding structure in previous iteration */
2931 if (j >= a->nr[prev]) {
2932 j = a->nr[prev] - 1;
2938 sfcp = (struct stats_fchost *) ((char *) a->buf[prev] + j * a->msize);
2939 if (!strcmp(sfcc->fchost_name, sfcp->fchost_name)) {
2944 if (++j >= a->nr[prev]) {
2953 /* This is a newly registered host */
2957 printf("%-11s", timestamp[curr]);
2958 cprintf_f(NO_UNIT, 4, 9, 2,
2959 S_VALUE(sfcp->f_rxframes, sfcc->f_rxframes, itv),
2960 S_VALUE(sfcp->f_txframes, sfcc->f_txframes, itv),
2961 S_VALUE(sfcp->f_rxwords, sfcc->f_rxwords, itv),
2962 S_VALUE(sfcp->f_txwords, sfcc->f_txwords, itv));
2963 cprintf_in(IS_STR, " %s\n", sfcc->fchost_name, 0);
2968 ***************************************************************************
2969 * Display softnet statistics.
2972 * @a Activity structure with statistics.
2973 * @prev Index in array where stats used as reference are.
2974 * @curr Index in array for current sample statistics.
2975 * @itv Interval of time in 1/100th of a second.
2976 ***************************************************************************
2978 __print_funct_t print_softnet_stats(struct activity *a, int prev, int curr,
2979 unsigned long long itv)
2982 struct stats_softnet
2983 *ssnc = (struct stats_softnet *) a->buf[curr],
2984 *ssnp = (struct stats_softnet *) a->buf[prev];
2985 unsigned char offline_cpu_bitmap[BITMAP_SIZE(NR_CPUS)] = {0};
2987 if (dish || DISPLAY_ZERO_OMIT(flags)) {
2988 print_hdr_line(timestamp[!curr], a, FIRST, 7, 9, NULL);
2992 * @nr[curr] cannot normally be greater than @nr_ini
2993 * (since @nr_ini counts up all CPU, even those offline).
2994 * If this happens, it may be because the machine has been
2995 * restarted with more CPU and no LINUX_RESTART has been
2998 if (a->nr[curr] > a->nr_ini) {
2999 a->nr_ini = a->nr[curr];
3002 /* Compute statistics for CPU "all" */
3003 get_global_soft_statistics(a, prev, curr, flags, offline_cpu_bitmap);
3005 for (i = 0; (i < a->nr_ini) && (i < a->bitmap->b_size + 1); i++) {
3008 * Should current CPU (including CPU "all") be displayed?
3009 * Note: a->nr is in [1, NR_CPUS + 1].
3010 * Bitmap size is provided for (NR_CPUS + 1) CPUs.
3011 * Anyway, NR_CPUS may vary between the version of sysstat
3012 * used by sadc to create a file, and the version of sysstat
3013 * used by sar to read it...
3015 if (!(a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))) ||
3016 offline_cpu_bitmap[i >> 3] & (1 << (i & 0x07)))
3020 * The size of a->buf[...] CPU structure may be different from the default
3021 * sizeof(struct stats_pwr_cpufreq) value if data have been read from a file!
3022 * That's why we don't use a syntax like:
3023 * ssnc = (struct stats_softnet *) a->buf[...] + i;
3025 ssnc = (struct stats_softnet *) ((char *) a->buf[curr] + i * a->msize);
3026 ssnp = (struct stats_softnet *) ((char *) a->buf[prev] + i * a->msize);
3028 if (DISPLAY_ZERO_OMIT(flags) && !memcmp(ssnp, ssnc, STATS_SOFTNET_SIZE))
3031 printf("%-11s", timestamp[curr]);
3034 /* This is CPU "all" */
3035 cprintf_in(IS_STR, " %s", " all", 0);
3038 cprintf_in(IS_INT, " %7d", "", i - 1);
3041 cprintf_f(NO_UNIT, 5, 9, 2,
3042 S_VALUE(ssnp->processed, ssnc->processed, itv),
3043 S_VALUE(ssnp->dropped, ssnc->dropped, itv),
3044 S_VALUE(ssnp->time_squeeze, ssnc->time_squeeze, itv),
3045 S_VALUE(ssnp->received_rps, ssnc->received_rps, itv),
3046 S_VALUE(ssnp->flow_limit, ssnc->flow_limit, itv));
3052 ***************************************************************************
3053 * Display pressure-stall CPU statistics. This function is used to display
3054 * instantaneous and average statistics.
3057 * @a Activity structure with statistics.
3058 * @prev Index in array where stats used as reference are.
3059 * @curr Index in array for current sample statistics.
3060 * @dispavg TRUE if displaying average statistics.
3061 * @itv Interval of time in 1/100th of a second.
3062 ***************************************************************************
3064 void stub_print_psicpu_stats(struct activity *a, int prev, int curr, int dispavg,
3065 unsigned long long itv)
3067 struct stats_psi_cpu
3068 *psic = (struct stats_psi_cpu *) a->buf[curr],
3069 *psip = (struct stats_psi_cpu *) a->buf[prev];
3070 static unsigned long long
3076 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9, NULL);
3078 printf("%-11s", timestamp[curr]);
3081 /* Display instantaneous values */
3082 cprintf_pc(DISPLAY_UNIT(flags), 3, 9, 2,
3083 (double) psic->some_acpu_10 / 100,
3084 (double) psic->some_acpu_60 / 100,
3085 (double) psic->some_acpu_300 / 100);
3087 /* Will be used to compute the average */
3088 s_avg10 += psic->some_acpu_10;
3089 s_avg60 += psic->some_acpu_60;
3090 s_avg300 += psic->some_acpu_300;
3093 /* Display average values */
3094 cprintf_pc(DISPLAY_UNIT(flags), 3, 9, 2,
3095 (double) s_avg10 / (avg_count * 100),
3096 (double) s_avg60 / (avg_count * 100),
3097 (double) s_avg300 / (avg_count * 100));
3099 /* Reset average counters */
3100 s_avg10 = s_avg60 = s_avg300 = 0;
3103 cprintf_pc(DISPLAY_UNIT(flags), 1, 9, 2,
3104 ((double) psic->some_cpu_total - psip->some_cpu_total) / (100 * itv));
3109 ***************************************************************************
3110 * Display pressure-stall CPU statistics.
3113 * @a Activity structure with statistics.
3114 * @prev Index in array where stats used as reference are.
3115 * @curr Index in array for current sample statistics.
3116 * @itv Interval of time in 1/100th of a second.
3117 ***************************************************************************
3119 __print_funct_t print_psicpu_stats(struct activity *a, int prev, int curr,
3120 unsigned long long itv)
3122 stub_print_psicpu_stats(a, prev, curr, FALSE, itv);
3126 ***************************************************************************
3127 * Display average pressure-stall CPU statistics.
3130 * @a Activity structure with statistics.
3131 * @prev Index in array where stats used as reference are.
3132 * @curr Index in array for current sample statistics.
3133 * @itv Interval of time in 1/100th of a second.
3134 ***************************************************************************
3136 __print_funct_t print_avg_psicpu_stats(struct activity *a, int prev, int curr,
3137 unsigned long long itv)
3139 stub_print_psicpu_stats(a, prev, curr, TRUE, itv);
3143 ***************************************************************************
3144 * Display pressure-stall I/O statistics. This function is used to display
3145 * instantaneous and average statistics.
3148 * @a Activity structure with statistics.
3149 * @prev Index in array where stats used as reference are.
3150 * @curr Index in array for current sample statistics.
3151 * @dispavg TRUE if displaying average statistics.
3152 * @itv Interval of time in 1/100th of a second.
3153 ***************************************************************************
3155 void stub_print_psiio_stats(struct activity *a, int prev, int curr, int dispavg,
3156 unsigned long long itv)
3159 *psic = (struct stats_psi_io *) a->buf[curr],
3160 *psip = (struct stats_psi_io *) a->buf[prev];
3161 static unsigned long long
3170 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9, NULL);
3172 printf("%-11s", timestamp[curr]);
3175 /* Display instantaneous "some" values */
3176 cprintf_pc(DISPLAY_UNIT(flags), 3, 9, 2,
3177 (double) psic->some_aio_10 / 100,
3178 (double) psic->some_aio_60 / 100,
3179 (double) psic->some_aio_300 / 100);
3181 /* Will be used to compute the average */
3182 s_avg10 += psic->some_aio_10;
3183 s_avg60 += psic->some_aio_60;
3184 s_avg300 += psic->some_aio_300;
3187 /* Display average "some" values */
3188 cprintf_pc(DISPLAY_UNIT(flags), 3, 9, 2,
3189 (double) s_avg10 / (avg_count * 100),
3190 (double) s_avg60 / (avg_count * 100),
3191 (double) s_avg300 / (avg_count * 100));
3193 /* Reset average counters */
3194 s_avg10 = s_avg60 = s_avg300 = 0;
3197 cprintf_pc(DISPLAY_UNIT(flags), 1, 9, 2,
3198 ((double) psic->some_io_total - psip->some_io_total) / (100 * itv));
3201 /* Display instantaneous "full" values */
3202 cprintf_pc(DISPLAY_UNIT(flags), 3, 9, 2,
3203 (double) psic->full_aio_10 / 100,
3204 (double) psic->full_aio_60 / 100,
3205 (double) psic->full_aio_300 / 100);
3207 /* Will be used to compute the average */
3208 f_avg10 += psic->full_aio_10;
3209 f_avg60 += psic->full_aio_60;
3210 f_avg300 += psic->full_aio_300;
3213 /* Display average "full" values */
3214 cprintf_pc(DISPLAY_UNIT(flags), 3, 9, 2,
3215 (double) f_avg10 / (avg_count * 100),
3216 (double) f_avg60 / (avg_count * 100),
3217 (double) f_avg300 / (avg_count * 100));
3219 /* Reset average counters */
3220 f_avg10 = f_avg60 = f_avg300 = 0;
3223 cprintf_pc(DISPLAY_UNIT(flags), 1, 9, 2,
3224 ((double) psic->full_io_total - psip->full_io_total) / (100 * itv));
3229 ***************************************************************************
3230 * Display pressure-stall I/O statistics.
3233 * @a Activity structure with statistics.
3234 * @prev Index in array where stats used as reference are.
3235 * @curr Index in array for current sample statistics.
3236 * @itv Interval of time in 1/100th of a second.
3237 ***************************************************************************
3239 __print_funct_t print_psiio_stats(struct activity *a, int prev, int curr,
3240 unsigned long long itv)
3242 stub_print_psiio_stats(a, prev, curr, FALSE, itv);
3246 ***************************************************************************
3247 * Display average pressure-stall I/O statistics.
3250 * @a Activity structure with statistics.
3251 * @prev Index in array where stats used as reference are.
3252 * @curr Index in array for current sample statistics.
3253 * @itv Interval of time in 1/100th of a second.
3254 ***************************************************************************
3256 __print_funct_t print_avg_psiio_stats(struct activity *a, int prev, int curr,
3257 unsigned long long itv)
3259 stub_print_psiio_stats(a, prev, curr, TRUE, itv);
3263 ***************************************************************************
3264 * Display pressure-stall memory statistics. This function is used to display
3265 * instantaneous and average statistics.
3268 * @a Activity structure with statistics.
3269 * @prev Index in array where stats used as reference are.
3270 * @curr Index in array for current sample statistics.
3271 * @dispavg TRUE if displaying average statistics.
3272 * @itv Interval of time in 1/100th of a second.
3273 ***************************************************************************
3275 void stub_print_psimem_stats(struct activity *a, int prev, int curr, int dispavg,
3276 unsigned long long itv)
3278 struct stats_psi_mem
3279 *psic = (struct stats_psi_mem *) a->buf[curr],
3280 *psip = (struct stats_psi_mem *) a->buf[prev];
3281 static unsigned long long
3290 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9, NULL);
3292 printf("%-11s", timestamp[curr]);
3295 /* Display instantaneous "some" values */
3296 cprintf_pc(DISPLAY_UNIT(flags), 3, 9, 2,
3297 (double) psic->some_amem_10 / 100,
3298 (double) psic->some_amem_60 / 100,
3299 (double) psic->some_amem_300 / 100);
3301 /* Will be used to compute the average */
3302 s_avg10 += psic->some_amem_10;
3303 s_avg60 += psic->some_amem_60;
3304 s_avg300 += psic->some_amem_300;
3307 /* Display average "some" values */
3308 cprintf_pc(DISPLAY_UNIT(flags), 3, 9, 2,
3309 (double) s_avg10 / (avg_count * 100),
3310 (double) s_avg60 / (avg_count * 100),
3311 (double) s_avg300 / (avg_count * 100));
3313 /* Reset average counters */
3314 s_avg10 = s_avg60 = s_avg300 = 0;
3317 cprintf_pc(DISPLAY_UNIT(flags), 1, 9, 2,
3318 ((double) psic->some_mem_total - psip->some_mem_total) / (100 * itv));
3321 /* Display instantaneous "full" values */
3322 cprintf_pc(DISPLAY_UNIT(flags), 3, 9, 2,
3323 (double) psic->full_amem_10 / 100,
3324 (double) psic->full_amem_60 / 100,
3325 (double) psic->full_amem_300 / 100);
3327 /* Will be used to compute the average */
3328 f_avg10 += psic->full_amem_10;
3329 f_avg60 += psic->full_amem_60;
3330 f_avg300 += psic->full_amem_300;
3333 /* Display average "full" values */
3334 cprintf_pc(DISPLAY_UNIT(flags), 3, 9, 2,
3335 (double) f_avg10 / (avg_count * 100),
3336 (double) f_avg60 / (avg_count * 100),
3337 (double) f_avg300 / (avg_count * 100));
3339 /* Reset average counters */
3340 f_avg10 = f_avg60 = f_avg300 = 0;
3343 cprintf_pc(DISPLAY_UNIT(flags), 1, 9, 2,
3344 ((double) psic->full_mem_total - psip->full_mem_total) / (100 * itv));
3349 ***************************************************************************
3350 * Display pressure-stall memory statistics.
3353 * @a Activity structure with statistics.
3354 * @prev Index in array where stats used as reference are.
3355 * @curr Index in array for current sample statistics.
3356 * @itv Interval of time in 1/100th of a second.
3357 ***************************************************************************
3359 __print_funct_t print_psimem_stats(struct activity *a, int prev, int curr,
3360 unsigned long long itv)
3362 stub_print_psimem_stats(a, prev, curr, FALSE, itv);
3366 ***************************************************************************
3367 * Display average pressure-stall memory statistics.
3370 * @a Activity structure with statistics.
3371 * @prev Index in array where stats used as reference are.
3372 * @curr Index in array for current sample statistics.
3373 * @itv Interval of time in 1/100th of a second.
3374 ***************************************************************************
3376 __print_funct_t print_avg_psimem_stats(struct activity *a, int prev, int curr,
3377 unsigned long long itv)
3379 stub_print_psimem_stats(a, prev, curr, TRUE, itv);