]> granicus.if.org Git - sysstat/blob - activity.c
sadf updated for USB devices statistics.
[sysstat] / activity.c
1 /*
2  * activity.c: Define system activities available for sar/sadc.
3  * (C) 1999-2011 by Sebastien GODARD (sysstat <at> orange.fr)
4  *
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.                                              *
10  *                                                                         *
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 *
14  * for more details.                                                       *
15  *                                                                         *
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  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA                   *
19  ***************************************************************************
20  */
21
22 #include "sa.h"
23
24 #ifdef SOURCE_SADC
25 #include "rd_stats.h"
26 #include "rd_sensors.h"
27 #endif
28
29 #ifdef SOURCE_SAR
30 #include "pr_stats.h"
31 #endif
32
33 #ifdef SOURCE_SADF
34 #include "rndr_stats.h"
35 #include "xml_stats.h"
36 #endif
37
38 /*
39  ***************************************************************************
40  * Definitions of system activities.
41  * See sa.h file for activity structure definition.
42  ***************************************************************************
43  */
44
45 /*
46  * Bitmaps needed by activities.
47  * Remember to allocate them before use!
48  */
49
50 /* CPU bitmap */
51 struct act_bitmap cpu_bitmap = {
52         .b_array        = NULL,
53         .b_size         = NR_CPUS
54 };
55
56 /* Interrupts bitmap */
57 struct act_bitmap irq_bitmap = {
58         .b_array        = NULL,
59         .b_size         = NR_IRQS
60 };
61
62
63 /*
64  * CPU statistics.
65  * This is the only activity which *must* be collected by sadc
66  * so that uptime can be filled.
67  */
68 struct activity cpu_act = {
69         .id             = A_CPU,
70         .options        = AO_COLLECTED + AO_REMANENT + AO_GLOBAL_ITV + AO_MULTIPLE_OUTPUTS,
71         .magic          = ACTIVITY_MAGIC_BASE,
72         .group          = G_DEFAULT,
73 #ifdef SOURCE_SADC
74         .f_count        = wrap_get_cpu_nr,
75         .f_count2       = NULL,
76         .f_read         = wrap_read_stat_cpu,
77 #endif
78 #ifdef SOURCE_SAR
79         .f_print        = print_cpu_stats,
80         .f_print_avg    = print_cpu_stats,
81 #endif
82 #ifdef SOURCE_SADF
83         .f_render       = render_cpu_stats,
84         .f_xml_print    = xml_print_cpu_stats,
85         .hdr_line       = "CPU;%user;%nice;%system;%iowait;%steal;%idle|"
86                           "CPU;%usr;%nice;%sys;%iowait;%steal;%irq;%soft;%guest;%idle",
87         .name           = "A_CPU",
88 #endif
89         .nr             = -1,
90         .nr2            = 1,
91         .fsize          = STATS_CPU_SIZE,
92         .msize          = STATS_CPU_SIZE,
93         .opt_flags      = AO_F_CPU_DEF,
94         .buf            = {NULL, NULL, NULL},
95         .bitmap         = &cpu_bitmap
96 };
97
98 /* Process (task) creation and context switch activity */
99 struct activity pcsw_act = {
100         .id             = A_PCSW,
101         .options        = AO_COLLECTED,
102         .magic          = ACTIVITY_MAGIC_BASE,
103         .group          = G_DEFAULT,
104 #ifdef SOURCE_SADC
105         .f_count        = NULL,
106         .f_count2       = NULL,
107         .f_read         = wrap_read_stat_pcsw,
108 #endif
109 #ifdef SOURCE_SAR
110         .f_print        = print_pcsw_stats,
111         .f_print_avg    = print_pcsw_stats,
112 #endif
113 #ifdef SOURCE_SADF
114         .f_render       = render_pcsw_stats,
115         .f_xml_print    = xml_print_pcsw_stats,
116         .hdr_line       = "proc/s;cswch/s",
117         .name           = "A_PCSW",
118 #endif
119         .nr             = 1,
120         .nr2            = 1,
121         .fsize          = STATS_PCSW_SIZE,
122         .msize          = STATS_PCSW_SIZE,
123         .opt_flags      = 0,
124         .buf            = {NULL, NULL, NULL},
125         .bitmap         = NULL
126 };
127
128 /* Interrupts statistics */
129 struct activity irq_act = {
130         .id             = A_IRQ,
131         .options        = AO_NULL,
132         .magic          = ACTIVITY_MAGIC_BASE,
133         .group          = G_INT,
134 #ifdef SOURCE_SADC
135         .f_count        = wrap_get_irq_nr,
136         .f_count2       = NULL,
137         .f_read         = wrap_read_stat_irq,
138 #endif
139 #ifdef SOURCE_SAR
140         .f_print        = print_irq_stats,
141         .f_print_avg    = print_irq_stats,
142 #endif
143 #ifdef SOURCE_SADF
144         .f_render       = render_irq_stats,
145         .f_xml_print    = xml_print_irq_stats,
146         .hdr_line       = "INTR;intr/s",
147         .name           = "A_IRQ",
148 #endif
149         .nr             = -1,
150         .nr2            = 1,
151         .fsize          = STATS_IRQ_SIZE,
152         .msize          = STATS_IRQ_SIZE,
153         .opt_flags      = 0,
154         .buf            = {NULL, NULL, NULL},
155         .bitmap         = &irq_bitmap
156 };
157
158 /* Swapping activity */
159 struct activity swap_act = {
160         .id             = A_SWAP,
161         .options        = AO_COLLECTED,
162         .magic          = ACTIVITY_MAGIC_BASE,
163         .group          = G_DEFAULT,
164 #ifdef SOURCE_SADC
165         .f_count        = NULL,
166         .f_count2       = NULL,
167         .f_read         = wrap_read_swap,
168 #endif
169 #ifdef SOURCE_SAR
170         .f_print        = print_swap_stats,
171         .f_print_avg    = print_swap_stats,
172 #endif
173 #ifdef SOURCE_SADF
174         .f_render       = render_swap_stats,
175         .f_xml_print    = xml_print_swap_stats,
176         .hdr_line       = "pswpin/s;pswpout/s",
177         .name           = "A_SWAP",
178 #endif
179         .nr             = 1,
180         .nr2            = 1,
181         .fsize          = STATS_SWAP_SIZE,
182         .msize          = STATS_SWAP_SIZE,
183         .opt_flags      = 0,
184         .buf            = {NULL, NULL, NULL},
185         .bitmap         = NULL
186 };
187
188 /* Paging activity */
189 struct activity paging_act = {
190         .id             = A_PAGE,
191         .options        = AO_COLLECTED,
192         .magic          = ACTIVITY_MAGIC_BASE,
193         .group          = G_DEFAULT,
194 #ifdef SOURCE_SADC
195         .f_count        = NULL,
196         .f_count2       = NULL,
197         .f_read         = wrap_read_paging,
198 #endif
199 #ifdef SOURCE_SAR
200         .f_print        = print_paging_stats,
201         .f_print_avg    = print_paging_stats,
202 #endif
203 #ifdef SOURCE_SADF
204         .f_render       = render_paging_stats,
205         .f_xml_print    = xml_print_paging_stats,
206         .hdr_line       = "pgpgin/s;pgpgout/s;fault/s;majflt/s;"
207                           "pgfree/s;pgscank/s;pgscand/s;pgsteal/s;%vmeff",
208         .name           = "A_PAGE",
209 #endif
210         .nr             = 1,
211         .nr2            = 1,
212         .fsize          = STATS_PAGING_SIZE,
213         .msize          = STATS_PAGING_SIZE,
214         .opt_flags      = 0,
215         .buf            = {NULL, NULL, NULL},
216         .bitmap         = NULL
217 };
218
219 /* I/O and transfer rate activity */
220 struct activity io_act = {
221         .id             = A_IO,
222         .options        = AO_COLLECTED,
223         .magic          = ACTIVITY_MAGIC_BASE,
224         .group          = G_DEFAULT,
225 #ifdef SOURCE_SADC
226         .f_count        = NULL,
227         .f_count2       = NULL,
228         .f_read         = wrap_read_io,
229 #endif
230 #ifdef SOURCE_SAR
231         .f_print        = print_io_stats,
232         .f_print_avg    = print_io_stats,
233 #endif
234 #ifdef SOURCE_SADF
235         .f_render       = render_io_stats,
236         .f_xml_print    = xml_print_io_stats,
237         .hdr_line       = "tps;rtps;wtps;bread/s;bwrtn/s",
238         .name           = "A_IO",
239 #endif
240         .nr             = 1,
241         .nr2            = 1,
242         .fsize          = STATS_IO_SIZE,
243         .msize          = STATS_IO_SIZE,
244         .opt_flags      = 0,
245         .buf            = {NULL, NULL, NULL},
246         .bitmap         = NULL
247 };
248
249 /* Memory and swap space utilization activity */
250 struct activity memory_act = {
251         .id             = A_MEMORY,
252         .options        = AO_COLLECTED + AO_MULTIPLE_OUTPUTS,
253         .magic          = ACTIVITY_MAGIC_BASE,
254         .group          = G_DEFAULT,
255 #ifdef SOURCE_SADC
256         .f_count        = NULL,
257         .f_count2       = NULL,
258         .f_read         = wrap_read_meminfo,
259 #endif
260 #ifdef SOURCE_SAR
261         .f_print        = print_memory_stats,
262         .f_print_avg    = print_avg_memory_stats,
263 #endif
264 #ifdef SOURCE_SADF
265         .f_render       = render_memory_stats,
266         .f_xml_print    = xml_print_memory_stats,
267         .hdr_line       = "frmpg/s;bufpg/s;campg/s|"
268                           "kbmemfree;kbmemused;%memused;kbbuffers;kbcached;kbcommit;%commit;kbactive;kbinact|"
269                           "kbswpfree;kbswpused;%swpused;kbswpcad;%swpcad",
270         .name           = "A_MEMORY",
271 #endif
272         .nr             = 1,
273         .nr2            = 1,
274         .fsize          = STATS_MEMORY_SIZE,
275         .msize          = STATS_MEMORY_SIZE,
276         .opt_flags      = 0,
277         .buf            = {NULL, NULL, NULL},
278         .bitmap         = NULL
279 };
280
281 /* Kernel tables activity */
282 struct activity ktables_act = {
283         .id             = A_KTABLES,
284         .options        = AO_COLLECTED,
285         .magic          = ACTIVITY_MAGIC_BASE,
286         .group          = G_DEFAULT,
287 #ifdef SOURCE_SADC
288         .f_count        = NULL,
289         .f_count2       = NULL,
290         .f_read         = wrap_read_kernel_tables,
291 #endif
292 #ifdef SOURCE_SAR
293         .f_print        = print_ktables_stats,
294         .f_print_avg    = print_avg_ktables_stats,
295 #endif
296 #ifdef SOURCE_SADF
297         .f_render       = render_ktables_stats,
298         .f_xml_print    = xml_print_ktables_stats,
299         .hdr_line       = "dentunusd;file-nr;inode-nr;pty-nr",
300         .name           = "A_KTABLES",
301 #endif
302         .nr             = 1,
303         .nr2            = 1,
304         .fsize          = STATS_KTABLES_SIZE,
305         .msize          = STATS_KTABLES_SIZE,
306         .opt_flags      = 0,
307         .buf            = {NULL, NULL, NULL},
308         .bitmap         = NULL
309 };
310
311 /* Queue and load activity */
312 struct activity queue_act = {
313         .id             = A_QUEUE,
314         .options        = AO_COLLECTED,
315         .magic          = ACTIVITY_MAGIC_BASE + 1,
316         .group          = G_DEFAULT,
317 #ifdef SOURCE_SADC
318         .f_count        = NULL,
319         .f_count2       = NULL,
320         .f_read         = wrap_read_loadavg,
321 #endif
322 #ifdef SOURCE_SAR
323         .f_print        = print_queue_stats,
324         .f_print_avg    = print_avg_queue_stats,
325 #endif
326 #ifdef SOURCE_SADF
327         .f_render       = render_queue_stats,
328         .f_xml_print    = xml_print_queue_stats,
329         .hdr_line       = "runq-sz;plist-sz;ldavg-1;ldavg-5;ldavg-15;blocked",
330         .name           = "A_QUEUE",
331 #endif
332         .nr             = 1,
333         .nr2            = 1,
334         .fsize          = STATS_QUEUE_SIZE,
335         .msize          = STATS_QUEUE_SIZE,
336         .opt_flags      = 0,
337         .buf            = {NULL, NULL, NULL},
338         .bitmap         = NULL
339 };
340
341 /* Serial lines activity */
342 struct activity serial_act = {
343         .id             = A_SERIAL,
344         .options        = AO_COLLECTED,
345         .magic          = ACTIVITY_MAGIC_BASE,
346         .group          = G_DEFAULT,
347 #ifdef SOURCE_SADC
348         .f_count        = wrap_get_serial_nr,
349         .f_count2       = NULL,
350         .f_read         = wrap_read_tty_driver_serial,
351 #endif
352 #ifdef SOURCE_SAR
353         .f_print        = print_serial_stats,
354         .f_print_avg    = print_serial_stats,
355 #endif
356 #ifdef SOURCE_SADF
357         .f_render       = render_serial_stats,
358         .f_xml_print    = xml_print_serial_stats,
359         .hdr_line       = "TTY;rcvin/s;txmtin/s;framerr/s;prtyerr/s;brk/s;ovrun/s",
360         .name           = "A_SERIAL",
361 #endif
362         .nr             = -1,
363         .nr2            = 1,
364         .fsize          = STATS_SERIAL_SIZE,
365         .msize          = STATS_SERIAL_SIZE,
366         .opt_flags      = 0,
367         .buf            = {NULL, NULL, NULL},
368         .bitmap         = NULL
369 };
370
371 /* Block devices activity */
372 struct activity disk_act = {
373         .id             = A_DISK,
374         .options        = AO_NULL,
375         .magic          = ACTIVITY_MAGIC_BASE,
376         .group          = G_DISK,
377 #ifdef SOURCE_SADC
378         .f_count        = wrap_get_disk_nr,
379         .f_count2       = NULL,
380         .f_read         = wrap_read_disk,
381 #endif
382 #ifdef SOURCE_SAR
383         .f_print        = print_disk_stats,
384         .f_print_avg    = print_disk_stats,
385 #endif
386 #ifdef SOURCE_SADF
387         .f_render       = render_disk_stats,
388         .f_xml_print    = xml_print_disk_stats,
389         .hdr_line       = "DEV;tps;rd_sec/s;wr_sec/s;avgrq-sz;avgqu-sz;await;svctm;%util",
390         .name           = "A_DISK",
391 #endif
392         .nr             = -1,
393         .nr2            = 1,
394         .fsize          = STATS_DISK_SIZE,
395         .msize          = STATS_DISK_SIZE,
396         .opt_flags      = 0,
397         .buf            = {NULL, NULL, NULL},
398         .bitmap         = NULL
399 };
400
401 /* Network interfaces activity */
402 struct activity net_dev_act = {
403         .id             = A_NET_DEV,
404         .options        = AO_COLLECTED,
405         .magic          = ACTIVITY_MAGIC_BASE,
406         .group          = G_DEFAULT,
407 #ifdef SOURCE_SADC
408         .f_count        = wrap_get_iface_nr,
409         .f_count2       = NULL,
410         .f_read         = wrap_read_net_dev,
411 #endif
412 #ifdef SOURCE_SAR
413         .f_print        = print_net_dev_stats,
414         .f_print_avg    = print_net_dev_stats,
415 #endif
416 #ifdef SOURCE_SADF
417         .f_render       = render_net_dev_stats,
418         .f_xml_print    = xml_print_net_dev_stats,
419         .hdr_line       = "IFACE;rxpck/s;txpck/s;rxkB/s;txkB/s;rxcmp/s;txcmp/s;rxmcst/s",
420         .name           = "A_NET_DEV",
421 #endif
422         .nr             = -1,
423         .nr2            = 1,
424         .fsize          = STATS_NET_DEV_SIZE,
425         .msize          = STATS_NET_DEV_SIZE,
426         .opt_flags      = 0,
427         .buf            = {NULL, NULL, NULL},
428         .bitmap         = NULL
429 };
430
431 /* Network interfaces activity */
432 struct activity net_edev_act = {
433         .id             = A_NET_EDEV,
434         .options        = AO_COLLECTED,
435         .magic          = ACTIVITY_MAGIC_BASE,
436         .group          = G_DEFAULT,
437 #ifdef SOURCE_SADC
438         .f_count        = wrap_get_iface_nr,
439         .f_count2       = NULL,
440         .f_read         = wrap_read_net_edev,
441 #endif
442 #ifdef SOURCE_SAR
443         .f_print        = print_net_edev_stats,
444         .f_print_avg    = print_net_edev_stats,
445 #endif
446 #ifdef SOURCE_SADF
447         .f_render       = render_net_edev_stats,
448         .f_xml_print    = xml_print_net_edev_stats,
449         .hdr_line       = "IFACE;rxerr/s;txerr/s;coll/s;rxdrop/s;txdrop/s;"
450                           "txcarr/s;rxfram/s;rxfifo/s;txfifo/s",
451         .name           = "A_NET_EDEV",
452 #endif
453         .nr             = -1,
454         .nr2            = 1,
455         .fsize          = STATS_NET_EDEV_SIZE,
456         .msize          = STATS_NET_EDEV_SIZE,
457         .opt_flags      = 0,
458         .buf            = {NULL, NULL, NULL},
459         .bitmap         = NULL
460 };
461
462 /* NFS client activity */
463 struct activity net_nfs_act = {
464         .id             = A_NET_NFS,
465         .options        = AO_COLLECTED,
466         .magic          = ACTIVITY_MAGIC_BASE,
467         .group          = G_DEFAULT,
468 #ifdef SOURCE_SADC
469         .f_count        = NULL,
470         .f_count2       = NULL,
471         .f_read         = wrap_read_net_nfs,
472 #endif
473 #ifdef SOURCE_SAR
474         .f_print        = print_net_nfs_stats,
475         .f_print_avg    = print_net_nfs_stats,
476 #endif
477 #ifdef SOURCE_SADF
478         .f_render       = render_net_nfs_stats,
479         .f_xml_print    = xml_print_net_nfs_stats,
480         .hdr_line       = "call/s;retrans/s;read/s;write/s;access/s;getatt/s",
481         .name           = "A_NET_NFS",
482 #endif
483         .nr             = 1,
484         .nr2            = 1,
485         .fsize          = STATS_NET_NFS_SIZE,
486         .msize          = STATS_NET_NFS_SIZE,
487         .opt_flags      = 0,
488         .buf            = {NULL, NULL, NULL},
489         .bitmap         = NULL
490 };
491
492 /* NFS server activity */
493 struct activity net_nfsd_act = {
494         .id             = A_NET_NFSD,
495         .options        = AO_COLLECTED,
496         .magic          = ACTIVITY_MAGIC_BASE,
497         .group          = G_DEFAULT,
498 #ifdef SOURCE_SADC
499         .f_count        = NULL,
500         .f_count2       = NULL,
501         .f_read         = wrap_read_net_nfsd,
502 #endif
503 #ifdef SOURCE_SAR
504         .f_print        = print_net_nfsd_stats,
505         .f_print_avg    = print_net_nfsd_stats,
506 #endif
507 #ifdef SOURCE_SADF
508         .f_render       = render_net_nfsd_stats,
509         .f_xml_print    = xml_print_net_nfsd_stats,
510         .hdr_line       = "scall/s;badcall/s;packet/s;udp/s;tcp/s;hit/s;miss/s;"
511                           "sread/s;swrite/s;saccess/s;sgetatt/s",
512         .name           = "A_NET_NFSD",
513 #endif
514         .nr             = 1,
515         .nr2            = 1,
516         .fsize          = STATS_NET_NFSD_SIZE,
517         .msize          = STATS_NET_NFSD_SIZE,
518         .opt_flags      = 0,
519         .buf            = {NULL, NULL, NULL},
520         .bitmap         = NULL
521 };
522
523 /* Network sockets activity */
524 struct activity net_sock_act = {
525         .id             = A_NET_SOCK,
526         .options        = AO_COLLECTED,
527         .magic          = ACTIVITY_MAGIC_BASE,
528         .group          = G_DEFAULT,
529 #ifdef SOURCE_SADC
530         .f_count        = NULL,
531         .f_count2       = NULL,
532         .f_read         = wrap_read_net_sock,
533 #endif
534 #ifdef SOURCE_SAR
535         .f_print        = print_net_sock_stats,
536         .f_print_avg    = print_avg_net_sock_stats,
537 #endif
538 #ifdef SOURCE_SADF
539         .f_render       = render_net_sock_stats,
540         .f_xml_print    = xml_print_net_sock_stats,
541         .hdr_line       = "totsck;tcpsck;udpsck;rawsck;ip-frag;tcp-tw",
542         .name           = "A_NET_SOCK",
543 #endif
544         .nr             = 1,
545         .nr2            = 1,
546         .fsize          = STATS_NET_SOCK_SIZE,
547         .msize          = STATS_NET_SOCK_SIZE,
548         .opt_flags      = 0,
549         .buf            = {NULL, NULL, NULL},
550         .bitmap         = NULL
551 };
552
553 /* IP network traffic activity */
554 struct activity net_ip_act = {
555         .id             = A_NET_IP,
556         .options        = AO_NULL,
557         .magic          = ACTIVITY_MAGIC_BASE,
558         .group          = G_SNMP,
559 #ifdef SOURCE_SADC
560         .f_count        = NULL,
561         .f_count2       = NULL,
562         .f_read         = wrap_read_net_ip,
563 #endif
564 #ifdef SOURCE_SAR
565         .f_print        = print_net_ip_stats,
566         .f_print_avg    = print_net_ip_stats,
567 #endif
568 #ifdef SOURCE_SADF
569         .f_render       = render_net_ip_stats,
570         .f_xml_print    = xml_print_net_ip_stats,
571         .hdr_line       = "irec/s;fwddgm/s;idel/s;orq/s;asmrq/s;asmok/s;fragok/s;fragcrt/s",
572         .name           = "A_NET_IP",
573 #endif
574         .nr             = 1,
575         .nr2            = 1,
576         .fsize          = STATS_NET_IP_SIZE,
577         .msize          = STATS_NET_IP_SIZE,
578         .opt_flags      = 0,
579         .buf            = {NULL, NULL, NULL},
580         .bitmap         = NULL
581 };
582
583 /* IP network traffic (errors) activity */
584 struct activity net_eip_act = {
585         .id             = A_NET_EIP,
586         .options        = AO_NULL,
587         .magic          = ACTIVITY_MAGIC_BASE,
588         .group          = G_SNMP,
589 #ifdef SOURCE_SADC
590         .f_count        = NULL,
591         .f_count2       = NULL,
592         .f_read         = wrap_read_net_eip,
593 #endif
594 #ifdef SOURCE_SAR
595         .f_print        = print_net_eip_stats,
596         .f_print_avg    = print_net_eip_stats,
597 #endif
598 #ifdef SOURCE_SADF
599         .f_render       = render_net_eip_stats,
600         .f_xml_print    = xml_print_net_eip_stats,
601         .hdr_line       = "ihdrerr/s;iadrerr/s;iukwnpr/s;idisc/s;odisc/s;onort/s;asmf/s;fragf/s",
602         .name           = "A_NET_EIP",
603 #endif
604         .nr             = 1,
605         .nr2            = 1,
606         .fsize          = STATS_NET_EIP_SIZE,
607         .msize          = STATS_NET_EIP_SIZE,
608         .opt_flags      = 0,
609         .buf            = {NULL, NULL, NULL},
610         .bitmap         = NULL
611 };
612
613 /* ICMP network traffic activity */
614 struct activity net_icmp_act = {
615         .id             = A_NET_ICMP,
616         .options        = AO_NULL,
617         .magic          = ACTIVITY_MAGIC_BASE,
618         .group          = G_SNMP,
619 #ifdef SOURCE_SADC
620         .f_count        = NULL,
621         .f_count2       = NULL,
622         .f_read         = wrap_read_net_icmp,
623 #endif
624 #ifdef SOURCE_SAR
625         .f_print        = print_net_icmp_stats,
626         .f_print_avg    = print_net_icmp_stats,
627 #endif
628 #ifdef SOURCE_SADF
629         .f_render       = render_net_icmp_stats,
630         .f_xml_print    = xml_print_net_icmp_stats,
631         .hdr_line       = "imsg/s;omsg/s;iech/s;iechr/s;oech/s;oechr/s;itm/s;itmr/s;otm/s;"
632                           "otmr/s;iadrmk/s;iadrmkr/s;oadrmk/s;oadrmkr/s",
633         .name           = "A_NET_ICMP",
634 #endif
635         .nr             = 1,
636         .nr2            = 1,
637         .fsize          = STATS_NET_ICMP_SIZE,
638         .msize          = STATS_NET_ICMP_SIZE,
639         .opt_flags      = 0,
640         .buf            = {NULL, NULL, NULL},
641         .bitmap         = NULL
642 };
643
644 /* ICMP network traffic (errors) activity */
645 struct activity net_eicmp_act = {
646         .id             = A_NET_EICMP,
647         .options        = AO_NULL,
648         .magic          = ACTIVITY_MAGIC_BASE,
649         .group          = G_SNMP,
650 #ifdef SOURCE_SADC
651         .f_count        = NULL,
652         .f_count2       = NULL,
653         .f_read         = wrap_read_net_eicmp,
654 #endif
655 #ifdef SOURCE_SAR
656         .f_print        = print_net_eicmp_stats,
657         .f_print_avg    = print_net_eicmp_stats,
658 #endif
659 #ifdef SOURCE_SADF
660         .f_render       = render_net_eicmp_stats,
661         .f_xml_print    = xml_print_net_eicmp_stats,
662         .hdr_line       = "ierr/s;oerr/s;idstunr/s;odstunr/s;itmex/s;otmex/s;"
663                           "iparmpb/s;oparmpb/s;isrcq/s;osrcq/s;iredir/s;oredir/s",
664         .name           = "A_NET_EICMP",
665 #endif
666         .nr             = 1,
667         .nr2            = 1,
668         .fsize          = STATS_NET_EICMP_SIZE,
669         .msize          = STATS_NET_EICMP_SIZE,
670         .opt_flags      = 0,
671         .buf            = {NULL, NULL, NULL},
672         .bitmap         = NULL
673 };
674
675 /* TCP network traffic activity */
676 struct activity net_tcp_act = {
677         .id             = A_NET_TCP,
678         .options        = AO_NULL,
679         .magic          = ACTIVITY_MAGIC_BASE,
680         .group          = G_SNMP,
681 #ifdef SOURCE_SADC
682         .f_count        = NULL,
683         .f_count2       = NULL,
684         .f_read         = wrap_read_net_tcp,
685 #endif
686 #ifdef SOURCE_SAR
687         .f_print        = print_net_tcp_stats,
688         .f_print_avg    = print_net_tcp_stats,
689 #endif
690 #ifdef SOURCE_SADF
691         .f_render       = render_net_tcp_stats,
692         .f_xml_print    = xml_print_net_tcp_stats,
693         .hdr_line       = "active/s;passive/s;iseg/s;oseg/s",
694         .name           = "A_NET_TCP",
695 #endif
696         .nr             = 1,
697         .nr2            = 1,
698         .fsize          = STATS_NET_TCP_SIZE,
699         .msize          = STATS_NET_TCP_SIZE,
700         .opt_flags      = 0,
701         .buf            = {NULL, NULL, NULL},
702         .bitmap         = NULL
703 };
704
705 /* TCP network traffic (errors) activity */
706 struct activity net_etcp_act = {
707         .id             = A_NET_ETCP,
708         .options        = AO_NULL,
709         .magic          = ACTIVITY_MAGIC_BASE,
710         .group          = G_SNMP,
711 #ifdef SOURCE_SADC
712         .f_count        = NULL,
713         .f_count2       = NULL,
714         .f_read         = wrap_read_net_etcp,
715 #endif
716 #ifdef SOURCE_SAR
717         .f_print        = print_net_etcp_stats,
718         .f_print_avg    = print_net_etcp_stats,
719 #endif
720 #ifdef SOURCE_SADF
721         .f_render       = render_net_etcp_stats,
722         .f_xml_print    = xml_print_net_etcp_stats,
723         .hdr_line       = "atmptf/s;estres/s;retrans/s;isegerr/s;orsts/s",
724         .name           = "A_NET_ETCP",
725 #endif
726         .nr             = 1,
727         .nr2            = 1,
728         .fsize          = STATS_NET_ETCP_SIZE,
729         .msize          = STATS_NET_ETCP_SIZE,
730         .opt_flags      = 0,
731         .buf            = {NULL, NULL, NULL},
732         .bitmap         = NULL
733 };
734
735 /* UDP network traffic activity */
736 struct activity net_udp_act = {
737         .id             = A_NET_UDP,
738         .options        = AO_NULL,
739         .magic          = ACTIVITY_MAGIC_BASE,
740         .group          = G_SNMP,
741 #ifdef SOURCE_SADC
742         .f_count        = NULL,
743         .f_count2       = NULL,
744         .f_read         = wrap_read_net_udp,
745 #endif
746 #ifdef SOURCE_SAR
747         .f_print        = print_net_udp_stats,
748         .f_print_avg    = print_net_udp_stats,
749 #endif
750 #ifdef SOURCE_SADF
751         .f_render       = render_net_udp_stats,
752         .f_xml_print    = xml_print_net_udp_stats,
753         .hdr_line       = "idgm/s;odgm/s;noport/s;idgmerr/s",
754         .name           = "A_NET_UDP",
755 #endif
756         .nr             = 1,
757         .nr2            = 1,
758         .fsize          = STATS_NET_UDP_SIZE,
759         .msize          = STATS_NET_UDP_SIZE,
760         .opt_flags      = 0,
761         .buf            = {NULL, NULL, NULL},
762         .bitmap         = NULL
763 };
764
765 /* IPv6 sockets activity */
766 struct activity net_sock6_act = {
767         .id             = A_NET_SOCK6,
768         .options        = AO_NULL,
769         .magic          = ACTIVITY_MAGIC_BASE,
770         .group          = G_IPV6,
771 #ifdef SOURCE_SADC
772         .f_count        = NULL,
773         .f_count2       = NULL,
774         .f_read         = wrap_read_net_sock6,
775 #endif
776 #ifdef SOURCE_SAR
777         .f_print        = print_net_sock6_stats,
778         .f_print_avg    = print_avg_net_sock6_stats,
779 #endif
780 #ifdef SOURCE_SADF
781         .f_render       = render_net_sock6_stats,
782         .f_xml_print    = xml_print_net_sock6_stats,
783         .hdr_line       = "tcp6sck;udp6sck;raw6sck;ip6-frag",
784         .name           = "A_NET_SOCK6",
785 #endif
786         .nr             = 1,
787         .nr2            = 1,
788         .fsize          = STATS_NET_SOCK6_SIZE,
789         .msize          = STATS_NET_SOCK6_SIZE,
790         .opt_flags      = 0,
791         .buf            = {NULL, NULL, NULL},
792         .bitmap         = NULL
793 };
794
795 /* IPv6 network traffic activity */
796 struct activity net_ip6_act = {
797         .id             = A_NET_IP6,
798         .options        = AO_NULL,
799         .magic          = ACTIVITY_MAGIC_BASE,
800         .group          = G_IPV6,
801 #ifdef SOURCE_SADC
802         .f_count        = NULL,
803         .f_count2       = NULL,
804         .f_read         = wrap_read_net_ip6,
805 #endif
806 #ifdef SOURCE_SAR
807         .f_print        = print_net_ip6_stats,
808         .f_print_avg    = print_net_ip6_stats,
809 #endif
810 #ifdef SOURCE_SADF
811         .f_render       = render_net_ip6_stats,
812         .f_xml_print    = xml_print_net_ip6_stats,
813         .hdr_line       = "irec6/s;fwddgm6/s;idel6/s;orq6/s;asmrq6/s;asmok6/s;"
814                           "imcpck6/s;omcpck6/s;fragok6/s;fragcr6/s",
815         .name           = "A_NET_IP6",
816 #endif
817         .nr             = 1,
818         .nr2            = 1,
819         .fsize          = STATS_NET_IP6_SIZE,
820         .msize          = STATS_NET_IP6_SIZE,
821         .opt_flags      = 0,
822         .buf            = {NULL, NULL, NULL},
823         .bitmap         = NULL
824 };
825
826 /* IPv6 network traffic (errors) activity */
827 struct activity net_eip6_act = {
828         .id             = A_NET_EIP6,
829         .options        = AO_NULL,
830         .magic          = ACTIVITY_MAGIC_BASE,
831         .group          = G_IPV6,
832 #ifdef SOURCE_SADC
833         .f_count        = NULL,
834         .f_count2       = NULL,
835         .f_read         = wrap_read_net_eip6,
836 #endif
837 #ifdef SOURCE_SAR
838         .f_print        = print_net_eip6_stats,
839         .f_print_avg    = print_net_eip6_stats,
840 #endif
841 #ifdef SOURCE_SADF
842         .f_render       = render_net_eip6_stats,
843         .f_xml_print    = xml_print_net_eip6_stats,
844         .hdr_line       = "ihdrer6/s;iadrer6/s;iukwnp6/s;i2big6/s;idisc6/s;odisc6/s;"
845                           "inort6/s;onort6/s;asmf6/s;fragf6/s;itrpck6/s",
846         .name           = "A_NET_EIP6",
847 #endif
848         .nr             = 1,
849         .nr2            = 1,
850         .fsize          = STATS_NET_EIP6_SIZE,
851         .msize          = STATS_NET_EIP6_SIZE,
852         .opt_flags      = 0,
853         .buf            = {NULL, NULL, NULL},
854         .bitmap         = NULL
855 };
856
857 /* ICMPv6 network traffic activity */
858 struct activity net_icmp6_act = {
859         .id             = A_NET_ICMP6,
860         .options        = AO_NULL,
861         .magic          = ACTIVITY_MAGIC_BASE,
862         .group          = G_IPV6,
863 #ifdef SOURCE_SADC
864         .f_count        = NULL,
865         .f_count2       = NULL,
866         .f_read         = wrap_read_net_icmp6,
867 #endif
868 #ifdef SOURCE_SAR
869         .f_print        = print_net_icmp6_stats,
870         .f_print_avg    = print_net_icmp6_stats,
871 #endif
872 #ifdef SOURCE_SADF
873         .f_render       = render_net_icmp6_stats,
874         .f_xml_print    = xml_print_net_icmp6_stats,
875         .hdr_line       = "imsg6/s;omsg6/s;iech6/s;iechr6/s;oechr6/s;igmbq6/s;igmbr6/s;ogmbr6/s;"
876                           "igmbrd6/s;ogmbrd6/s;irtsol6/s;ortsol6/s;irtad6/s;inbsol6/s;onbsol6/s;"
877                           "inbad6/s;onbad6/s",
878         .name           = "A_NET_ICMP6",
879 #endif
880         .nr             = 1,
881         .nr2            = 1,
882         .fsize          = STATS_NET_ICMP6_SIZE,
883         .msize          = STATS_NET_ICMP6_SIZE,
884         .opt_flags      = 0,
885         .buf            = {NULL, NULL, NULL},
886         .bitmap         = NULL
887 };
888
889 /* ICMPv6 network traffic (errors) activity */
890 struct activity net_eicmp6_act = {
891         .id             = A_NET_EICMP6,
892         .options        = AO_NULL,
893         .magic          = ACTIVITY_MAGIC_BASE,
894         .group          = G_IPV6,
895 #ifdef SOURCE_SADC
896         .f_count        = NULL,
897         .f_count2       = NULL,
898         .f_read         = wrap_read_net_eicmp6,
899 #endif
900 #ifdef SOURCE_SAR
901         .f_print        = print_net_eicmp6_stats,
902         .f_print_avg    = print_net_eicmp6_stats,
903 #endif
904 #ifdef SOURCE_SADF
905         .f_render       = render_net_eicmp6_stats,
906         .f_xml_print    = xml_print_net_eicmp6_stats,
907         .hdr_line       = "ierr6/s;idtunr6/s;odtunr6/s;itmex6/s;otmex6/s;"
908                           "iprmpb6/s;oprmpb6/s;iredir6/s;oredir6/s;ipck2b6/s;opck2b6/s",
909         .name           = "A_NET_EICMP6",
910 #endif
911         .nr             = 1,
912         .nr2            = 1,
913         .fsize          = STATS_NET_EICMP6_SIZE,
914         .msize          = STATS_NET_EICMP6_SIZE,
915         .opt_flags      = 0,
916         .buf            = {NULL, NULL, NULL},
917         .bitmap         = NULL
918 };
919
920 /* UDPv6 network traffic activity */
921 struct activity net_udp6_act = {
922         .id             = A_NET_UDP6,
923         .options        = AO_CLOSE_MARKUP,
924         .magic          = ACTIVITY_MAGIC_BASE,
925         .group          = G_IPV6,
926 #ifdef SOURCE_SADC
927         .f_count        = NULL,
928         .f_count2       = NULL,
929         .f_read         = wrap_read_net_udp6,
930 #endif
931 #ifdef SOURCE_SAR
932         .f_print        = print_net_udp6_stats,
933         .f_print_avg    = print_net_udp6_stats,
934 #endif
935 #ifdef SOURCE_SADF
936         .f_render       = render_net_udp6_stats,
937         .f_xml_print    = xml_print_net_udp6_stats,
938         .hdr_line       = "idgm6/s;odgm6/s;noport6/s;idgmer6/s",
939         .name           = "A_NET_UDP6",
940 #endif
941         .nr             = 1,
942         .nr2            = 1,
943         .fsize          = STATS_NET_UDP6_SIZE,
944         .msize          = STATS_NET_UDP6_SIZE,
945         .opt_flags      = 0,
946         .buf            = {NULL, NULL, NULL},
947         .bitmap         = NULL
948 };
949
950 /* CPU frequency */
951 struct activity pwr_cpufreq_act = {
952         .id             = A_PWR_CPUFREQ,
953         .options        = AO_NULL,
954         .magic          = ACTIVITY_MAGIC_BASE,
955         .group          = G_POWER,
956 #ifdef SOURCE_SADC
957         .f_count        = wrap_get_cpu_nr,
958         .f_count2       = NULL,
959         .f_read         = wrap_read_cpuinfo,
960 #endif
961 #ifdef SOURCE_SAR
962         .f_print        = print_pwr_cpufreq_stats,
963         .f_print_avg    = print_avg_pwr_cpufreq_stats,
964 #endif
965 #ifdef SOURCE_SADF
966         .f_render       = render_pwr_cpufreq_stats,
967         .f_xml_print    = xml_print_pwr_cpufreq_stats,
968         .hdr_line       = "CPU;MHz",
969         .name           = "A_PWR_CPUFREQ",
970 #endif
971         .nr             = -1,
972         .nr2            = 1,
973         .fsize          = STATS_PWR_CPUFREQ_SIZE,
974         .msize          = STATS_PWR_CPUFREQ_SIZE,
975         .opt_flags      = 0,
976         .buf            = {NULL, NULL, NULL},
977         .bitmap         = &cpu_bitmap
978 };
979
980 /* Fan */
981 struct activity pwr_fan_act = {
982         .id             = A_PWR_FAN,
983         .options        = AO_NULL,
984         .magic          = ACTIVITY_MAGIC_BASE,
985         .group          = G_POWER,
986 #ifdef SOURCE_SADC
987         .f_count        = wrap_get_fan_nr,
988         .f_count2       = NULL,
989         .f_read         = wrap_read_fan,
990 #endif
991 #ifdef SOURCE_SAR
992         .f_print        = print_pwr_fan_stats,
993         .f_print_avg    = print_avg_pwr_fan_stats,
994 #endif
995 #ifdef SOURCE_SADF
996         .f_render       = render_pwr_fan_stats,
997         .f_xml_print    = xml_print_pwr_fan_stats,
998         .hdr_line       = "FAN;DEVICE;rpm;drpm",
999         .name           = "A_PWR_FAN",
1000 #endif
1001         .nr             = -1,
1002         .nr2            = 1,
1003         .fsize          = STATS_PWR_FAN_SIZE,
1004         .msize          = STATS_PWR_FAN_SIZE,
1005         .opt_flags      = 0,
1006         .buf            = {NULL, NULL, NULL},
1007         .bitmap         = NULL
1008 };
1009
1010 /* Temperature */
1011 struct activity pwr_temp_act = {
1012         .id             = A_PWR_TEMP,
1013         .options        = AO_NULL,
1014         .magic          = ACTIVITY_MAGIC_BASE,
1015         .group          = G_POWER,
1016 #ifdef SOURCE_SADC
1017         .f_count        = wrap_get_temp_nr,
1018         .f_count2       = NULL,
1019         .f_read         = wrap_read_temp,
1020 #endif
1021 #ifdef SOURCE_SAR
1022         .f_print        = print_pwr_temp_stats,
1023         .f_print_avg    = print_avg_pwr_temp_stats,
1024 #endif
1025 #ifdef SOURCE_SADF
1026         .f_render       = render_pwr_temp_stats,
1027         .f_xml_print    = xml_print_pwr_temp_stats,
1028         .hdr_line       = "TEMP;DEVICE;degC;%temp",
1029         .name           = "A_PWR_TEMP",
1030 #endif
1031         .nr             = -1,
1032         .nr2            = 1,
1033         .fsize          = STATS_PWR_TEMP_SIZE,
1034         .msize          = STATS_PWR_TEMP_SIZE,
1035         .opt_flags      = 0,
1036         .buf            = {NULL, NULL, NULL},
1037         .bitmap         = NULL
1038 };
1039
1040 /* Voltage inputs */
1041 struct activity pwr_in_act = {
1042         .id             = A_PWR_IN,
1043         .options        = AO_NULL,
1044         .magic          = ACTIVITY_MAGIC_BASE,
1045         .group          = G_POWER,
1046 #ifdef SOURCE_SADC
1047         .f_count        = wrap_get_in_nr,
1048         .f_count2       = NULL,
1049         .f_read         = wrap_read_in,
1050 #endif
1051 #ifdef SOURCE_SAR
1052         .f_print        = print_pwr_in_stats,
1053         .f_print_avg    = print_avg_pwr_in_stats,
1054 #endif
1055 #ifdef SOURCE_SADF
1056         .f_render       = render_pwr_in_stats,
1057         .f_xml_print    = xml_print_pwr_in_stats,
1058         .hdr_line       = "IN;DEVICE;inV;%in",
1059         .name           = "A_PWR_IN",
1060 #endif
1061         .nr             = -1,
1062         .nr2            = 1,
1063         .fsize          = STATS_PWR_IN_SIZE,
1064         .msize          = STATS_PWR_IN_SIZE,
1065         .opt_flags      = 0,
1066         .buf            = {NULL, NULL, NULL},
1067         .bitmap         = NULL
1068 };
1069
1070 /* Hugepages activity */
1071 struct activity huge_act = {
1072         .id             = A_HUGE,
1073         .options        = AO_COLLECTED,
1074         .magic          = ACTIVITY_MAGIC_BASE,
1075         .group          = G_DEFAULT,
1076 #ifdef SOURCE_SADC
1077         .f_count        = NULL,
1078         .f_count2       = NULL,
1079         .f_read         = wrap_read_meminfo_huge,
1080 #endif
1081 #ifdef SOURCE_SAR
1082         .f_print        = print_huge_stats,
1083         .f_print_avg    = print_avg_huge_stats,
1084 #endif
1085 #ifdef SOURCE_SADF
1086         .f_render       = render_huge_stats,
1087         .f_xml_print    = xml_print_huge_stats,
1088         .hdr_line       = "kbhugfree;kbhugused;%hugused",
1089         .name           = "A_HUGE",
1090 #endif
1091         .nr             = 1,
1092         .nr2            = 1,
1093         .fsize          = STATS_HUGE_SIZE,
1094         .msize          = STATS_HUGE_SIZE,
1095         .opt_flags      = 0,
1096         .buf            = {NULL, NULL, NULL},
1097         .bitmap         = NULL
1098 };
1099
1100 /* CPU weighted frequency */
1101 struct activity pwr_wghfreq_act = {
1102         .id             = A_PWR_WGHFREQ,
1103         .options        = AO_NULL,
1104         .magic          = ACTIVITY_MAGIC_BASE,
1105         .group          = G_POWER,
1106 #ifdef SOURCE_SADC
1107         .f_count        = wrap_get_cpu_nr,
1108         .f_count2       = wrap_get_freq_nr,
1109         .f_read         = wrap_read_time_in_state,
1110 #endif
1111 #ifdef SOURCE_SAR
1112         .f_print        = print_pwr_wghfreq_stats,
1113         .f_print_avg    = print_pwr_wghfreq_stats,
1114 #endif
1115 #ifdef SOURCE_SADF
1116         .f_render       = render_pwr_wghfreq_stats,
1117         .f_xml_print    = xml_print_pwr_wghfreq_stats,
1118         .hdr_line       = "CPU;wghMHz",
1119         .name           = "A_PWR_WGHFREQ",
1120 #endif
1121         .nr             = -1,
1122         .nr2            = 1,
1123         .fsize          = STATS_PWR_WGHFREQ_SIZE,
1124         .msize          = STATS_PWR_WGHFREQ_SIZE,
1125         .opt_flags      = 0,
1126         .buf            = {NULL, NULL, NULL},
1127         .bitmap         = &cpu_bitmap
1128 };
1129
1130 /* USB devices plugged into the system */
1131 struct activity pwr_usb_act = {
1132         .id             = A_PWR_USB,
1133         .options        = AO_CLOSE_MARKUP,
1134         .magic          = ACTIVITY_MAGIC_BASE,
1135         .group          = G_POWER,
1136 #ifdef SOURCE_SADC
1137         .f_count        = wrap_get_usb_nr,
1138         .f_count2       = NULL,
1139         .f_read         = wrap_read_bus_usb_dev,
1140 #endif
1141 #ifdef SOURCE_SAR
1142         .f_print        = print_pwr_usb_stats,
1143         .f_print_avg    = print_avg_pwr_usb_stats,
1144 #endif
1145 #ifdef SOURCE_SADF
1146         .f_render       = render_pwr_usb_stats,
1147         .f_xml_print    = xml_print_pwr_usb_stats,
1148         .hdr_line       = "manufact;product;BUS;idvendor;idprod;maxpower",
1149         .name           = "A_PWR_USB",
1150 #endif
1151         .nr             = -1,
1152         .nr2            = 1,
1153         .fsize          = STATS_PWR_USB_SIZE,
1154         .msize          = STATS_PWR_USB_SIZE,
1155         .opt_flags      = 0,
1156         .buf            = {NULL, NULL, NULL},
1157         .bitmap         = NULL
1158 };
1159
1160
1161 /*
1162  * Array of activities.
1163  */
1164 struct activity *act[NR_ACT] = {
1165         &cpu_act,
1166         &pcsw_act,
1167         &irq_act,
1168         &swap_act,
1169         &paging_act,
1170         &io_act,
1171         &memory_act,
1172         &ktables_act,
1173         &queue_act,
1174         &serial_act,
1175         &disk_act,
1176         &net_dev_act,
1177         &net_edev_act,
1178         &net_nfs_act,
1179         &net_nfsd_act,
1180         &net_sock_act,
1181         &net_ip_act,
1182         &net_eip_act,
1183         &net_icmp_act,
1184         &net_eicmp_act,
1185         &net_tcp_act,
1186         &net_etcp_act,
1187         &net_udp_act,
1188         &net_sock6_act,
1189         &net_ip6_act,
1190         &net_eip6_act,
1191         &net_icmp6_act,
1192         &net_eicmp6_act,
1193         &net_udp6_act,
1194         &pwr_cpufreq_act,
1195         &pwr_fan_act,
1196         &pwr_temp_act,
1197         &pwr_in_act,
1198         &huge_act,
1199         &pwr_wghfreq_act,
1200         &pwr_usb_act
1201 };