2 * sysstat - sa_wrap.c: Functions used in activity.c
3 * (C) 1999-2023 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 ***************************************************************************
28 extern unsigned int flags;
29 extern struct record_header record_hdr;
32 ***************************************************************************
33 * Reallocate buffer where statistics will be saved. The new size is the
34 * double of the original one.
35 * This is typically called when we find that current buffer is too small
36 * to save all the data.
39 * @a Activity structure.
42 * New pointer address on buffer.
43 ***************************************************************************
45 void *reallocate_buffer(struct activity *a)
47 SREALLOC(a->_buf0, void,
48 (size_t) a->msize * (size_t) a->nr_allocated * 2); /* a->nr2 value is 1 */
49 memset(a->_buf0, 0, (size_t) a->msize * (size_t) a->nr_allocated * 2);
51 a->nr_allocated *= 2; /* NB: nr_allocated > 0 */
57 ***************************************************************************
58 * Read CPU statistics.
61 * @a Activity structure.
64 * @a Activity structure with statistics.
65 ***************************************************************************
67 __read_funct_t wrap_read_stat_cpu(struct activity *a)
69 struct stats_cpu *st_cpu
70 = (struct stats_cpu *) a->_buf0;
73 /* Read CPU statistics */
75 nr_read = read_stat_cpu(st_cpu, a->nr_allocated);
78 /* Buffer needs to be reallocated */
79 st_cpu = (struct stats_cpu *) reallocate_buffer(a);
90 ***************************************************************************
91 * Read process (task) creation and context switch statistics.
94 * @a Activity structure.
97 * @a Activity structure with statistics.
98 ***************************************************************************
100 __read_funct_t wrap_read_stat_pcsw(struct activity *a)
102 struct stats_pcsw *st_pcsw
103 = (struct stats_pcsw *) a->_buf0;
105 /* Read process and context switch stats */
106 read_stat_pcsw(st_pcsw);
112 ***************************************************************************
113 * Read interrupt statistics.
116 * @a Activity structure.
119 * @a Activity structure with statistics.
120 ***************************************************************************
122 __read_funct_t wrap_read_stat_irq(struct activity *a)
124 struct stats_irq *st_irq
125 = (struct stats_irq *) a->_buf0;
128 /* Read interrupts stats */
130 nr_read = read_stat_irq(st_irq, a->nr_allocated, a->nr2);
133 /* Buffer needs to be reallocated (for CPU, not interrupts) */
134 st_irq = (struct stats_irq *) reallocate_buffer(a);
145 ***************************************************************************
146 * Read queue and load statistics.
149 * @a Activity structure.
152 * @a Activity structure with statistics.
153 ***************************************************************************
155 __read_funct_t wrap_read_loadavg(struct activity *a)
157 struct stats_queue *st_queue
158 = (struct stats_queue *) a->_buf0;
160 /* Read queue and load stats */
161 read_loadavg(st_queue);
167 ***************************************************************************
168 * Read memory statistics.
171 * @a Activity structure.
174 * @a Activity structure with statistics.
175 ***************************************************************************
177 __read_funct_t wrap_read_meminfo(struct activity *a)
179 struct stats_memory *st_memory
180 = (struct stats_memory *) a->_buf0;
182 /* Read memory stats */
183 read_meminfo(st_memory);
189 ***************************************************************************
190 * Read swapping statistics.
193 * @a Activity structure.
196 * @a Activity structure with statistics.
197 ***************************************************************************
199 __read_funct_t wrap_read_swap(struct activity *a)
201 struct stats_swap *st_swap
202 = (struct stats_swap *) a->_buf0;
204 /* Read stats from /proc/vmstat */
205 read_vmstat_swap(st_swap);
211 ***************************************************************************
212 * Read paging statistics.
215 * @a Activity structure.
218 * @a Activity structure with statistics.
219 ***************************************************************************
221 __read_funct_t wrap_read_paging(struct activity *a)
223 struct stats_paging *st_paging
224 = (struct stats_paging *) a->_buf0;
226 /* Read stats from /proc/vmstat */
227 read_vmstat_paging(st_paging);
233 ***************************************************************************
234 * Read I/O and transfer rates statistics.
237 * @a Activity structure.
240 * @a Activity structure with statistics.
241 ***************************************************************************
243 __read_funct_t wrap_read_io(struct activity *a)
245 struct stats_io *st_io
246 = (struct stats_io *) a->_buf0;
248 /* Read stats from /proc/diskstats */
249 read_diskstats_io(st_io);
255 ***************************************************************************
256 * Read block devices statistics.
259 * @a Activity structure.
262 * @a Activity structure with statistics.
263 ***************************************************************************
265 __read_funct_t wrap_read_disk(struct activity *a)
267 struct stats_disk *st_disk
268 = (struct stats_disk *) a->_buf0;
271 /* Read stats from /proc/diskstats */
273 nr_read = read_diskstats_disk(st_disk, a->nr_allocated,
274 COLLECT_PARTITIONS(a->opt_flags));
277 /* Buffer needs to be reallocated */
278 st_disk = (struct stats_disk *) reallocate_buffer(a);
289 ***************************************************************************
290 * Read serial lines statistics.
293 * @a Activity structure.
296 * @a Activity structure with statistics.
297 ***************************************************************************
299 __read_funct_t wrap_read_tty_driver_serial(struct activity *a)
301 struct stats_serial *st_serial
302 = (struct stats_serial *) a->_buf0;
305 /* Read serial lines stats */
307 nr_read = read_tty_driver_serial(st_serial, a->nr_allocated);
310 /* Buffer needs to be reallocated */
311 st_serial = (struct stats_serial *) reallocate_buffer(a);
322 ***************************************************************************
323 * Read kernel tables statistics.
326 * @a Activity structure.
329 * @a Activity structure with statistics.
330 ***************************************************************************
332 __read_funct_t wrap_read_kernel_tables(struct activity *a)
334 struct stats_ktables *st_ktables
335 = (struct stats_ktables *) a->_buf0;
337 /* Read kernel tables stats */
338 read_kernel_tables(st_ktables);
344 ***************************************************************************
345 * Read network interfaces statistics.
348 * @a Activity structure.
351 * @a Activity structure with statistics.
352 ***************************************************************************
354 __read_funct_t wrap_read_net_dev(struct activity *a)
356 struct stats_net_dev *st_net_dev
357 = (struct stats_net_dev *) a->_buf0;
360 /* Read network interfaces stats */
362 nr_read = read_net_dev(st_net_dev, a->nr_allocated);
365 /* Buffer needs to be reallocated */
366 st_net_dev = (struct stats_net_dev *) reallocate_buffer(a);
374 /* No data read. Exit */
377 /* Read duplex and speed info for each interface */
378 read_if_info(st_net_dev, nr_read);
384 ***************************************************************************
385 * Read network interfaces errors statistics.
388 * @a Activity structure.
391 * @a Activity structure with statistics.
392 ***************************************************************************
394 __read_funct_t wrap_read_net_edev(struct activity *a)
396 struct stats_net_edev *st_net_edev
397 = (struct stats_net_edev *) a->_buf0;
400 /* Read network interfaces errors stats */
402 nr_read = read_net_edev(st_net_edev, a->nr_allocated);
405 /* Buffer needs to be reallocated */
406 st_net_edev = (struct stats_net_edev *) reallocate_buffer(a);
417 ***************************************************************************
418 * Read NFS client statistics.
421 * @a Activity structure.
424 * @a Activity structure with statistics.
425 ***************************************************************************
427 __read_funct_t wrap_read_net_nfs(struct activity *a)
429 struct stats_net_nfs *st_net_nfs
430 = (struct stats_net_nfs *) a->_buf0;
432 /* Read NFS client stats */
433 read_net_nfs(st_net_nfs);
439 ***************************************************************************
440 * Read NFS server statistics.
443 * @a Activity structure.
446 * @a Activity structure with statistics.
447 ***************************************************************************
449 __read_funct_t wrap_read_net_nfsd(struct activity *a)
451 struct stats_net_nfsd *st_net_nfsd
452 = (struct stats_net_nfsd *) a->_buf0;
454 /* Read NFS server stats */
455 read_net_nfsd(st_net_nfsd);
461 ***************************************************************************
462 * Read network sockets statistics.
465 * @a Activity structure.
468 * @a Activity structure with statistics.
469 ***************************************************************************
471 __read_funct_t wrap_read_net_sock(struct activity *a)
473 struct stats_net_sock *st_net_sock
474 = (struct stats_net_sock *) a->_buf0;
476 /* Read network sockets stats */
477 read_net_sock(st_net_sock);
483 ***************************************************************************
484 * Read IP statistics.
487 * @a Activity structure.
490 * @a Activity structure with statistics.
491 ***************************************************************************
493 __read_funct_t wrap_read_net_ip(struct activity *a)
495 struct stats_net_ip *st_net_ip
496 = (struct stats_net_ip *) a->_buf0;
499 read_net_ip(st_net_ip);
505 ***************************************************************************
506 * Read IP error statistics.
509 * @a Activity structure.
512 * @a Activity structure with statistics.
513 ***************************************************************************
515 __read_funct_t wrap_read_net_eip(struct activity *a)
517 struct stats_net_eip *st_net_eip
518 = (struct stats_net_eip *) a->_buf0;
520 /* Read IP error stats */
521 read_net_eip(st_net_eip);
527 ***************************************************************************
528 * Read ICMP statistics.
531 * @a Activity structure.
534 * @a Activity structure with statistics.
535 ***************************************************************************
537 __read_funct_t wrap_read_net_icmp(struct activity *a)
539 struct stats_net_icmp *st_net_icmp
540 = (struct stats_net_icmp *) a->_buf0;
542 /* Read ICMP stats */
543 read_net_icmp(st_net_icmp);
549 ***************************************************************************
550 * Read ICMP error statistics.
553 * @a Activity structure.
556 * @a Activity structure with statistics.
557 ***************************************************************************
559 __read_funct_t wrap_read_net_eicmp(struct activity *a)
561 struct stats_net_eicmp *st_net_eicmp
562 = (struct stats_net_eicmp *) a->_buf0;
564 /* Read ICMP error stats */
565 read_net_eicmp(st_net_eicmp);
571 ***************************************************************************
572 * Read TCP statistics.
575 * @a Activity structure.
578 * @a Activity structure with statistics.
579 ***************************************************************************
581 __read_funct_t wrap_read_net_tcp(struct activity *a)
583 struct stats_net_tcp *st_net_tcp
584 = (struct stats_net_tcp *) a->_buf0;
587 read_net_tcp(st_net_tcp);
593 ***************************************************************************
594 * Read TCP error statistics.
597 * @a Activity structure.
600 * @a Activity structure with statistics.
601 ***************************************************************************
603 __read_funct_t wrap_read_net_etcp(struct activity *a)
605 struct stats_net_etcp *st_net_etcp
606 = (struct stats_net_etcp *) a->_buf0;
608 /* Read TCP error stats */
609 read_net_etcp(st_net_etcp);
615 ***************************************************************************
616 * Read UDP statistics.
619 * @a Activity structure.
622 * @a Activity structure with statistics.
623 ***************************************************************************
625 __read_funct_t wrap_read_net_udp(struct activity *a)
627 struct stats_net_udp *st_net_udp
628 = (struct stats_net_udp *) a->_buf0;
631 read_net_udp(st_net_udp);
637 ***************************************************************************
638 * Read IPv6 network sockets statistics.
641 * @a Activity structure.
644 * @a Activity structure with statistics.
645 ***************************************************************************
647 __read_funct_t wrap_read_net_sock6(struct activity *a)
649 struct stats_net_sock6 *st_net_sock6
650 = (struct stats_net_sock6 *) a->_buf0;
652 /* Read IPv6 network sockets stats */
653 read_net_sock6(st_net_sock6);
659 ***************************************************************************
660 * Read IPv6 statistics.
663 * @a Activity structure.
666 * @a Activity structure with statistics.
667 ***************************************************************************
669 __read_funct_t wrap_read_net_ip6(struct activity *a)
671 struct stats_net_ip6 *st_net_ip6
672 = (struct stats_net_ip6 *) a->_buf0;
674 /* Read IPv6 stats */
675 read_net_ip6(st_net_ip6);
681 ***************************************************************************
682 * Read IPv6 error statistics.
685 * @a Activity structure.
688 * @a Activity structure with statistics.
689 ***************************************************************************
691 __read_funct_t wrap_read_net_eip6(struct activity *a)
693 struct stats_net_eip6 *st_net_eip6
694 = (struct stats_net_eip6 *) a->_buf0;
696 /* Read IPv6 error stats */
697 read_net_eip6(st_net_eip6);
703 ***************************************************************************
704 * Read ICMPv6 statistics.
707 * @a Activity structure.
710 * @a Activity structure with statistics.
711 ***************************************************************************
713 __read_funct_t wrap_read_net_icmp6(struct activity *a)
715 struct stats_net_icmp6 *st_net_icmp6
716 = (struct stats_net_icmp6 *) a->_buf0;
718 /* Read ICMPv6 stats */
719 read_net_icmp6(st_net_icmp6);
725 ***************************************************************************
726 * Read ICMPv6 error statistics.
729 * @a Activity structure.
732 * @a Activity structure with statistics.
733 ***************************************************************************
735 __read_funct_t wrap_read_net_eicmp6(struct activity *a)
737 struct stats_net_eicmp6 *st_net_eicmp6
738 = (struct stats_net_eicmp6 *) a->_buf0;
740 /* Read ICMPv6 error stats */
741 read_net_eicmp6(st_net_eicmp6);
747 ***************************************************************************
748 * Read UDPv6 statistics.
751 * @a Activity structure.
754 * @a Activity structure with statistics.
755 ***************************************************************************
757 __read_funct_t wrap_read_net_udp6(struct activity *a)
759 struct stats_net_udp6 *st_net_udp6
760 = (struct stats_net_udp6 *) a->_buf0;
762 /* Read UDPv6 stats */
763 read_net_udp6(st_net_udp6);
769 ***************************************************************************
770 * Read CPU frequency statistics.
773 * @a Activity structure.
776 * @a Activity structure with statistics.
777 ***************************************************************************
779 __read_funct_t wrap_read_cpuinfo(struct activity *a)
781 struct stats_pwr_cpufreq *st_pwr_cpufreq
782 = (struct stats_pwr_cpufreq *) a->_buf0;
785 /* Read CPU frequency stats */
787 nr_read = read_cpuinfo(st_pwr_cpufreq, a->nr_allocated);
790 /* Buffer needs to be reallocated */
791 st_pwr_cpufreq = (struct stats_pwr_cpufreq *) reallocate_buffer(a);
802 ***************************************************************************
803 * Read fan statistics.
806 * @a Activity structure.
809 * @a Activity structure with statistics.
810 ***************************************************************************
812 __read_funct_t wrap_read_fan(struct activity *a)
814 struct stats_pwr_fan *st_pwr_fan
815 = (struct stats_pwr_fan *) a->_buf0;
820 nr_read = read_fan(st_pwr_fan, a->nr_allocated);
823 /* Buffer needs to be reallocated */
824 st_pwr_fan = (struct stats_pwr_fan *) reallocate_buffer(a);
835 ***************************************************************************
836 * Read temperature statistics.
839 * @a Activity structure.
842 * @a Activity structure with statistics.
843 ***************************************************************************
845 __read_funct_t wrap_read_temp(struct activity *a)
847 struct stats_pwr_temp *st_pwr_temp
848 = (struct stats_pwr_temp *) a->_buf0;
851 /* Read temperature stats */
853 nr_read = read_temp(st_pwr_temp, a->nr_allocated);
856 /* Buffer needs to be reallocated */
857 st_pwr_temp = (struct stats_pwr_temp *) reallocate_buffer(a);
868 ***************************************************************************
869 * Read voltage input statistics.
872 * @a Activity structure.
875 * @a Activity structure with statistics.
876 ***************************************************************************
878 __read_funct_t wrap_read_in(struct activity *a)
880 struct stats_pwr_in *st_pwr_in
881 = (struct stats_pwr_in *) a->_buf0;
884 /* Read voltage input stats */
886 nr_read = read_in(st_pwr_in, a->nr_allocated);
889 /* Buffer needs to be reallocated */
890 st_pwr_in = (struct stats_pwr_in *) reallocate_buffer(a);
901 ***************************************************************************
902 * Read hugepages statistics.
905 * @a Activity structure.
908 * @a Activity structure with statistics.
909 ***************************************************************************
911 __read_funct_t wrap_read_meminfo_huge(struct activity *a)
913 struct stats_huge *st_huge
914 = (struct stats_huge *) a->_buf0;
916 /* Read hugepages stats */
917 read_meminfo_huge(st_huge);
923 ***************************************************************************
924 * Read weighted CPU frequency statistics.
927 * @a Activity structure.
930 * @a Activity structure with statistics.
931 ***************************************************************************
933 __read_funct_t wrap_read_cpu_wghfreq(struct activity *a)
935 struct stats_pwr_wghfreq *st_pwr_wghfreq
936 = (struct stats_pwr_wghfreq *) a->_buf0;
939 /* Read weighted CPU frequency statistics */
941 nr_read = read_cpu_wghfreq(st_pwr_wghfreq, a->nr_allocated, a->nr2);
944 /* Buffer needs to be reallocated */
945 SREALLOC(a->_buf0, void,
946 (size_t) a->msize * (size_t) a->nr2 * (size_t) a->nr_allocated * 2);
948 (size_t) a->msize * (size_t) a->nr2 * (size_t) a->nr_allocated * 2);
950 /* NB: nr_allocated > 0 */
951 a->nr_allocated *= 2;
952 st_pwr_wghfreq = (struct stats_pwr_wghfreq *) a->_buf0;
963 ***************************************************************************
964 * Read USB devices statistics.
967 * @a Activity structure.
970 * @a Activity structure with statistics.
971 ***************************************************************************
973 __read_funct_t wrap_read_bus_usb_dev(struct activity *a)
975 struct stats_pwr_usb *st_pwr_usb
976 = (struct stats_pwr_usb *) a->_buf0;
979 /* Read USB devices stats */
981 nr_read = read_bus_usb_dev(st_pwr_usb, a->nr_allocated);
984 /* Buffer needs to be reallocated */
985 st_pwr_usb = (struct stats_pwr_usb *) reallocate_buffer(a);
996 ***************************************************************************
997 * Read filesystem statistics.
1000 * @a Activity structure.
1003 * @a Activity structure with statistics.
1004 ***************************************************************************
1006 __read_funct_t wrap_read_filesystem(struct activity *a)
1008 struct stats_filesystem *st_filesystem
1009 = (struct stats_filesystem *) a->_buf0;
1012 /* Read filesystems from /etc/mtab */
1014 nr_read = read_filesystem(st_filesystem, a->nr_allocated);
1017 /* Buffer needs to be reallocated */
1018 st_filesystem = (struct stats_filesystem *) reallocate_buffer(a);
1021 while (nr_read < 0);
1029 ***************************************************************************
1030 * Read Fibre Channel HBA statistics.
1033 * @a Activity structure.
1036 * @a Activity structure with statistics.
1037 ***************************************************************************
1039 __read_funct_t wrap_read_fchost(struct activity *a)
1041 struct stats_fchost *st_fc
1042 = (struct stats_fchost *) a->_buf0;
1045 /* Read FC hosts statistics */
1047 nr_read = read_fchost(st_fc, a->nr_allocated);
1050 /* Buffer needs to be reallocated */
1051 st_fc = (struct stats_fchost *) reallocate_buffer(a);
1054 while (nr_read < 0);
1062 * **************************************************************************
1063 * Read batteries statistics.
1066 * @a Activity structure.
1069 * @a Activity structure with statistics.
1070 ***************************************************************************
1072 __read_funct_t wrap_read_bat(struct activity *a)
1074 struct stats_pwr_bat *st_bat
1075 = (struct stats_pwr_bat *) a->_buf0;
1078 /* Read batteries statistics */
1080 nr_read = read_bat(st_bat, a->nr_allocated);
1083 /* Buffer needs to be reallocated */
1084 st_bat = (struct stats_pwr_bat *) reallocate_buffer(a);
1087 while (nr_read < 0);
1095 ***************************************************************************
1096 * Look for online CPU and fill corresponding bitmap.
1099 * @bitmap_size Size of the CPU bitmap.
1102 * @online_cpu_bitmap
1103 * CPU bitmap which has been filled.
1106 * Number of CPU for which statistics have to be read.
1107 * 1 means CPU "all", 2 means CPU "all" and CPU 0, etc.
1108 * Or -1 if the buffer was too small and needs to be reallocated.
1109 ***************************************************************************
1111 int get_online_cpu_list(unsigned char online_cpu_bitmap[], int bitmap_size)
1117 if ((fp = fopen(STAT, "r")) == NULL)
1120 while (fgets(line, sizeof(line), fp) != NULL) {
1122 if (!strncmp(line, "cpu ", 4))
1125 if (!strncmp(line, "cpu", 3)) {
1126 sscanf(line + 3, "%d", &proc_nr);
1128 if ((proc_nr + 1 > bitmap_size) || (proc_nr < 0)) {
1130 /* Return -1 or 0 */
1131 return ((proc_nr >= 0) * -1);
1133 online_cpu_bitmap[proc_nr >> 3] |= 1 << (proc_nr & 0x07);
1142 ***************************************************************************
1143 * Read softnet statistics.
1146 * @a Activity structure.
1149 * @a Activity structure with statistics.
1150 ***************************************************************************
1152 __read_funct_t wrap_read_softnet(struct activity *a)
1154 struct stats_softnet *st_softnet
1155 = (struct stats_softnet *) a->_buf0;
1157 static unsigned char *online_cpu_bitmap = NULL;
1158 static int bitmap_size = 0;
1160 /* Read softnet stats */
1162 /* Allocate bitmap for online CPU */
1163 if (bitmap_size < a->nr_allocated) {
1164 unsigned char *p = (unsigned char *) realloc(online_cpu_bitmap,
1165 BITMAP_SIZE(a->nr_allocated));
1168 if (online_cpu_bitmap) {
1169 free(online_cpu_bitmap);
1173 online_cpu_bitmap = p;
1174 bitmap_size = a->nr_allocated;
1176 memset(online_cpu_bitmap, 0, BITMAP_SIZE(a->nr_allocated));
1178 /* Get online CPU list */
1179 nr_read = get_online_cpu_list(online_cpu_bitmap, bitmap_size);
1182 /* Read /proc/net/softnet stats */
1183 nr_read *= read_softnet(st_softnet, a->nr_allocated, online_cpu_bitmap);
1187 /* Buffer needs to be reallocated */
1188 st_softnet = (struct stats_softnet *) reallocate_buffer(a);
1191 while (nr_read < 0);
1199 ***************************************************************************
1200 * Read pressure-stall CPU statistics.
1203 * @a Activity structure.
1206 * @a Activity structure with statistics.
1207 ***************************************************************************
1209 __read_funct_t wrap_read_psicpu(struct activity *a)
1211 struct stats_psi_cpu *st_psicpu
1212 = (struct stats_psi_cpu *) a->_buf0;
1214 /* Read pressure-stall CPU stats */
1215 read_psicpu(st_psicpu);
1221 ***************************************************************************
1222 * Read pressure-stall I/O statistics.
1225 * @a Activity structure.
1228 * @a Activity structure with statistics.
1229 ***************************************************************************
1231 __read_funct_t wrap_read_psiio(struct activity *a)
1233 struct stats_psi_io *st_psiio
1234 = (struct stats_psi_io *) a->_buf0;
1236 /* Read pressure-stall I/O stats */
1237 read_psiio(st_psiio);
1243 ***************************************************************************
1244 * Read pressure-stall memory statistics.
1247 * @a Activity structure.
1250 * @a Activity structure with statistics.
1251 ***************************************************************************
1253 __read_funct_t wrap_read_psimem(struct activity *a)
1255 struct stats_psi_mem *st_psimem
1256 = (struct stats_psi_mem *) a->_buf0;
1258 /* Read pressure-stall memory stats */
1259 read_psimem(st_psimem);
1265 ***************************************************************************
1266 * Count number of interrupts that are in /proc/interrupts file, including
1267 * total number of interrupts.
1268 * Truncate the number of different individual interrupts to NR_IRQS.
1271 * @a Activity structure.
1274 * Number of interrupts, including total number of interrupts.
1275 * Value in [0, NR_IRQS + 1].
1276 ***************************************************************************
1278 __nr_t wrap_get_irq_nr(struct activity *a)
1283 * Get number of different interrupts.
1284 * Number of CPU (including CPU "all") has already been calculated and saved in a->nr_ini.
1286 n = get_irqcpu_nr(INTERRUPTS, a->bitmap->b_size, a->nr_ini - 1);
1288 n++; /* Add 1 for total number of interrupts. A value of bitmap->b_size + 1 is OK. */
1295 ***************************************************************************
1296 * Find number of serial lines that support tx/rx accounting
1297 * in /proc/tty/driver/serial file.
1300 * @a Activity structure.
1303 * Number of serial lines supporting tx/rx accouting.
1304 * Number cannot exceed MAX_NR_SERIAL_LINES.
1305 ***************************************************************************
1307 __nr_t wrap_get_serial_nr(struct activity *a)
1311 if ((n = get_serial_nr()) > 0) {
1312 if (n > MAX_NR_SERIAL_LINES)
1313 return MAX_NR_SERIAL_LINES;
1322 ***************************************************************************
1323 * Find number of interfaces (network devices) that are in /proc/net/dev
1327 * @a Activity structure.
1330 * Number of network interfaces. Number cannot exceed MAX_NR_IFACES.
1331 ***************************************************************************
1333 __nr_t wrap_get_iface_nr(struct activity *a)
1337 if ((n = get_iface_nr()) > 0) {
1338 if (n > MAX_NR_IFACES)
1339 return MAX_NR_IFACES;
1348 ***************************************************************************
1349 * Compute number of CPU structures to allocate.
1352 * @a Activity structure.
1355 * Number of structures (value in [1, NR_CPUS + 1]).
1356 * 1 means that there is only one proc and non SMP kernel (CPU "all").
1357 * 2 means one proc and SMP kernel (CPU "all" and CPU 0).
1359 ***************************************************************************
1361 __nr_t wrap_get_cpu_nr(struct activity *a)
1363 return (get_cpu_nr(a->bitmap->b_size, FALSE) + 1);
1367 ***************************************************************************
1368 * Get number of devices in /proc/diskstats.
1369 * Always done, since disk stats must be read at least for sar -b
1370 * if not for sar -d.
1373 * @a Activity structure.
1376 * Number of devices. Number cannot exceed MAX_NR_DISKS.
1377 ***************************************************************************
1379 __nr_t wrap_get_disk_nr(struct activity *a)
1382 unsigned int f = COLLECT_PARTITIONS(a->opt_flags);
1384 if ((n = get_disk_nr(f)) > 0) {
1385 if (n > MAX_NR_DISKS)
1386 return MAX_NR_DISKS;
1395 ***************************************************************************
1396 * Get number of fan sensors.
1399 * @a Activity structure.
1402 * Number of fan sensors. Number cannot exceed MAX_NR_FANS.
1403 ***************************************************************************
1405 __nr_t wrap_get_fan_nr(struct activity *a)
1409 if ((n = get_fan_nr()) > MAX_NR_FANS)
1416 ***************************************************************************
1417 * Get number of temp sensors.
1420 * @a Activity structure.
1423 * Number of temp sensors. Number cannot exceed MAX_NR_TEMP_SENSORS.
1424 ***************************************************************************
1426 __nr_t wrap_get_temp_nr(struct activity *a)
1430 if ((n = get_temp_nr()) > MAX_NR_TEMP_SENSORS)
1431 return MAX_NR_TEMP_SENSORS;
1437 ***************************************************************************
1438 * Get number of voltage input sensors.
1441 * @a Activity structure.
1444 * Number of voltage input sensors. Number cannot exceed MAX_NR_IN_SENSORS.
1445 ***************************************************************************
1447 __nr_t wrap_get_in_nr(struct activity *a)
1451 if ((n = get_in_nr()) > MAX_NR_IN_SENSORS)
1452 return MAX_NR_IN_SENSORS;
1458 ***************************************************************************
1459 * Count number of possible frequencies for CPU#0.
1462 * @a Activity structure.
1465 * Number of CPU frequencies.
1466 ***************************************************************************
1468 __nr_t wrap_get_freq_nr(struct activity *a)
1472 if ((n = get_freq_nr()) > 0)
1479 ***************************************************************************
1480 * Count number of USB devices plugged into the system.
1483 * @a Activity structure.
1486 * Number of USB devices. Number cannot exceed MAX_NR_USB.
1487 ***************************************************************************
1489 __nr_t wrap_get_usb_nr(struct activity *a)
1493 if ((n = get_usb_nr()) > 0) {
1504 ***************************************************************************
1505 * Get number of mounted filesystems from /etc/mtab. Don't take into account
1506 * pseudo-filesystems.
1509 * @a Activity structure.
1512 * Number of filesystems. Number cannot exceed MAX_NR_FS.
1513 ***************************************************************************
1515 __nr_t wrap_get_filesystem_nr(struct activity *a)
1519 if ((n = get_filesystem_nr()) > 0) {
1530 ***************************************************************************
1531 * Get number of FC hosts.
1534 * @a Activity structure.
1537 * Number of FC hosts. Number cannot exceed MAX_NR_FCHOSTS.
1538 ***************************************************************************
1540 __nr_t wrap_get_fchost_nr(struct activity *a)
1544 if ((n = get_fchost_nr()) > 0) {
1545 if (n > MAX_NR_FCHOSTS)
1546 return MAX_NR_FCHOSTS;
1555 ***************************************************************************
1556 * Check that /proc/pressure directory exists.
1559 * @a Activity structure.
1562 * TRUE if directory exists.
1563 ***************************************************************************
1565 __nr_t wrap_detect_psi(struct activity *a)
1567 return (check_dir(PRESSURE));
1571 * **************************************************************************
1572 * Get number of batteries.
1575 * @a Activity structure.
1578 * Number of batteries installed. Number cannot exceed MAX_NR_BAT.
1579 ***************************************************************************
1581 __nr_t wrap_get_bat_nr(struct activity *a)
1585 if ((n = get_bat_nr()) > 0) {
1586 if (n > MAX_NR_BATS)