]> granicus.if.org Git - sysstat/blob - rd_stats.h
Replace strcpy() with strncpy() to avoid buffer overflows
[sysstat] / rd_stats.h
1 /*
2  * rd_stats.h: Include file used to read system statistics
3  * (C) 1999-2016 by Sebastien Godard (sysstat <at> orange.fr)
4  */
5
6 #ifndef _RD_STATS_H
7 #define _RD_STATS_H
8
9
10 /*
11  ***************************************************************************
12  * Miscellaneous constants
13  ***************************************************************************
14  */
15
16 /* Get IFNAMSIZ */
17 #include <net/if.h>
18 #ifndef IFNAMSIZ
19 #define IFNAMSIZ        16
20 #endif
21
22 /* Maximum length of network interface name */
23 #define MAX_IFACE_LEN   IFNAMSIZ
24 /* Maximum length of USB manufacturer string */
25 #define MAX_MANUF_LEN   24
26 /* Maximum length of USB product string */
27 #define MAX_PROD_LEN    48
28 /* Maximum length of filesystem name */
29 #define MAX_FS_LEN      128
30 /* Maximum length of FC host name */
31 #define MAX_FCH_LEN     16
32
33 #define CNT_PART        1
34 #define CNT_ALL_DEV     0
35 #define CNT_USED_DEV    1
36
37 #define K_DUPLEX_HALF   "half"
38 #define K_DUPLEX_FULL   "full"
39
40 #define C_DUPLEX_HALF   1
41 #define C_DUPLEX_FULL   2
42
43 /*
44  ***************************************************************************
45  * System files containing statistics
46  ***************************************************************************
47  */
48
49 /* Files */
50 #define PROC            "/proc"
51 #define SERIAL          "/proc/tty/driver/serial"
52 #define FDENTRY_STATE   "/proc/sys/fs/dentry-state"
53 #define FFILE_NR        "/proc/sys/fs/file-nr"
54 #define FINODE_STATE    "/proc/sys/fs/inode-state"
55 #define PTY_NR          "/proc/sys/kernel/pty/nr"
56 #define NET_DEV         "/proc/net/dev"
57 #define NET_SOCKSTAT    "/proc/net/sockstat"
58 #define NET_SOCKSTAT6   "/proc/net/sockstat6"
59 #define NET_RPC_NFS     "/proc/net/rpc/nfs"
60 #define NET_RPC_NFSD    "/proc/net/rpc/nfsd"
61 #define LOADAVG         "/proc/loadavg"
62 #define VMSTAT          "/proc/vmstat"
63 #define NET_SNMP        "/proc/net/snmp"
64 #define NET_SNMP6       "/proc/net/snmp6"
65 #define CPUINFO         "/proc/cpuinfo"
66 #define MTAB            "/etc/mtab"
67 #define IF_DUPLEX       "/sys/class/net/%s/duplex"
68 #define IF_SPEED        "/sys/class/net/%s/speed"
69 #define FC_RX_FRAMES    "%s/%s/statistics/rx_frames"
70 #define FC_TX_FRAMES    "%s/%s/statistics/tx_frames"
71 #define FC_RX_WORDS     "%s/%s/statistics/rx_words"
72 #define FC_TX_WORDS     "%s/%s/statistics/tx_words"
73
74 /*
75  ***************************************************************************
76  * Definitions of structures for system statistics
77  ***************************************************************************
78  */
79
80 #define ULL_ALIGNMENT_WIDTH 16
81 #define UL_ALIGNMENT_WIDTH 8
82 #define U_ALIGNMENT_WIDTH 4
83
84 /*
85  * Structure for CPU statistics.
86  * In activity buffer: First structure is for global CPU utilisation ("all").
87  * Following structures are for each individual CPU (0, 1, etc.)
88  */
89 struct stats_cpu {
90         unsigned long long cpu_user             __attribute__ ((aligned (16)));
91         unsigned long long cpu_nice             __attribute__ ((aligned (16)));
92         unsigned long long cpu_sys              __attribute__ ((aligned (16)));
93         unsigned long long cpu_idle             __attribute__ ((aligned (16)));
94         unsigned long long cpu_iowait           __attribute__ ((aligned (16)));
95         unsigned long long cpu_steal            __attribute__ ((aligned (16)));
96         unsigned long long cpu_hardirq          __attribute__ ((aligned (16)));
97         unsigned long long cpu_softirq          __attribute__ ((aligned (16)));
98         unsigned long long cpu_guest            __attribute__ ((aligned (16)));
99         unsigned long long cpu_guest_nice       __attribute__ ((aligned (16)));
100 };
101
102 #define STATS_CPU_SIZE  (sizeof(struct stats_cpu))
103
104 /*
105  * Structure for task creation and context switch statistics.
106  * The attribute (aligned(16)) is necessary so that sizeof(structure) has
107  * the same value on 32 and 64-bit architectures.
108  */
109 struct stats_pcsw {
110         unsigned long long context_switch       __attribute__ ((aligned (16)));
111         unsigned long processes                 __attribute__ ((aligned (16)));
112 };
113
114 #define STATS_PCSW_SIZE (sizeof(struct stats_pcsw))
115
116 /*
117  * Structure for interrupts statistics.
118  * In activity buffer: First structure is for total number of interrupts ("SUM").
119  * Following structures are for each individual interrupt (0, 1, etc.)
120  *
121  * NOTE: The total number of interrupts is saved as a %llu by the kernel,
122  * whereas individual interrupts are saved as %u.
123  */
124 struct stats_irq {
125         unsigned long long irq_nr       __attribute__ ((aligned (16)));
126 };
127
128 #define STATS_IRQ_SIZE  (sizeof(struct stats_irq))
129
130 /* Structure for swapping statistics */
131 struct stats_swap {
132         unsigned long pswpin    __attribute__ ((aligned (8)));
133         unsigned long pswpout   __attribute__ ((aligned (8)));
134 };
135
136 #define STATS_SWAP_SIZE (sizeof(struct stats_swap))
137
138 /* Structure for paging statistics */
139 struct stats_paging {
140         unsigned long pgpgin            __attribute__ ((aligned (8)));
141         unsigned long pgpgout           __attribute__ ((aligned (8)));
142         unsigned long pgfault           __attribute__ ((aligned (8)));
143         unsigned long pgmajfault        __attribute__ ((aligned (8)));
144         unsigned long pgfree            __attribute__ ((aligned (8)));
145         unsigned long pgscan_kswapd     __attribute__ ((aligned (8)));
146         unsigned long pgscan_direct     __attribute__ ((aligned (8)));
147         unsigned long pgsteal           __attribute__ ((aligned (8)));
148 };
149
150 #define STATS_PAGING_SIZE       (sizeof(struct stats_paging))
151
152 /* Structure for I/O and transfer rate statistics */
153 struct stats_io {
154         unsigned long long dk_drive             __attribute__ ((aligned (16)));
155         unsigned long long dk_drive_rio         __attribute__ ((packed));
156         unsigned long long dk_drive_wio         __attribute__ ((packed));
157         unsigned long long dk_drive_rblk        __attribute__ ((packed));
158         unsigned long long dk_drive_wblk        __attribute__ ((packed));
159 };
160
161 #define STATS_IO_SIZE   (sizeof(struct stats_io))
162
163 /* Structure for memory and swap space utilization statistics */
164 struct stats_memory {
165         unsigned long frmkb     __attribute__ ((aligned (8)));
166         unsigned long bufkb     __attribute__ ((aligned (8)));
167         unsigned long camkb     __attribute__ ((aligned (8)));
168         unsigned long tlmkb     __attribute__ ((aligned (8)));
169         unsigned long frskb     __attribute__ ((aligned (8)));
170         unsigned long tlskb     __attribute__ ((aligned (8)));
171         unsigned long caskb     __attribute__ ((aligned (8)));
172         unsigned long comkb     __attribute__ ((aligned (8)));
173         unsigned long activekb  __attribute__ ((aligned (8)));
174         unsigned long inactkb   __attribute__ ((aligned (8)));
175         unsigned long dirtykb   __attribute__ ((aligned (8)));
176         unsigned long anonpgkb  __attribute__ ((aligned (8)));
177         unsigned long slabkb    __attribute__ ((aligned (8)));
178         unsigned long kstackkb  __attribute__ ((aligned (8)));
179         unsigned long pgtblkb   __attribute__ ((aligned (8)));
180         unsigned long vmusedkb  __attribute__ ((aligned (8)));
181 };
182
183 #define STATS_MEMORY_SIZE       (sizeof(struct stats_memory))
184
185 /* Structure for kernel tables statistics */
186 struct stats_ktables {
187         unsigned int  file_used         __attribute__ ((aligned (4)));
188         unsigned int  inode_used        __attribute__ ((packed));
189         unsigned int  dentry_stat       __attribute__ ((packed));
190         unsigned int  pty_nr            __attribute__ ((packed));
191 };
192
193 #define STATS_KTABLES_SIZE      (sizeof(struct stats_ktables))
194
195 /* Structure for queue and load statistics */
196 struct stats_queue {
197         unsigned long nr_running        __attribute__ ((aligned (8)));
198         unsigned long procs_blocked     __attribute__ ((aligned (8)));
199         unsigned int  load_avg_1        __attribute__ ((aligned (8)));
200         unsigned int  load_avg_5        __attribute__ ((packed));
201         unsigned int  load_avg_15       __attribute__ ((packed));
202         unsigned int  nr_threads        __attribute__ ((packed));
203 };
204
205 #define STATS_QUEUE_SIZE        (sizeof(struct stats_queue))
206
207 /* Structure for serial statistics */
208 struct stats_serial {
209         unsigned int rx         __attribute__ ((aligned (4)));
210         unsigned int tx         __attribute__ ((packed));
211         unsigned int frame      __attribute__ ((packed));
212         unsigned int parity     __attribute__ ((packed));
213         unsigned int brk        __attribute__ ((packed));
214         unsigned int overrun    __attribute__ ((packed));
215         /*
216          * A value of 0 means that the structure is unused.
217          * To avoid the confusion, the line number is saved as (line# + 1)
218          */
219         unsigned int line       __attribute__ ((packed));
220 };
221
222 #define STATS_SERIAL_SIZE       (sizeof(struct stats_serial))
223
224 /* Structure for block devices statistics */
225 struct stats_disk {
226         unsigned long long nr_ios       __attribute__ ((aligned (16)));
227         unsigned long rd_sect           __attribute__ ((aligned (16)));
228         unsigned long wr_sect           __attribute__ ((aligned (8)));
229         unsigned int rd_ticks           __attribute__ ((aligned (8)));
230         unsigned int wr_ticks           __attribute__ ((packed));
231         unsigned int tot_ticks          __attribute__ ((packed));
232         unsigned int rq_ticks           __attribute__ ((packed));
233         unsigned int major              __attribute__ ((packed));
234         unsigned int minor              __attribute__ ((packed));
235 };
236
237 #define STATS_DISK_SIZE (sizeof(struct stats_disk))
238
239 /* Structure for network interfaces statistics */
240 struct stats_net_dev {
241         unsigned long long rx_packets           __attribute__ ((aligned (16)));
242         unsigned long long tx_packets           __attribute__ ((aligned (16)));
243         unsigned long long rx_bytes             __attribute__ ((aligned (16)));
244         unsigned long long tx_bytes             __attribute__ ((aligned (16)));
245         unsigned long long rx_compressed        __attribute__ ((aligned (16)));
246         unsigned long long tx_compressed        __attribute__ ((aligned (16)));
247         unsigned long long multicast            __attribute__ ((aligned (16)));
248         unsigned int       speed                __attribute__ ((aligned (16)));
249         char     interface[MAX_IFACE_LEN]       __attribute__ ((aligned (4)));
250         char     duplex;
251 };
252
253 #define STATS_NET_DEV_SIZE      (sizeof(struct stats_net_dev))
254
255 /* Structure for network interface errors statistics */
256 struct stats_net_edev {
257         unsigned long long collisions           __attribute__ ((aligned (16)));
258         unsigned long long rx_errors            __attribute__ ((aligned (16)));
259         unsigned long long tx_errors            __attribute__ ((aligned (16)));
260         unsigned long long rx_dropped           __attribute__ ((aligned (16)));
261         unsigned long long tx_dropped           __attribute__ ((aligned (16)));
262         unsigned long long rx_fifo_errors       __attribute__ ((aligned (16)));
263         unsigned long long tx_fifo_errors       __attribute__ ((aligned (16)));
264         unsigned long long rx_frame_errors      __attribute__ ((aligned (16)));
265         unsigned long long tx_carrier_errors    __attribute__ ((aligned (16)));
266         char          interface[MAX_IFACE_LEN]  __attribute__ ((aligned (16)));
267 };
268
269 #define STATS_NET_EDEV_SIZE     (sizeof(struct stats_net_edev))
270
271 /* Structure for NFS client statistics */
272 struct stats_net_nfs {
273         unsigned int  nfs_rpccnt        __attribute__ ((aligned (4)));
274         unsigned int  nfs_rpcretrans    __attribute__ ((packed));
275         unsigned int  nfs_readcnt       __attribute__ ((packed));
276         unsigned int  nfs_writecnt      __attribute__ ((packed));
277         unsigned int  nfs_accesscnt     __attribute__ ((packed));
278         unsigned int  nfs_getattcnt     __attribute__ ((packed));
279 };
280
281 #define STATS_NET_NFS_SIZE      (sizeof(struct stats_net_nfs))
282
283 /* Structure for NFS server statistics */
284 struct stats_net_nfsd {
285         unsigned int  nfsd_rpccnt       __attribute__ ((aligned (4)));
286         unsigned int  nfsd_rpcbad       __attribute__ ((packed));
287         unsigned int  nfsd_netcnt       __attribute__ ((packed));
288         unsigned int  nfsd_netudpcnt    __attribute__ ((packed));
289         unsigned int  nfsd_nettcpcnt    __attribute__ ((packed));
290         unsigned int  nfsd_rchits       __attribute__ ((packed));
291         unsigned int  nfsd_rcmisses     __attribute__ ((packed));
292         unsigned int  nfsd_readcnt      __attribute__ ((packed));
293         unsigned int  nfsd_writecnt     __attribute__ ((packed));
294         unsigned int  nfsd_accesscnt    __attribute__ ((packed));
295         unsigned int  nfsd_getattcnt    __attribute__ ((packed));
296 };
297
298 #define STATS_NET_NFSD_SIZE     (sizeof(struct stats_net_nfsd))
299
300 /* Structure for IPv4 sockets statistics */
301 struct stats_net_sock {
302         unsigned int  sock_inuse        __attribute__ ((aligned (4)));
303         unsigned int  tcp_inuse         __attribute__ ((packed));
304         unsigned int  tcp_tw            __attribute__ ((packed));
305         unsigned int  udp_inuse         __attribute__ ((packed));
306         unsigned int  raw_inuse         __attribute__ ((packed));
307         unsigned int  frag_inuse        __attribute__ ((packed));
308 };
309
310 #define STATS_NET_SOCK_SIZE     (sizeof(struct stats_net_sock))
311
312 /* Structure for IP statistics */
313 struct stats_net_ip {
314         unsigned long long InReceives           __attribute__ ((aligned (16)));
315         unsigned long long ForwDatagrams        __attribute__ ((aligned (16)));
316         unsigned long long InDelivers           __attribute__ ((aligned (16)));
317         unsigned long long OutRequests          __attribute__ ((aligned (16)));
318         unsigned long long ReasmReqds           __attribute__ ((aligned (16)));
319         unsigned long long ReasmOKs             __attribute__ ((aligned (16)));
320         unsigned long long FragOKs              __attribute__ ((aligned (16)));
321         unsigned long long FragCreates          __attribute__ ((aligned (16)));
322 };
323
324 #define STATS_NET_IP_SIZE       (sizeof(struct stats_net_ip))
325
326 /* Structure for IP errors statistics */
327 struct stats_net_eip {
328         unsigned long long InHdrErrors          __attribute__ ((aligned (16)));
329         unsigned long long InAddrErrors         __attribute__ ((aligned (16)));
330         unsigned long long InUnknownProtos      __attribute__ ((aligned (16)));
331         unsigned long long InDiscards           __attribute__ ((aligned (16)));
332         unsigned long long OutDiscards          __attribute__ ((aligned (16)));
333         unsigned long long OutNoRoutes          __attribute__ ((aligned (16)));
334         unsigned long long ReasmFails           __attribute__ ((aligned (16)));
335         unsigned long long FragFails            __attribute__ ((aligned (16)));
336 };
337
338 #define STATS_NET_EIP_SIZE      (sizeof(struct stats_net_eip))
339
340 /* Structure for ICMP statistics */
341 struct stats_net_icmp {
342         unsigned long InMsgs            __attribute__ ((aligned (8)));
343         unsigned long OutMsgs           __attribute__ ((aligned (8)));
344         unsigned long InEchos           __attribute__ ((aligned (8)));
345         unsigned long InEchoReps        __attribute__ ((aligned (8)));
346         unsigned long OutEchos          __attribute__ ((aligned (8)));
347         unsigned long OutEchoReps       __attribute__ ((aligned (8)));
348         unsigned long InTimestamps      __attribute__ ((aligned (8)));
349         unsigned long InTimestampReps   __attribute__ ((aligned (8)));
350         unsigned long OutTimestamps     __attribute__ ((aligned (8)));
351         unsigned long OutTimestampReps  __attribute__ ((aligned (8)));
352         unsigned long InAddrMasks       __attribute__ ((aligned (8)));
353         unsigned long InAddrMaskReps    __attribute__ ((aligned (8)));
354         unsigned long OutAddrMasks      __attribute__ ((aligned (8)));
355         unsigned long OutAddrMaskReps   __attribute__ ((aligned (8)));
356 };
357
358 #define STATS_NET_ICMP_SIZE     (sizeof(struct stats_net_icmp))
359
360 /* Structure for ICMP error message statistics */
361 struct stats_net_eicmp {
362         unsigned long InErrors          __attribute__ ((aligned (8)));
363         unsigned long OutErrors         __attribute__ ((aligned (8)));
364         unsigned long InDestUnreachs    __attribute__ ((aligned (8)));
365         unsigned long OutDestUnreachs   __attribute__ ((aligned (8)));
366         unsigned long InTimeExcds       __attribute__ ((aligned (8)));
367         unsigned long OutTimeExcds      __attribute__ ((aligned (8)));
368         unsigned long InParmProbs       __attribute__ ((aligned (8)));
369         unsigned long OutParmProbs      __attribute__ ((aligned (8)));
370         unsigned long InSrcQuenchs      __attribute__ ((aligned (8)));
371         unsigned long OutSrcQuenchs     __attribute__ ((aligned (8)));
372         unsigned long InRedirects       __attribute__ ((aligned (8)));
373         unsigned long OutRedirects      __attribute__ ((aligned (8)));
374 };
375
376 #define STATS_NET_EICMP_SIZE    (sizeof(struct stats_net_eicmp))
377
378 /* Structure for TCP statistics */
379 struct stats_net_tcp {
380         unsigned long ActiveOpens       __attribute__ ((aligned (8)));
381         unsigned long PassiveOpens      __attribute__ ((aligned (8)));
382         unsigned long InSegs            __attribute__ ((aligned (8)));
383         unsigned long OutSegs           __attribute__ ((aligned (8)));
384 };
385
386 #define STATS_NET_TCP_SIZE      (sizeof(struct stats_net_tcp))
387
388 /* Structure for TCP errors statistics */
389 struct stats_net_etcp {
390         unsigned long AttemptFails      __attribute__ ((aligned (8)));
391         unsigned long EstabResets       __attribute__ ((aligned (8)));
392         unsigned long RetransSegs       __attribute__ ((aligned (8)));
393         unsigned long InErrs            __attribute__ ((aligned (8)));
394         unsigned long OutRsts           __attribute__ ((aligned (8)));
395 };
396
397 #define STATS_NET_ETCP_SIZE     (sizeof(struct stats_net_etcp))
398
399 /* Structure for UDP statistics */
400 struct stats_net_udp {
401         unsigned long InDatagrams       __attribute__ ((aligned (8)));
402         unsigned long OutDatagrams      __attribute__ ((aligned (8)));
403         unsigned long NoPorts           __attribute__ ((aligned (8)));
404         unsigned long InErrors          __attribute__ ((aligned (8)));
405 };
406
407 #define STATS_NET_UDP_SIZE      (sizeof(struct stats_net_udp))
408
409 /* Structure for IPv6 statistics */
410 struct stats_net_ip6 {
411         unsigned long long InReceives6          __attribute__ ((aligned (16)));
412         unsigned long long OutForwDatagrams6    __attribute__ ((aligned (16)));
413         unsigned long long InDelivers6          __attribute__ ((aligned (16)));
414         unsigned long long OutRequests6         __attribute__ ((aligned (16)));
415         unsigned long long ReasmReqds6          __attribute__ ((aligned (16)));
416         unsigned long long ReasmOKs6            __attribute__ ((aligned (16)));
417         unsigned long long InMcastPkts6         __attribute__ ((aligned (16)));
418         unsigned long long OutMcastPkts6        __attribute__ ((aligned (16)));
419         unsigned long long FragOKs6             __attribute__ ((aligned (16)));
420         unsigned long long FragCreates6         __attribute__ ((aligned (16)));
421 };
422
423 #define STATS_NET_IP6_SIZE      (sizeof(struct stats_net_ip6))
424
425 /* Structure for IPv6 errors statistics */
426 struct stats_net_eip6 {
427         unsigned long long InHdrErrors6         __attribute__ ((aligned (16)));
428         unsigned long long InAddrErrors6        __attribute__ ((aligned (16)));
429         unsigned long long InUnknownProtos6     __attribute__ ((aligned (16)));
430         unsigned long long InTooBigErrors6      __attribute__ ((aligned (16)));
431         unsigned long long InDiscards6          __attribute__ ((aligned (16)));
432         unsigned long long OutDiscards6         __attribute__ ((aligned (16)));
433         unsigned long long InNoRoutes6          __attribute__ ((aligned (16)));
434         unsigned long long OutNoRoutes6         __attribute__ ((aligned (16)));
435         unsigned long long ReasmFails6          __attribute__ ((aligned (16)));
436         unsigned long long FragFails6           __attribute__ ((aligned (16)));
437         unsigned long long InTruncatedPkts6     __attribute__ ((aligned (16)));
438 };
439
440 #define STATS_NET_EIP6_SIZE     (sizeof(struct stats_net_eip6))
441
442 /* Structure for ICMPv6 statistics */
443 struct stats_net_icmp6 {
444         unsigned long InMsgs6                           __attribute__ ((aligned (8)));
445         unsigned long OutMsgs6                          __attribute__ ((aligned (8)));
446         unsigned long InEchos6                          __attribute__ ((aligned (8)));
447         unsigned long InEchoReplies6                    __attribute__ ((aligned (8)));
448         unsigned long OutEchoReplies6                   __attribute__ ((aligned (8)));
449         unsigned long InGroupMembQueries6               __attribute__ ((aligned (8)));
450         unsigned long InGroupMembResponses6             __attribute__ ((aligned (8)));
451         unsigned long OutGroupMembResponses6            __attribute__ ((aligned (8)));
452         unsigned long InGroupMembReductions6            __attribute__ ((aligned (8)));
453         unsigned long OutGroupMembReductions6           __attribute__ ((aligned (8)));
454         unsigned long InRouterSolicits6                 __attribute__ ((aligned (8)));
455         unsigned long OutRouterSolicits6                __attribute__ ((aligned (8)));
456         unsigned long InRouterAdvertisements6           __attribute__ ((aligned (8)));
457         unsigned long InNeighborSolicits6               __attribute__ ((aligned (8)));
458         unsigned long OutNeighborSolicits6              __attribute__ ((aligned (8)));
459         unsigned long InNeighborAdvertisements6         __attribute__ ((aligned (8)));
460         unsigned long OutNeighborAdvertisements6        __attribute__ ((aligned (8)));
461 };
462
463 #define STATS_NET_ICMP6_SIZE    (sizeof(struct stats_net_icmp6))
464
465 /* Structure for ICMPv6 error message statistics */
466 struct stats_net_eicmp6 {
467         unsigned long InErrors6         __attribute__ ((aligned (8)));
468         unsigned long InDestUnreachs6   __attribute__ ((aligned (8)));
469         unsigned long OutDestUnreachs6  __attribute__ ((aligned (8)));
470         unsigned long InTimeExcds6      __attribute__ ((aligned (8)));
471         unsigned long OutTimeExcds6     __attribute__ ((aligned (8)));
472         unsigned long InParmProblems6   __attribute__ ((aligned (8)));
473         unsigned long OutParmProblems6  __attribute__ ((aligned (8)));
474         unsigned long InRedirects6      __attribute__ ((aligned (8)));
475         unsigned long OutRedirects6     __attribute__ ((aligned (8)));
476         unsigned long InPktTooBigs6     __attribute__ ((aligned (8)));
477         unsigned long OutPktTooBigs6    __attribute__ ((aligned (8)));
478 };
479
480 #define STATS_NET_EICMP6_SIZE   (sizeof(struct stats_net_eicmp6))
481
482 /* Structure for UDPv6 statistics */
483 struct stats_net_udp6 {
484         unsigned long InDatagrams6      __attribute__ ((aligned (8)));
485         unsigned long OutDatagrams6     __attribute__ ((aligned (8)));
486         unsigned long NoPorts6          __attribute__ ((aligned (8)));
487         unsigned long InErrors6         __attribute__ ((aligned (8)));
488 };
489
490 #define STATS_NET_UDP6_SIZE     (sizeof(struct stats_net_udp6))
491
492 /* Structure for IPv6 sockets statistics */
493 struct stats_net_sock6 {
494         unsigned int  tcp6_inuse        __attribute__ ((aligned (4)));
495         unsigned int  udp6_inuse        __attribute__ ((packed));
496         unsigned int  raw6_inuse        __attribute__ ((packed));
497         unsigned int  frag6_inuse       __attribute__ ((packed));
498 };
499
500 #define STATS_NET_SOCK6_SIZE    (sizeof(struct stats_net_sock6))
501
502 /*
503  * Structure for CPU frequency statistics.
504  * In activity buffer: First structure is for global CPU utilisation ("all").
505  * Following structures are for each individual CPU (0, 1, etc.)
506  */
507 struct stats_pwr_cpufreq {
508         unsigned long cpufreq   __attribute__ ((aligned (8)));
509 };
510
511 #define STATS_PWR_CPUFREQ_SIZE  (sizeof(struct stats_pwr_cpufreq))
512
513 /* Structure for hugepages statistics */
514 struct stats_huge {
515         unsigned long frhkb                     __attribute__ ((aligned (8)));
516         unsigned long tlhkb                     __attribute__ ((aligned (8)));
517 };
518
519 #define STATS_HUGE_SIZE (sizeof(struct stats_memory))
520
521 /*
522  * Structure for weighted CPU frequency statistics.
523  * In activity buffer: First structure is for global CPU utilisation ("all").
524  * Following structures are for each individual CPU (0, 1, etc.)
525  */
526 struct stats_pwr_wghfreq {
527         unsigned long long      time_in_state   __attribute__ ((aligned (16)));
528         unsigned long           freq            __attribute__ ((aligned (16)));
529 };
530
531 #define STATS_PWR_WGHFREQ_SIZE  (sizeof(struct stats_pwr_wghfreq))
532
533 /*
534  * Structure for USB devices plugged into the system.
535  */
536 struct stats_pwr_usb {
537         unsigned int  bus_nr                            __attribute__ ((aligned (4)));
538         unsigned int  vendor_id                         __attribute__ ((packed));
539         unsigned int  product_id                        __attribute__ ((packed));
540         unsigned int  bmaxpower                         __attribute__ ((packed));
541         char          manufacturer[MAX_MANUF_LEN];
542         char          product[MAX_PROD_LEN];
543 };
544
545 #define STATS_PWR_USB_SIZE      (sizeof(struct stats_pwr_usb))
546
547 /* Structure for filesystems statistics */
548 struct stats_filesystem {
549         unsigned long long f_blocks             __attribute__ ((aligned (16)));
550         unsigned long long f_bfree              __attribute__ ((aligned (16)));
551         unsigned long long f_bavail             __attribute__ ((aligned (16)));
552         unsigned long long f_files              __attribute__ ((aligned (16)));
553         unsigned long long f_ffree              __attribute__ ((aligned (16)));
554         char               fs_name[MAX_FS_LEN]  __attribute__ ((aligned (16)));
555         char               mountp[MAX_FS_LEN];
556 };
557
558 #define STATS_FILESYSTEM_SIZE   (sizeof(struct stats_filesystem))
559
560 /* Structure for Fibre Channel HBA statistics */
561 struct stats_fchost {
562         unsigned long f_rxframes                __attribute__ ((aligned (8)));
563         unsigned long f_txframes                __attribute__ ((aligned (8)));
564         unsigned long f_rxwords                 __attribute__ ((aligned (8)));
565         unsigned long f_txwords                 __attribute__ ((aligned (8)));
566         char          fchost_name[MAX_FCH_LEN]  __attribute__ ((aligned (8)));
567 };
568
569 #define STATS_FCHOST_SIZE       (sizeof(struct stats_fchost))
570
571 /*
572  ***************************************************************************
573  * Prototypes for functions used to read system statistics
574  ***************************************************************************
575  */
576
577 void oct2chr
578         (char *);
579 void read_stat_cpu
580         (struct stats_cpu *, int, unsigned long long *, unsigned long long *);
581 void read_stat_irq
582         (struct stats_irq *, int);
583 void read_meminfo
584         (struct stats_memory *);
585 void read_uptime
586         (unsigned long long *);
587 void read_stat_pcsw
588         (struct stats_pcsw *);
589 void read_loadavg
590         (struct stats_queue *);
591 void read_vmstat_swap
592         (struct stats_swap *);
593 void read_vmstat_paging
594         (struct stats_paging *);
595 void read_diskstats_io
596         (struct stats_io *);
597 void read_diskstats_disk
598         (struct stats_disk *, int, int);
599 void read_tty_driver_serial
600         (struct stats_serial *, int);
601 void read_kernel_tables
602         (struct stats_ktables *);
603 int read_net_dev
604         (struct stats_net_dev *, int);
605 void read_if_info
606         (struct stats_net_dev *, int);
607 void read_net_edev
608         (struct stats_net_edev *, int);
609 void read_net_nfs
610         (struct stats_net_nfs *);
611 void read_net_nfsd
612         (struct stats_net_nfsd *);
613 void read_net_sock
614         (struct stats_net_sock *);
615 void read_net_ip
616         (struct stats_net_ip *);
617 void read_net_eip
618         (struct stats_net_eip *);
619 void read_net_icmp
620         (struct stats_net_icmp *);
621 void read_net_eicmp
622         (struct stats_net_eicmp *);
623 void read_net_tcp
624         (struct stats_net_tcp *);
625 void read_net_etcp
626         (struct stats_net_etcp *);
627 void read_net_udp
628         (struct stats_net_udp *);
629 void read_net_sock6
630         (struct stats_net_sock6 *);
631 void read_net_ip6
632         (struct stats_net_ip6 *);
633 void read_net_eip6
634         (struct stats_net_eip6 *);
635 void read_net_icmp6
636         (struct stats_net_icmp6 *);
637 void read_net_eicmp6
638         (struct stats_net_eicmp6 *);
639 void read_net_udp6
640         (struct stats_net_udp6 *);
641 void read_cpuinfo
642         (struct stats_pwr_cpufreq *, int);
643 void read_meminfo_huge
644         (struct stats_huge *);
645 void read_time_in_state
646         (struct stats_pwr_wghfreq *, int, int);
647 void read_bus_usb_dev
648         (struct stats_pwr_usb *, int);
649 void read_filesystem
650         (struct stats_filesystem *, int);
651 void read_fchost
652         (struct stats_fchost *, int);
653
654 #endif /* _RD_STATS_H */