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