2 * pr_stats.c: Functions used by sar to display statistics
3 * (C) 1999-2018 by Sebastien GODARD (sysstat <at> orange.fr)
5 ***************************************************************************
6 * This program is free software; you can redistribute it and/or modify it *
7 * under the terms of the GNU General Public License as published by the *
8 * Free Software Foundation; either version 2 of the License, or (at your *
9 * option) any later version. *
11 * This program is distributed in the hope that it will be useful, but *
12 * WITHOUT ANY WARRANTY; without the implied warranty of MERCHANTABILITY *
13 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License *
16 * You should have received a copy of the GNU General Public License along *
17 * with this program; if not, write to the Free Software Foundation, Inc., *
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA *
19 ***************************************************************************
34 #define _(string) gettext(string)
36 #define _(string) (string)
39 extern unsigned int flags;
41 extern char timestamp[][TIMESTAMP_LEN];
42 extern unsigned long avg_count;
45 ***************************************************************************
46 * Display current activity header line.
49 * @timestamp Timestamp for previous stat sample.
50 * @a Activity structure.
51 * @pos Index in @.hdr_line string, 0 being the first one (header
52 * are delimited by the '|' character).
53 * @iwidth First column width (generally this is the item name). A
54 * negative value means that the corresponding field shall be
55 * displayed at the end of the line, with no indication of width.
56 * @vwidth Column width for stats values.
57 ***************************************************************************
59 void print_hdr_line(char *timestamp, struct activity *a, int pos, int iwidth, int vwidth)
61 char hline[HEADER_LINE_LEN] = "";
62 char *hl, *tk, *it = NULL;
66 strncpy(hline, a->hdr_line, HEADER_LINE_LEN - 1);
67 hline[HEADER_LINE_LEN - 1] = '\0';
68 for (hl = strtok(hline, "|"); hl && (pos > 0); hl = strtok(NULL, "|"), pos--);
70 /* Bad @pos arg given to function */
73 printf("\n%-11s", timestamp);
75 if (strchr(hl, '&')) {
77 if ((a->opt_flags & 0xff00) & (1 << (8 + p))) {
78 /* Display whole header line */
82 /* Display only the first part of the header line */
86 /* Display each field */
87 for (tk = strtok(hl, ";"); tk; tk = strtok(NULL, ";"), i--) {
89 printf(" %*s", iwidth, tk);
93 if ((iwidth < 0) && (iwidth == i)) {
98 printf(" %*s", vwidth, tk);
108 ***************************************************************************
109 * Display CPU statistics.
110 * NB: The stats are only calculated over the part of the time interval when
111 * the CPU was online. As a consequence, the sum (%user + %nice + ... + %idle)
112 * will always be 100% on the time interval even if the CPU has been offline
116 * @a Activity structure with statistics.
117 * @prev Index in array where stats used as reference are.
118 * @curr Index in array for current sample statistics.
119 * @itv Interval of time in 1/100th of a second (independent of the
120 * number of processors). Unused here.
121 ***************************************************************************
123 __print_funct_t print_cpu_stats(struct activity *a, int prev, int curr,
124 unsigned long long itv)
127 unsigned long long deltot_jiffies = 1;
128 struct stats_cpu *scc, *scp;
129 unsigned char offline_cpu_bitmap[BITMAP_SIZE(NR_CPUS)] = {0};
132 print_hdr_line(timestamp[!curr], a, FIRST + DISPLAY_CPU_ALL(a->opt_flags), 7, 9);
136 * @nr[curr] cannot normally be greater than @nr_ini
137 * (since @nr_ini counts up all CPU, even those offline).
138 * If this happens, it may be because the machine has been
139 * restarted with more CPU and no LINUX_RESTART has been
141 * No problem here with @nr_allocated. Having been able to
142 * read @nr[curr] structures shows that buffers are large enough.
144 if (a->nr[curr] > a->nr_ini) {
145 a->nr_ini = a->nr[curr];
149 * Compute CPU "all" as sum of all individual CPU (on SMP machines)
150 * and look for offline CPU.
153 deltot_jiffies = get_global_cpu_statistics(a, prev, curr,
154 flags, offline_cpu_bitmap);
158 * Now display CPU statistics (including CPU "all"),
159 * except for offline CPU or CPU that the user doesn't want to see.
161 for (i = 0; (i < a->nr_ini) && (i < a->bitmap->b_size + 1); i++) {
164 * Should current CPU (including CPU "all") be displayed?
165 * Note: @nr[curr] is in [1, NR_CPUS + 1].
166 * Bitmap size is provided for (NR_CPUS + 1) CPUs.
167 * Anyway, NR_CPUS may vary between the version of sysstat
168 * used by sadc to create a file, and the version of sysstat
169 * used by sar to read it...
171 if (!(a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))) ||
172 offline_cpu_bitmap[i >> 3] & (1 << (i & 0x07)))
173 /* Don't display CPU */
176 scc = (struct stats_cpu *) ((char *) a->buf[curr] + i * a->msize);
177 scp = (struct stats_cpu *) ((char *) a->buf[prev] + i * a->msize);
179 printf("%-11s", timestamp[curr]);
182 /* This is CPU "all" */
183 cprintf_in(IS_STR, " %s", " all", 0);
185 if (a->nr_ini == 1) {
187 * This is a UP machine. In this case
188 * interval has still not been calculated.
190 deltot_jiffies = get_per_cpu_interval(scc, scp);
192 if (!deltot_jiffies) {
193 /* CPU "all" cannot be tickless */
198 cprintf_in(IS_INT, " %7d", "", i - 1);
200 /* Recalculate interval for current proc */
201 deltot_jiffies = get_per_cpu_interval(scc, scp);
203 if (!deltot_jiffies) {
205 * If the CPU is tickless then there is no change in CPU values
206 * but the sum of values is not zero.
207 * %user, %nice, %system, %iowait, %steal, ..., %idle
209 cprintf_pc(DISPLAY_UNIT(flags), 5, 9, 2,
210 0.0, 0.0, 0.0, 0.0, 0.0);
212 if (DISPLAY_CPU_DEF(a->opt_flags)) {
213 cprintf_pc(DISPLAY_UNIT(flags), 1, 9, 2, 100.0);
217 * Four additional fields to display:
218 * %irq, %soft, %guest, %gnice.
220 else if (DISPLAY_CPU_ALL(a->opt_flags)) {
221 cprintf_pc(DISPLAY_UNIT(flags), 4, 9, 2,
222 0.0, 0.0, 0.0, 100.0);
229 if (DISPLAY_CPU_DEF(a->opt_flags)) {
230 cprintf_pc(DISPLAY_UNIT(flags), 6, 9, 2,
231 ll_sp_value(scp->cpu_user, scc->cpu_user, deltot_jiffies),
232 ll_sp_value(scp->cpu_nice, scc->cpu_nice, deltot_jiffies),
233 ll_sp_value(scp->cpu_sys + scp->cpu_hardirq + scp->cpu_softirq,
234 scc->cpu_sys + scc->cpu_hardirq + scc->cpu_softirq,
236 ll_sp_value(scp->cpu_iowait, scc->cpu_iowait, deltot_jiffies),
237 ll_sp_value(scp->cpu_steal, scc->cpu_steal, deltot_jiffies),
238 scc->cpu_idle < scp->cpu_idle ?
240 ll_sp_value(scp->cpu_idle, scc->cpu_idle, deltot_jiffies));
243 else if (DISPLAY_CPU_ALL(a->opt_flags)) {
244 cprintf_pc(DISPLAY_UNIT(flags), 10, 9, 2,
245 (scc->cpu_user - scc->cpu_guest) < (scp->cpu_user - scp->cpu_guest) ?
247 ll_sp_value(scp->cpu_user - scp->cpu_guest,
248 scc->cpu_user - scc->cpu_guest, deltot_jiffies),
249 (scc->cpu_nice - scc->cpu_guest_nice) < (scp->cpu_nice - scp->cpu_guest_nice) ?
251 ll_sp_value(scp->cpu_nice - scp->cpu_guest_nice,
252 scc->cpu_nice - scc->cpu_guest_nice, deltot_jiffies),
253 ll_sp_value(scp->cpu_sys, scc->cpu_sys, deltot_jiffies),
254 ll_sp_value(scp->cpu_iowait, scc->cpu_iowait, deltot_jiffies),
255 ll_sp_value(scp->cpu_steal, scc->cpu_steal, deltot_jiffies),
256 ll_sp_value(scp->cpu_hardirq, scc->cpu_hardirq, deltot_jiffies),
257 ll_sp_value(scp->cpu_softirq, scc->cpu_softirq, deltot_jiffies),
258 ll_sp_value(scp->cpu_guest, scc->cpu_guest, deltot_jiffies),
259 ll_sp_value(scp->cpu_guest_nice, scc->cpu_guest_nice, deltot_jiffies),
260 scc->cpu_idle < scp->cpu_idle ?
262 ll_sp_value(scp->cpu_idle, scc->cpu_idle, deltot_jiffies));
269 ***************************************************************************
270 * Display tasks creation and context switches statistics.
273 * @a Activity structure with statistics.
274 * @prev Index in array where stats used as reference are.
275 * @curr Index in array for current sample statistics.
276 * @itv Interval of time in 1/100th of a second.
277 ***************************************************************************
279 __print_funct_t print_pcsw_stats(struct activity *a, int prev, int curr,
280 unsigned long long itv)
283 *spc = (struct stats_pcsw *) a->buf[curr],
284 *spp = (struct stats_pcsw *) a->buf[prev];
287 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
290 printf("%-11s", timestamp[curr]);
291 cprintf_f(NO_UNIT, 2, 9, 2,
292 S_VALUE(spp->processes, spc->processes, itv),
293 S_VALUE(spp->context_switch, spc->context_switch, itv));
298 ***************************************************************************
299 * Display interrupts statistics.
302 * @a Activity structure with statistics.
303 * @prev Index in array where stats used as reference are.
304 * @curr Index in array for current sample statistics.
305 * @itv Interval of time in 1/100th of a second.
306 ***************************************************************************
308 __print_funct_t print_irq_stats(struct activity *a, int prev, int curr,
309 unsigned long long itv)
312 struct stats_irq *sic, *sip;
314 if (dis || DISPLAY_ZERO_OMIT(flags)) {
315 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
318 for (i = 0; (i < a->nr[curr]) && (i < a->bitmap->b_size + 1); i++) {
321 * If @nr[curr] > @nr[prev] then we consider that previous
322 * interrupt value was 0.
324 sic = (struct stats_irq *) ((char *) a->buf[curr] + i * a->msize);
325 sip = (struct stats_irq *) ((char *) a->buf[prev] + i * a->msize);
328 * Note: @nr[curr] gives the number of interrupts read (1 .. NR_IRQS + 1).
329 * Bitmap size is provided for (NR_IRQS + 1) interrupts.
330 * Anyway, NR_IRQS may vary between the version of sysstat
331 * used by sadc to create a file, and the version of sysstat
332 * used by sar to read it...
335 /* Should current interrupt (including int "sum") be displayed? */
336 if (a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))) {
338 if (DISPLAY_ZERO_OMIT(flags) && !memcmp(sip, sic, STATS_IRQ_SIZE))
341 /* Yes: Display it */
342 printf("%-11s", timestamp[curr]);
344 /* This is interrupt "sum" */
345 cprintf_in(IS_STR, " %s", " sum", 0);
348 cprintf_in(IS_INT, " %9d", "", i -1);
351 cprintf_f(NO_UNIT, 1, 9, 2, S_VALUE(sip->irq_nr, sic->irq_nr, itv));
358 ***************************************************************************
359 * Display swapping statistics.
362 * @a Activity structure with statistics.
363 * @prev Index in array where stats used as reference are.
364 * @curr Index in array for current sample statistics.
365 * @itv Interval of time in 1/100th of a second.
366 ***************************************************************************
368 __print_funct_t print_swap_stats(struct activity *a, int prev, int curr,
369 unsigned long long itv)
372 *ssc = (struct stats_swap *) a->buf[curr],
373 *ssp = (struct stats_swap *) a->buf[prev];
376 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
379 printf("%-11s", timestamp[curr]);
380 cprintf_f(NO_UNIT, 2, 9, 2,
381 S_VALUE(ssp->pswpin, ssc->pswpin, itv),
382 S_VALUE(ssp->pswpout, ssc->pswpout, itv));
387 ***************************************************************************
388 * Display paging statistics.
391 * @a Activity structure with statistics.
392 * @prev Index in array where stats used as reference are.
393 * @curr Index in array for current sample statistics.
394 * @itv Interval of time in 1/100th of a second.
395 ***************************************************************************
397 __print_funct_t print_paging_stats(struct activity *a, int prev, int curr,
398 unsigned long long itv)
401 *spc = (struct stats_paging *) a->buf[curr],
402 *spp = (struct stats_paging *) a->buf[prev];
405 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
408 printf("%-11s", timestamp[curr]);
409 cprintf_f(NO_UNIT, 8, 9, 2,
410 S_VALUE(spp->pgpgin, spc->pgpgin, itv),
411 S_VALUE(spp->pgpgout, spc->pgpgout, itv),
412 S_VALUE(spp->pgfault, spc->pgfault, itv),
413 S_VALUE(spp->pgmajfault, spc->pgmajfault, itv),
414 S_VALUE(spp->pgfree, spc->pgfree, itv),
415 S_VALUE(spp->pgscan_kswapd, spc->pgscan_kswapd, itv),
416 S_VALUE(spp->pgscan_direct, spc->pgscan_direct, itv),
417 S_VALUE(spp->pgsteal, spc->pgsteal, itv));
418 cprintf_pc(DISPLAY_UNIT(flags), 1, 9, 2,
419 (spc->pgscan_kswapd + spc->pgscan_direct -
420 spp->pgscan_kswapd - spp->pgscan_direct) ?
421 SP_VALUE(spp->pgsteal, spc->pgsteal,
422 spc->pgscan_kswapd + spc->pgscan_direct -
423 spp->pgscan_kswapd - spp->pgscan_direct)
429 ***************************************************************************
430 * Display I/O and transfer rate statistics.
433 * @a Activity structure with statistics.
434 * @prev Index in array where stats used as reference are.
435 * @curr Index in array for current sample statistics.
436 * @itv Interval of time in 1/100th of a second.
437 ***************************************************************************
439 __print_funct_t print_io_stats(struct activity *a, int prev, int curr,
440 unsigned long long itv)
443 *sic = (struct stats_io *) a->buf[curr],
444 *sip = (struct stats_io *) a->buf[prev];
447 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
450 printf("%-11s", timestamp[curr]);
452 * If we get negative values, this is probably because
453 * one or more devices/filesystems have been unmounted.
454 * We display 0.0 in this case though we should rather tell
455 * the user that the value cannot be calculated here.
457 cprintf_f(NO_UNIT, 5, 9, 2,
458 sic->dk_drive < sip->dk_drive ? 0.0 :
459 S_VALUE(sip->dk_drive, sic->dk_drive, itv),
460 sic->dk_drive_rio < sip->dk_drive_rio ? 0.0 :
461 S_VALUE(sip->dk_drive_rio, sic->dk_drive_rio, itv),
462 sic->dk_drive_wio < sip->dk_drive_wio ? 0.0 :
463 S_VALUE(sip->dk_drive_wio, sic->dk_drive_wio, itv),
464 sic->dk_drive_rblk < sip->dk_drive_rblk ? 0.0 :
465 S_VALUE(sip->dk_drive_rblk, sic->dk_drive_rblk, itv),
466 sic->dk_drive_wblk < sip->dk_drive_wblk ? 0.0 :
467 S_VALUE(sip->dk_drive_wblk, sic->dk_drive_wblk, itv));
472 ***************************************************************************
473 * Display memory and swap statistics. This function is used to
474 * display instantaneous and average statistics.
477 * @a Activity structure with statistics.
478 * @prev Index in array where stats used as reference are.
479 * @curr Index in array for current sample statistics.
480 * @dispavg TRUE if displaying average statistics.
481 ***************************************************************************
483 void stub_print_memory_stats(struct activity *a, int prev, int curr, int dispavg)
486 *smc = (struct stats_memory *) a->buf[curr];
487 static unsigned long long
501 static unsigned long long
506 unsigned long long nousedmem;
508 if (DISPLAY_UNIT(flags)) {
509 /* Default values unit is kB */
510 unit = UNIT_KILOBYTE;
513 if (DISPLAY_MEMORY(a->opt_flags)) {
515 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
519 /* Display instantaneous values */
520 nousedmem = smc->frmkb + smc->bufkb + smc->camkb + smc->slabkb;
521 if (nousedmem > smc->tlmkb) {
522 nousedmem = smc->tlmkb;
524 printf("%-11s", timestamp[curr]);
525 cprintf_u64(unit, 3, 9,
526 (unsigned long long) smc->frmkb,
527 (unsigned long long) smc->availablekb,
528 (unsigned long long) (smc->tlmkb - nousedmem));
529 cprintf_pc(DISPLAY_UNIT(flags), 1, 9, 2,
531 SP_VALUE(nousedmem, smc->tlmkb, smc->tlmkb)
533 cprintf_u64(unit, 3, 9,
534 (unsigned long long) smc->bufkb,
535 (unsigned long long) smc->camkb,
536 (unsigned long long) smc->comkb);
537 cprintf_pc(DISPLAY_UNIT(flags), 1, 9, 2,
538 (smc->tlmkb + smc->tlskb) ?
539 SP_VALUE(0, smc->comkb, smc->tlmkb + smc->tlskb)
541 cprintf_u64(unit, 3, 9,
542 (unsigned long long) smc->activekb,
543 (unsigned long long) smc->inactkb,
544 (unsigned long long) smc->dirtykb);
546 if (DISPLAY_MEM_ALL(a->opt_flags)) {
547 /* Display extended memory statistics */
548 cprintf_u64(unit, 5, 9,
549 (unsigned long long) smc->anonpgkb,
550 (unsigned long long) smc->slabkb,
551 (unsigned long long) smc->kstackkb,
552 (unsigned long long) smc->pgtblkb,
553 (unsigned long long) smc->vmusedkb);
559 * Will be used to compute the average.
560 * We assume that the total amount of memory installed can not vary
561 * during the interval given on the command line.
563 avg_frmkb += smc->frmkb;
564 avg_bufkb += smc->bufkb;
565 avg_camkb += smc->camkb;
566 avg_comkb += smc->comkb;
567 avg_activekb += smc->activekb;
568 avg_inactkb += smc->inactkb;
569 avg_dirtykb += smc->dirtykb;
570 avg_anonpgkb += smc->anonpgkb;
571 avg_slabkb += smc->slabkb;
572 avg_kstackkb += smc->kstackkb;
573 avg_pgtblkb += smc->pgtblkb;
574 avg_vmusedkb += smc->vmusedkb;
575 avg_availablekb += smc->availablekb;
578 /* Display average values */
579 nousedmem = avg_frmkb + avg_bufkb + avg_camkb + avg_slabkb;
580 printf("%-11s", timestamp[curr]);
581 cprintf_f(unit, 3, 9, 0,
582 (double) avg_frmkb / avg_count,
583 (double) avg_availablekb / avg_count,
584 (double) smc->tlmkb - ((double) nousedmem / avg_count));
585 cprintf_pc(DISPLAY_UNIT(flags), 1, 9, 2,
587 SP_VALUE((double) (nousedmem / avg_count), smc->tlmkb, smc->tlmkb)
589 cprintf_f(unit, 3, 9, 0,
590 (double) avg_bufkb / avg_count,
591 (double) avg_camkb / avg_count,
592 (double) avg_comkb / avg_count);
593 cprintf_pc(DISPLAY_UNIT(flags), 1, 9, 2,
594 (smc->tlmkb + smc->tlskb) ?
595 SP_VALUE(0.0, (double) (avg_comkb / avg_count), smc->tlmkb + smc->tlskb)
597 cprintf_f(unit, 3, 9, 0,
598 (double) avg_activekb / avg_count,
599 (double) avg_inactkb / avg_count,
600 (double) avg_dirtykb / avg_count);
602 if (DISPLAY_MEM_ALL(a->opt_flags)) {
603 cprintf_f(unit, 5, 9, 0,
604 (double) avg_anonpgkb / avg_count,
605 (double) avg_slabkb / avg_count,
606 (double) avg_kstackkb / avg_count,
607 (double) avg_pgtblkb / avg_count,
608 (double) avg_vmusedkb / avg_count);
613 /* Reset average counters */
614 avg_frmkb = avg_bufkb = avg_camkb = avg_comkb = 0;
615 avg_activekb = avg_inactkb = avg_dirtykb = 0;
616 avg_anonpgkb = avg_slabkb = avg_kstackkb = 0;
617 avg_pgtblkb = avg_vmusedkb = avg_availablekb = 0;
621 if (DISPLAY_SWAP(a->opt_flags)) {
623 print_hdr_line(timestamp[!curr], a, SECOND, 0, 9);
627 /* Display instantaneous values */
628 printf("%-11s", timestamp[curr]);
629 cprintf_u64(unit, 2, 9,
630 (unsigned long long) smc->frskb,
631 (unsigned long long) (smc->tlskb - smc->frskb));
632 cprintf_pc(DISPLAY_UNIT(flags), 1, 9, 2,
634 SP_VALUE(smc->frskb, smc->tlskb, smc->tlskb)
636 cprintf_u64(unit, 1, 9,
637 (unsigned long long) smc->caskb);
638 cprintf_pc(DISPLAY_UNIT(flags), 1, 9, 2,
639 (smc->tlskb - smc->frskb) ?
640 SP_VALUE(0, smc->caskb, smc->tlskb - smc->frskb)
646 * Will be used to compute the average.
647 * We assume that the total amount of swap space may vary.
649 avg_frskb += smc->frskb;
650 avg_tlskb += smc->tlskb;
651 avg_caskb += smc->caskb;
654 /* Display average values */
655 printf("%-11s", timestamp[curr]);
656 cprintf_f(unit, 2, 9, 0,
657 (double) avg_frskb / avg_count,
658 ((double) avg_tlskb / avg_count) -
659 ((double) avg_frskb / avg_count));
660 cprintf_pc(DISPLAY_UNIT(flags), 1, 9, 2,
662 SP_VALUE((double) avg_frskb / avg_count,
663 (double) avg_tlskb / avg_count,
664 (double) avg_tlskb / avg_count)
666 cprintf_f(unit, 1, 9, 0,
667 (double) avg_caskb / avg_count);
668 cprintf_pc(DISPLAY_UNIT(flags), 1, 9, 2,
669 (avg_tlskb != avg_frskb) ?
670 SP_VALUE(0.0, (double) avg_caskb / avg_count,
671 ((double) avg_tlskb / avg_count) -
672 ((double) avg_frskb / avg_count))
676 /* Reset average counters */
677 avg_frskb = avg_tlskb = avg_caskb = 0;
683 ***************************************************************************
684 * Display memory and swap statistics.
687 * @a Activity structure with statistics.
688 * @prev Index in array where stats used as reference are.
689 * @curr Index in array for current sample statistics.
690 * @itv Interval of time in 1/100th of a second.
691 ***************************************************************************
693 __print_funct_t print_memory_stats(struct activity *a, int prev, int curr,
694 unsigned long long itv)
696 stub_print_memory_stats(a, prev, curr, FALSE);
700 ***************************************************************************
701 * Display average memory statistics.
704 * @a Activity structure with statistics.
705 * @prev Index in array where stats used as reference are.
706 * @curr Index in array for current sample statistics.
707 * @itv Interval of time in 1/100th of a second.
708 ***************************************************************************
710 __print_funct_t print_avg_memory_stats(struct activity *a, int prev, int curr,
711 unsigned long long itv)
713 stub_print_memory_stats(a, prev, curr, TRUE);
717 ***************************************************************************
718 * Display kernel tables statistics. This function is used to display
719 * instantaneous and average statistics.
722 * @a Activity structure with statistics.
723 * @curr Index in array for current sample statistics.
724 * @dispavg True if displaying average statistics.
725 ***************************************************************************
727 void stub_print_ktables_stats(struct activity *a, int curr, int dispavg)
730 *skc = (struct stats_ktables *) a->buf[curr];
731 static unsigned long long
739 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
743 /* Display instantaneous values */
744 printf("%-11s", timestamp[curr]);
745 cprintf_u64(NO_UNIT, 4, 9,
746 (unsigned long long) skc->dentry_stat,
747 (unsigned long long) skc->file_used,
748 (unsigned long long) skc->inode_used,
749 (unsigned long long) skc->pty_nr);
753 * Will be used to compute the average.
754 * Note: Overflow unlikely to happen but not impossible...
756 avg_dentry_stat += skc->dentry_stat;
757 avg_file_used += skc->file_used;
758 avg_inode_used += skc->inode_used;
759 avg_pty_nr += skc->pty_nr;
762 /* Display average values */
763 printf("%-11s", timestamp[curr]);
764 cprintf_f(NO_UNIT, 4, 9, 0,
765 (double) avg_dentry_stat / avg_count,
766 (double) avg_file_used / avg_count,
767 (double) avg_inode_used / avg_count,
768 (double) avg_pty_nr / avg_count);
771 /* Reset average counters */
772 avg_dentry_stat = avg_file_used = avg_inode_used = avg_pty_nr = 0;
777 ***************************************************************************
778 * Display kernel tables statistics.
781 * @a Activity structure with statistics.
782 * @prev Index in array where stats used as reference are.
783 * @curr Index in array for current sample statistics.
784 * @itv Interval of time in 1/100th of a second.
785 ***************************************************************************
787 __print_funct_t print_ktables_stats(struct activity *a, int prev, int curr,
788 unsigned long long itv)
790 stub_print_ktables_stats(a, curr, FALSE);
794 ***************************************************************************
795 * Display average kernel tables statistics.
798 * @a Activity structure with statistics.
799 * @prev Index in array where stats used as reference are.
800 * @curr Index in array for current sample statistics.
801 * @itv Interval of time in 1/100th of a second.
802 ***************************************************************************
804 __print_funct_t print_avg_ktables_stats(struct activity *a, int prev, int curr,
805 unsigned long long itv)
807 stub_print_ktables_stats(a, curr, TRUE);
811 ***************************************************************************
812 * Display queue and load statistics. This function is used to display
813 * instantaneous and average statistics.
816 * @a Activity structure with statistics.
817 * @curr Index in array for current sample statistics.
818 * @dispavg TRUE if displaying average statistics.
819 ***************************************************************************
821 void stub_print_queue_stats(struct activity *a, int curr, int dispavg)
824 *sqc = (struct stats_queue *) a->buf[curr];
825 static unsigned long long
831 avg_procs_blocked = 0;
834 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
838 /* Display instantaneous values */
839 printf("%-11s", timestamp[curr]);
840 cprintf_u64(NO_UNIT, 2, 9,
841 (unsigned long long) sqc->nr_running,
842 (unsigned long long) sqc->nr_threads);
843 cprintf_f(NO_UNIT, 3, 9, 2,
844 (double) sqc->load_avg_1 / 100,
845 (double) sqc->load_avg_5 / 100,
846 (double) sqc->load_avg_15 / 100);
847 cprintf_u64(NO_UNIT, 1, 9,
848 (unsigned long long) sqc->procs_blocked);
851 /* Will be used to compute the average */
852 avg_nr_running += sqc->nr_running;
853 avg_nr_threads += sqc->nr_threads;
854 avg_load_avg_1 += sqc->load_avg_1;
855 avg_load_avg_5 += sqc->load_avg_5;
856 avg_load_avg_15 += sqc->load_avg_15;
857 avg_procs_blocked += sqc->procs_blocked;
860 /* Display average values */
861 printf("%-11s", timestamp[curr]);
862 cprintf_f(NO_UNIT, 2, 9, 0,
863 (double) avg_nr_running / avg_count,
864 (double) avg_nr_threads / avg_count);
865 cprintf_f(NO_UNIT, 3, 9, 2,
866 (double) avg_load_avg_1 / (avg_count * 100),
867 (double) avg_load_avg_5 / (avg_count * 100),
868 (double) avg_load_avg_15 / (avg_count * 100));
869 cprintf_f(NO_UNIT, 1, 9, 0,
870 (double) avg_procs_blocked / avg_count);
873 /* Reset average counters */
874 avg_nr_running = avg_nr_threads = 0;
875 avg_load_avg_1 = avg_load_avg_5 = avg_load_avg_15 = 0;
876 avg_procs_blocked = 0;
881 ***************************************************************************
882 * Display queue and load statistics.
885 * @a Activity structure with statistics.
886 * @prev Index in array where stats used as reference are.
887 * @curr Index in array for current sample statistics.
888 * @itv Interval of time in 1/100th of a second.
889 ***************************************************************************
891 __print_funct_t print_queue_stats(struct activity *a, int prev, int curr,
892 unsigned long long itv)
894 stub_print_queue_stats(a, curr, FALSE);
898 ***************************************************************************
899 * Display average queue and load statistics.
902 * @a Activity structure with statistics.
903 * @prev Index in array where stats used as reference are.
904 * @curr Index in array for current sample statistics.
905 * @itv Interval of time in 1/100th of a second.
906 ***************************************************************************
908 __print_funct_t print_avg_queue_stats(struct activity *a, int prev, int curr,
909 unsigned long long itv)
911 stub_print_queue_stats(a, curr, TRUE);
915 ***************************************************************************
916 * Display serial lines statistics.
919 * @a Activity structure with statistics.
920 * @prev Index in array where stats used as reference are.
921 * @curr Index in array for current sample statistics.
922 * @itv Interval of time in 1/100th of a second.
923 ***************************************************************************
925 __print_funct_t print_serial_stats(struct activity *a, int prev, int curr,
926 unsigned long long itv)
929 struct stats_serial *ssc, *ssp;
931 if (dis || DISPLAY_ZERO_OMIT(flags)) {
932 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
935 for (i = 0; i < a->nr[curr]; i++) {
936 ssc = (struct stats_serial *) ((char *) a->buf[curr] + i * a->msize);
938 if (WANT_SINCE_BOOT(flags)) {
940 * We want to display statistics since boot time.
941 * Take the first structure from buf[prev]: This is a
942 * structure that only contains 0 (it has been set to 0
943 * when it has been allocated), and which exists since
944 * there is the same number of allocated structures for
945 * buf[prev] and bur[curr] (even if nothing has been read).
947 ssp = (struct stats_serial *) ((char *) a->buf[prev]);
953 if (a->nr[prev] > 0) {
954 /* Look for corresponding serial line in previous iteration */
957 if (j >= a->nr[prev]) {
964 ssp = (struct stats_serial *) ((char *) a->buf[prev] + j * a->msize);
965 if (ssc->line == ssp->line) {
969 if (++j >= a->nr[prev]) {
980 if (DISPLAY_ZERO_OMIT(flags) && !memcmp(ssp, ssc, STATS_SERIAL_SIZE))
983 printf("%-11s", timestamp[curr]);
984 cprintf_in(IS_INT, " %3d", "", ssc->line);
986 cprintf_f(NO_UNIT, 6, 9, 2,
987 S_VALUE(ssp->rx, ssc->rx, itv),
988 S_VALUE(ssp->tx, ssc->tx, itv),
989 S_VALUE(ssp->frame, ssc->frame, itv),
990 S_VALUE(ssp->parity, ssc->parity, itv),
991 S_VALUE(ssp->brk, ssc->brk, itv),
992 S_VALUE(ssp->overrun, ssc->overrun, itv));
998 ***************************************************************************
999 * Display disks statistics.
1002 * @a Activity structure with statistics.
1003 * @prev Index in array where stats used as reference are.
1004 * @curr Index in array for current sample statistics.
1005 * @itv Interval of time in 1/100th of a second.
1006 ***************************************************************************
1008 __print_funct_t print_disk_stats(struct activity *a, int prev, int curr,
1009 unsigned long long itv)
1012 struct stats_disk *sdc, *sdp, sdpzero;
1013 struct ext_disk_stats xds;
1017 memset(&sdpzero, 0, STATS_DISK_SIZE);
1019 if (DISPLAY_UNIT(flags)) {
1020 /* Default values unit is kB */
1021 unit = UNIT_KILOBYTE;
1024 if (dis || DISPLAY_ZERO_OMIT(flags)) {
1025 print_hdr_line(timestamp[!curr], a, FIRST, DISPLAY_HUMAN_READ(flags) ? -1 : 0, 9);
1028 for (i = 0; i < a->nr[curr]; i++) {
1029 sdc = (struct stats_disk *) ((char *) a->buf[curr] + i * a->msize);
1031 if (!WANT_SINCE_BOOT(flags)) {
1032 j = check_disk_reg(a, curr, prev, i);
1039 * This is a newly registered device or we want stats since boot time.
1040 * Previous stats are zero.
1045 sdp = (struct stats_disk *) ((char *) a->buf[prev] + j * a->msize);
1048 if (DISPLAY_ZERO_OMIT(flags) && !memcmp(sdp, sdc, STATS_DISK_SIZE))
1051 /* Get device name */
1052 dev_name = get_sa_devname(sdc->major, sdc->minor, flags);
1054 if (a->item_list != NULL) {
1055 /* A list of devices has been entered on the command line */
1056 if (!search_list_item(a->item_list, dev_name))
1057 /* Device not found */
1061 /* Compute service time, etc. */
1062 compute_ext_disk_stats(sdc, sdp, itv, &xds);
1064 printf("%-11s", timestamp[curr]);
1066 if (!DISPLAY_HUMAN_READ(flags)) {
1067 cprintf_in(IS_STR, " %9s", dev_name, 0);
1069 cprintf_f(NO_UNIT, 1, 9, 2,
1070 S_VALUE(sdp->nr_ios, sdc->nr_ios, itv));
1071 cprintf_f(unit, 2, 9, 2,
1072 S_VALUE(sdp->rd_sect, sdc->rd_sect, itv) / 2,
1073 S_VALUE(sdp->wr_sect, sdc->wr_sect, itv) / 2);
1074 /* See iostat for explanations */
1075 cprintf_f(unit, 1, 9, 2,
1077 cprintf_f(NO_UNIT, 3, 9, 2,
1078 S_VALUE(sdp->rq_ticks, sdc->rq_ticks, itv) / 1000.0,
1081 cprintf_pc(DISPLAY_UNIT(flags), 1, 9, 2,
1083 if (DISPLAY_HUMAN_READ(flags)) {
1084 cprintf_in(IS_STR, " %s", dev_name, 0);
1091 ***************************************************************************
1092 * Display network interfaces statistics.
1095 * @a Activity structure with statistics.
1096 * @prev Index in array where stats used as reference are.
1097 * @curr Index in array for current sample statistics.
1098 * @itv Interval of time in 1/100th of a second.
1099 ***************************************************************************
1101 __print_funct_t print_net_dev_stats(struct activity *a, int prev, int curr,
1102 unsigned long long itv)
1105 struct stats_net_dev *sndc, *sndp, sndzero;
1106 double rxkb, txkb, ifutil;
1109 memset(&sndzero, 0, STATS_NET_DEV_SIZE);
1111 if (DISPLAY_UNIT(flags)) {
1112 /* Default values unit is bytes */
1116 if (dis || DISPLAY_ZERO_OMIT(flags)) {
1117 print_hdr_line(timestamp[!curr], a, FIRST, DISPLAY_HUMAN_READ(flags) ? -1 : 0, 9);
1120 for (i = 0; i < a->nr[curr]; i++) {
1121 sndc = (struct stats_net_dev *) ((char *) a->buf[curr] + i * a->msize);
1123 if (a->item_list != NULL) {
1124 /* A list of devices has been entered on the command line */
1125 if (!search_list_item(a->item_list, sndc->interface))
1126 /* Device not found */
1130 if (!WANT_SINCE_BOOT(flags)) {
1131 j = check_net_dev_reg(a, curr, prev, i);
1138 * This is a newly registered interface or we want stats since boot time.
1139 * Previous stats are zero.
1144 sndp = (struct stats_net_dev *) ((char *) a->buf[prev] + j * a->msize);
1147 if (DISPLAY_ZERO_OMIT(flags) && !memcmp(sndp, sndc, STATS_NET_DEV_SIZE2CMP))
1150 printf("%-11s", timestamp[curr]);
1152 if (!DISPLAY_HUMAN_READ(flags)) {
1153 cprintf_in(IS_STR, " %9s", sndc->interface, 0);
1155 rxkb = S_VALUE(sndp->rx_bytes, sndc->rx_bytes, itv);
1156 txkb = S_VALUE(sndp->tx_bytes, sndc->tx_bytes, itv);
1158 cprintf_f(NO_UNIT, 2, 9, 2,
1159 S_VALUE(sndp->rx_packets, sndc->rx_packets, itv),
1160 S_VALUE(sndp->tx_packets, sndc->tx_packets, itv));
1161 cprintf_f(unit, 2, 9, 2,
1162 unit < 0 ? rxkb / 1024 : rxkb,
1163 unit < 0 ? txkb / 1024 : txkb);
1164 cprintf_f(NO_UNIT, 3, 9, 2,
1165 S_VALUE(sndp->rx_compressed, sndc->rx_compressed, itv),
1166 S_VALUE(sndp->tx_compressed, sndc->tx_compressed, itv),
1167 S_VALUE(sndp->multicast, sndc->multicast, itv));
1168 ifutil = compute_ifutil(sndc, rxkb, txkb);
1169 cprintf_pc(DISPLAY_UNIT(flags), 1, 9, 2, ifutil);
1170 if (DISPLAY_HUMAN_READ(flags)) {
1171 cprintf_in(IS_STR, " %s", sndc->interface, 0);
1178 ***************************************************************************
1179 * Display network interface errors statistics.
1182 * @a Activity structure with statistics.
1183 * @prev Index in array where stats used as reference are.
1184 * @curr Index in array for current sample statistics.
1185 * @itv Interval of time in 1/100th of a second.
1186 ***************************************************************************
1188 __print_funct_t print_net_edev_stats(struct activity *a, int prev, int curr,
1189 unsigned long long itv)
1192 struct stats_net_edev *snedc, *snedp, snedzero;
1194 memset(&snedzero, 0, STATS_NET_EDEV_SIZE);
1196 if (dis || DISPLAY_ZERO_OMIT(flags)) {
1197 print_hdr_line(timestamp[!curr], a, FIRST, DISPLAY_HUMAN_READ(flags) ? -1 : 0, 9);
1200 for (i = 0; i < a->nr[curr]; i++) {
1201 snedc = (struct stats_net_edev *) ((char *) a->buf[curr] + i * a->msize);
1203 if (a->item_list != NULL) {
1204 /* A list of devices has been entered on the command line */
1205 if (!search_list_item(a->item_list, snedc->interface))
1206 /* Device not found */
1210 if (!WANT_SINCE_BOOT(flags)) {
1211 j = check_net_edev_reg(a, curr, prev, i);
1218 * This is a newly registered interface or we want stats since boot time.
1219 * Previous stats are zero.
1224 snedp = (struct stats_net_edev *) ((char *) a->buf[prev] + j * a->msize);
1227 if (DISPLAY_ZERO_OMIT(flags) && !memcmp(snedp, snedc, STATS_NET_EDEV_SIZE2CMP))
1230 printf("%-11s", timestamp[curr]);
1232 if (!DISPLAY_HUMAN_READ(flags)) {
1233 cprintf_in(IS_STR, " %9s", snedc->interface, 0);
1235 cprintf_f(NO_UNIT, 9, 9, 2,
1236 S_VALUE(snedp->rx_errors, snedc->rx_errors, itv),
1237 S_VALUE(snedp->tx_errors, snedc->tx_errors, itv),
1238 S_VALUE(snedp->collisions, snedc->collisions, itv),
1239 S_VALUE(snedp->rx_dropped, snedc->rx_dropped, itv),
1240 S_VALUE(snedp->tx_dropped, snedc->tx_dropped, itv),
1241 S_VALUE(snedp->tx_carrier_errors, snedc->tx_carrier_errors, itv),
1242 S_VALUE(snedp->rx_frame_errors, snedc->rx_frame_errors, itv),
1243 S_VALUE(snedp->rx_fifo_errors, snedc->rx_fifo_errors, itv),
1244 S_VALUE(snedp->tx_fifo_errors, snedc->tx_fifo_errors, itv));
1245 if (DISPLAY_HUMAN_READ(flags)) {
1246 cprintf_in(IS_STR, " %s", snedc->interface, 0);
1253 ***************************************************************************
1254 * Display NFS client statistics.
1257 * @a Activity structure with statistics.
1258 * @prev Index in array where stats used as reference are.
1259 * @curr Index in array for current sample statistics.
1260 * @itv Interval of time in 1/100th of a second.
1261 ***************************************************************************
1263 __print_funct_t print_net_nfs_stats(struct activity *a, int prev, int curr,
1264 unsigned long long itv)
1266 struct stats_net_nfs
1267 *snnc = (struct stats_net_nfs *) a->buf[curr],
1268 *snnp = (struct stats_net_nfs *) a->buf[prev];
1271 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
1274 printf("%-11s", timestamp[curr]);
1275 cprintf_f(NO_UNIT, 6, 9, 2,
1276 S_VALUE(snnp->nfs_rpccnt, snnc->nfs_rpccnt, itv),
1277 S_VALUE(snnp->nfs_rpcretrans, snnc->nfs_rpcretrans, itv),
1278 S_VALUE(snnp->nfs_readcnt, snnc->nfs_readcnt, itv),
1279 S_VALUE(snnp->nfs_writecnt, snnc->nfs_writecnt, itv),
1280 S_VALUE(snnp->nfs_accesscnt, snnc->nfs_accesscnt, itv),
1281 S_VALUE(snnp->nfs_getattcnt, snnc->nfs_getattcnt, itv));
1286 ***************************************************************************
1287 * Display NFS server statistics.
1290 * @a Activity structure with statistics.
1291 * @prev Index in array where stats used as reference are.
1292 * @curr Index in array for current sample statistics.
1293 * @itv Interval of time in 1/100th of a second.
1294 ***************************************************************************
1296 __print_funct_t print_net_nfsd_stats(struct activity *a, int prev, int curr,
1297 unsigned long long itv)
1299 struct stats_net_nfsd
1300 *snndc = (struct stats_net_nfsd *) a->buf[curr],
1301 *snndp = (struct stats_net_nfsd *) a->buf[prev];
1304 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
1307 printf("%-11s", timestamp[curr]);
1308 cprintf_f(NO_UNIT, 11, 9, 2,
1309 S_VALUE(snndp->nfsd_rpccnt, snndc->nfsd_rpccnt, itv),
1310 S_VALUE(snndp->nfsd_rpcbad, snndc->nfsd_rpcbad, itv),
1311 S_VALUE(snndp->nfsd_netcnt, snndc->nfsd_netcnt, itv),
1312 S_VALUE(snndp->nfsd_netudpcnt, snndc->nfsd_netudpcnt, itv),
1313 S_VALUE(snndp->nfsd_nettcpcnt, snndc->nfsd_nettcpcnt, itv),
1314 S_VALUE(snndp->nfsd_rchits, snndc->nfsd_rchits, itv),
1315 S_VALUE(snndp->nfsd_rcmisses, snndc->nfsd_rcmisses, itv),
1316 S_VALUE(snndp->nfsd_readcnt, snndc->nfsd_readcnt, itv),
1317 S_VALUE(snndp->nfsd_writecnt, snndc->nfsd_writecnt, itv),
1318 S_VALUE(snndp->nfsd_accesscnt, snndc->nfsd_accesscnt, itv),
1319 S_VALUE(snndp->nfsd_getattcnt, snndc->nfsd_getattcnt, itv));
1324 ***************************************************************************
1325 * Display network sockets statistics. This function is used to display
1326 * instantaneous and average statistics.
1329 * @a Activity structure with statistics.
1330 * @curr Index in array for current sample statistics.
1331 * @dispavg TRUE if displaying average statistics.
1332 ***************************************************************************
1334 void stub_print_net_sock_stats(struct activity *a, int curr, int dispavg)
1336 struct stats_net_sock
1337 *snsc = (struct stats_net_sock *) a->buf[curr];
1338 static unsigned long long
1347 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
1351 /* Display instantaneous values */
1352 printf("%-11s", timestamp[curr]);
1353 cprintf_u64(NO_UNIT, 6, 9,
1354 (unsigned long long) snsc->sock_inuse,
1355 (unsigned long long) snsc->tcp_inuse,
1356 (unsigned long long) snsc->udp_inuse,
1357 (unsigned long long) snsc->raw_inuse,
1358 (unsigned long long) snsc->frag_inuse,
1359 (unsigned long long) snsc->tcp_tw);
1362 /* Will be used to compute the average */
1363 avg_sock_inuse += snsc->sock_inuse;
1364 avg_tcp_inuse += snsc->tcp_inuse;
1365 avg_udp_inuse += snsc->udp_inuse;
1366 avg_raw_inuse += snsc->raw_inuse;
1367 avg_frag_inuse += snsc->frag_inuse;
1368 avg_tcp_tw += snsc->tcp_tw;
1371 /* Display average values */
1372 printf("%-11s", timestamp[curr]);
1373 cprintf_f(NO_UNIT, 6, 9, 0,
1374 (double) avg_sock_inuse / avg_count,
1375 (double) avg_tcp_inuse / avg_count,
1376 (double) avg_udp_inuse / avg_count,
1377 (double) avg_raw_inuse / avg_count,
1378 (double) avg_frag_inuse / avg_count,
1379 (double) avg_tcp_tw / avg_count);
1382 /* Reset average counters */
1383 avg_sock_inuse = avg_tcp_inuse = avg_udp_inuse = 0;
1384 avg_raw_inuse = avg_frag_inuse = avg_tcp_tw = 0;
1389 ***************************************************************************
1390 * Display network sockets statistics.
1393 * @a Activity structure with statistics.
1394 * @prev Index in array where stats used as reference are.
1395 * @curr Index in array for current sample statistics.
1396 * @itv Interval of time in 1/100th of a second.
1397 ***************************************************************************
1399 __print_funct_t print_net_sock_stats(struct activity *a, int prev, int curr,
1400 unsigned long long itv)
1402 stub_print_net_sock_stats(a, curr, FALSE);
1406 ***************************************************************************
1407 * Display average network sockets statistics.
1410 * @a Activity structure with statistics.
1411 * @prev Index in array where stats used as reference are.
1412 * @curr Index in array for current sample statistics.
1413 * @itv Interval of time in 1/100th of a second.
1414 ***************************************************************************
1416 __print_funct_t print_avg_net_sock_stats(struct activity *a, int prev, int curr,
1417 unsigned long long itv)
1419 stub_print_net_sock_stats(a, curr, TRUE);
1423 ***************************************************************************
1424 * Display IP network traffic statistics.
1427 * @a Activity structure with statistics.
1428 * @prev Index in array where stats used as reference are.
1429 * @curr Index in array for current sample statistics.
1430 * @itv Interval of time in 1/100th of a second.
1431 ***************************************************************************
1433 __print_funct_t print_net_ip_stats(struct activity *a, int prev, int curr,
1434 unsigned long long itv)
1437 *snic = (struct stats_net_ip *) a->buf[curr],
1438 *snip = (struct stats_net_ip *) a->buf[prev];
1441 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
1444 printf("%-11s", timestamp[curr]);
1445 cprintf_f(NO_UNIT, 8, 9, 2,
1446 S_VALUE(snip->InReceives, snic->InReceives, itv),
1447 S_VALUE(snip->ForwDatagrams, snic->ForwDatagrams, itv),
1448 S_VALUE(snip->InDelivers, snic->InDelivers, itv),
1449 S_VALUE(snip->OutRequests, snic->OutRequests, itv),
1450 S_VALUE(snip->ReasmReqds, snic->ReasmReqds, itv),
1451 S_VALUE(snip->ReasmOKs, snic->ReasmOKs, itv),
1452 S_VALUE(snip->FragOKs, snic->FragOKs, itv),
1453 S_VALUE(snip->FragCreates, snic->FragCreates, itv));
1458 ***************************************************************************
1459 * Display IP network errors statistics.
1462 * @a Activity structure with statistics.
1463 * @prev Index in array where stats used as reference are.
1464 * @curr Index in array for current sample statistics.
1465 * @itv Interval of time in 1/100th of a second.
1466 ***************************************************************************
1468 __print_funct_t print_net_eip_stats(struct activity *a, int prev, int curr,
1469 unsigned long long itv)
1471 struct stats_net_eip
1472 *sneic = (struct stats_net_eip *) a->buf[curr],
1473 *sneip = (struct stats_net_eip *) a->buf[prev];
1476 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
1479 printf("%-11s", timestamp[curr]);
1480 cprintf_f(NO_UNIT, 8, 9, 2,
1481 S_VALUE(sneip->InHdrErrors, sneic->InHdrErrors, itv),
1482 S_VALUE(sneip->InAddrErrors, sneic->InAddrErrors, itv),
1483 S_VALUE(sneip->InUnknownProtos, sneic->InUnknownProtos, itv),
1484 S_VALUE(sneip->InDiscards, sneic->InDiscards, itv),
1485 S_VALUE(sneip->OutDiscards, sneic->OutDiscards, itv),
1486 S_VALUE(sneip->OutNoRoutes, sneic->OutNoRoutes, itv),
1487 S_VALUE(sneip->ReasmFails, sneic->ReasmFails, itv),
1488 S_VALUE(sneip->FragFails, sneic->FragFails, itv));
1493 ***************************************************************************
1494 * Display ICMP network traffic statistics.
1497 * @a Activity structure with statistics.
1498 * @prev Index in array where stats used as reference are.
1499 * @curr Index in array for current sample statistics.
1500 * @itv Interval of time in 1/100th of a second.
1501 ***************************************************************************
1503 __print_funct_t print_net_icmp_stats(struct activity *a, int prev, int curr,
1504 unsigned long long itv)
1506 struct stats_net_icmp
1507 *snic = (struct stats_net_icmp *) a->buf[curr],
1508 *snip = (struct stats_net_icmp *) a->buf[prev];
1511 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
1514 printf("%-11s", timestamp[curr]);
1515 cprintf_f(NO_UNIT, 14, 9, 2,
1516 S_VALUE(snip->InMsgs, snic->InMsgs, itv),
1517 S_VALUE(snip->OutMsgs, snic->OutMsgs, itv),
1518 S_VALUE(snip->InEchos, snic->InEchos, itv),
1519 S_VALUE(snip->InEchoReps, snic->InEchoReps, itv),
1520 S_VALUE(snip->OutEchos, snic->OutEchos, itv),
1521 S_VALUE(snip->OutEchoReps, snic->OutEchoReps, itv),
1522 S_VALUE(snip->InTimestamps, snic->InTimestamps, itv),
1523 S_VALUE(snip->InTimestampReps, snic->InTimestampReps, itv),
1524 S_VALUE(snip->OutTimestamps, snic->OutTimestamps, itv),
1525 S_VALUE(snip->OutTimestampReps, snic->OutTimestampReps, itv),
1526 S_VALUE(snip->InAddrMasks, snic->InAddrMasks, itv),
1527 S_VALUE(snip->InAddrMaskReps, snic->InAddrMaskReps, itv),
1528 S_VALUE(snip->OutAddrMasks, snic->OutAddrMasks, itv),
1529 S_VALUE(snip->OutAddrMaskReps, snic->OutAddrMaskReps, itv));
1534 ***************************************************************************
1535 * Display ICMP network errors statistics.
1538 * @a Activity structure with statistics.
1539 * @prev Index in array where stats used as reference are.
1540 * @curr Index in array for current sample statistics.
1541 * @itv Interval of time in 1/100th of a second.
1542 ***************************************************************************
1544 __print_funct_t print_net_eicmp_stats(struct activity *a, int prev, int curr,
1545 unsigned long long itv)
1547 struct stats_net_eicmp
1548 *sneic = (struct stats_net_eicmp *) a->buf[curr],
1549 *sneip = (struct stats_net_eicmp *) a->buf[prev];
1552 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
1555 printf("%-11s", timestamp[curr]);
1556 cprintf_f(NO_UNIT, 12, 9, 2,
1557 S_VALUE(sneip->InErrors, sneic->InErrors, itv),
1558 S_VALUE(sneip->OutErrors, sneic->OutErrors, itv),
1559 S_VALUE(sneip->InDestUnreachs, sneic->InDestUnreachs, itv),
1560 S_VALUE(sneip->OutDestUnreachs, sneic->OutDestUnreachs, itv),
1561 S_VALUE(sneip->InTimeExcds, sneic->InTimeExcds, itv),
1562 S_VALUE(sneip->OutTimeExcds, sneic->OutTimeExcds, itv),
1563 S_VALUE(sneip->InParmProbs, sneic->InParmProbs, itv),
1564 S_VALUE(sneip->OutParmProbs, sneic->OutParmProbs, itv),
1565 S_VALUE(sneip->InSrcQuenchs, sneic->InSrcQuenchs, itv),
1566 S_VALUE(sneip->OutSrcQuenchs, sneic->OutSrcQuenchs, itv),
1567 S_VALUE(sneip->InRedirects, sneic->InRedirects, itv),
1568 S_VALUE(sneip->OutRedirects, sneic->OutRedirects, itv));
1573 ***************************************************************************
1574 * Display TCP network traffic statistics.
1577 * @a Activity structure with statistics.
1578 * @prev Index in array where stats used as reference are.
1579 * @curr Index in array for current sample statistics.
1580 * @itv Interval of time in 1/100th of a second.
1581 ***************************************************************************
1583 __print_funct_t print_net_tcp_stats(struct activity *a, int prev, int curr,
1584 unsigned long long itv)
1586 struct stats_net_tcp
1587 *sntc = (struct stats_net_tcp *) a->buf[curr],
1588 *sntp = (struct stats_net_tcp *) a->buf[prev];
1591 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
1594 printf("%-11s", timestamp[curr]);
1595 cprintf_f(NO_UNIT, 4, 9, 2,
1596 S_VALUE(sntp->ActiveOpens, sntc->ActiveOpens, itv),
1597 S_VALUE(sntp->PassiveOpens, sntc->PassiveOpens, itv),
1598 S_VALUE(sntp->InSegs, sntc->InSegs, itv),
1599 S_VALUE(sntp->OutSegs, sntc->OutSegs, itv));
1604 ***************************************************************************
1605 * Display TCP network errors 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_etcp_stats(struct activity *a, int prev, int curr,
1615 unsigned long long itv)
1617 struct stats_net_etcp
1618 *snetc = (struct stats_net_etcp *) a->buf[curr],
1619 *snetp = (struct stats_net_etcp *) a->buf[prev];
1622 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
1625 printf("%-11s", timestamp[curr]);
1626 cprintf_f(NO_UNIT, 5, 9, 2,
1627 S_VALUE(snetp->AttemptFails, snetc->AttemptFails, itv),
1628 S_VALUE(snetp->EstabResets, snetc->EstabResets, itv),
1629 S_VALUE(snetp->RetransSegs, snetc->RetransSegs, itv),
1630 S_VALUE(snetp->InErrs, snetc->InErrs, itv),
1631 S_VALUE(snetp->OutRsts, snetc->OutRsts, itv));
1636 ***************************************************************************
1637 * Display UDP network traffic statistics.
1640 * @a Activity structure with statistics.
1641 * @prev Index in array where stats used as reference are.
1642 * @curr Index in array for current sample statistics.
1643 * @itv Interval of time in 1/100th of a second.
1644 ***************************************************************************
1646 __print_funct_t print_net_udp_stats(struct activity *a, int prev, int curr,
1647 unsigned long long itv)
1649 struct stats_net_udp
1650 *snuc = (struct stats_net_udp *) a->buf[curr],
1651 *snup = (struct stats_net_udp *) a->buf[prev];
1654 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
1657 printf("%-11s", timestamp[curr]);
1658 cprintf_f(NO_UNIT, 4, 9, 2,
1659 S_VALUE(snup->InDatagrams, snuc->InDatagrams, itv),
1660 S_VALUE(snup->OutDatagrams, snuc->OutDatagrams, itv),
1661 S_VALUE(snup->NoPorts, snuc->NoPorts, itv),
1662 S_VALUE(snup->InErrors, snuc->InErrors, itv));
1667 ***************************************************************************
1668 * Display IPv6 sockets statistics. This function is used to display
1669 * instantaneous and average statistics.
1672 * @a Activity structure with statistics.
1673 * @curr Index in array for current sample statistics.
1674 * @dispavg TRUE if displaying average statistics.
1675 ***************************************************************************
1677 void stub_print_net_sock6_stats(struct activity *a, int curr, int dispavg)
1679 struct stats_net_sock6
1680 *snsc = (struct stats_net_sock6 *) a->buf[curr];
1681 static unsigned long long
1685 avg_frag6_inuse = 0;
1688 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
1692 /* Display instantaneous values */
1693 printf("%-11s", timestamp[curr]);
1694 cprintf_u64(NO_UNIT, 4, 9,
1695 (unsigned long long) snsc->tcp6_inuse,
1696 (unsigned long long) snsc->udp6_inuse,
1697 (unsigned long long) snsc->raw6_inuse,
1698 (unsigned long long) snsc->frag6_inuse);
1701 /* Will be used to compute the average */
1702 avg_tcp6_inuse += snsc->tcp6_inuse;
1703 avg_udp6_inuse += snsc->udp6_inuse;
1704 avg_raw6_inuse += snsc->raw6_inuse;
1705 avg_frag6_inuse += snsc->frag6_inuse;
1708 /* Display average values */
1709 printf("%-11s", timestamp[curr]);
1710 cprintf_f(NO_UNIT, 4, 9, 0,
1711 (double) avg_tcp6_inuse / avg_count,
1712 (double) avg_udp6_inuse / avg_count,
1713 (double) avg_raw6_inuse / avg_count,
1714 (double) avg_frag6_inuse / avg_count);
1717 /* Reset average counters */
1718 avg_tcp6_inuse = avg_udp6_inuse = avg_raw6_inuse = avg_frag6_inuse = 0;
1723 ***************************************************************************
1724 * Display IPv6 sockets statistics.
1727 * @a Activity structure with statistics.
1728 * @prev Index in array where stats used as reference are.
1729 * @curr Index in array for current sample statistics.
1730 * @itv Interval of time in 1/100th of a second.
1731 ***************************************************************************
1733 __print_funct_t print_net_sock6_stats(struct activity *a, int prev, int curr,
1734 unsigned long long itv)
1736 stub_print_net_sock6_stats(a, curr, FALSE);
1740 ***************************************************************************
1741 * Display average IPv6 sockets statistics.
1744 * @a Activity structure with statistics.
1745 * @prev Index in array where stats used as reference are.
1746 * @curr Index in array for current sample statistics.
1747 * @itv Interval of time in 1/100th of a second.
1748 ***************************************************************************
1750 __print_funct_t print_avg_net_sock6_stats(struct activity *a, int prev, int curr,
1751 unsigned long long itv)
1753 stub_print_net_sock6_stats(a, curr, TRUE);
1757 ***************************************************************************
1758 * Display IPv6 network traffic statistics.
1761 * @a Activity structure with statistics.
1762 * @prev Index in array where stats used as reference are.
1763 * @curr Index in array for current sample statistics.
1764 * @itv Interval of time in 1/100th of a second.
1765 ***************************************************************************
1767 __print_funct_t print_net_ip6_stats(struct activity *a, int prev, int curr,
1768 unsigned long long itv)
1770 struct stats_net_ip6
1771 *snic = (struct stats_net_ip6 *) a->buf[curr],
1772 *snip = (struct stats_net_ip6 *) a->buf[prev];
1775 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
1778 printf("%-11s", timestamp[curr]);
1779 cprintf_f(NO_UNIT, 10, 9, 2,
1780 S_VALUE(snip->InReceives6, snic->InReceives6, itv),
1781 S_VALUE(snip->OutForwDatagrams6, snic->OutForwDatagrams6, itv),
1782 S_VALUE(snip->InDelivers6, snic->InDelivers6, itv),
1783 S_VALUE(snip->OutRequests6, snic->OutRequests6, itv),
1784 S_VALUE(snip->ReasmReqds6, snic->ReasmReqds6, itv),
1785 S_VALUE(snip->ReasmOKs6, snic->ReasmOKs6, itv),
1786 S_VALUE(snip->InMcastPkts6, snic->InMcastPkts6, itv),
1787 S_VALUE(snip->OutMcastPkts6, snic->OutMcastPkts6, itv),
1788 S_VALUE(snip->FragOKs6, snic->FragOKs6, itv),
1789 S_VALUE(snip->FragCreates6, snic->FragCreates6, itv));
1794 ***************************************************************************
1795 * Display IPv6 network errors statistics.
1798 * @a Activity structure with statistics.
1799 * @prev Index in array where stats used as reference are.
1800 * @curr Index in array for current sample statistics.
1801 * @itv Interval of time in 1/100th of a second.
1802 ***************************************************************************
1804 __print_funct_t print_net_eip6_stats(struct activity *a, int prev, int curr,
1805 unsigned long long itv)
1807 struct stats_net_eip6
1808 *sneic = (struct stats_net_eip6 *) a->buf[curr],
1809 *sneip = (struct stats_net_eip6 *) a->buf[prev];
1812 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
1815 printf("%-11s", timestamp[curr]);
1816 cprintf_f(NO_UNIT, 11, 9, 2,
1817 S_VALUE(sneip->InHdrErrors6, sneic->InHdrErrors6, itv),
1818 S_VALUE(sneip->InAddrErrors6, sneic->InAddrErrors6, itv),
1819 S_VALUE(sneip->InUnknownProtos6, sneic->InUnknownProtos6, itv),
1820 S_VALUE(sneip->InTooBigErrors6, sneic->InTooBigErrors6, itv),
1821 S_VALUE(sneip->InDiscards6, sneic->InDiscards6, itv),
1822 S_VALUE(sneip->OutDiscards6, sneic->OutDiscards6, itv),
1823 S_VALUE(sneip->InNoRoutes6, sneic->InNoRoutes6, itv),
1824 S_VALUE(sneip->OutNoRoutes6, sneic->OutNoRoutes6, itv),
1825 S_VALUE(sneip->ReasmFails6, sneic->ReasmFails6, itv),
1826 S_VALUE(sneip->FragFails6, sneic->FragFails6, itv),
1827 S_VALUE(sneip->InTruncatedPkts6, sneic->InTruncatedPkts6, itv));
1832 ***************************************************************************
1833 * Display ICMPv6 network traffic statistics.
1836 * @a Activity structure with statistics.
1837 * @prev Index in array where stats used as reference are.
1838 * @curr Index in array for current sample statistics.
1839 * @itv Interval of time in 1/100th of a second.
1840 ***************************************************************************
1842 __print_funct_t print_net_icmp6_stats(struct activity *a, int prev, int curr,
1843 unsigned long long itv)
1845 struct stats_net_icmp6
1846 *snic = (struct stats_net_icmp6 *) a->buf[curr],
1847 *snip = (struct stats_net_icmp6 *) a->buf[prev];
1850 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
1853 printf("%-11s", timestamp[curr]);
1854 cprintf_f(NO_UNIT, 17, 9, 2,
1855 S_VALUE(snip->InMsgs6, snic->InMsgs6, itv),
1856 S_VALUE(snip->OutMsgs6, snic->OutMsgs6, itv),
1857 S_VALUE(snip->InEchos6, snic->InEchos6, itv),
1858 S_VALUE(snip->InEchoReplies6, snic->InEchoReplies6, itv),
1859 S_VALUE(snip->OutEchoReplies6, snic->OutEchoReplies6, itv),
1860 S_VALUE(snip->InGroupMembQueries6, snic->InGroupMembQueries6, itv),
1861 S_VALUE(snip->InGroupMembResponses6, snic->InGroupMembResponses6, itv),
1862 S_VALUE(snip->OutGroupMembResponses6, snic->OutGroupMembResponses6, itv),
1863 S_VALUE(snip->InGroupMembReductions6, snic->InGroupMembReductions6, itv),
1864 S_VALUE(snip->OutGroupMembReductions6, snic->OutGroupMembReductions6, itv),
1865 S_VALUE(snip->InRouterSolicits6, snic->InRouterSolicits6, itv),
1866 S_VALUE(snip->OutRouterSolicits6, snic->OutRouterSolicits6, itv),
1867 S_VALUE(snip->InRouterAdvertisements6, snic->InRouterAdvertisements6, itv),
1868 S_VALUE(snip->InNeighborSolicits6, snic->InNeighborSolicits6, itv),
1869 S_VALUE(snip->OutNeighborSolicits6, snic->OutNeighborSolicits6, itv),
1870 S_VALUE(snip->InNeighborAdvertisements6, snic->InNeighborAdvertisements6, itv),
1871 S_VALUE(snip->OutNeighborAdvertisements6, snic->OutNeighborAdvertisements6, itv));
1876 ***************************************************************************
1877 * Display ICMPv6 network errors statistics.
1880 * @a Activity structure with statistics.
1881 * @prev Index in array where stats used as reference are.
1882 * @curr Index in array for current sample statistics.
1883 * @itv Interval of time in 1/100th of a second.
1884 ***************************************************************************
1886 __print_funct_t print_net_eicmp6_stats(struct activity *a, int prev, int curr,
1887 unsigned long long itv)
1889 struct stats_net_eicmp6
1890 *sneic = (struct stats_net_eicmp6 *) a->buf[curr],
1891 *sneip = (struct stats_net_eicmp6 *) a->buf[prev];
1894 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
1897 printf("%-11s", timestamp[curr]);
1898 cprintf_f(NO_UNIT, 11, 9, 2,
1899 S_VALUE(sneip->InErrors6, sneic->InErrors6, itv),
1900 S_VALUE(sneip->InDestUnreachs6, sneic->InDestUnreachs6, itv),
1901 S_VALUE(sneip->OutDestUnreachs6, sneic->OutDestUnreachs6, itv),
1902 S_VALUE(sneip->InTimeExcds6, sneic->InTimeExcds6, itv),
1903 S_VALUE(sneip->OutTimeExcds6, sneic->OutTimeExcds6, itv),
1904 S_VALUE(sneip->InParmProblems6, sneic->InParmProblems6, itv),
1905 S_VALUE(sneip->OutParmProblems6, sneic->OutParmProblems6, itv),
1906 S_VALUE(sneip->InRedirects6, sneic->InRedirects6, itv),
1907 S_VALUE(sneip->OutRedirects6, sneic->OutRedirects6, itv),
1908 S_VALUE(sneip->InPktTooBigs6, sneic->InPktTooBigs6, itv),
1909 S_VALUE(sneip->OutPktTooBigs6, sneic->OutPktTooBigs6, itv));
1914 ***************************************************************************
1915 * Display UDPv6 network traffic statistics.
1918 * @a Activity structure with statistics.
1919 * @prev Index in array where stats used as reference are.
1920 * @curr Index in array for current sample statistics.
1921 * @itv Interval of time in 1/100th of a second.
1922 ***************************************************************************
1924 __print_funct_t print_net_udp6_stats(struct activity *a, int prev, int curr,
1925 unsigned long long itv)
1927 struct stats_net_udp6
1928 *snuc = (struct stats_net_udp6 *) a->buf[curr],
1929 *snup = (struct stats_net_udp6 *) a->buf[prev];
1932 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
1935 printf("%-11s", timestamp[curr]);
1936 cprintf_f(NO_UNIT, 4, 9, 2,
1937 S_VALUE(snup->InDatagrams6, snuc->InDatagrams6, itv),
1938 S_VALUE(snup->OutDatagrams6, snuc->OutDatagrams6, itv),
1939 S_VALUE(snup->NoPorts6, snuc->NoPorts6, itv),
1940 S_VALUE(snup->InErrors6, snuc->InErrors6, itv));
1945 ***************************************************************************
1946 * Display CPU frequency statistics. This function is used to display
1947 * instantaneous and average statistics.
1950 * @a Activity structure with statistics.
1951 * @curr Index in array for current sample statistics.
1952 * @dispavg True if displaying average statistics.
1953 ***************************************************************************
1955 void stub_print_pwr_cpufreq_stats(struct activity *a, int curr, int dispavg)
1958 struct stats_pwr_cpufreq *spc;
1959 static __nr_t nr_alloc = 0;
1960 static unsigned long long
1961 *avg_cpufreq = NULL;
1963 if (!avg_cpufreq || (a->nr[curr] > nr_alloc)) {
1964 /* Allocate array of CPU frequency */
1965 SREALLOC(avg_cpufreq, unsigned long long, sizeof(unsigned long long) * a->nr[curr]);
1966 if (a->nr[curr] > nr_alloc) {
1967 /* Init additional space allocated */
1968 memset(avg_cpufreq + nr_alloc, 0,
1969 sizeof(unsigned long long) * (a->nr[curr] - nr_alloc));
1971 nr_alloc = a->nr[curr];
1975 print_hdr_line(timestamp[!curr], a, FIRST, 7, 9);
1978 for (i = 0; (i < a->nr[curr]) && (i < a->bitmap->b_size + 1); i++) {
1981 * The size of a->buf[...] CPU structure may be different from the default
1982 * sizeof(struct stats_pwr_cpufreq) value if data have been read from a file!
1983 * That's why we don't use a syntax like:
1984 * spc = (struct stats_pwr_cpufreq *) a->buf[...] + i;
1986 spc = (struct stats_pwr_cpufreq *) ((char *) a->buf[curr] + i * a->msize);
1989 /* This CPU is offline: Don't display it */
1993 * Note: @nr[curr] is in [1, NR_CPUS + 1].
1994 * Bitmap size is provided for (NR_CPUS + 1) CPUs.
1995 * Anyway, NR_CPUS may vary between the version of sysstat
1996 * used by sadc to create a file, and the version of sysstat
1997 * used by sar to read it...
2000 /* Should current CPU (including CPU "all") be displayed? */
2001 if (!(a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))))
2005 printf("%-11s", timestamp[curr]);
2008 /* This is CPU "all" */
2009 cprintf_in(IS_STR, "%s", " all", 0);
2012 cprintf_in(IS_INT, " %3d", "", i - 1);
2016 /* Display instantaneous values */
2017 cprintf_f(NO_UNIT, 1, 9, 2,
2018 ((double) spc->cpufreq) / 100);
2021 * Will be used to compute the average.
2022 * Note: Overflow unlikely to happen but not impossible...
2024 avg_cpufreq[i] += spc->cpufreq;
2027 /* Display average values */
2028 cprintf_f(NO_UNIT, 1, 9, 2,
2029 (double) avg_cpufreq[i] / (100 * avg_count));
2034 if (dispavg && avg_cpufreq) {
2035 /* Array of CPU frequency no longer needed: Free it! */
2043 ***************************************************************************
2044 * Display CPU frequency statistics.
2047 * @a Activity structure with statistics.
2048 * @prev Index in array where stats used as reference are.
2049 * @curr Index in array for current sample statistics.
2050 * @itv Interval of time in 1/100th of a second.
2051 ***************************************************************************
2053 __print_funct_t print_pwr_cpufreq_stats(struct activity *a, int prev, int curr,
2054 unsigned long long itv)
2056 stub_print_pwr_cpufreq_stats(a, curr, FALSE);
2060 ***************************************************************************
2061 * Display average CPU frequency statistics.
2064 * @a Activity structure with statistics.
2065 * @prev Index in array where stats used as reference are.
2066 * @curr Index in array for current sample statistics.
2067 * @itv Interval of time in 1/100th of a second.
2068 ***************************************************************************
2070 __print_funct_t print_avg_pwr_cpufreq_stats(struct activity *a, int prev, int curr,
2071 unsigned long long itv)
2073 stub_print_pwr_cpufreq_stats(a, curr, TRUE);
2077 ***************************************************************************
2078 * Display fan statistics. This function is used to display
2079 * instantaneous and average statistics.
2082 * @a Activity structure with statistics.
2083 * @curr Index in array for current sample statistics.
2084 * @dispavg True if displaying average statistics.
2085 ***************************************************************************
2087 void stub_print_pwr_fan_stats(struct activity *a, int curr, int dispavg)
2090 struct stats_pwr_fan *spc;
2091 static __nr_t nr_alloc = 0;
2092 static double *avg_fan = NULL;
2093 static double *avg_fan_min = NULL;
2095 /* Allocate arrays of fan RPMs */
2096 if (!avg_fan || (a->nr[curr] > nr_alloc)) {
2097 SREALLOC(avg_fan, double, sizeof(double) * a->nr[curr]);
2098 SREALLOC(avg_fan_min, double, sizeof(double) * a->nr[curr]);
2100 if (a->nr[curr] > nr_alloc) {
2101 /* Init additional space allocated */
2102 memset(avg_fan + nr_alloc, 0,
2103 sizeof(double) * (a->nr[curr] - nr_alloc));
2104 memset(avg_fan_min + nr_alloc, 0,
2105 sizeof(double) * (a->nr[curr] - nr_alloc));
2107 nr_alloc = a->nr[curr];
2111 print_hdr_line(timestamp[!curr], a, FIRST, -2, 9);
2114 for (i = 0; i < a->nr[curr]; i++) {
2115 spc = (struct stats_pwr_fan *) ((char *) a->buf[curr] + i * a->msize);
2117 printf("%-11s", timestamp[curr]);
2118 cprintf_in(IS_INT, " %5d", "", i + 1);
2121 /* Display average values */
2122 cprintf_f(NO_UNIT, 2, 9, 2,
2123 (double) avg_fan[i] / avg_count,
2124 (double) (avg_fan[i] - avg_fan_min[i]) / avg_count);
2127 /* Display instantaneous values */
2128 cprintf_f(NO_UNIT, 2, 9, 2,
2130 spc->rpm - spc->rpm_min);
2131 avg_fan[i] += spc->rpm;
2132 avg_fan_min[i] += spc->rpm_min;
2135 cprintf_in(IS_STR, " %s\n", spc->device, 0);
2138 if (dispavg && avg_fan) {
2148 ***************************************************************************
2149 * Display fan statistics.
2152 * @a Activity structure with statistics.
2153 * @prev Index in array where stats used as reference are.
2154 * @curr Index in array for current sample statistics.
2155 * @itv Interval of time in 1/100th of a second.
2156 ***************************************************************************
2158 __print_funct_t print_pwr_fan_stats(struct activity *a, int prev, int curr,
2159 unsigned long long itv)
2161 stub_print_pwr_fan_stats(a, curr, FALSE);
2165 ***************************************************************************
2166 * Display average fan statistics.
2169 * @a Activity structure with statistics.
2170 * @prev Index in array where stats used as reference are.
2171 * @curr Index in array for current sample statistics.
2172 * @itv Interval of time in 1/100th of a second.
2173 ***************************************************************************
2175 __print_funct_t print_avg_pwr_fan_stats(struct activity *a, int prev, int curr,
2176 unsigned long long itv)
2178 stub_print_pwr_fan_stats(a, curr, TRUE);
2182 ***************************************************************************
2183 * Display device temperature statistics. This function is used to display
2184 * instantaneous and average statistics.
2187 * @a Activity structure with statistics.
2188 * @curr Index in array for current sample statistics.
2189 * @dispavg True if displaying average statistics.
2190 ***************************************************************************
2192 void stub_print_pwr_temp_stats(struct activity *a, int curr, int dispavg)
2195 struct stats_pwr_temp *spc;
2196 static __nr_t nr_alloc = 0;
2197 static double *avg_temp = NULL;
2198 static double *avg_temp_min = NULL, *avg_temp_max = NULL;
2200 /* Allocate arrays of temperatures */
2201 if (!avg_temp || (a->nr[curr] > nr_alloc)) {
2202 SREALLOC(avg_temp, double, sizeof(double) * a->nr[curr]);
2203 SREALLOC(avg_temp_min, double, sizeof(double) * a->nr[curr]);
2204 SREALLOC(avg_temp_max, double, sizeof(double) * a->nr[curr]);
2206 if (a->nr[curr] > nr_alloc) {
2207 /* Init additional space allocated */
2208 memset(avg_temp + nr_alloc, 0,
2209 sizeof(double) * (a->nr[curr] - nr_alloc));
2210 memset(avg_temp_min + nr_alloc, 0,
2211 sizeof(double) * (a->nr[curr] - nr_alloc));
2212 memset(avg_temp_max + nr_alloc, 0,
2213 sizeof(double) * (a->nr[curr] - nr_alloc));
2215 nr_alloc = a->nr[curr];
2219 print_hdr_line(timestamp[!curr], a, FIRST, -2, 9);
2222 for (i = 0; i < a->nr[curr]; i++) {
2223 spc = (struct stats_pwr_temp *) ((char *) a->buf[curr] + i * a->msize);
2225 printf("%-11s", timestamp[curr]);
2226 cprintf_in(IS_INT, " %5d", "", i + 1);
2229 /* Display average values */
2230 cprintf_f(NO_UNIT, 1, 9, 2, (double) avg_temp[i] / avg_count);
2231 cprintf_pc(DISPLAY_UNIT(flags), 1, 9, 2,
2232 (avg_temp_max[i] - avg_temp_min[i]) ?
2233 ((double) (avg_temp[i] / avg_count) - avg_temp_min[i]) / (avg_temp_max[i] - avg_temp_min[i]) * 100
2237 /* Display instantaneous values */
2238 cprintf_f(NO_UNIT, 1, 9, 2, spc->temp);
2239 cprintf_pc(DISPLAY_UNIT(flags), 1, 9, 2,
2240 (spc->temp_max - spc->temp_min) ?
2241 (spc->temp - spc->temp_min) / (spc->temp_max - spc->temp_min) * 100
2243 avg_temp[i] += spc->temp;
2244 /* Assume that min and max temperatures cannot vary */
2245 avg_temp_min[i] = spc->temp_min;
2246 avg_temp_max[i] = spc->temp_max;
2249 cprintf_in(IS_STR, " %s\n", spc->device, 0);
2252 if (dispavg && avg_temp) {
2257 avg_temp_min = NULL;
2258 avg_temp_max = NULL;
2264 ***************************************************************************
2265 * Display temperature statistics.
2268 * @a Activity structure with statistics.
2269 * @prev Index in array where stats used as reference are.
2270 * @curr Index in array for current sample statistics.
2271 * @itv Interval of time in 1/100th of a second.
2272 ***************************************************************************
2274 __print_funct_t print_pwr_temp_stats(struct activity *a, int prev, int curr,
2275 unsigned long long itv)
2277 stub_print_pwr_temp_stats(a, curr, FALSE);
2281 ***************************************************************************
2282 * Display average temperature statistics.
2285 * @a Activity structure with statistics.
2286 * @prev Index in array where stats used as reference are.
2287 * @curr Index in array for current sample statistics.
2288 * @itv Interval of time in 1/100th of a second.
2289 ***************************************************************************
2291 __print_funct_t print_avg_pwr_temp_stats(struct activity *a, int prev, int curr,
2292 unsigned long long itv)
2294 stub_print_pwr_temp_stats(a, curr, TRUE);
2298 ***************************************************************************
2299 * Display voltage inputs statistics. This function is used to display
2300 * instantaneous and average statistics.
2303 * @a Activity structure with statistics.
2304 * @curr Index in array for current sample statistics.
2305 * @dispavg True if displaying average statistics.
2306 ***************************************************************************
2308 void stub_print_pwr_in_stats(struct activity *a, int curr, int dispavg)
2311 struct stats_pwr_in *spc;
2312 static __nr_t nr_alloc = 0;
2313 static double *avg_in = NULL;
2314 static double *avg_in_min = NULL, *avg_in_max = NULL;
2316 /* Allocate arrays of voltage inputs */
2317 if (!avg_in || (a->nr[curr] > nr_alloc)) {
2318 SREALLOC(avg_in, double, sizeof(double) * a->nr[curr]);
2319 SREALLOC(avg_in_min, double, sizeof(double) * a->nr[curr]);
2320 SREALLOC(avg_in_max, double, sizeof(double) * a->nr[curr]);
2322 if (a->nr[curr] > nr_alloc) {
2323 /* Init additional space allocated */
2324 memset(avg_in + nr_alloc, 0,
2325 sizeof(double) * (a->nr[curr] - nr_alloc));
2326 memset(avg_in_min + nr_alloc, 0,
2327 sizeof(double) * (a->nr[curr] - nr_alloc));
2328 memset(avg_in_max + nr_alloc, 0,
2329 sizeof(double) * (a->nr[curr] - nr_alloc));
2331 nr_alloc = a->nr[curr];
2335 print_hdr_line(timestamp[!curr], a, FIRST, -2, 9);
2338 for (i = 0; i < a->nr[curr]; i++) {
2339 spc = (struct stats_pwr_in *) ((char *) a->buf[curr] + i * a->msize);
2341 printf("%-11s", timestamp[curr]);
2342 cprintf_in(IS_INT, " %5d", "", i);
2345 /* Display average values */
2346 cprintf_f(NO_UNIT, 1, 9, 2, (double) avg_in[i] / avg_count);
2347 cprintf_pc(DISPLAY_UNIT(flags), 1, 9, 2,
2348 (avg_in_max[i] - avg_in_min[i]) ?
2349 ((double) (avg_in[i] / avg_count) - avg_in_min[i]) / (avg_in_max[i] - avg_in_min[i]) * 100
2353 /* Display instantaneous values */
2354 cprintf_f(NO_UNIT, 1, 9, 2, spc->in);
2355 cprintf_pc(DISPLAY_UNIT(flags), 1, 9, 2,
2356 (spc->in_max - spc->in_min) ?
2357 (spc->in - spc->in_min) / (spc->in_max - spc->in_min) * 100
2359 avg_in[i] += spc->in;
2360 /* Assume that min and max voltage inputs cannot vary */
2361 avg_in_min[i] = spc->in_min;
2362 avg_in_max[i] = spc->in_max;
2365 cprintf_in(IS_STR, " %s\n", spc->device, 0);
2368 if (dispavg && avg_in) {
2380 ***************************************************************************
2381 * Display voltage inputs statistics.
2384 * @a Activity structure with statistics.
2385 * @prev Index in array where stats used as reference are.
2386 * @curr Index in array for current sample statistics.
2387 * @itv Interval of time in 1/100th of a second.
2388 ***************************************************************************
2390 __print_funct_t print_pwr_in_stats(struct activity *a, int prev, int curr,
2391 unsigned long long itv)
2393 stub_print_pwr_in_stats(a, curr, FALSE);
2397 ***************************************************************************
2398 * Display average voltage inputs statistics.
2401 * @a Activity structure with statistics.
2402 * @prev Index in array where stats used as reference are.
2403 * @curr Index in array for current sample statistics.
2404 * @itv Interval of time in 1/100th of a second.
2405 ***************************************************************************
2407 __print_funct_t print_avg_pwr_in_stats(struct activity *a, int prev, int curr,
2408 unsigned long long itv)
2410 stub_print_pwr_in_stats(a, curr, TRUE);
2414 ***************************************************************************
2415 * Display huge pages statistics. This function is used to
2416 * display instantaneous and average statistics.
2419 * @a Activity structure with statistics.
2420 * @curr Index in array for current sample statistics.
2421 * @dispavg TRUE if displaying average statistics.
2422 ***************************************************************************
2424 void stub_print_huge_stats(struct activity *a, int curr, int dispavg)
2427 *smc = (struct stats_huge *) a->buf[curr];
2428 static unsigned long long
2435 if (DISPLAY_UNIT(flags)) {
2436 /* Default values unit is kB */
2437 unit = UNIT_KILOBYTE;
2441 print_hdr_line(timestamp[!curr], a, FIRST, 0, 9);
2445 /* Display instantaneous values */
2446 printf("%-11s", timestamp[curr]);
2447 cprintf_u64(unit, 2, 9,
2448 (unsigned long long) smc->frhkb,
2449 (unsigned long long) (smc->tlhkb - smc->frhkb));
2450 cprintf_pc(DISPLAY_UNIT(flags), 1, 9, 2,
2452 SP_VALUE(smc->frhkb, smc->tlhkb, smc->tlhkb) : 0.0);
2453 cprintf_u64(unit, 2, 9,
2454 (unsigned long long) smc->rsvdhkb,
2455 (unsigned long long) (smc->surphkb));
2458 /* Will be used to compute the average */
2459 avg_frhkb += smc->frhkb;
2460 avg_tlhkb += smc->tlhkb;
2461 avg_rsvdhkb += smc->rsvdhkb;
2462 avg_surphkb += smc->surphkb;
2465 /* Display average values */
2466 printf("%-11s", timestamp[curr]);
2467 cprintf_f(unit, 2, 9, 0,
2468 (double) avg_frhkb / avg_count,
2469 ((double) avg_tlhkb / avg_count) -
2470 ((double) avg_frhkb / avg_count));
2471 cprintf_pc(DISPLAY_UNIT(flags), 1, 9, 2,
2473 SP_VALUE((double) avg_frhkb / avg_count,
2474 (double) avg_tlhkb / avg_count,
2475 (double) avg_tlhkb / avg_count) : 0.0);
2476 cprintf_f(unit, 2, 9, 0,
2477 (double) avg_rsvdhkb / avg_count,
2478 (double) avg_surphkb / avg_count);
2481 /* Reset average counters */
2482 avg_frhkb = avg_tlhkb = avg_rsvdhkb = avg_surphkb = 0;
2487 ***************************************************************************
2488 * Display huge pages statistics.
2491 * @a Activity structure with statistics.
2492 * @prev Index in array where stats used as reference are.
2493 * @curr Index in array for current sample statistics.
2494 * @itv Interval of time in 1/100th of a second.
2495 ***************************************************************************
2497 __print_funct_t print_huge_stats(struct activity *a, int prev, int curr,
2498 unsigned long long itv)
2500 stub_print_huge_stats(a, curr, FALSE);
2504 ***************************************************************************
2505 * Display huge pages statistics.
2508 * @a Activity structure with statistics.
2509 * @prev Index in array where stats used as reference are.
2510 * @curr Index in array for current sample statistics.
2511 * @itv Interval of time in 1/100th of a second.
2512 ***************************************************************************
2514 __print_funct_t print_avg_huge_stats(struct activity *a, int prev, int curr,
2515 unsigned long long itv)
2517 stub_print_huge_stats(a, curr, TRUE);
2521 ***************************************************************************
2522 * Display CPU weighted frequency statistics. This function is used to
2523 * display instantaneous and average statistics.
2526 * @a Activity structure with statistics.
2527 * @prev Index in array where stats used as reference are.
2528 * @curr Index in array for current sample statistics.
2529 * @itv Interval of time in 1/100th of a second.
2530 ***************************************************************************
2532 void print_pwr_wghfreq_stats(struct activity *a, int prev, int curr,
2533 unsigned long long itv)
2536 struct stats_pwr_wghfreq *spc, *spp, *spc_k, *spp_k;
2537 unsigned long long tis, tisfreq;
2540 print_hdr_line(timestamp[!curr], a, FIRST, 7, 9);
2543 for (i = 0; (i < a->nr[curr]) && (i < a->bitmap->b_size + 1); i++) {
2546 * The size of a->buf[...] CPU structure may be different from the default
2547 * sizeof(struct stats_pwr_wghfreq) value if data have been read from a file!
2548 * That's why we don't use a syntax like:
2549 * spc = (struct stats_pwr_wghfreq *) a->buf[...] + i;
2551 spc = (struct stats_pwr_wghfreq *) ((char *) a->buf[curr] + i * a->msize * a->nr2);
2552 spp = (struct stats_pwr_wghfreq *) ((char *) a->buf[prev] + i * a->msize * a->nr2);
2555 * Note: a->nr is in [1, NR_CPUS + 1].
2556 * Bitmap size is provided for (NR_CPUS + 1) CPUs.
2557 * Anyway, NR_CPUS may vary between the version of sysstat
2558 * used by sadc to create a file, and the version of sysstat
2559 * used by sar to read it...
2562 /* Should current CPU (including CPU "all") be displayed? */
2563 if (!(a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))))
2567 /* Yes: Display it */
2568 printf("%-11s", timestamp[curr]);
2571 /* This is CPU "all" */
2572 cprintf_in(IS_STR, "%s", " all", 0);
2575 cprintf_in(IS_INT, " %3d", "", i - 1);
2581 for (k = 0; k < a->nr2; k++) {
2583 spc_k = (struct stats_pwr_wghfreq *) ((char *) spc + k * a->msize);
2586 spp_k = (struct stats_pwr_wghfreq *) ((char *) spp + k * a->msize);
2588 tisfreq += (spc_k->freq / 1000) *
2589 (spc_k->time_in_state - spp_k->time_in_state);
2590 tis += (spc_k->time_in_state - spp_k->time_in_state);
2593 /* Display weighted frequency for current CPU */
2594 cprintf_f(NO_UNIT, 1, 9, 2,
2595 tis ? ((double) tisfreq) / tis : 0.0);
2601 ***************************************************************************
2602 * Display USB devices statistics. This function is used to
2603 * display instantaneous and summary statistics.
2606 * @a Activity structure with statistics.
2607 * @curr Index in array for current sample statistics.
2608 * @dispavg TRUE if displaying average statistics.
2609 ***************************************************************************
2611 void stub_print_pwr_usb_stats(struct activity *a, int curr, int dispavg)
2615 struct stats_pwr_usb *suc, *sum;
2618 printf("\n%-11s BUS idvendor idprod maxpower",
2619 (dispavg ? _("Summary:") : timestamp[!curr]));
2620 printf(" %-*s product\n", MAX_MANUF_LEN - 1, "manufact");
2623 for (i = 0; i < a->nr[curr]; i++) {
2624 suc = (struct stats_pwr_usb *) ((char *) a->buf[curr] + i * a->msize);
2626 printf("%-11s", (dispavg ? _("Summary:") : timestamp[curr]));
2627 cprintf_in(IS_INT, " %6d", "", suc->bus_nr);
2631 cprintf_u64(NO_UNIT, 1, 9,
2632 /* bMaxPower is expressed in 2 mA units */
2633 (unsigned long long) (suc->bmaxpower << 1));
2635 snprintf(fmt, 16, " %%-%ds", MAX_MANUF_LEN - 1);
2636 cprintf_s(IS_STR, fmt, suc->manufacturer);
2637 cprintf_s(IS_STR, " %s\n", suc->product);
2640 /* Save current USB device in summary list */
2641 for (j = 0; j < a->nr_allocated; j++) {
2642 sum = (struct stats_pwr_usb *) ((char *) a->buf[2] + j * a->msize);
2644 if ((sum->bus_nr == suc->bus_nr) &&
2645 (sum->vendor_id == suc->vendor_id) &&
2646 (sum->product_id == suc->product_id))
2647 /* USB device found in summary list */
2651 * Current slot is free:
2652 * Save USB device in summary list.
2659 if (j == a->nr_allocated) {
2661 * No free slot has been found for current device.
2662 * So enlarge buffers then save device in list.
2664 reallocate_all_buffers(a, j);
2665 sum = (struct stats_pwr_usb *) ((char *) a->buf[2] + j * a->msize);
2674 ***************************************************************************
2675 * Display USB devices statistics.
2678 * @a Activity structure with statistics.
2679 * @prev Index in array where stats used as reference are.
2680 * @curr Index in array for current sample statistics.
2681 * @itv Interval of time in 1/100th of a second.
2682 ***************************************************************************
2684 __print_funct_t print_pwr_usb_stats(struct activity *a, int prev, int curr,
2685 unsigned long long itv)
2687 stub_print_pwr_usb_stats(a, curr, FALSE);
2691 ***************************************************************************
2692 * Display average USB devices statistics.
2695 * @a Activity structure with statistics.
2696 * @prev Index in array where stats used as reference are.
2697 * @curr Index in array for current sample statistics.
2698 * @itv Interval of time in 1/100th of a second.
2699 ***************************************************************************
2701 __print_funct_t print_avg_pwr_usb_stats(struct activity *a, int prev, int curr,
2702 unsigned long long itv)
2704 stub_print_pwr_usb_stats(a, 2, TRUE);
2708 ***************************************************************************
2709 * Display filesystems statistics. This function is used to
2710 * display instantaneous and average statistics.
2713 * @a Activity structure with statistics.
2714 * @prev Index in array where stats used as reference are.
2715 * @curr Index in array for current sample statistics.
2716 * @dispavg TRUE if displaying average statistics.
2717 ***************************************************************************
2719 __print_funct_t stub_print_filesystem_stats(struct activity *a, int prev, int curr, int dispavg)
2721 int i, j, j0, found;
2722 struct stats_filesystem *sfc, *sfp, *sfm;
2725 if (DISPLAY_UNIT(flags)) {
2726 /* Default values unit is B */
2730 if (dis || DISPLAY_ZERO_OMIT(flags)) {
2731 print_hdr_line((dispavg ? _("Summary:") : timestamp[!curr]),
2732 a, FIRST + DISPLAY_MOUNT(a->opt_flags), -1, 9);
2735 for (i = 0; i < a->nr[curr]; i++) {
2736 sfc = (struct stats_filesystem *) ((char *) a->buf[curr] + i * a->msize);
2738 if (a->item_list != NULL) {
2739 /* A list of devices has been entered on the command line */
2740 if (!search_list_item(a->item_list,
2741 DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name))
2742 /* Device not found */
2747 if (DISPLAY_ZERO_OMIT(flags) && !dispavg) {
2749 if (a->nr[prev] > 0) {
2750 /* Look for corresponding fs in previous iteration */
2753 if (j >= a->nr[prev]) {
2754 j = a->nr[prev] - 1;
2760 sfp = (struct stats_filesystem *) ((char *) a->buf[prev] + j * a->msize);
2761 if (!strcmp(sfp->fs_name, sfc->fs_name)) {
2765 if (++j >= a->nr[prev]) {
2773 if (!DISPLAY_ZERO_OMIT(flags) || dispavg || WANT_SINCE_BOOT(flags) || !found ||
2774 (found && memcmp(sfp, sfc, STATS_FILESYSTEM_SIZE2CMP))) {
2776 printf("%-11s", (dispavg ? _("Summary:") : timestamp[curr]));
2777 cprintf_f(unit, 2, 9, 0,
2778 unit < 0 ? (double) sfc->f_bfree / 1024 / 1024 : (double) sfc->f_bfree,
2779 unit < 0 ? (double) (sfc->f_blocks - sfc->f_bfree) / 1024 / 1024 :
2780 (double) (sfc->f_blocks - sfc->f_bfree));
2781 cprintf_pc(DISPLAY_UNIT(flags), 2, 9, 2,
2782 /* f_blocks is not zero. But test it anyway ;-) */
2783 sfc->f_blocks ? SP_VALUE(sfc->f_bfree, sfc->f_blocks, sfc->f_blocks)
2785 sfc->f_blocks ? SP_VALUE(sfc->f_bavail, sfc->f_blocks, sfc->f_blocks)
2787 cprintf_u64(NO_UNIT, 2, 9,
2788 (unsigned long long) sfc->f_ffree,
2789 (unsigned long long) (sfc->f_files - sfc->f_ffree));
2790 cprintf_pc(DISPLAY_UNIT(flags), 1, 9, 2,
2791 sfc->f_files ? SP_VALUE(sfc->f_ffree, sfc->f_files, sfc->f_files)
2793 cprintf_in(IS_STR, " %s\n",
2794 DISPLAY_MOUNT(a->opt_flags) ? sfc->mountp : sfc->fs_name, 0);
2798 /* Save current filesystem in summary list */
2799 for (j = 0; j < a->nr_allocated; j++) {
2800 sfm = (struct stats_filesystem *) ((char *) a->buf[2] + j * a->msize);
2802 if (!strcmp(sfm->fs_name, sfc->fs_name) ||
2805 * Filesystem found in list (then save again its stats)
2806 * or free slot (end of list).
2809 if (j >= a->nr[2]) {
2815 if (j == a->nr_allocated) {
2817 * No free slot has been found for current filesystem.
2818 * So enlarge buffers then save filesystem in list.
2820 reallocate_all_buffers(a, j);
2821 sfm = (struct stats_filesystem *) ((char *) a->buf[2] + j * a->msize);
2830 ***************************************************************************
2831 * Display filesystems statistics.
2834 * @a Activity structure with statistics.
2835 * @prev Index in array where stats used as reference are.
2836 * @curr Index in array for current sample statistics.
2837 * @itv Interval of time in 1/100th of a second.
2838 ***************************************************************************
2840 __print_funct_t print_filesystem_stats(struct activity *a, int prev, int curr,
2841 unsigned long long itv)
2843 stub_print_filesystem_stats(a, prev, curr, FALSE);
2847 ***************************************************************************
2848 * Display average filesystems statistics.
2851 * @a Activity structure with statistics.
2852 * @prev Index in array where stats used as reference are.
2853 * @curr Index in array for current sample statistics.
2854 * @itv Interval of time in 1/100th of a second.
2855 ***************************************************************************
2857 __print_funct_t print_avg_filesystem_stats(struct activity *a, int prev, int curr,
2858 unsigned long long itv)
2860 stub_print_filesystem_stats(a, prev, 2, TRUE);
2864 ***************************************************************************
2865 * Display Fibre Channel HBA statistics.
2868 * @a Activity structure with statistics.
2869 * @prev Index in array where stats used as reference are.
2870 * @curr Index in array for current sample statistics.
2871 * @itv Interval of time in 1/100th of a second.
2872 ***************************************************************************
2874 __print_funct_t print_fchost_stats(struct activity *a, int prev, int curr,
2875 unsigned long long itv)
2877 int i, j, j0, found;
2878 struct stats_fchost *sfcc, *sfcp;
2881 print_hdr_line(timestamp[!curr], a, FIRST, -1, 9);
2884 for (i = 0; i < a->nr[curr]; i++) {
2885 sfcc = (struct stats_fchost *) ((char *) a->buf[curr] + i * a->msize);
2887 if (WANT_SINCE_BOOT(flags)) {
2888 sfcp = (struct stats_fchost *) ((char *) a->buf[prev]);
2894 if (a->nr[prev] > 0) {
2895 /* Look for corresponding structure in previous iteration */
2898 if (j >= a->nr[prev]) {
2899 j = a->nr[prev] - 1;
2905 sfcp = (struct stats_fchost *) ((char *) a->buf[prev] + j * a->msize);
2906 if (!strcmp(sfcc->fchost_name, sfcp->fchost_name)) {
2911 if (++j >= a->nr[prev]) {
2922 printf("%-11s", timestamp[curr]);
2923 cprintf_f(NO_UNIT, 4, 9, 2,
2924 S_VALUE(sfcp->f_rxframes, sfcc->f_rxframes, itv),
2925 S_VALUE(sfcp->f_txframes, sfcc->f_txframes, itv),
2926 S_VALUE(sfcp->f_rxwords, sfcc->f_rxwords, itv),
2927 S_VALUE(sfcp->f_txwords, sfcc->f_txwords, itv));
2928 cprintf_in(IS_STR, " %s\n", sfcc->fchost_name, 0);
2933 ***************************************************************************
2934 * Display softnet statistics.
2937 * @a Activity structure with statistics.
2938 * @prev Index in array where stats used as reference are.
2939 * @curr Index in array for current sample statistics.
2940 * @itv Interval of time in 1/100th of a second.
2941 ***************************************************************************
2943 __print_funct_t print_softnet_stats(struct activity *a, int prev, int curr,
2944 unsigned long long itv)
2947 struct stats_softnet
2948 *ssnc = (struct stats_softnet *) a->buf[curr],
2949 *ssnp = (struct stats_softnet *) a->buf[prev];
2950 unsigned char offline_cpu_bitmap[BITMAP_SIZE(NR_CPUS)] = {0};
2952 if (dis || DISPLAY_ZERO_OMIT(flags)) {
2953 print_hdr_line(timestamp[!curr], a, FIRST, 7, 9);
2957 * @nr[curr] cannot normally be greater than @nr_ini
2958 * (since @nr_ini counts up all CPU, even those offline).
2959 * If this happens, it may be because the machine has been
2960 * restarted with more CPU and no LINUX_RESTART has been
2963 if (a->nr[curr] > a->nr_ini) {
2964 a->nr_ini = a->nr[curr];
2967 /* Compute statistics for CPU "all" */
2968 get_global_soft_statistics(a, prev, curr, flags, offline_cpu_bitmap);
2970 for (i = 0; (i < a->nr_ini) && (i < a->bitmap->b_size + 1); i++) {
2973 * Should current CPU (including CPU "all") be displayed?
2974 * Note: a->nr is in [1, NR_CPUS + 1].
2975 * Bitmap size is provided for (NR_CPUS + 1) CPUs.
2976 * Anyway, NR_CPUS may vary between the version of sysstat
2977 * used by sadc to create a file, and the version of sysstat
2978 * used by sar to read it...
2980 if (!(a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))) ||
2981 offline_cpu_bitmap[i >> 3] & (1 << (i & 0x07)))
2985 * The size of a->buf[...] CPU structure may be different from the default
2986 * sizeof(struct stats_pwr_cpufreq) value if data have been read from a file!
2987 * That's why we don't use a syntax like:
2988 * ssnc = (struct stats_softnet *) a->buf[...] + i;
2990 ssnc = (struct stats_softnet *) ((char *) a->buf[curr] + i * a->msize);
2991 ssnp = (struct stats_softnet *) ((char *) a->buf[prev] + i * a->msize);
2993 if (DISPLAY_ZERO_OMIT(flags) && !memcmp(ssnp, ssnc, STATS_SOFTNET_SIZE))
2996 printf("%-11s", timestamp[curr]);
2999 /* This is CPU "all" */
3000 cprintf_in(IS_STR, " %s", " all", 0);
3003 cprintf_in(IS_INT, " %7d", "", i - 1);
3006 cprintf_f(NO_UNIT, 5, 9, 2,
3007 S_VALUE(ssnp->processed, ssnc->processed, itv),
3008 S_VALUE(ssnp->dropped, ssnc->dropped, itv),
3009 S_VALUE(ssnp->time_squeeze, ssnc->time_squeeze, itv),
3010 S_VALUE(ssnp->received_rps, ssnc->received_rps, itv),
3011 S_VALUE(ssnp->flow_limit, ssnc->flow_limit, itv));