]> granicus.if.org Git - sysstat/blob - rd_stats.h
sysstat-12.5.3
[sysstat] / rd_stats.h
1 /*
2  * rd_stats.h: Include file used to read system statistics
3  * (C) 1999-2021 by Sebastien Godard (sysstat <at> orange.fr)
4  */
5
6 #ifndef _RD_STATS_H
7 #define _RD_STATS_H
8
9 #include "common.h"
10
11 /*
12  ***************************************************************************
13  * Miscellaneous constants
14  ***************************************************************************
15  */
16
17 /* Maximum length of block device name */
18 #define MAX_DEV_LEN     128
19 /* Maximum length of network interface name */
20 #define MAX_IFACE_LEN   16
21 /* Maximum length of USB manufacturer string */
22 #define MAX_MANUF_LEN   24
23 /* Maximum length of USB product string */
24 #define MAX_PROD_LEN    48
25 /* Maximum length of filesystem name */
26 #define MAX_FS_LEN      128
27 /* Maximum length of FC host name */
28 #define MAX_FCH_LEN     16
29
30 #define CNT_PART        1
31 #define CNT_ALL_DEV     0
32 #define CNT_USED_DEV    1
33
34 #define K_DUPLEX_HALF   "half"
35 #define K_DUPLEX_FULL   "full"
36
37 #define C_DUPLEX_HALF   1
38 #define C_DUPLEX_FULL   2
39
40 /* Type for all functions counting items. Value can be negative (-1) */
41 #define __nr_t          int
42
43 /*
44  ***************************************************************************
45  * System files containing statistics
46  ***************************************************************************
47  */
48
49 /* Files */
50 #define SERIAL          PRE "/proc/tty/driver/serial"
51 #define FDENTRY_STATE   PRE "/proc/sys/fs/dentry-state"
52 #define FFILE_NR        PRE "/proc/sys/fs/file-nr"
53 #define FINODE_STATE    PRE "/proc/sys/fs/inode-state"
54 #define PTY_NR          PRE "/proc/sys/kernel/pty/nr"
55 #define NET_DEV         PRE "/proc/net/dev"
56 #define NET_SOCKSTAT    PRE "/proc/net/sockstat"
57 #define NET_SOCKSTAT6   PRE "/proc/net/sockstat6"
58 #define NET_RPC_NFS     PRE "/proc/net/rpc/nfs"
59 #define NET_RPC_NFSD    PRE "/proc/net/rpc/nfsd"
60 #define NET_SOFTNET     PRE "/proc/net/softnet_stat"
61 #define LOADAVG         PRE "/proc/loadavg"
62 #define PRESSURE        PRE "/proc/pressure"
63 #define PSI_CPU         PRESSURE "/cpu"
64 #define PSI_IO          PRESSURE "/io"
65 #define PSI_MEM         PRESSURE "/memory"
66 #define VMSTAT          PRE "/proc/vmstat"
67 #define NET_SNMP        PRE "/proc/net/snmp"
68 #define NET_SNMP6       PRE "/proc/net/snmp6"
69 #define CPUINFO         PRE "/proc/cpuinfo"
70 #define MTAB            PRE "/etc/mtab"
71 #define IF_DUPLEX       PRE "/sys/class/net/%s/duplex"
72 #define IF_SPEED        PRE "/sys/class/net/%s/speed"
73 #define FC_RX_FRAMES    "%s/%s/statistics/rx_frames"
74 #define FC_TX_FRAMES    "%s/%s/statistics/tx_frames"
75 #define FC_RX_WORDS     "%s/%s/statistics/rx_words"
76 #define FC_TX_WORDS     "%s/%s/statistics/tx_words"
77
78 /*
79  ***************************************************************************
80  * Definitions of structures for system statistics.
81  * WARNING: Fields order matters for SVG graphs!
82  ***************************************************************************
83  */
84
85 #define SIZEOF_LONG_64BIT       8
86 #define ULL_ALIGNMENT_WIDTH     8
87 #define UL_ALIGNMENT_WIDTH      SIZEOF_LONG_64BIT
88 #define U_ALIGNMENT_WIDTH       4
89
90 #define MAP_SIZE(m)     ((m[0] * ULL_ALIGNMENT_WIDTH) + \
91                          (m[1] * UL_ALIGNMENT_WIDTH) +  \
92                          (m[2] * U_ALIGNMENT_WIDTH))
93
94 /*
95  * Structure for CPU statistics.
96  * In activity buffer: First structure is for global CPU utilisation ("all").
97  * Following structures are for each individual CPU (0, 1, etc.)
98  */
99 struct stats_cpu {
100         unsigned long long cpu_user;
101         unsigned long long cpu_nice;
102         unsigned long long cpu_sys;
103         unsigned long long cpu_idle;
104         unsigned long long cpu_iowait;
105         unsigned long long cpu_steal;
106         unsigned long long cpu_hardirq;
107         unsigned long long cpu_softirq;
108         unsigned long long cpu_guest;
109         unsigned long long cpu_guest_nice;
110 };
111
112 #define STATS_CPU_SIZE  (sizeof(struct stats_cpu))
113 #define STATS_CPU_ULL   10
114 #define STATS_CPU_UL    0
115 #define STATS_CPU_U     0
116
117 /*
118  * Structure for task creation and context switch statistics.
119  * The attribute (aligned(8)) is necessary so that sizeof(structure) has
120  * the same value on 32 and 64-bit architectures.
121  */
122 struct stats_pcsw {
123         unsigned long long context_switch;
124         unsigned long      processes    __attribute__ ((aligned (8)));
125 };
126
127 #define STATS_PCSW_SIZE (sizeof(struct stats_pcsw))
128 #define STATS_PCSW_ULL  1
129 #define STATS_PCSW_UL   1
130 #define STATS_PCSW_U    0
131
132 /*
133  * Structure for interrupts statistics.
134  * In activity buffer: First structure is for total number of interrupts ("SUM").
135  * Following structures are for each individual interrupt (0, 1, etc.)
136  */
137 struct stats_irq {
138         unsigned long long irq_nr;
139 };
140
141 #define STATS_IRQ_SIZE  (sizeof(struct stats_irq))
142 #define STATS_IRQ_ULL   1
143 #define STATS_IRQ_UL    0
144 #define STATS_IRQ_U     0
145
146 /* Structure for swapping statistics */
147 struct stats_swap {
148         unsigned long pswpin    __attribute__ ((aligned (8)));
149         unsigned long pswpout   __attribute__ ((aligned (8)));
150 };
151
152 #define STATS_SWAP_SIZE (sizeof(struct stats_swap))
153 #define STATS_SWAP_ULL  0
154 #define STATS_SWAP_UL   2
155 #define STATS_SWAP_U    0
156
157 /* Structure for paging statistics */
158 struct stats_paging {
159         unsigned long pgpgin            __attribute__ ((aligned (8)));
160         unsigned long pgpgout           __attribute__ ((aligned (8)));
161         unsigned long pgfault           __attribute__ ((aligned (8)));
162         unsigned long pgmajfault        __attribute__ ((aligned (8)));
163         unsigned long pgfree            __attribute__ ((aligned (8)));
164         unsigned long pgscan_kswapd     __attribute__ ((aligned (8)));
165         unsigned long pgscan_direct     __attribute__ ((aligned (8)));
166         unsigned long pgsteal           __attribute__ ((aligned (8)));
167 };
168
169 #define STATS_PAGING_SIZE       (sizeof(struct stats_paging))
170 #define STATS_PAGING_ULL        0
171 #define STATS_PAGING_UL         8
172 #define STATS_PAGING_U          0
173
174 /* Structure for I/O and transfer rate statistics */
175 struct stats_io {
176         unsigned long long dk_drive;
177         unsigned long long dk_drive_rio;
178         unsigned long long dk_drive_wio;
179         unsigned long long dk_drive_rblk;
180         unsigned long long dk_drive_wblk;
181         unsigned long long dk_drive_dio;
182         unsigned long long dk_drive_dblk;
183 };
184
185 #define STATS_IO_SIZE   (sizeof(struct stats_io))
186 #define STATS_IO_ULL    7
187 #define STATS_IO_UL     0
188 #define STATS_IO_U      0
189
190 /* Structure for memory and swap space utilization statistics */
191 struct stats_memory {
192         unsigned long long frmkb;
193         unsigned long long bufkb;
194         unsigned long long camkb;
195         unsigned long long tlmkb;
196         unsigned long long frskb;
197         unsigned long long tlskb;
198         unsigned long long caskb;
199         unsigned long long comkb;
200         unsigned long long activekb;
201         unsigned long long inactkb;
202         unsigned long long dirtykb;
203         unsigned long long anonpgkb;
204         unsigned long long slabkb;
205         unsigned long long kstackkb;
206         unsigned long long pgtblkb;
207         unsigned long long vmusedkb;
208         unsigned long long availablekb;
209 };
210
211 #define STATS_MEMORY_SIZE       (sizeof(struct stats_memory))
212 #define STATS_MEMORY_ULL        17
213 #define STATS_MEMORY_UL         0
214 #define STATS_MEMORY_U          0
215
216 /* Structure for kernel tables statistics */
217 struct stats_ktables {
218         unsigned long long file_used;
219         unsigned long long inode_used;
220         unsigned long long dentry_stat;
221         unsigned long long pty_nr;
222 };
223
224 #define STATS_KTABLES_SIZE      (sizeof(struct stats_ktables))
225 #define STATS_KTABLES_ULL       4
226 #define STATS_KTABLES_UL        0
227 #define STATS_KTABLES_U         0
228
229 /* Structure for queue and load statistics */
230 struct stats_queue {
231         unsigned long long nr_running;
232         unsigned long long procs_blocked;
233         unsigned long long nr_threads;
234         unsigned int       load_avg_1;
235         unsigned int       load_avg_5;
236         unsigned int       load_avg_15;
237 };
238
239 #define STATS_QUEUE_SIZE        (sizeof(struct stats_queue))
240 #define STATS_QUEUE_ULL         3
241 #define STATS_QUEUE_UL          0
242 #define STATS_QUEUE_U           3
243
244 /* Structure for serial statistics */
245 struct stats_serial {
246         unsigned int rx;
247         unsigned int tx;
248         unsigned int frame;
249         unsigned int parity;
250         unsigned int brk;
251         unsigned int overrun;
252         unsigned int line;
253 };
254
255 #define STATS_SERIAL_SIZE       (sizeof(struct stats_serial))
256 #define STATS_SERIAL_ULL        0
257 #define STATS_SERIAL_UL         0
258 #define STATS_SERIAL_U          7
259
260 /* Structure for block devices statistics */
261 struct stats_disk {
262         unsigned long long nr_ios;
263         unsigned long long wwn[2];
264         unsigned long      rd_sect      __attribute__ ((aligned (8)));
265         unsigned long      wr_sect      __attribute__ ((aligned (8)));
266         unsigned long      dc_sect      __attribute__ ((aligned (8)));
267         unsigned int       rd_ticks     __attribute__ ((aligned (8)));
268         unsigned int       wr_ticks;
269         unsigned int       tot_ticks;
270         unsigned int       rq_ticks;
271         unsigned int       major;
272         unsigned int       minor;
273         unsigned int       dc_ticks;
274         unsigned int       part_nr;
275 };
276
277 #define STATS_DISK_SIZE (sizeof(struct stats_disk))
278 #define STATS_DISK_ULL  3
279 #define STATS_DISK_UL   3
280 #define STATS_DISK_U    8
281
282 /* Structure for network interfaces statistics */
283 struct stats_net_dev {
284         unsigned long long rx_packets;
285         unsigned long long tx_packets;
286         unsigned long long rx_bytes;
287         unsigned long long tx_bytes;
288         unsigned long long rx_compressed;
289         unsigned long long tx_compressed;
290         unsigned long long multicast;
291         unsigned int       speed;
292         char               interface[MAX_IFACE_LEN];
293         char               duplex;
294 };
295
296 #define STATS_NET_DEV_SIZE      (sizeof(struct stats_net_dev))
297 #define STATS_NET_DEV_SIZE2CMP  (STATS_NET_DEV_SIZE - MAX_IFACE_LEN - 1)
298 #define STATS_NET_DEV_ULL       7
299 #define STATS_NET_DEV_UL        0
300 #define STATS_NET_DEV_U         1
301
302 /* Structure for network interface errors statistics */
303 struct stats_net_edev {
304         unsigned long long collisions;
305         unsigned long long rx_errors;
306         unsigned long long tx_errors;
307         unsigned long long rx_dropped;
308         unsigned long long tx_dropped;
309         unsigned long long rx_fifo_errors;
310         unsigned long long tx_fifo_errors;
311         unsigned long long rx_frame_errors;
312         unsigned long long tx_carrier_errors;
313         char               interface[MAX_IFACE_LEN];
314 };
315
316 #define STATS_NET_EDEV_SIZE     (sizeof(struct stats_net_edev))
317 #define STATS_NET_EDEV_SIZE2CMP (STATS_NET_EDEV_SIZE - MAX_IFACE_LEN)
318 #define STATS_NET_EDEV_ULL      9
319 #define STATS_NET_EDEV_UL       0
320 #define STATS_NET_EDEV_U        0
321
322 /* Structure for NFS client statistics */
323 struct stats_net_nfs {
324         unsigned int nfs_rpccnt;
325         unsigned int nfs_rpcretrans;
326         unsigned int nfs_readcnt;
327         unsigned int nfs_writecnt;
328         unsigned int nfs_accesscnt;
329         unsigned int nfs_getattcnt;
330 };
331
332 #define STATS_NET_NFS_SIZE      (sizeof(struct stats_net_nfs))
333 #define STATS_NET_NFS_ULL       0
334 #define STATS_NET_NFS_UL        0
335 #define STATS_NET_NFS_U         6
336
337 /* Structure for NFS server statistics */
338 struct stats_net_nfsd {
339         unsigned int nfsd_rpccnt;
340         unsigned int nfsd_rpcbad;
341         unsigned int nfsd_netcnt;
342         unsigned int nfsd_netudpcnt;
343         unsigned int nfsd_nettcpcnt;
344         unsigned int nfsd_rchits;
345         unsigned int nfsd_rcmisses;
346         unsigned int nfsd_readcnt;
347         unsigned int nfsd_writecnt;
348         unsigned int nfsd_accesscnt;
349         unsigned int nfsd_getattcnt;
350 };
351
352 #define STATS_NET_NFSD_SIZE     (sizeof(struct stats_net_nfsd))
353 #define STATS_NET_NFSD_ULL      0
354 #define STATS_NET_NFSD_UL       0
355 #define STATS_NET_NFSD_U        11
356
357 /* Structure for IPv4 sockets statistics */
358 struct stats_net_sock {
359         unsigned int sock_inuse;
360         unsigned int tcp_inuse;
361         unsigned int tcp_tw;
362         unsigned int udp_inuse;
363         unsigned int raw_inuse;
364         unsigned int frag_inuse;
365 };
366
367 #define STATS_NET_SOCK_SIZE     (sizeof(struct stats_net_sock))
368 #define STATS_NET_SOCK_ULL      0
369 #define STATS_NET_SOCK_UL       0
370 #define STATS_NET_SOCK_U        6
371
372 /* Structure for IP statistics */
373 struct stats_net_ip {
374         unsigned long long InReceives;
375         unsigned long long ForwDatagrams;
376         unsigned long long InDelivers;
377         unsigned long long OutRequests;
378         unsigned long long ReasmReqds;
379         unsigned long long ReasmOKs;
380         unsigned long long FragOKs;
381         unsigned long long FragCreates;
382 };
383
384 #define STATS_NET_IP_SIZE       (sizeof(struct stats_net_ip))
385 #define STATS_NET_IP_ULL        8
386 #define STATS_NET_IP_UL         0
387 #define STATS_NET_IP_U          0
388
389 /* Structure for IP errors statistics */
390 struct stats_net_eip {
391         unsigned long long InHdrErrors;
392         unsigned long long InAddrErrors;
393         unsigned long long InUnknownProtos;
394         unsigned long long InDiscards;
395         unsigned long long OutDiscards;
396         unsigned long long OutNoRoutes;
397         unsigned long long ReasmFails;
398         unsigned long long FragFails;
399 };
400
401 #define STATS_NET_EIP_SIZE      (sizeof(struct stats_net_eip))
402 #define STATS_NET_EIP_ULL       8
403 #define STATS_NET_EIP_UL        0
404 #define STATS_NET_EIP_U         0
405
406 /* Structure for ICMP statistics */
407 struct stats_net_icmp {
408         unsigned long InMsgs            __attribute__ ((aligned (8)));
409         unsigned long OutMsgs           __attribute__ ((aligned (8)));
410         unsigned long InEchos           __attribute__ ((aligned (8)));
411         unsigned long InEchoReps        __attribute__ ((aligned (8)));
412         unsigned long OutEchos          __attribute__ ((aligned (8)));
413         unsigned long OutEchoReps       __attribute__ ((aligned (8)));
414         unsigned long InTimestamps      __attribute__ ((aligned (8)));
415         unsigned long InTimestampReps   __attribute__ ((aligned (8)));
416         unsigned long OutTimestamps     __attribute__ ((aligned (8)));
417         unsigned long OutTimestampReps  __attribute__ ((aligned (8)));
418         unsigned long InAddrMasks       __attribute__ ((aligned (8)));
419         unsigned long InAddrMaskReps    __attribute__ ((aligned (8)));
420         unsigned long OutAddrMasks      __attribute__ ((aligned (8)));
421         unsigned long OutAddrMaskReps   __attribute__ ((aligned (8)));
422 };
423
424 #define STATS_NET_ICMP_SIZE     (sizeof(struct stats_net_icmp))
425 #define STATS_NET_ICMP_ULL      0
426 #define STATS_NET_ICMP_UL       14
427 #define STATS_NET_ICMP_U        0
428
429 /* Structure for ICMP error message statistics */
430 struct stats_net_eicmp {
431         unsigned long InErrors          __attribute__ ((aligned (8)));
432         unsigned long OutErrors         __attribute__ ((aligned (8)));
433         unsigned long InDestUnreachs    __attribute__ ((aligned (8)));
434         unsigned long OutDestUnreachs   __attribute__ ((aligned (8)));
435         unsigned long InTimeExcds       __attribute__ ((aligned (8)));
436         unsigned long OutTimeExcds      __attribute__ ((aligned (8)));
437         unsigned long InParmProbs       __attribute__ ((aligned (8)));
438         unsigned long OutParmProbs      __attribute__ ((aligned (8)));
439         unsigned long InSrcQuenchs      __attribute__ ((aligned (8)));
440         unsigned long OutSrcQuenchs     __attribute__ ((aligned (8)));
441         unsigned long InRedirects       __attribute__ ((aligned (8)));
442         unsigned long OutRedirects      __attribute__ ((aligned (8)));
443 };
444
445 #define STATS_NET_EICMP_SIZE    (sizeof(struct stats_net_eicmp))
446 #define STATS_NET_EICMP_ULL     0
447 #define STATS_NET_EICMP_UL      12
448 #define STATS_NET_EICMP_U       0
449
450 /* Structure for TCP statistics */
451 struct stats_net_tcp {
452         unsigned long ActiveOpens       __attribute__ ((aligned (8)));
453         unsigned long PassiveOpens      __attribute__ ((aligned (8)));
454         unsigned long InSegs            __attribute__ ((aligned (8)));
455         unsigned long OutSegs           __attribute__ ((aligned (8)));
456 };
457
458 #define STATS_NET_TCP_SIZE      (sizeof(struct stats_net_tcp))
459 #define STATS_NET_TCP_ULL       0
460 #define STATS_NET_TCP_UL        4
461 #define STATS_NET_TCP_U         0
462
463 /* Structure for TCP errors statistics */
464 struct stats_net_etcp {
465         unsigned long AttemptFails      __attribute__ ((aligned (8)));
466         unsigned long EstabResets       __attribute__ ((aligned (8)));
467         unsigned long RetransSegs       __attribute__ ((aligned (8)));
468         unsigned long InErrs            __attribute__ ((aligned (8)));
469         unsigned long OutRsts           __attribute__ ((aligned (8)));
470 };
471
472 #define STATS_NET_ETCP_SIZE     (sizeof(struct stats_net_etcp))
473 #define STATS_NET_ETCP_ULL      0
474 #define STATS_NET_ETCP_UL       5
475 #define STATS_NET_ETCP_U        0
476
477 /* Structure for UDP statistics */
478 struct stats_net_udp {
479         unsigned long InDatagrams       __attribute__ ((aligned (8)));
480         unsigned long OutDatagrams      __attribute__ ((aligned (8)));
481         unsigned long NoPorts           __attribute__ ((aligned (8)));
482         unsigned long InErrors          __attribute__ ((aligned (8)));
483 };
484
485 #define STATS_NET_UDP_SIZE      (sizeof(struct stats_net_udp))
486 #define STATS_NET_UDP_ULL       0
487 #define STATS_NET_UDP_UL        4
488 #define STATS_NET_UDP_U         0
489
490 /* Structure for IPv6 sockets statistics */
491 struct stats_net_sock6 {
492         unsigned int tcp6_inuse;
493         unsigned int udp6_inuse;
494         unsigned int raw6_inuse;
495         unsigned int frag6_inuse;
496 };
497
498 #define STATS_NET_SOCK6_SIZE    (sizeof(struct stats_net_sock6))
499 #define STATS_NET_SOCK6_ULL     0
500 #define STATS_NET_SOCK6_UL      0
501 #define STATS_NET_SOCK6_U       4
502
503 /* Structure for IPv6 statistics */
504 struct stats_net_ip6 {
505         unsigned long long InReceives6;
506         unsigned long long OutForwDatagrams6;
507         unsigned long long InDelivers6;
508         unsigned long long OutRequests6;
509         unsigned long long ReasmReqds6;
510         unsigned long long ReasmOKs6;
511         unsigned long long InMcastPkts6;
512         unsigned long long OutMcastPkts6;
513         unsigned long long FragOKs6;
514         unsigned long long FragCreates6;
515 };
516
517 #define STATS_NET_IP6_SIZE      (sizeof(struct stats_net_ip6))
518 #define STATS_NET_IP6_ULL       10
519 #define STATS_NET_IP6_UL        0
520 #define STATS_NET_IP6_U         0
521
522 /* Structure for IPv6 errors statistics */
523 struct stats_net_eip6 {
524         unsigned long long InHdrErrors6;
525         unsigned long long InAddrErrors6;
526         unsigned long long InUnknownProtos6;
527         unsigned long long InTooBigErrors6;
528         unsigned long long InDiscards6;
529         unsigned long long OutDiscards6;
530         unsigned long long InNoRoutes6;
531         unsigned long long OutNoRoutes6;
532         unsigned long long ReasmFails6;
533         unsigned long long FragFails6;
534         unsigned long long InTruncatedPkts6;
535 };
536
537 #define STATS_NET_EIP6_SIZE     (sizeof(struct stats_net_eip6))
538 #define STATS_NET_EIP6_ULL      11
539 #define STATS_NET_EIP6_UL       0
540 #define STATS_NET_EIP6_U        0
541
542 /* Structure for ICMPv6 statistics */
543 struct stats_net_icmp6 {
544         unsigned long InMsgs6                           __attribute__ ((aligned (8)));
545         unsigned long OutMsgs6                          __attribute__ ((aligned (8)));
546         unsigned long InEchos6                          __attribute__ ((aligned (8)));
547         unsigned long InEchoReplies6                    __attribute__ ((aligned (8)));
548         unsigned long OutEchoReplies6                   __attribute__ ((aligned (8)));
549         unsigned long InGroupMembQueries6               __attribute__ ((aligned (8)));
550         unsigned long InGroupMembResponses6             __attribute__ ((aligned (8)));
551         unsigned long OutGroupMembResponses6            __attribute__ ((aligned (8)));
552         unsigned long InGroupMembReductions6            __attribute__ ((aligned (8)));
553         unsigned long OutGroupMembReductions6           __attribute__ ((aligned (8)));
554         unsigned long InRouterSolicits6                 __attribute__ ((aligned (8)));
555         unsigned long OutRouterSolicits6                __attribute__ ((aligned (8)));
556         unsigned long InRouterAdvertisements6           __attribute__ ((aligned (8)));
557         unsigned long InNeighborSolicits6               __attribute__ ((aligned (8)));
558         unsigned long OutNeighborSolicits6              __attribute__ ((aligned (8)));
559         unsigned long InNeighborAdvertisements6         __attribute__ ((aligned (8)));
560         unsigned long OutNeighborAdvertisements6        __attribute__ ((aligned (8)));
561 };
562
563 #define STATS_NET_ICMP6_SIZE    (sizeof(struct stats_net_icmp6))
564 #define STATS_NET_ICMP6_ULL     0
565 #define STATS_NET_ICMP6_UL      17
566 #define STATS_NET_ICMP6_U       0
567
568 /* Structure for ICMPv6 error message statistics */
569 struct stats_net_eicmp6 {
570         unsigned long InErrors6         __attribute__ ((aligned (8)));
571         unsigned long InDestUnreachs6   __attribute__ ((aligned (8)));
572         unsigned long OutDestUnreachs6  __attribute__ ((aligned (8)));
573         unsigned long InTimeExcds6      __attribute__ ((aligned (8)));
574         unsigned long OutTimeExcds6     __attribute__ ((aligned (8)));
575         unsigned long InParmProblems6   __attribute__ ((aligned (8)));
576         unsigned long OutParmProblems6  __attribute__ ((aligned (8)));
577         unsigned long InRedirects6      __attribute__ ((aligned (8)));
578         unsigned long OutRedirects6     __attribute__ ((aligned (8)));
579         unsigned long InPktTooBigs6     __attribute__ ((aligned (8)));
580         unsigned long OutPktTooBigs6    __attribute__ ((aligned (8)));
581 };
582
583 #define STATS_NET_EICMP6_SIZE   (sizeof(struct stats_net_eicmp6))
584 #define STATS_NET_EICMP6_ULL    0
585 #define STATS_NET_EICMP6_UL     11
586 #define STATS_NET_EICMP6_U      0
587
588 /* Structure for UDPv6 statistics */
589 struct stats_net_udp6 {
590         unsigned long InDatagrams6      __attribute__ ((aligned (8)));
591         unsigned long OutDatagrams6     __attribute__ ((aligned (8)));
592         unsigned long NoPorts6          __attribute__ ((aligned (8)));
593         unsigned long InErrors6         __attribute__ ((aligned (8)));
594 };
595
596 #define STATS_NET_UDP6_SIZE     (sizeof(struct stats_net_udp6))
597 #define STATS_NET_UDP6_ULL      0
598 #define STATS_NET_UDP6_UL       4
599 #define STATS_NET_UDP6_U        0
600
601 /*
602  * Structure for CPU frequency statistics.
603  * In activity buffer: First structure is for global CPU utilisation ("all").
604  * Following structures are for each individual CPU (0, 1, etc.)
605  */
606 struct stats_pwr_cpufreq {
607         unsigned long cpufreq   __attribute__ ((aligned (8)));
608 };
609
610 #define STATS_PWR_CPUFREQ_SIZE  (sizeof(struct stats_pwr_cpufreq))
611 #define STATS_PWR_CPUFREQ_ULL   0
612 #define STATS_PWR_CPUFREQ_UL    1
613 #define STATS_PWR_CPUFREQ_U     0
614
615 /* Structure for hugepages statistics */
616 struct stats_huge {
617         unsigned long long frhkb;
618         unsigned long long tlhkb;
619         unsigned long long rsvdhkb;
620         unsigned long long surphkb;
621 };
622
623 #define STATS_HUGE_SIZE (sizeof(struct stats_huge))
624 #define STATS_HUGE_ULL  4
625 #define STATS_HUGE_UL   0
626 #define STATS_HUGE_U    0
627
628 /*
629  * Structure for weighted CPU frequency statistics.
630  * In activity buffer: First structure is for global CPU utilisation ("all").
631  * Following structures are for each individual CPU (0, 1, etc.)
632  */
633 struct stats_pwr_wghfreq {
634         unsigned long long time_in_state;
635         unsigned long      freq         __attribute__ ((aligned (8)));
636 };
637
638 #define STATS_PWR_WGHFREQ_SIZE  (sizeof(struct stats_pwr_wghfreq))
639 #define STATS_PWR_WGHFREQ_ULL   1
640 #define STATS_PWR_WGHFREQ_UL    1
641 #define STATS_PWR_WGHFREQ_U     0
642
643 /*
644  * Structure for USB devices plugged into the system.
645  */
646 struct stats_pwr_usb {
647         unsigned int bus_nr;
648         unsigned int vendor_id;
649         unsigned int product_id;
650         unsigned int bmaxpower;
651         char         manufacturer[MAX_MANUF_LEN];
652         char         product[MAX_PROD_LEN];
653 };
654
655 #define STATS_PWR_USB_SIZE      (sizeof(struct stats_pwr_usb))
656 #define STATS_PWR_USB_ULL       0
657 #define STATS_PWR_USB_UL        0
658 #define STATS_PWR_USB_U         4
659
660 /* Structure for filesystems statistics */
661 struct stats_filesystem {
662         unsigned long long f_blocks;
663         unsigned long long f_bfree;
664         unsigned long long f_bavail;
665         unsigned long long f_files;
666         unsigned long long f_ffree;
667         char               fs_name[MAX_FS_LEN];
668         char               mountp[MAX_FS_LEN];
669 };
670
671 #define STATS_FILESYSTEM_SIZE           (sizeof(struct stats_filesystem))
672 #define STATS_FILESYSTEM_SIZE2CMP       (STATS_FILESYSTEM_SIZE - 2 * MAX_FS_LEN)
673 #define STATS_FILESYSTEM_ULL            5
674 #define STATS_FILESYSTEM_UL             0
675 #define STATS_FILESYSTEM_U              0
676
677 /* Structure for Fibre Channel HBA statistics */
678 struct stats_fchost {
679         unsigned long f_rxframes                __attribute__ ((aligned (8)));
680         unsigned long f_txframes                __attribute__ ((aligned (8)));
681         unsigned long f_rxwords                 __attribute__ ((aligned (8)));
682         unsigned long f_txwords                 __attribute__ ((aligned (8)));
683         char          fchost_name[MAX_FCH_LEN]  __attribute__ ((aligned (8)));
684 };
685
686 #define STATS_FCHOST_SIZE       (sizeof(struct stats_fchost))
687 #define STATS_FCHOST_ULL        0
688 #define STATS_FCHOST_UL         4
689 #define STATS_FCHOST_U          0
690
691 /* Structure for softnet statistics */
692 struct stats_softnet {
693         unsigned int processed;
694         unsigned int dropped;
695         unsigned int time_squeeze;
696         unsigned int received_rps;
697         unsigned int flow_limit;
698 };
699
700 #define STATS_SOFTNET_SIZE      (sizeof(struct stats_softnet))
701 #define STATS_SOFTNET_ULL       0
702 #define STATS_SOFTNET_UL        0
703 #define STATS_SOFTNET_U         5
704
705 /* Structure for pressure-stall CPU statistics */
706 struct stats_psi_cpu {
707         unsigned long long some_cpu_total;
708         unsigned long      some_acpu_10         __attribute__ ((aligned (8)));
709         unsigned long      some_acpu_60         __attribute__ ((aligned (8)));
710         unsigned long      some_acpu_300        __attribute__ ((aligned (8)));
711 };
712
713 #define STATS_PSI_CPU_SIZE      (sizeof(struct stats_psi_cpu))
714 #define STATS_PSI_CPU_ULL       1
715 #define STATS_PSI_CPU_UL        3
716 #define STATS_PSI_CPU_U         0
717
718 /* Structure for pressure-stall I/O statistics */
719 struct stats_psi_io {
720         unsigned long long some_io_total;
721         unsigned long long full_io_total;
722         unsigned long      some_aio_10          __attribute__ ((aligned (8)));
723         unsigned long      some_aio_60          __attribute__ ((aligned (8)));
724         unsigned long      some_aio_300         __attribute__ ((aligned (8)));
725         unsigned long      full_aio_10          __attribute__ ((aligned (8)));
726         unsigned long      full_aio_60          __attribute__ ((aligned (8)));
727         unsigned long      full_aio_300         __attribute__ ((aligned (8)));
728 };
729
730 #define STATS_PSI_IO_SIZE       (sizeof(struct stats_psi_io))
731 #define STATS_PSI_IO_ULL        2
732 #define STATS_PSI_IO_UL         6
733 #define STATS_PSI_IO_U          0
734
735 /* Structure for pressure-stall memory statistics */
736 struct stats_psi_mem {
737         unsigned long long some_mem_total;
738         unsigned long long full_mem_total;
739         unsigned long      some_amem_10         __attribute__ ((aligned (8)));
740         unsigned long      some_amem_60         __attribute__ ((aligned (8)));
741         unsigned long      some_amem_300        __attribute__ ((aligned (8)));
742         unsigned long      full_amem_10         __attribute__ ((aligned (8)));
743         unsigned long      full_amem_60         __attribute__ ((aligned (8)));
744         unsigned long      full_amem_300        __attribute__ ((aligned (8)));
745 };
746
747 #define STATS_PSI_MEM_SIZE      (sizeof(struct stats_psi_mem))
748 #define STATS_PSI_MEM_ULL       2
749 #define STATS_PSI_MEM_UL        6
750 #define STATS_PSI_MEM_U         0
751
752 /*
753  ***************************************************************************
754  * Prototypes for functions used to read system statistics
755  ***************************************************************************
756  */
757
758 void compute_ext_disk_stats
759         (struct stats_disk *, struct stats_disk *, unsigned long long,
760          struct ext_disk_stats *);
761 unsigned long long get_per_cpu_interval
762         (struct stats_cpu *, struct stats_cpu *);
763 __nr_t read_stat_cpu
764         (struct stats_cpu *, __nr_t);
765 __nr_t read_stat_irq
766         (struct stats_irq *, __nr_t);
767 __nr_t read_meminfo
768         (struct stats_memory *);
769 void read_uptime
770         (unsigned long long *);
771 #ifdef SOURCE_SADC
772 void oct2chr
773         (char *);
774 __nr_t read_stat_pcsw
775         (struct stats_pcsw *);
776 __nr_t read_loadavg
777         (struct stats_queue *);
778 __nr_t read_vmstat_swap
779         (struct stats_swap *);
780 __nr_t read_vmstat_paging
781         (struct stats_paging *);
782 __nr_t read_diskstats_io
783         (struct stats_io *);
784 __nr_t read_diskstats_disk
785         (struct stats_disk *, __nr_t, int);
786 __nr_t read_tty_driver_serial
787         (struct stats_serial *, __nr_t);
788 __nr_t read_kernel_tables
789         (struct stats_ktables *);
790 __nr_t read_net_dev
791         (struct stats_net_dev *, __nr_t);
792 void read_if_info
793         (struct stats_net_dev *, int);
794 __nr_t read_net_edev
795         (struct stats_net_edev *, __nr_t);
796 __nr_t read_net_nfs
797         (struct stats_net_nfs *);
798 __nr_t read_net_nfsd
799         (struct stats_net_nfsd *);
800 __nr_t read_net_sock
801         (struct stats_net_sock *);
802 __nr_t read_net_ip
803         (struct stats_net_ip *);
804 __nr_t read_net_eip
805         (struct stats_net_eip *);
806 __nr_t read_net_icmp
807         (struct stats_net_icmp *);
808 __nr_t read_net_eicmp
809         (struct stats_net_eicmp *);
810 __nr_t read_net_tcp
811         (struct stats_net_tcp *);
812 __nr_t read_net_etcp
813         (struct stats_net_etcp *);
814 __nr_t read_net_udp
815         (struct stats_net_udp *);
816 __nr_t read_net_sock6
817         (struct stats_net_sock6 *);
818 __nr_t read_net_ip6
819         (struct stats_net_ip6 *);
820 __nr_t read_net_eip6
821         (struct stats_net_eip6 *);
822 __nr_t read_net_icmp6
823         (struct stats_net_icmp6 *);
824 __nr_t read_net_eicmp6
825         (struct stats_net_eicmp6 *);
826 __nr_t read_net_udp6
827         (struct stats_net_udp6 *);
828 __nr_t read_cpuinfo
829         (struct stats_pwr_cpufreq *, __nr_t);
830 __nr_t read_meminfo_huge
831         (struct stats_huge *);
832 __nr_t read_cpu_wghfreq
833         (struct stats_pwr_wghfreq *, __nr_t, __nr_t);
834 __nr_t read_bus_usb_dev
835         (struct stats_pwr_usb *, __nr_t);
836 __nr_t read_filesystem
837         (struct stats_filesystem *, __nr_t);
838 __nr_t read_fchost
839         (struct stats_fchost *, __nr_t);
840 int read_softnet
841         (struct stats_softnet *, __nr_t, unsigned char []);
842 __nr_t read_psicpu
843         (struct stats_psi_cpu *);
844 __nr_t read_psiio
845         (struct stats_psi_io *);
846 __nr_t read_psimem
847         (struct stats_psi_mem *);
848
849 #endif /* SOURCE_SADC */
850
851 #endif /* _RD_STATS_H */