3 #include <sys/vmmeter.h>
4 #include <sys/devicestat.h>
6 #include <vm/vm_param.h>
14 #include <net/netisr.h>
18 #include <netinet/ip.h>
19 #include <netinet/ip_var.h>
20 #include <netinet/ip_icmp.h>
21 #include <netinet/icmp_var.h>
22 #include <netinet6/ip6_var.h>
23 #include <netinet/icmp6.h>
24 #include <netinet/tcp_var.h>
25 #include <netinet/tcp_fsm.h>
26 #include <netinet/udp.h>
27 #include <netinet/udp_var.h>
29 // --------------------------------------------------------------------------------------------------------------------
30 // common definitions and variables
32 #define KILO_FACTOR 1024
33 #define MEGA_FACTOR 1048576 // 1024 * 1024
34 #define GIGA_FACTOR 1073741824 // 1024 * 1024 * 1024
36 #define MAX_INT_DIGITS 10 // maximum number of digits for int
38 int system_pagesize = PAGE_SIZE;
39 int number_of_cpus = 1;
41 // --------------------------------------------------------------------------------------------------------------------
42 // FreeBSD plugin initialization
44 int freebsd_plugin_init()
46 system_pagesize = getpagesize();
47 if (system_pagesize <= 0) {
48 error("FREEBSD: can't get system page size");
52 if (unlikely(GETSYSCTL_BY_NAME("kern.smp.cpus", number_of_cpus))) {
53 error("FREEBSD: can't get number of cpus");
57 if (unlikely(!number_of_cpus)) {
58 error("FREEBSD: wrong number of cpus");
65 // --------------------------------------------------------------------------------------------------------------------
68 // FreeBSD calculates load averages once every 5 seconds
69 #define MIN_LOADAVG_UPDATE_EVERY 5
71 int do_vm_loadavg(int update_every, usec_t dt){
72 static usec_t next_loadavg_dt = 0;
74 if (next_loadavg_dt <= dt) {
75 static int mib[2] = {0, 0};
76 struct loadavg sysload;
78 if (unlikely(GETSYSCTL_SIMPLE("vm.loadavg", mib, sysload))) {
79 error("DISABLED: system.load chart");
80 error("DISABLED: vm.loadavg module");
84 // --------------------------------------------------------------------
86 static RRDSET *st = NULL;
87 static RRDDIM *rd_load1 = NULL, *rd_load2 = NULL, *rd_load3 = NULL;
90 st = rrdset_create_localhost("system",
95 "System Load Average",
98 (update_every < MIN_LOADAVG_UPDATE_EVERY) ?
99 MIN_LOADAVG_UPDATE_EVERY : update_every, RRDSET_TYPE_LINE
101 rd_load1 = rrddim_add(st, "load1", NULL, 1, 1000, RRD_ALGORITHM_ABSOLUTE);
102 rd_load2 = rrddim_add(st, "load5", NULL, 1, 1000, RRD_ALGORITHM_ABSOLUTE);
103 rd_load3 = rrddim_add(st, "load15", NULL, 1, 1000, RRD_ALGORITHM_ABSOLUTE);
107 rrddim_set_by_pointer(st, rd_load1, (collected_number) ((double) sysload.ldavg[0] / sysload.fscale * 1000));
108 rrddim_set_by_pointer(st, rd_load2, (collected_number) ((double) sysload.ldavg[1] / sysload.fscale * 1000));
109 rrddim_set_by_pointer(st, rd_load3, (collected_number) ((double) sysload.ldavg[2] / sysload.fscale * 1000));
112 next_loadavg_dt = st->update_every * USEC_PER_SEC;
116 next_loadavg_dt -= dt;
121 // --------------------------------------------------------------------------------------------------------------------
124 int do_vm_vmtotal(int update_every, usec_t dt) {
125 static int do_all_processes = -1, do_processes = -1, do_committed = -1;
127 if (unlikely(do_all_processes == -1)) {
128 do_all_processes = config_get_boolean("plugin:freebsd:vm.vmtotal", "enable total processes", 1);
129 do_processes = config_get_boolean("plugin:freebsd:vm.vmtotal", "processes running", 1);
130 do_committed = config_get_boolean("plugin:freebsd:vm.vmtotal", "committed memory", 1);
133 if (likely(do_all_processes | do_processes | do_committed)) {
134 static int mib[2] = {0, 0};
135 struct vmtotal vmtotal_data;
137 if (unlikely(GETSYSCTL_SIMPLE("vm.vmtotal", mib, vmtotal_data))) {
138 do_all_processes = 0;
139 error("DISABLED: system.active_processes chart");
141 error("DISABLED: system.processes chart");
143 error("DISABLED: mem.committed chart");
144 error("DISABLED: vm.vmtotal module");
148 // --------------------------------------------------------------------
150 if (likely(do_all_processes)) {
151 static RRDSET *st = NULL;
152 static RRDDIM *rd = NULL;
155 st = rrdset_create_localhost("system",
160 "System Active Processes",
166 rd = rrddim_add(st, "active", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
168 else rrdset_next(st);
170 rrddim_set_by_pointer(st, rd, (vmtotal_data.t_rq + vmtotal_data.t_dw + vmtotal_data.t_pw + vmtotal_data.t_sl + vmtotal_data.t_sw));
174 // --------------------------------------------------------------------
176 if (likely(do_processes)) {
177 static RRDSET *st = NULL;
178 static RRDDIM *rd_running = NULL, *rd_blocked = NULL;
181 st = rrdset_create_localhost("system",
193 rd_running = rrddim_add(st, "running", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
194 rd_blocked = rrddim_add(st, "blocked", NULL, -1, 1, RRD_ALGORITHM_ABSOLUTE);
196 else rrdset_next(st);
198 rrddim_set_by_pointer(st, rd_running, vmtotal_data.t_rq);
199 rrddim_set_by_pointer(st, rd_blocked, (vmtotal_data.t_dw + vmtotal_data.t_pw));
203 // --------------------------------------------------------------------
205 if (likely(do_committed)) {
206 static RRDSET *st = NULL;
207 static RRDDIM *rd = NULL;
210 st = rrdset_create_localhost("mem",
215 "Committed (Allocated) Memory",
221 rrdset_flag_set(st, RRDSET_FLAG_DETAIL);
223 rd = rrddim_add(st, "Committed_AS", NULL, system_pagesize, MEGA_FACTOR, RRD_ALGORITHM_ABSOLUTE);
225 else rrdset_next(st);
227 rrddim_set_by_pointer(st, rd, vmtotal_data.t_rm);
232 error("DISABLED: vm.vmtotal module");
239 // --------------------------------------------------------------------------------------------------------------------
242 int do_kern_cp_time(int update_every, usec_t dt) {
243 if (unlikely(CPUSTATES != 5)) {
244 error("FREEBSD: There are %d CPU states (5 was expected)", CPUSTATES);
245 error("DISABLED: system.cpu chart");
246 error("DISABLED: kern.cp_time module");
249 static int mib[2] = {0, 0};
250 long cp_time[CPUSTATES];
252 if (unlikely(GETSYSCTL_SIMPLE("kern.cp_time", mib, cp_time))) {
253 error("DISABLED: system.cpu chart");
254 error("DISABLED: kern.cp_time module");
258 // --------------------------------------------------------------------
260 static RRDSET *st = NULL;
261 static RRDDIM *rd_nice = NULL, *rd_system = NULL, *rd_user = NULL, *rd_interrupt = NULL, *rd_idle = NULL;
264 st = rrdset_create_localhost("system",
269 "Total CPU utilization",
275 rd_nice = rrddim_add(st, "nice", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL);
276 rd_system = rrddim_add(st, "system", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL);
277 rd_user = rrddim_add(st, "user", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL);
278 rd_interrupt = rrddim_add(st, "interrupt", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL);
279 rd_idle = rrddim_add(st, "idle", NULL, 1, 1, RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL);
280 rrddim_hide(st, "idle");
282 else rrdset_next(st);
284 rrddim_set_by_pointer(st, rd_nice, cp_time[1]);
285 rrddim_set_by_pointer(st, rd_system, cp_time[2]);
286 rrddim_set_by_pointer(st, rd_user, cp_time[0]);
287 rrddim_set_by_pointer(st, rd_interrupt, cp_time[3]);
288 rrddim_set_by_pointer(st, rd_idle, cp_time[4]);
296 // --------------------------------------------------------------------------------------------------------------------
299 int do_kern_cp_times(int update_every, usec_t dt) {
300 if (unlikely(CPUSTATES != 5)) {
301 error("FREEBSD: There are %d CPU states (5 was expected)", CPUSTATES);
302 error("DISABLED: cpu.cpuXX charts");
303 error("DISABLED: kern.cp_times module");
306 static int mib[2] = {0, 0};
307 long cp_time[CPUSTATES];
308 static long *pcpu_cp_time = NULL;
310 pcpu_cp_time = reallocz(pcpu_cp_time, sizeof(cp_time) * number_of_cpus);
311 if (unlikely(GETSYSCTL_WSIZE("kern.cp_times", mib, pcpu_cp_time, sizeof(cp_time) * number_of_cpus))) {
312 error("DISABLED: cpu.cpuXX charts");
313 error("DISABLED: kern.cp_times module");
317 // --------------------------------------------------------------------
320 static struct cpu_chart {
321 char cpuid[MAX_INT_DIGITS + 4];
326 RRDDIM *rd_interrupt;
328 } *all_cpu_charts = NULL;
330 all_cpu_charts = reallocz(all_cpu_charts, sizeof(struct cpu_chart) * number_of_cpus);
332 for (i = 0; i < number_of_cpus; i++) {
333 if (unlikely(!all_cpu_charts[i].st)) {
334 snprintfz(all_cpu_charts[i].cpuid, MAX_INT_DIGITS, "cpu%d", i);
335 all_cpu_charts[i].st = rrdset_create_localhost("cpu",
336 all_cpu_charts[i].cpuid,
347 all_cpu_charts[i].rd_nice = rrddim_add(all_cpu_charts[i].st, "nice", NULL, 1, 1,
348 RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL);
349 all_cpu_charts[i].rd_system = rrddim_add(all_cpu_charts[i].st, "system", NULL, 1, 1,
350 RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL);
351 all_cpu_charts[i].rd_user = rrddim_add(all_cpu_charts[i].st, "user", NULL, 1, 1,
352 RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL);
353 all_cpu_charts[i].rd_interrupt = rrddim_add(all_cpu_charts[i].st, "interrupt", NULL, 1, 1,
354 RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL);
355 all_cpu_charts[i].rd_idle = rrddim_add(all_cpu_charts[i].st, "idle", NULL, 1, 1,
356 RRD_ALGORITHM_PCENT_OVER_DIFF_TOTAL);
357 rrddim_hide(all_cpu_charts[i].st, "idle");
358 } else rrdset_next(all_cpu_charts[i].st);
360 rrddim_set_by_pointer(all_cpu_charts[i].st, all_cpu_charts[i].rd_nice, pcpu_cp_time[i * 5 + 1]);
361 rrddim_set_by_pointer(all_cpu_charts[i].st, all_cpu_charts[i].rd_system, pcpu_cp_time[i * 5 + 2]);
362 rrddim_set_by_pointer(all_cpu_charts[i].st, all_cpu_charts[i].rd_user, pcpu_cp_time[i * 5 + 0]);
363 rrddim_set_by_pointer(all_cpu_charts[i].st, all_cpu_charts[i].rd_interrupt, pcpu_cp_time[i * 5 + 3]);
364 rrddim_set_by_pointer(all_cpu_charts[i].st, all_cpu_charts[i].rd_idle, pcpu_cp_time[i * 5 + 4]);
365 rrdset_done(all_cpu_charts[i].st);
373 // --------------------------------------------------------------------------------------------------------------------
376 int do_hw_intcnt(int update_every, usec_t dt) {
377 static int mib_hw_intrcnt[2] = {0, 0};
381 if (unlikely(GETSYSCTL_SIZE("hw.intrcnt", mib_hw_intrcnt, intrcnt_size))) {
382 error("DISABLED: system.intr chart");
383 error("DISABLED: system.interrupts chart");
384 error("DISABLED: hw.intrcnt module");
387 unsigned long nintr = 0;
388 static unsigned long *intrcnt = NULL;
389 unsigned long long totalintr = 0;
391 nintr = intrcnt_size / sizeof(u_long);
392 intrcnt = reallocz(intrcnt, nintr * sizeof(u_long));
393 if (unlikely(GETSYSCTL_WSIZE("hw.intrcnt", mib_hw_intrcnt, intrcnt, nintr * sizeof(u_long)))) {
394 error("DISABLED: system.intr chart");
395 error("DISABLED: system.interrupts chart");
396 error("DISABLED: hw.intrcnt module");
399 for (i = 0; i < nintr; i++)
400 totalintr += intrcnt[i];
402 // --------------------------------------------------------------------
404 static RRDSET *st_intr = NULL;
405 static RRDDIM *rd_intr = NULL;
407 if (unlikely(!st_intr)) {
408 st_intr = rrdset_create_localhost("system",
413 "Total Hardware Interrupts",
419 rrdset_flag_set(st_intr, RRDSET_FLAG_DETAIL);
421 rd_intr = rrddim_add(st_intr, "interrupts", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
423 rrdset_next(st_intr);
425 rrddim_set_by_pointer(st_intr, rd_intr, totalintr);
426 rrdset_done(st_intr);
428 // --------------------------------------------------------------------
431 static int mib_hw_intrnames[2] = {0, 0};
432 static char *intrnames = NULL;
434 size = nintr * (MAXCOMLEN + 1);
435 intrnames = reallocz(intrnames, size);
436 if (unlikely(GETSYSCTL_WSIZE("hw.intrnames", mib_hw_intrnames, intrnames, size))) {
437 error("DISABLED: system.intr chart");
438 error("DISABLED: system.interrupts chart");
439 error("DISABLED: hw.intrcnt module");
443 // --------------------------------------------------------------------
445 static RRDSET *st_interrupts = NULL;
446 RRDDIM *rd_interrupts = NULL;
449 if (unlikely(!st_interrupts))
450 st_interrupts = rrdset_create_localhost("system",
462 rrdset_next(st_interrupts);
464 for (i = 0; i < nintr; i++) {
465 p = intrnames + i * (MAXCOMLEN + 1);
466 if (unlikely((intrcnt[i] != 0) && (*(char *) p != 0))) {
467 rd_interrupts = rrddim_find(st_interrupts, p);
468 if (unlikely(!rd_interrupts))
469 rd_interrupts = rrddim_add(st_interrupts, p, NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
470 rrddim_set_by_pointer(st_interrupts, rd_interrupts, intrcnt[i]);
473 rrdset_done(st_interrupts);
481 // --------------------------------------------------------------------------------------------------------------------
482 // vm.stats.sys.v_intr
484 int do_vm_stats_sys_v_intr(int update_every, usec_t dt) {
485 static int mib[4] = {0, 0, 0, 0};
488 if (unlikely(GETSYSCTL_SIMPLE("vm.stats.sys.v_intr", mib, int_number))) {
489 error("DISABLED: system.dev_intr chart");
490 error("DISABLED: vm.stats.sys.v_intr module");
494 // --------------------------------------------------------------------
496 static RRDSET *st = NULL;
497 static RRDDIM *rd = NULL;
500 st = rrdset_create_localhost("system",
512 rd = rrddim_add(st, "interrupts", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
514 else rrdset_next(st);
516 rrddim_set_by_pointer(st, rd, int_number);
523 // --------------------------------------------------------------------------------------------------------------------
524 // vm.stats.sys.v_soft
526 int do_vm_stats_sys_v_soft(int update_every, usec_t dt) {
527 static int mib[4] = {0, 0, 0, 0};
528 u_int soft_intr_number;
530 if (unlikely(GETSYSCTL_SIMPLE("vm.stats.sys.v_soft", mib, soft_intr_number))) {
531 error("DISABLED: system.dev_intr chart");
532 error("DISABLED: vm.stats.sys.v_soft module");
536 // --------------------------------------------------------------------
538 static RRDSET *st = NULL;
539 static RRDDIM *rd = NULL;
542 st = rrdset_create_localhost("system",
547 "Software Interrupts",
554 rd = rrddim_add(st, "interrupts", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
556 else rrdset_next(st);
558 rrddim_set_by_pointer(st, rd, soft_intr_number);
565 // --------------------------------------------------------------------------------------------------------------------
566 // vm.stats.sys.v_swtch
568 int do_vm_stats_sys_v_swtch(int update_every, usec_t dt) {
569 static int mib[4] = {0, 0, 0, 0};
572 if (unlikely(GETSYSCTL_SIMPLE("vm.stats.sys.v_swtch", mib, ctxt_number))) {
573 error("DISABLED: system.ctxt chart");
574 error("DISABLED: vm.stats.sys.v_swtch module");
578 // --------------------------------------------------------------------
580 static RRDSET *st = NULL;
581 static RRDDIM *rd = NULL;
584 st = rrdset_create_localhost("system",
589 "CPU Context Switches",
590 "context switches/s",
596 rd = rrddim_add(st, "switches", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
598 else rrdset_next(st);
600 rrddim_set_by_pointer(st, rd, ctxt_number);
607 // --------------------------------------------------------------------------------------------------------------------
608 // vm.stats.vm.v_forks
610 int do_vm_stats_sys_v_forks(int update_every, usec_t dt) {
611 static int mib[4] = {0, 0, 0, 0};
614 if (unlikely(GETSYSCTL_SIMPLE("vm.stats.vm.v_forks", mib, forks_number))) {
615 error("DISABLED: system.forks chart");
616 error("DISABLED: vm.stats.sys.v_swtch module");
620 // --------------------------------------------------------------------
622 static RRDSET *st = NULL;
623 static RRDDIM *rd = NULL;
626 st = rrdset_create_localhost("system",
638 rrdset_flag_set(st, RRDSET_FLAG_DETAIL);
640 rd = rrddim_add(st, "started", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
642 else rrdset_next(st);
644 rrddim_set_by_pointer(st, rd, forks_number);
651 // --------------------------------------------------------------------------------------------------------------------
654 int do_vm_swap_info(int update_every, usec_t dt) {
655 static int mib[3] = {0, 0, 0};
657 if (unlikely(getsysctl_mib("vm.swap_info", mib, 2))) {
658 error("DISABLED: system.swap chart");
659 error("DISABLED: vm.swap_info module");
665 collected_number bytes_used;
666 collected_number bytes_total;
667 } total_xsw = {0, 0};
674 if (unlikely(sysctl(mib, 3, &xsw, &size, NULL, 0) == -1 )) {
675 if (unlikely(errno != ENOENT)) {
676 error("FREEBSD: sysctl(%s...) failed: %s", "vm.swap_info", strerror(errno));
677 error("DISABLED: system.swap chart");
678 error("DISABLED: vm.swap_info module");
681 if (unlikely(size != sizeof(xsw))) {
682 error("FREEBSD: sysctl(%s...) expected %lu, got %lu", "vm.swap_info", (unsigned long)sizeof(xsw), (unsigned long)size);
683 error("DISABLED: system.swap chart");
684 error("DISABLED: vm.swap_info module");
689 total_xsw.bytes_used += xsw.xsw_used;
690 total_xsw.bytes_total += xsw.xsw_nblks;
693 // --------------------------------------------------------------------
695 static RRDSET *st = NULL;
696 static RRDDIM *rd_free = NULL, *rd_used = NULL;
699 st = rrdset_create_localhost("system",
711 rrdset_flag_set(st, RRDSET_FLAG_DETAIL);
713 rd_free = rrddim_add(st, "free", NULL, system_pagesize, MEGA_FACTOR, RRD_ALGORITHM_ABSOLUTE);
714 rd_used = rrddim_add(st, "used", NULL, system_pagesize, MEGA_FACTOR, RRD_ALGORITHM_ABSOLUTE);
716 else rrdset_next(st);
718 rrddim_set_by_pointer(st, rd_free, total_xsw.bytes_total - total_xsw.bytes_used);
719 rrddim_set_by_pointer(st, rd_used, total_xsw.bytes_used);
726 // --------------------------------------------------------------------------------------------------------------------
729 int do_system_ram(int update_every, usec_t dt) {
730 static int mib_active_count[4] = {0, 0, 0, 0}, mib_inactive_count[4] = {0, 0, 0, 0}, mib_wire_count[4] = {0, 0, 0, 0},
731 mib_cache_count[4] = {0, 0, 0, 0}, mib_vfs_bufspace[2] = {0, 0}, mib_free_count[4] = {0, 0, 0, 0};
732 struct vmmeter vmmeter_data;
733 int vfs_bufspace_count;
735 if (unlikely(GETSYSCTL_SIMPLE("vm.stats.vm.v_active_count", mib_active_count, vmmeter_data.v_active_count) ||
736 GETSYSCTL_SIMPLE("vm.stats.vm.v_inactive_count", mib_inactive_count, vmmeter_data.v_inactive_count) ||
737 GETSYSCTL_SIMPLE("vm.stats.vm.v_wire_count", mib_wire_count, vmmeter_data.v_wire_count) ||
738 #if __FreeBSD_version < 1200016
739 GETSYSCTL_SIMPLE("vm.stats.vm.v_cache_count", mib_cache_count, vmmeter_data.v_cache_count) ||
741 GETSYSCTL_SIMPLE("vfs.bufspace", mib_vfs_bufspace, vfs_bufspace_count) ||
742 GETSYSCTL_SIMPLE("vm.stats.vm.v_free_count", mib_free_count, vmmeter_data.v_free_count))) {
743 error("DISABLED: system.ram chart");
744 error("DISABLED: System.ram module");
748 // --------------------------------------------------------------------
750 static RRDSET *st = NULL;
751 static RRDDIM *rd_free = NULL, *rd_active = NULL, *rd_inactive = NULL,
752 *rd_wired = NULL, *rd_cache = NULL, *rd_buffers = NULL;
754 st = rrdset_find_localhost("system.ram");
756 st = rrdset_create_localhost("system",
768 rd_free = rrddim_add(st, "free", NULL, system_pagesize, MEGA_FACTOR, RRD_ALGORITHM_ABSOLUTE);
769 rd_active = rrddim_add(st, "active", NULL, system_pagesize, MEGA_FACTOR, RRD_ALGORITHM_ABSOLUTE);
770 rd_inactive = rrddim_add(st, "inactive", NULL, system_pagesize, MEGA_FACTOR, RRD_ALGORITHM_ABSOLUTE);
771 rd_wired = rrddim_add(st, "wired", NULL, system_pagesize, MEGA_FACTOR, RRD_ALGORITHM_ABSOLUTE);
772 #if __FreeBSD_version < 1200016
773 rd_cache = rrddim_add(st, "cache", NULL, system_pagesize, MEGA_FACTOR, RRD_ALGORITHM_ABSOLUTE);
775 rd_buffers = rrddim_add(st, "buffers", NULL, 1, MEGA_FACTOR, RRD_ALGORITHM_ABSOLUTE);
777 else rrdset_next(st);
779 rrddim_set_by_pointer(st, rd_free, vmmeter_data.v_free_count);
780 rrddim_set_by_pointer(st, rd_active, vmmeter_data.v_active_count);
781 rrddim_set_by_pointer(st, rd_inactive, vmmeter_data.v_inactive_count);
782 rrddim_set_by_pointer(st, rd_wired, vmmeter_data.v_wire_count);
783 #if __FreeBSD_version < 1200016
784 rrddim_set_by_pointer(st, rd_cache, vmmeter_data.v_cache_count);
786 rrddim_set_by_pointer(st, rd_buffers, vfs_bufspace_count);
793 // --------------------------------------------------------------------------------------------------------------------
794 // vm.stats.vm.v_swappgs
796 int do_vm_stats_sys_v_swappgs(int update_every, usec_t dt) {
797 static int mib_swappgsin[4] = {0, 0, 0, 0}, mib_swappgsout[4] = {0, 0, 0, 0};
798 struct vmmeter vmmeter_data;
800 if (unlikely(GETSYSCTL_SIMPLE("vm.stats.vm.v_swappgsin", mib_swappgsin, vmmeter_data.v_swappgsin) ||
801 GETSYSCTL_SIMPLE("vm.stats.vm.v_swappgsout", mib_swappgsout, vmmeter_data.v_swappgsout))) {
802 error("DISABLED: system.swapio chart");
803 error("DISABLED: vm.stats.vm.v_swappgs module");
807 // --------------------------------------------------------------------
809 static RRDSET *st = NULL;
810 static RRDDIM *rd_in = NULL, *rd_out = NULL;
813 st = rrdset_create_localhost("system",
825 rd_in = rrddim_add(st, "in", NULL, system_pagesize, KILO_FACTOR, RRD_ALGORITHM_INCREMENTAL);
826 rd_out = rrddim_add(st, "out", NULL, -system_pagesize, KILO_FACTOR, RRD_ALGORITHM_INCREMENTAL);
828 else rrdset_next(st);
830 rrddim_set_by_pointer(st, rd_in, vmmeter_data.v_swappgsin);
831 rrddim_set_by_pointer(st, rd_out, vmmeter_data.v_swappgsout);
838 // --------------------------------------------------------------------------------------------------------------------
839 // vm.stats.vm.v_pgfaults
841 int do_vm_stats_sys_v_pgfaults(int update_every, usec_t dt) {
842 static int mib_vm_faults[4] = {0, 0, 0, 0}, mib_io_faults[4] = {0, 0, 0, 0}, mib_cow_faults[4] = {0, 0, 0, 0},
843 mib_cow_optim[4] = {0, 0, 0, 0}, mib_intrans[4] = {0, 0, 0, 0};
844 struct vmmeter vmmeter_data;
846 if (unlikely(GETSYSCTL_SIMPLE("vm.stats.vm.v_vm_faults", mib_vm_faults, vmmeter_data.v_vm_faults) ||
847 GETSYSCTL_SIMPLE("vm.stats.vm.v_io_faults", mib_io_faults, vmmeter_data.v_io_faults) ||
848 GETSYSCTL_SIMPLE("vm.stats.vm.v_cow_faults", mib_cow_faults, vmmeter_data.v_cow_faults) ||
849 GETSYSCTL_SIMPLE("vm.stats.vm.v_cow_optim", mib_cow_optim, vmmeter_data.v_cow_optim) ||
850 GETSYSCTL_SIMPLE("vm.stats.vm.v_intrans", mib_intrans, vmmeter_data.v_intrans))) {
851 error("DISABLED: mem.pgfaults chart");
852 error("DISABLED: vm.stats.vm.v_pgfaults module");
856 // --------------------------------------------------------------------
858 static RRDSET *st = NULL;
859 static RRDDIM *rd_memory = NULL, *rd_io_requiring = NULL, *rd_cow = NULL,
860 *rd_cow_optimized = NULL, *rd_in_transit = NULL;
863 st = rrdset_create_localhost("mem",
868 "Memory Page Faults",
875 rrdset_flag_set(st, RRDSET_FLAG_DETAIL);
877 rd_memory = rrddim_add(st, "memory", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
878 rd_io_requiring = rrddim_add(st, "io_requiring", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
879 rd_cow = rrddim_add(st, "cow", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
880 rd_cow_optimized = rrddim_add(st, "cow_optimized", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
881 rd_in_transit = rrddim_add(st, "in_transit", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
883 else rrdset_next(st);
885 rrddim_set_by_pointer(st, rd_memory, vmmeter_data.v_vm_faults);
886 rrddim_set_by_pointer(st, rd_io_requiring, vmmeter_data.v_io_faults);
887 rrddim_set_by_pointer(st, rd_cow, vmmeter_data.v_cow_faults);
888 rrddim_set_by_pointer(st, rd_cow_optimized, vmmeter_data.v_cow_optim);
889 rrddim_set_by_pointer(st, rd_in_transit, vmmeter_data.v_intrans);
896 // --------------------------------------------------------------------------------------------------------------------
899 int do_kern_ipc_sem(int update_every, usec_t dt) {
900 static int mib_semmni[3] = {0, 0, 0}, mib_sema[3] = {0, 0, 0};
903 collected_number sets;
904 collected_number semaphores;
905 } ipc_sem = {0, 0, 0};
907 if (unlikely(GETSYSCTL_SIMPLE("kern.ipc.semmni", mib_semmni, ipc_sem.semmni))) {
908 error("DISABLED: system.ipc_semaphores chart");
909 error("DISABLED: system.ipc_semaphore_arrays chart");
910 error("DISABLED: kern.ipc.sem module");
913 static struct semid_kernel *ipc_sem_data = NULL;
915 ipc_sem_data = reallocz(ipc_sem_data, sizeof(struct semid_kernel) * ipc_sem.semmni);
916 if (unlikely(GETSYSCTL_WSIZE("kern.ipc.sema", mib_sema, ipc_sem_data, sizeof(struct semid_kernel) * ipc_sem.semmni))) {
917 error("DISABLED: system.ipc_semaphores chart");
918 error("DISABLED: system.ipc_semaphore_arrays chart");
919 error("DISABLED: kern.ipc.sem module");
924 for (i = 0; i < ipc_sem.semmni; i++) {
925 if (unlikely(ipc_sem_data[i].u.sem_perm.mode & SEM_ALLOC)) {
927 ipc_sem.semaphores += ipc_sem_data[i].u.sem_nsems;
931 // --------------------------------------------------------------------
933 static RRDSET *st_semaphores = NULL, *st_semaphore_arrays = NULL;
934 static RRDDIM *rd_semaphores = NULL, *rd_semaphore_arrays = NULL;
936 if (unlikely(!st_semaphores)) {
937 st_semaphores = rrdset_create_localhost("system",
945 localhost->rrd_update_every,
949 rd_semaphores = rrddim_add(st_semaphores, "semaphores", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
951 else rrdset_next(st_semaphores);
953 rrddim_set_by_pointer(st_semaphores, rd_semaphores, ipc_sem.semaphores);
954 rrdset_done(st_semaphores);
956 // --------------------------------------------------------------------
958 if (unlikely(!st_semaphore_arrays)) {
959 st_semaphore_arrays = rrdset_create_localhost("system",
960 "ipc_semaphore_arrays",
964 "IPC Semaphore Arrays",
967 localhost->rrd_update_every,
971 rd_semaphore_arrays = rrddim_add(st_semaphore_arrays, "arrays", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
973 else rrdset_next(st_semaphore_arrays);
975 rrddim_set_by_pointer(st_semaphore_arrays, rd_semaphore_arrays, ipc_sem.sets);
976 rrdset_done(st_semaphore_arrays);
983 // --------------------------------------------------------------------------------------------------------------------
986 int do_kern_ipc_shm(int update_every, usec_t dt) {
987 static int mib_shmmni[3] = {0, 0, 0}, mib_shmsegs[3] = {0, 0, 0};
990 collected_number segs;
991 collected_number segsize;
992 } ipc_shm = {0, 0, 0};
994 if (unlikely(GETSYSCTL_SIMPLE("kern.ipc.shmmni", mib_shmmni, ipc_shm.shmmni))) {
995 error("DISABLED: system.ipc_shared_mem_segs chart");
996 error("DISABLED: system.ipc_shared_mem_size chart");
997 error("DISABLED: kern.ipc.shmmodule");
1000 static struct shmid_kernel *ipc_shm_data = NULL;
1002 ipc_shm_data = reallocz(ipc_shm_data, sizeof(struct shmid_kernel) * ipc_shm.shmmni);
1004 GETSYSCTL_WSIZE("kern.ipc.shmsegs", mib_shmsegs, ipc_shm_data, sizeof(struct shmid_kernel) * ipc_shm.shmmni))) {
1005 error("DISABLED: system.ipc_shared_mem_segs chart");
1006 error("DISABLED: system.ipc_shared_mem_size chart");
1007 error("DISABLED: kern.ipc.shmmodule");
1012 for (i = 0; i < ipc_shm.shmmni; i++) {
1013 if (unlikely(ipc_shm_data[i].u.shm_perm.mode & 0x0800)) {
1015 ipc_shm.segsize += ipc_shm_data[i].u.shm_segsz;
1019 // --------------------------------------------------------------------
1021 static RRDSET *st_segs = NULL, *st_size = NULL;
1022 static RRDDIM *rd_segments = NULL, *rd_allocated = NULL;
1024 if (unlikely(!st_segs)) {
1025 st_segs = rrdset_create_localhost("system",
1026 "ipc_shared_mem_segs",
1028 "ipc shared memory",
1030 "IPC Shared Memory Segments",
1033 localhost->rrd_update_every,
1037 rd_segments = rrddim_add(st_segs, "segments", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
1039 else rrdset_next(st_segs);
1041 rrddim_set_by_pointer(st_segs, rd_segments, ipc_shm.segs);
1042 rrdset_done(st_segs);
1044 // --------------------------------------------------------------------
1046 if (unlikely(!st_size)) {
1047 st_size = rrdset_create_localhost("system",
1048 "ipc_shared_mem_size",
1050 "ipc shared memory",
1052 "IPC Shared Memory Segments Size",
1055 localhost->rrd_update_every,
1059 rd_allocated = rrddim_add(st_size, "allocated", NULL, 1, KILO_FACTOR, RRD_ALGORITHM_ABSOLUTE);
1061 else rrdset_next(st_size);
1063 rrddim_set_by_pointer(st_size, rd_allocated, ipc_shm.segsize);
1064 rrdset_done(st_size);
1071 // --------------------------------------------------------------------------------------------------------------------
1074 int do_kern_ipc_msq(int update_every, usec_t dt) {
1075 static int mib_msgmni[3] = {0, 0, 0}, mib_msqids[3] = {0, 0, 0};
1078 collected_number queues;
1079 collected_number messages;
1080 collected_number usedsize;
1081 collected_number allocsize;
1082 } ipc_msq = {0, 0, 0, 0, 0};
1084 if (unlikely(GETSYSCTL_SIMPLE("kern.ipc.msgmni", mib_msgmni, ipc_msq.msgmni))) {
1085 error("DISABLED: system.ipc_msq_queues chart");
1086 error("DISABLED: system.ipc_msq_messages chart");
1087 error("DISABLED: system.ipc_msq_size chart");
1088 error("DISABLED: kern.ipc.msg module");
1091 static struct msqid_kernel *ipc_msq_data = NULL;
1093 ipc_msq_data = reallocz(ipc_msq_data, sizeof(struct msqid_kernel) * ipc_msq.msgmni);
1095 GETSYSCTL_WSIZE("kern.ipc.msqids", mib_msqids, ipc_msq_data, sizeof(struct msqid_kernel) * ipc_msq.msgmni))) {
1096 error("DISABLED: system.ipc_msq_queues chart");
1097 error("DISABLED: system.ipc_msq_messages chart");
1098 error("DISABLED: system.ipc_msq_size chart");
1099 error("DISABLED: kern.ipc.msg module");
1104 for (i = 0; i < ipc_msq.msgmni; i++) {
1105 if (unlikely(ipc_msq_data[i].u.msg_qbytes != 0)) {
1106 ipc_msq.queues += 1;
1107 ipc_msq.messages += ipc_msq_data[i].u.msg_qnum;
1108 ipc_msq.usedsize += ipc_msq_data[i].u.msg_cbytes;
1109 ipc_msq.allocsize += ipc_msq_data[i].u.msg_qbytes;
1113 // --------------------------------------------------------------------
1115 static RRDSET *st_queues = NULL, *st_messages = NULL, *st_size = NULL;
1116 static RRDDIM *rd_queues = NULL, *rd_messages = NULL, *rd_allocated = NULL, *rd_used = NULL;
1118 if (unlikely(!st_queues)) {
1119 st_queues = rrdset_create_localhost("system",
1122 "ipc message queues",
1124 "Number of IPC Message Queues",
1127 localhost->rrd_update_every,
1131 rd_queues = rrddim_add(st_queues, "queues", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
1133 else rrdset_next(st_queues);
1135 rrddim_set_by_pointer(st_queues, rd_queues, ipc_msq.queues);
1136 rrdset_done(st_queues);
1138 // --------------------------------------------------------------------
1140 if (unlikely(!st_messages)) {
1141 st_messages = rrdset_create_localhost("system",
1144 "ipc message queues",
1146 "Number of Messages in IPC Message Queues",
1149 localhost->rrd_update_every,
1153 rd_messages = rrddim_add(st_messages, "messages", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
1155 else rrdset_next(st_messages);
1157 rrddim_set_by_pointer(st_messages, rd_messages, ipc_msq.messages);
1158 rrdset_done(st_messages);
1160 // --------------------------------------------------------------------
1162 if (unlikely(!st_size)) {
1163 st_size = rrdset_create_localhost("system",
1166 "ipc message queues",
1168 "Size of IPC Message Queues",
1171 localhost->rrd_update_every,
1175 rd_allocated = rrddim_add(st_size, "allocated", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
1176 rd_used = rrddim_add(st_size, "used", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
1178 else rrdset_next(st_size);
1180 rrddim_set_by_pointer(st_size, rd_allocated, ipc_msq.allocsize);
1181 rrddim_set_by_pointer(st_size, rd_used, ipc_msq.usedsize);
1182 rrdset_done(st_size);
1189 // --------------------------------------------------------------------------------------------------------------------
1192 int do_uptime(int update_every, usec_t dt) {
1193 struct timespec up_time;
1195 clock_gettime(CLOCK_UPTIME, &up_time);
1197 // --------------------------------------------------------------------
1199 static RRDSET *st = NULL;
1200 static RRDDIM *rd = NULL;
1203 st = rrdset_create_localhost("system",
1215 rd = rrddim_add(st, "uptime", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
1217 else rrdset_next(st);
1219 rrddim_set_by_pointer(st, rd, up_time.tv_sec);
1225 // --------------------------------------------------------------------------------------------------------------------
1228 int do_net_isr(int update_every, usec_t dt) {
1229 static int do_netisr = -1, do_netisr_per_core = -1;
1231 if (unlikely(do_netisr == -1)) {
1232 do_netisr = config_get_boolean("plugin:freebsd:net.isr", "netisr", 1);
1233 do_netisr_per_core = config_get_boolean("plugin:freebsd:net.isr", "netisr per core", 1);
1236 static int mib_workstream[3] = {0, 0, 0}, mib_work[3] = {0, 0, 0};
1237 int common_error = 0;
1239 size_t netisr_workstream_size, netisr_work_size;
1240 unsigned long num_netisr_workstreams = 0, num_netisr_works = 0;
1241 static struct sysctl_netisr_workstream *netisr_workstream = NULL;
1242 static struct sysctl_netisr_work *netisr_work = NULL;
1243 static struct netisr_stats {
1244 collected_number dispatched;
1245 collected_number hybrid_dispatched;
1246 collected_number qdrops;
1247 collected_number queued;
1248 } *netisr_stats = NULL;
1250 if (likely(do_netisr || do_netisr_per_core)) {
1251 if (unlikely(GETSYSCTL_SIZE("net.isr.workstream", mib_workstream, netisr_workstream_size))) {
1253 } else if (unlikely(GETSYSCTL_SIZE("net.isr.work", mib_work, netisr_work_size))) {
1256 num_netisr_workstreams = netisr_workstream_size / sizeof(struct sysctl_netisr_workstream);
1257 netisr_workstream = reallocz(netisr_workstream, num_netisr_workstreams * sizeof(struct sysctl_netisr_workstream));
1258 if (unlikely(GETSYSCTL_WSIZE("net.isr.workstream", mib_workstream, netisr_workstream,
1259 num_netisr_workstreams * sizeof(struct sysctl_netisr_workstream)))){
1262 num_netisr_works = netisr_work_size / sizeof(struct sysctl_netisr_work);
1263 netisr_work = reallocz(netisr_work, num_netisr_works * sizeof(struct sysctl_netisr_work));
1264 if (unlikely(GETSYSCTL_WSIZE("net.isr.work", mib_work, netisr_work,
1265 num_netisr_works * sizeof(struct sysctl_netisr_work)))){
1270 if (unlikely(common_error)) {
1272 error("DISABLED: system.softnet_stat chart");
1273 do_netisr_per_core = 0;
1274 error("DISABLED: system.cpuX_softnet_stat chart");
1276 error("DISABLED: net.isr module");
1279 netisr_stats = reallocz(netisr_stats, (number_of_cpus + 1) * sizeof(struct netisr_stats));
1280 bzero(netisr_stats, (number_of_cpus + 1) * sizeof(struct netisr_stats));
1281 for (i = 0; i < num_netisr_workstreams; i++) {
1282 for (n = 0; n < num_netisr_works; n++) {
1283 if (netisr_workstream[i].snws_wsid == netisr_work[n].snw_wsid) {
1284 netisr_stats[netisr_workstream[i].snws_cpu].dispatched += netisr_work[n].snw_dispatched;
1285 netisr_stats[netisr_workstream[i].snws_cpu].hybrid_dispatched += netisr_work[n].snw_hybrid_dispatched;
1286 netisr_stats[netisr_workstream[i].snws_cpu].qdrops += netisr_work[n].snw_qdrops;
1287 netisr_stats[netisr_workstream[i].snws_cpu].queued += netisr_work[n].snw_queued;
1291 for (i = 0; i < number_of_cpus; i++) {
1292 netisr_stats[number_of_cpus].dispatched += netisr_stats[i].dispatched;
1293 netisr_stats[number_of_cpus].hybrid_dispatched += netisr_stats[i].hybrid_dispatched;
1294 netisr_stats[number_of_cpus].qdrops += netisr_stats[i].qdrops;
1295 netisr_stats[number_of_cpus].queued += netisr_stats[i].queued;
1299 error("DISABLED: net.isr module");
1303 // --------------------------------------------------------------------
1305 if (likely(do_netisr)) {
1306 static RRDSET *st = NULL;
1307 static RRDDIM *rd_dispatched = NULL, *rd_hybrid_dispatched = NULL, *rd_qdrops = NULL, *rd_queued = NULL;
1309 if (unlikely(!st)) {
1310 st = rrdset_create_localhost("system",
1315 "System softnet_stat",
1322 rd_dispatched = rrddim_add(st, "dispatched", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
1323 rd_hybrid_dispatched = rrddim_add(st, "hybrid_dispatched", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
1324 rd_qdrops = rrddim_add(st, "qdrops", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
1325 rd_queued = rrddim_add(st, "queued", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
1327 else rrdset_next(st);
1329 rrddim_set_by_pointer(st, rd_dispatched, netisr_stats[number_of_cpus].dispatched);
1330 rrddim_set_by_pointer(st, rd_hybrid_dispatched, netisr_stats[number_of_cpus].hybrid_dispatched);
1331 rrddim_set_by_pointer(st, rd_qdrops, netisr_stats[number_of_cpus].qdrops);
1332 rrddim_set_by_pointer(st, rd_queued, netisr_stats[number_of_cpus].queued);
1336 // --------------------------------------------------------------------
1338 if (likely(do_netisr_per_core)) {
1339 static struct softnet_chart {
1340 char netisr_cpuid[MAX_INT_DIGITS + 17];
1342 RRDDIM *rd_dispatched;
1343 RRDDIM *rd_hybrid_dispatched;
1346 } *all_softnet_charts = NULL;
1348 all_softnet_charts = reallocz(all_softnet_charts, sizeof(struct softnet_chart) * number_of_cpus);
1350 for (i = 0; i < number_of_cpus ;i++) {
1351 snprintfz(all_softnet_charts[i].netisr_cpuid, MAX_INT_DIGITS + 17, "cpu%d_softnet_stat", i);
1353 if (unlikely(!all_softnet_charts[i].st)) {
1354 all_softnet_charts[i].st = rrdset_create_localhost("cpu",
1355 all_softnet_charts[i].netisr_cpuid,
1359 "Per CPU netisr statistics",
1366 all_softnet_charts[i].rd_dispatched = rrddim_add(all_softnet_charts[i].st, "dispatched",
1367 NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
1368 all_softnet_charts[i].rd_hybrid_dispatched = rrddim_add(all_softnet_charts[i].st, "hybrid_dispatched",
1369 NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
1370 all_softnet_charts[i].rd_qdrops = rrddim_add(all_softnet_charts[i].st, "qdrops",
1371 NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
1372 all_softnet_charts[i].rd_queued = rrddim_add(all_softnet_charts[i].st, "queued",
1373 NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
1375 else rrdset_next(all_softnet_charts[i].st);
1377 rrddim_set_by_pointer(all_softnet_charts[i].st, all_softnet_charts[i].rd_dispatched,
1378 netisr_stats[i].dispatched);
1379 rrddim_set_by_pointer(all_softnet_charts[i].st, all_softnet_charts[i].rd_hybrid_dispatched,
1380 netisr_stats[i].hybrid_dispatched);
1381 rrddim_set_by_pointer(all_softnet_charts[i].st, all_softnet_charts[i].rd_qdrops,
1382 netisr_stats[i].qdrops);
1383 rrddim_set_by_pointer(all_softnet_charts[i].st, all_softnet_charts[i].rd_queued,
1384 netisr_stats[i].queued);
1385 rrdset_done(all_softnet_charts[i].st);
1392 // --------------------------------------------------------------------------------------------------------------------
1393 // net.inet.tcp.states
1395 int do_net_inet_tcp_states(int update_every, usec_t dt) {
1396 static int mib[4] = {0, 0, 0, 0};
1397 uint64_t tcps_states[TCP_NSTATES];
1399 // see http://net-snmp.sourceforge.net/docs/mibs/tcp.html
1400 if (unlikely(GETSYSCTL_SIMPLE("net.inet.tcp.states", mib, tcps_states))) {
1401 error("DISABLED: ipv4.tcpsock chart");
1402 error("DISABLED: net.inet.tcp.states module");
1406 // --------------------------------------------------------------------
1408 static RRDSET *st = NULL;
1409 static RRDDIM *rd = NULL;
1411 if (unlikely(!st)) {
1412 st = rrdset_create_localhost("ipv4",
1417 "IPv4 TCP Connections",
1418 "active connections",
1424 rd = rrddim_add(st, "CurrEstab", "connections", 1, 1, RRD_ALGORITHM_ABSOLUTE);
1428 rrddim_set_by_pointer(st, rd, tcps_states[TCPS_ESTABLISHED]);
1435 // --------------------------------------------------------------------------------------------------------------------
1436 // net.inet.tcp.stats
1438 int do_net_inet_tcp_stats(int update_every, usec_t dt) {
1439 static int do_tcp_packets = -1, do_tcp_errors = -1, do_tcp_handshake = -1, do_tcpext_connaborts = -1, do_tcpext_ofo = -1, do_tcpext_syncookies = -1, do_ecn = -1;
1441 if (unlikely(do_tcp_packets == -1)) {
1442 do_tcp_packets = config_get_boolean("plugin:freebsd:net.inet.tcp.stats", "ipv4 TCP packets", 1);
1443 do_tcp_errors = config_get_boolean("plugin:freebsd:net.inet.tcp.stats", "ipv4 TCP errors", 1);
1444 do_tcp_handshake = config_get_boolean("plugin:freebsd:net.inet.tcp.stats", "ipv4 TCP handshake issues", 1);
1445 do_tcpext_connaborts = config_get_boolean_ondemand("plugin:freebsd:net.inet.tcp.stats", "TCP connection aborts",
1446 CONFIG_BOOLEAN_AUTO);
1447 do_tcpext_ofo = config_get_boolean_ondemand("plugin:freebsd:net.inet.tcp.stats", "TCP out-of-order queue",
1448 CONFIG_BOOLEAN_AUTO);
1449 do_tcpext_syncookies = config_get_boolean_ondemand("plugin:freebsd:net.inet.tcp.stats", "TCP SYN cookies",
1450 CONFIG_BOOLEAN_AUTO);
1451 do_ecn = config_get_boolean_ondemand("plugin:freebsd:net.inet.tcp.stats", "ECN packets",
1452 CONFIG_BOOLEAN_AUTO);
1455 // see http://net-snmp.sourceforge.net/docs/mibs/tcp.html
1456 if (likely(do_tcp_packets || do_tcp_errors || do_tcp_handshake || do_tcpext_connaborts || do_tcpext_ofo || do_tcpext_syncookies || do_ecn)) {
1457 static int mib[4] = {0, 0, 0, 0};
1458 struct tcpstat tcpstat;
1460 if (unlikely(GETSYSCTL_SIMPLE("net.inet.tcp.stats", mib, tcpstat))) {
1462 error("DISABLED: ipv4.tcppackets chart");
1464 error("DISABLED: ipv4.tcperrors chart");
1465 do_tcp_handshake = 0;
1466 error("DISABLED: ipv4.tcphandshake chart");
1467 do_tcpext_connaborts = 0;
1468 error("DISABLED: ipv4.tcpconnaborts chart");
1470 error("DISABLED: ipv4.tcpofo chart");
1471 do_tcpext_syncookies = 0;
1472 error("DISABLED: ipv4.tcpsyncookies chart");
1474 error("DISABLED: ipv4.ecnpkts chart");
1475 error("DISABLED: net.inet.tcp.stats module");
1479 // --------------------------------------------------------------------
1481 if (likely(do_tcp_packets)) {
1482 static RRDSET *st = NULL;
1483 static RRDDIM *rd_in_segs = NULL, *rd_out_segs = NULL;
1485 if (unlikely(!st)) {
1486 st = rrdset_create_localhost("ipv4",
1498 rd_in_segs = rrddim_add(st, "InSegs", "received", 1, 1, RRD_ALGORITHM_INCREMENTAL);
1499 rd_out_segs = rrddim_add(st, "OutSegs", "sent", -1, 1, RRD_ALGORITHM_INCREMENTAL);
1503 rrddim_set_by_pointer(st, rd_in_segs, tcpstat.tcps_rcvtotal);
1504 rrddim_set_by_pointer(st, rd_out_segs, tcpstat.tcps_sndtotal);
1508 // --------------------------------------------------------------------
1510 if (likely(do_tcp_errors)) {
1511 static RRDSET *st = NULL;
1512 static RRDDIM *rd_in_errs = NULL, *rd_in_csum_errs = NULL, *rd_retrans_segs = NULL;
1514 if (unlikely(!st)) {
1515 st = rrdset_create_localhost("ipv4",
1527 rrdset_flag_set(st, RRDSET_FLAG_DETAIL);
1529 rd_in_errs = rrddim_add(st, "InErrs", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
1530 rd_in_csum_errs = rrddim_add(st, "InCsumErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
1531 rd_retrans_segs = rrddim_add(st, "RetransSegs", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
1535 #if __FreeBSD__ >= 11
1536 rrddim_set_by_pointer(st, rd_in_errs, tcpstat.tcps_rcvbadoff + tcpstat.tcps_rcvreassfull +
1537 tcpstat.tcps_rcvshort);
1539 rrddim_set_by_pointer(st, rd_in_errs, tcpstat.tcps_rcvbadoff + tcpstat.tcps_rcvshort);
1541 rrddim_set_by_pointer(st, rd_in_csum_errs, tcpstat.tcps_rcvbadsum);
1542 rrddim_set_by_pointer(st, rd_retrans_segs, tcpstat.tcps_sndrexmitpack);
1546 // --------------------------------------------------------------------
1548 if (likely(do_tcp_handshake)) {
1549 static RRDSET *st = NULL;
1550 static RRDDIM *rd_estab_resets = NULL, *rd_active_opens = NULL, *rd_passive_opens = NULL,
1551 *rd_attempt_fails = NULL;
1553 if (unlikely(!st)) {
1554 st = rrdset_create_localhost("ipv4",
1559 "IPv4 TCP Handshake Issues",
1566 rrdset_flag_set(st, RRDSET_FLAG_DETAIL);
1568 rd_estab_resets = rrddim_add(st, "EstabResets", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
1569 rd_active_opens = rrddim_add(st, "ActiveOpens", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
1570 rd_passive_opens = rrddim_add(st, "PassiveOpens", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
1571 rd_attempt_fails = rrddim_add(st, "AttemptFails", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
1575 rrddim_set_by_pointer(st, rd_estab_resets, tcpstat.tcps_drops);
1576 rrddim_set_by_pointer(st, rd_active_opens, tcpstat.tcps_connattempt);
1577 rrddim_set_by_pointer(st, rd_passive_opens, tcpstat.tcps_accepts);
1578 rrddim_set_by_pointer(st, rd_attempt_fails, tcpstat.tcps_conndrops);
1582 // --------------------------------------------------------------------
1584 if (do_tcpext_connaborts == CONFIG_BOOLEAN_YES || (do_tcpext_connaborts == CONFIG_BOOLEAN_AUTO && (tcpstat.tcps_rcvpackafterwin || tcpstat.tcps_rcvafterclose || tcpstat.tcps_rcvmemdrop || tcpstat.tcps_persistdrop || tcpstat.tcps_finwait2_drops))) {
1585 do_tcpext_connaborts = CONFIG_BOOLEAN_YES;
1587 static RRDSET *st = NULL;
1588 static RRDDIM *rd_on_data = NULL, *rd_on_close = NULL, *rd_on_memory = NULL,
1589 *rd_on_timeout = NULL, *rd_on_linger = NULL;
1591 if (unlikely(!st)) {
1592 st = rrdset_create_localhost("ipv4",
1597 "TCP Connection Aborts",
1604 rd_on_data = rrddim_add(st, "TCPAbortOnData", "baddata", 1, 1, RRD_ALGORITHM_INCREMENTAL);
1605 rd_on_close = rrddim_add(st, "TCPAbortOnClose", "userclosed", 1, 1, RRD_ALGORITHM_INCREMENTAL);
1606 rd_on_memory = rrddim_add(st, "TCPAbortOnMemory", "nomemory", 1, 1, RRD_ALGORITHM_INCREMENTAL);
1607 rd_on_timeout = rrddim_add(st, "TCPAbortOnTimeout", "timeout", 1, 1, RRD_ALGORITHM_INCREMENTAL);
1608 rd_on_linger = rrddim_add(st, "TCPAbortOnLinger", "linger", 1, 1, RRD_ALGORITHM_INCREMENTAL);
1610 else rrdset_next(st);
1612 rrddim_set_by_pointer(st, rd_on_data, tcpstat.tcps_rcvpackafterwin);
1613 rrddim_set_by_pointer(st, rd_on_close, tcpstat.tcps_rcvafterclose);
1614 rrddim_set_by_pointer(st, rd_on_memory, tcpstat.tcps_rcvmemdrop);
1615 rrddim_set_by_pointer(st, rd_on_timeout, tcpstat.tcps_persistdrop);
1616 rrddim_set_by_pointer(st, rd_on_linger, tcpstat.tcps_finwait2_drops);
1620 // --------------------------------------------------------------------
1622 if (do_tcpext_ofo == CONFIG_BOOLEAN_YES || (do_tcpext_ofo == CONFIG_BOOLEAN_AUTO && tcpstat.tcps_rcvoopack)) {
1623 do_tcpext_ofo = CONFIG_BOOLEAN_YES;
1625 static RRDSET *st = NULL;
1626 static RRDDIM *rd_ofo_queue = NULL;
1628 if (unlikely(!st)) {
1629 st = rrdset_create_localhost("ipv4",
1634 "TCP Out-Of-Order Queue",
1641 rd_ofo_queue = rrddim_add(st, "TCPOFOQueue", "inqueue", 1, 1, RRD_ALGORITHM_INCREMENTAL);
1643 else rrdset_next(st);
1645 rrddim_set_by_pointer(st, rd_ofo_queue, tcpstat.tcps_rcvoopack);
1649 // --------------------------------------------------------------------
1651 if (do_tcpext_syncookies == CONFIG_BOOLEAN_YES || (do_tcpext_syncookies == CONFIG_BOOLEAN_AUTO && (tcpstat.tcps_sc_sendcookie || tcpstat.tcps_sc_recvcookie || tcpstat.tcps_sc_zonefail))) {
1652 do_tcpext_syncookies = CONFIG_BOOLEAN_YES;
1654 static RRDSET *st = NULL;
1655 static RRDDIM *rd_recv = NULL, *rd_send = NULL, *rd_failed = NULL;
1657 if (unlikely(!st)) {
1658 st = rrdset_create_localhost("ipv4",
1670 rd_recv = rrddim_add(st, "SyncookiesRecv", "received", 1, 1, RRD_ALGORITHM_INCREMENTAL);
1671 rd_send = rrddim_add(st, "SyncookiesSent", "sent", -1, 1, RRD_ALGORITHM_INCREMENTAL);
1672 rd_failed = rrddim_add(st, "SyncookiesFailed", "failed", -1, 1, RRD_ALGORITHM_INCREMENTAL);
1674 else rrdset_next(st);
1676 rrddim_set_by_pointer(st, rd_recv, tcpstat.tcps_sc_recvcookie);
1677 rrddim_set_by_pointer(st, rd_send, tcpstat.tcps_sc_sendcookie);
1678 rrddim_set_by_pointer(st, rd_failed, tcpstat.tcps_sc_zonefail);
1682 // --------------------------------------------------------------------
1684 if (do_ecn == CONFIG_BOOLEAN_YES || (do_ecn == CONFIG_BOOLEAN_AUTO && (tcpstat.tcps_ecn_ce || tcpstat.tcps_ecn_ect0 || tcpstat.tcps_ecn_ect1))) {
1685 do_ecn = CONFIG_BOOLEAN_YES;
1687 static RRDSET *st = NULL;
1688 static RRDDIM *rd_ce = NULL, *rd_no_ect = NULL, *rd_ect0 = NULL, *rd_ect1 = NULL;
1690 if (unlikely(!st)) {
1691 st = rrdset_create_localhost("ipv4",
1696 "IPv4 ECN Statistics",
1703 rrdset_flag_set(st, RRDSET_FLAG_DETAIL);
1705 rd_ce = rrddim_add(st, "InCEPkts", "CEP", 1, 1, RRD_ALGORITHM_INCREMENTAL);
1706 rd_no_ect = rrddim_add(st, "InNoECTPkts", "NoECTP", -1, 1, RRD_ALGORITHM_INCREMENTAL);
1707 rd_ect0 = rrddim_add(st, "InECT0Pkts", "ECTP0", 1, 1, RRD_ALGORITHM_INCREMENTAL);
1708 rd_ect1 = rrddim_add(st, "InECT1Pkts", "ECTP1", 1, 1, RRD_ALGORITHM_INCREMENTAL);
1710 else rrdset_next(st);
1712 rrddim_set_by_pointer(st, rd_ce, tcpstat.tcps_ecn_ce);
1713 rrddim_set_by_pointer(st, rd_no_ect, tcpstat.tcps_ecn_ce - (tcpstat.tcps_ecn_ect0 +
1714 tcpstat.tcps_ecn_ect1));
1715 rrddim_set_by_pointer(st, rd_ect0, tcpstat.tcps_ecn_ect0);
1716 rrddim_set_by_pointer(st, rd_ect1, tcpstat.tcps_ecn_ect1);
1722 error("DISABLED: net.inet.tcp.stats module");
1729 // --------------------------------------------------------------------------------------------------------------------
1730 // net.inet.udp.stats
1732 int do_net_inet_udp_stats(int update_every, usec_t dt) {
1733 static int do_udp_packets = -1, do_udp_errors = -1;
1735 if (unlikely(do_udp_packets == -1)) {
1736 do_udp_packets = config_get_boolean("plugin:freebsd:net.inet.udp.stats", "ipv4 UDP packets", 1);
1737 do_udp_errors = config_get_boolean("plugin:freebsd:net.inet.udp.stats", "ipv4 UDP errors", 1);
1740 // see http://net-snmp.sourceforge.net/docs/mibs/udp.html
1741 if (likely(do_udp_packets || do_udp_errors)) {
1742 static int mib[4] = {0, 0, 0, 0};
1743 struct udpstat udpstat;
1745 if (unlikely(GETSYSCTL_SIMPLE("net.inet.udp.stats", mib, udpstat))) {
1747 error("DISABLED: ipv4.udppackets chart");
1749 error("DISABLED: ipv4.udperrors chart");
1750 error("DISABLED: net.inet.udp.stats module");
1754 // --------------------------------------------------------------------
1756 if (likely(do_udp_packets)) {
1757 static RRDSET *st = NULL;
1758 static RRDDIM *rd_in = NULL, *rd_out = NULL;
1760 if (unlikely(!st)) {
1761 st = rrdset_create_localhost("ipv4",
1773 rd_in = rrddim_add(st, "InDatagrams", "received", 1, 1, RRD_ALGORITHM_INCREMENTAL);
1774 rd_out = rrddim_add(st, "OutDatagrams", "sent", -1, 1, RRD_ALGORITHM_INCREMENTAL);
1778 rrddim_set_by_pointer(st, rd_in, udpstat.udps_ipackets);
1779 rrddim_set_by_pointer(st, rd_out, udpstat.udps_opackets);
1783 // --------------------------------------------------------------------
1785 if (likely(do_udp_errors)) {
1786 static RRDSET *st = NULL;
1787 static RRDDIM *rd_in_errors = NULL, *rd_no_ports = NULL, *rd_recv_buf_errors = NULL,
1788 *rd_in_csum_errors = NULL, *rd_ignored_multi = NULL;
1790 if (unlikely(!st)) {
1791 st = rrdset_create_localhost("ipv4",
1803 rrdset_flag_set(st, RRDSET_FLAG_DETAIL);
1805 rd_in_errors = rrddim_add(st, "InErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
1806 rd_no_ports = rrddim_add(st, "NoPorts", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
1807 rd_recv_buf_errors = rrddim_add(st, "RcvbufErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
1808 rd_in_csum_errors = rrddim_add(st, "InCsumErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
1809 rd_ignored_multi = rrddim_add(st, "IgnoredMulti", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
1813 rrddim_set_by_pointer(st, rd_in_errors, udpstat.udps_hdrops + udpstat.udps_badlen);
1814 rrddim_set_by_pointer(st, rd_no_ports, udpstat.udps_noport);
1815 rrddim_set_by_pointer(st, rd_recv_buf_errors, udpstat.udps_fullsock);
1816 rrddim_set_by_pointer(st, rd_in_csum_errors, udpstat.udps_badsum + udpstat.udps_nosum);
1817 rrddim_set_by_pointer(st, rd_ignored_multi, udpstat.udps_filtermcast);
1822 error("DISABLED: net.inet.udp.stats module");
1829 // --------------------------------------------------------------------------------------------------------------------
1830 // net.inet.icmp.stats
1832 int do_net_inet_icmp_stats(int update_every, usec_t dt) {
1833 static int do_icmp_packets = -1, do_icmp_errors = -1, do_icmpmsg = -1;
1835 if (unlikely(do_icmp_packets == -1)) {
1836 do_icmp_packets = config_get_boolean("plugin:freebsd:net.inet.icmp.stats", "ipv4 ICMP packets", 1);
1837 do_icmp_errors = config_get_boolean("plugin:freebsd:net.inet.icmp.stats", "ipv4 ICMP errors", 1);
1838 do_icmpmsg = config_get_boolean("plugin:freebsd:net.inet.icmp.stats", "ipv4 ICMP messages", 1);
1841 if (likely(do_icmp_packets || do_icmp_errors || do_icmpmsg)) {
1842 static int mib[4] = {0, 0, 0, 0};
1843 struct icmpstat icmpstat;
1848 } icmp_total = {0, 0};
1850 if (unlikely(GETSYSCTL_SIMPLE("net.inet.icmp.stats", mib, icmpstat))) {
1851 do_icmp_packets = 0;
1852 error("DISABLED: ipv4.icmp chart");
1854 error("DISABLED: ipv4.icmp_errors chart");
1856 error("DISABLED: ipv4.icmpmsg chart");
1857 error("DISABLED: net.inet.icmp.stats module");
1860 for (i = 0; i <= ICMP_MAXTYPE; i++) {
1861 icmp_total.msgs_in += icmpstat.icps_inhist[i];
1862 icmp_total.msgs_out += icmpstat.icps_outhist[i];
1864 icmp_total.msgs_in += icmpstat.icps_badcode + icmpstat.icps_badlen + icmpstat.icps_checksum + icmpstat.icps_tooshort;
1866 // --------------------------------------------------------------------
1868 if (likely(do_icmp_packets)) {
1869 static RRDSET *st = NULL;
1870 static RRDDIM *rd_in = NULL, *rd_out = NULL;
1872 if (unlikely(!st)) {
1873 st = rrdset_create_localhost("ipv4",
1878 "IPv4 ICMP Packets",
1885 rd_in = rrddim_add(st, "InMsgs", "received", 1, 1, RRD_ALGORITHM_INCREMENTAL);
1886 rd_out = rrddim_add(st, "OutMsgs", "sent", -1, 1, RRD_ALGORITHM_INCREMENTAL);
1890 rrddim_set_by_pointer(st, rd_in, icmp_total.msgs_in);
1891 rrddim_set_by_pointer(st, rd_out, icmp_total.msgs_out);
1896 // --------------------------------------------------------------------
1898 if (likely(do_icmp_errors)) {
1899 static RRDSET *st = NULL;
1900 static RRDDIM *rd_in = NULL, *rd_out = NULL, *rd_in_csum = NULL;
1902 if (unlikely(!st)) {
1903 st = rrdset_create_localhost("ipv4", "icmp_errors", NULL, "icmp", NULL, "IPv4 ICMP Errors",
1905 2603, update_every, RRDSET_TYPE_LINE);
1907 rd_in = rrddim_add(st, "InErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
1908 rd_out = rrddim_add(st, "OutErrors", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
1909 rd_in_csum = rrddim_add(st, "InCsumErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
1913 rrddim_set_by_pointer(st, rd_in, icmpstat.icps_badcode + icmpstat.icps_badlen +
1914 icmpstat.icps_checksum + icmpstat.icps_tooshort);
1915 rrddim_set_by_pointer(st, rd_out, icmpstat.icps_error);
1916 rrddim_set_by_pointer(st, rd_in_csum, icmpstat.icps_checksum);
1921 // --------------------------------------------------------------------
1923 if (likely(do_icmpmsg)) {
1924 static RRDSET *st = NULL;
1925 static RRDDIM *rd_in_reps = NULL, *rd_out_reps = NULL, *rd_in = NULL, *rd_out = NULL;
1927 if (unlikely(!st)) {
1928 st = rrdset_create_localhost("ipv4", "icmpmsg", NULL, "icmp", NULL, "IPv4 ICMP Messsages",
1929 "packets/s", 2604, update_every, RRDSET_TYPE_LINE);
1931 rd_in_reps = rrddim_add(st, "InEchoReps", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
1932 rd_out_reps = rrddim_add(st, "OutEchoReps", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
1933 rd_in = rrddim_add(st, "InEchos", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
1934 rd_out = rrddim_add(st, "OutEchos", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
1938 rrddim_set_by_pointer(st, rd_in_reps, icmpstat.icps_inhist[ICMP_ECHOREPLY]);
1939 rrddim_set_by_pointer(st, rd_out_reps, icmpstat.icps_outhist[ICMP_ECHOREPLY]);
1940 rrddim_set_by_pointer(st, rd_in, icmpstat.icps_inhist[ICMP_ECHO]);
1941 rrddim_set_by_pointer(st, rd_out, icmpstat.icps_outhist[ICMP_ECHO]);
1947 error("DISABLED: net.inet.icmp.stats module");
1954 // --------------------------------------------------------------------------------------------------------------------
1955 // net.inet.ip.stats
1957 int do_net_inet_ip_stats(int update_every, usec_t dt) {
1958 static int do_ip_packets = -1, do_ip_fragsout = -1, do_ip_fragsin = -1, do_ip_errors = -1;
1960 if (unlikely(do_ip_packets == -1)) {
1961 do_ip_packets = config_get_boolean("plugin:freebsd:net.inet.ip.stats", "ipv4 packets", 1);
1962 do_ip_fragsout = config_get_boolean("plugin:freebsd:net.inet.ip.stats", "ipv4 fragments sent", 1);
1963 do_ip_fragsin = config_get_boolean("plugin:freebsd:net.inet.ip.stats", "ipv4 fragments assembly", 1);
1964 do_ip_errors = config_get_boolean("plugin:freebsd:net.inet.ip.stats", "ipv4 errors", 1);
1967 // see also http://net-snmp.sourceforge.net/docs/mibs/ip.html
1968 if (likely(do_ip_packets || do_ip_fragsout || do_ip_fragsin || do_ip_errors)) {
1969 static int mib[4] = {0, 0, 0, 0};
1970 struct ipstat ipstat;
1972 if (unlikely(GETSYSCTL_SIMPLE("net.inet.ip.stats", mib, ipstat))) {
1974 error("DISABLED: ipv4.packets chart");
1976 error("DISABLED: ipv4.fragsout chart");
1978 error("DISABLED: ipv4.fragsin chart");
1980 error("DISABLED: ipv4.errors chart");
1981 error("DISABLED: net.inet.ip.stats module");
1985 // --------------------------------------------------------------------
1987 if (likely(do_ip_packets)) {
1988 static RRDSET *st = NULL;
1989 static RRDDIM *rd_in_receives = NULL, *rd_out_requests = NULL, *rd_forward_datagrams = NULL,
1990 *rd_in_delivers = NULL;
1992 if (unlikely(!st)) {
1993 st = rrdset_create_localhost("ipv4",
2005 rd_in_receives = rrddim_add(st, "InReceives", "received", 1, 1, RRD_ALGORITHM_INCREMENTAL);
2006 rd_out_requests = rrddim_add(st, "OutRequests", "sent", -1, 1, RRD_ALGORITHM_INCREMENTAL);
2007 rd_forward_datagrams = rrddim_add(st, "ForwDatagrams", "forwarded", 1, 1, RRD_ALGORITHM_INCREMENTAL);
2008 rd_in_delivers = rrddim_add(st, "InDelivers", "delivered", 1, 1, RRD_ALGORITHM_INCREMENTAL);
2012 rrddim_set_by_pointer(st, rd_in_receives, ipstat.ips_total);
2013 rrddim_set_by_pointer(st, rd_out_requests, ipstat.ips_localout);
2014 rrddim_set_by_pointer(st, rd_forward_datagrams, ipstat.ips_forward);
2015 rrddim_set_by_pointer(st, rd_in_delivers, ipstat.ips_delivered);
2019 // --------------------------------------------------------------------
2021 if (likely(do_ip_fragsout)) {
2022 static RRDSET *st = NULL;
2023 static RRDDIM *rd_ok = NULL, *rd_fails = NULL, *rd_created = NULL;
2025 if (unlikely(!st)) {
2026 st = rrdset_create_localhost("ipv4",
2031 "IPv4 Fragments Sent",
2038 rrdset_flag_set(st, RRDSET_FLAG_DETAIL);
2040 rd_ok = rrddim_add(st, "FragOKs", "ok", 1, 1, RRD_ALGORITHM_INCREMENTAL);
2041 rd_fails = rrddim_add(st, "FragFails", "failed", -1, 1, RRD_ALGORITHM_INCREMENTAL);
2042 rd_created = rrddim_add(st, "FragCreates", "created", 1, 1, RRD_ALGORITHM_INCREMENTAL);
2046 rrddim_set_by_pointer(st, rd_ok, ipstat.ips_fragmented);
2047 rrddim_set_by_pointer(st, rd_fails, ipstat.ips_cantfrag);
2048 rrddim_set_by_pointer(st, rd_created, ipstat.ips_ofragments);
2052 // --------------------------------------------------------------------
2054 if (likely(do_ip_fragsin)) {
2055 static RRDSET *st = NULL;
2056 static RRDDIM *rd_ok = NULL, *rd_failed = NULL, *rd_all = NULL;
2058 if (unlikely(!st)) {
2059 st = rrdset_create_localhost("ipv4",
2064 "IPv4 Fragments Reassembly",
2071 rrdset_flag_set(st, RRDSET_FLAG_DETAIL);
2073 rd_ok = rrddim_add(st, "ReasmOKs", "ok", 1, 1, RRD_ALGORITHM_INCREMENTAL);
2074 rd_failed = rrddim_add(st, "ReasmFails", "failed", -1, 1, RRD_ALGORITHM_INCREMENTAL);
2075 rd_all = rrddim_add(st, "ReasmReqds", "all", 1, 1, RRD_ALGORITHM_INCREMENTAL);
2079 rrddim_set_by_pointer(st, rd_ok, ipstat.ips_fragments);
2080 rrddim_set_by_pointer(st, rd_failed, ipstat.ips_fragdropped);
2081 rrddim_set_by_pointer(st, rd_all, ipstat.ips_reassembled);
2085 // --------------------------------------------------------------------
2087 if (likely(do_ip_errors)) {
2088 static RRDSET *st = NULL;
2089 static RRDDIM *rd_in_discards = NULL, *rd_out_discards = NULL,
2090 *rd_in_hdr_errors = NULL, *rd_out_no_routes = NULL,
2091 *rd_in_addr_errors = NULL, *rd_in_unknown_protos = NULL;
2093 if (unlikely(!st)) {
2094 st = rrdset_create_localhost("ipv4",
2106 rrdset_flag_set(st, RRDSET_FLAG_DETAIL);
2108 rd_in_discards = rrddim_add(st, "InDiscards", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
2109 rd_out_discards = rrddim_add(st, "OutDiscards", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
2110 rd_in_hdr_errors = rrddim_add(st, "InHdrErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
2111 rd_out_no_routes = rrddim_add(st, "OutNoRoutes", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
2112 rd_in_addr_errors = rrddim_add(st, "InAddrErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
2113 rd_in_unknown_protos = rrddim_add(st, "InUnknownProtos", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
2117 rrddim_set_by_pointer(st, rd_in_discards, ipstat.ips_badsum + ipstat.ips_tooshort +
2118 ipstat.ips_toosmall + ipstat.ips_toolong);
2119 rrddim_set_by_pointer(st, rd_out_discards, ipstat.ips_odropped);
2120 rrddim_set_by_pointer(st, rd_in_hdr_errors, ipstat.ips_badhlen + ipstat.ips_badlen +
2121 ipstat.ips_badoptions + ipstat.ips_badvers);
2122 rrddim_set_by_pointer(st, rd_out_no_routes, ipstat.ips_noroute);
2123 rrddim_set_by_pointer(st, rd_in_addr_errors, ipstat.ips_badaddr);
2124 rrddim_set_by_pointer(st, rd_in_unknown_protos, ipstat.ips_noproto);
2129 error("DISABLED: net.inet.ip.stats module");
2136 // --------------------------------------------------------------------------------------------------------------------
2137 // net.inet6.ip6.stats
2139 int do_net_inet6_ip6_stats(int update_every, usec_t dt) {
2140 static int do_ip6_packets = -1, do_ip6_fragsout = -1, do_ip6_fragsin = -1, do_ip6_errors = -1;
2142 if (unlikely(do_ip6_packets == -1)) {
2143 do_ip6_packets = config_get_boolean_ondemand("plugin:freebsd:net.inet6.ip6.stats", "ipv6 packets",
2144 CONFIG_BOOLEAN_AUTO);
2145 do_ip6_fragsout = config_get_boolean_ondemand("plugin:freebsd:net.inet6.ip6.stats", "ipv6 fragments sent",
2146 CONFIG_BOOLEAN_AUTO);
2147 do_ip6_fragsin = config_get_boolean_ondemand("plugin:freebsd:net.inet6.ip6.stats", "ipv6 fragments assembly",
2148 CONFIG_BOOLEAN_AUTO);
2149 do_ip6_errors = config_get_boolean_ondemand("plugin:freebsd:net.inet6.ip6.stats", "ipv6 errors",
2150 CONFIG_BOOLEAN_AUTO);
2153 if (likely(do_ip6_packets || do_ip6_fragsout || do_ip6_fragsin || do_ip6_errors)) {
2154 static int mib[4] = {0, 0, 0, 0};
2155 struct ip6stat ip6stat;
2157 if (unlikely(GETSYSCTL_SIMPLE("net.inet6.ip6.stats", mib, ip6stat))) {
2159 error("DISABLED: ipv6.packets chart");
2160 do_ip6_fragsout = 0;
2161 error("DISABLED: ipv6.fragsout chart");
2163 error("DISABLED: ipv6.fragsin chart");
2165 error("DISABLED: ipv6.errors chart");
2166 error("DISABLED: net.inet6.ip6.stats module");
2170 // --------------------------------------------------------------------
2172 if (do_ip6_packets == CONFIG_BOOLEAN_YES || (do_ip6_packets == CONFIG_BOOLEAN_AUTO &&
2173 (ip6stat.ip6s_localout || ip6stat.ip6s_total ||
2174 ip6stat.ip6s_forward || ip6stat.ip6s_delivered))) {
2175 do_ip6_packets = CONFIG_BOOLEAN_YES;
2177 static RRDSET *st = NULL;
2178 static RRDDIM *rd_received = NULL, *rd_sent = NULL, *rd_forwarded = NULL, *rd_delivers = NULL;
2180 if (unlikely(!st)) {
2181 st = rrdset_create_localhost("ipv6",
2193 rd_received = rrddim_add(st, "received", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
2194 rd_sent = rrddim_add(st, "sent", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
2195 rd_forwarded = rrddim_add(st, "forwarded", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
2196 rd_delivers = rrddim_add(st, "delivers", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
2200 rrddim_set_by_pointer(st, rd_sent, ip6stat.ip6s_localout);
2201 rrddim_set_by_pointer(st, rd_received, ip6stat.ip6s_total);
2202 rrddim_set_by_pointer(st, rd_forwarded, ip6stat.ip6s_forward);
2203 rrddim_set_by_pointer(st, rd_delivers, ip6stat.ip6s_delivered);
2207 // --------------------------------------------------------------------
2209 if (do_ip6_fragsout == CONFIG_BOOLEAN_YES || (do_ip6_fragsout == CONFIG_BOOLEAN_AUTO &&
2210 (ip6stat.ip6s_fragmented || ip6stat.ip6s_cantfrag ||
2211 ip6stat.ip6s_ofragments))) {
2212 do_ip6_fragsout = CONFIG_BOOLEAN_YES;
2214 static RRDSET *st = NULL;
2215 static RRDDIM *rd_ok = NULL, *rd_failed = NULL, *rd_all = NULL;
2217 if (unlikely(!st)) {
2218 st = rrdset_create_localhost("ipv6",
2223 "IPv6 Fragments Sent",
2230 rrdset_flag_set(st, RRDSET_FLAG_DETAIL);
2232 rd_ok = rrddim_add(st, "ok", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
2233 rd_failed = rrddim_add(st, "failed", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
2234 rd_all = rrddim_add(st, "all", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
2238 rrddim_set_by_pointer(st, rd_ok, ip6stat.ip6s_fragmented);
2239 rrddim_set_by_pointer(st, rd_failed, ip6stat.ip6s_cantfrag);
2240 rrddim_set_by_pointer(st, rd_all, ip6stat.ip6s_ofragments);
2244 // --------------------------------------------------------------------
2246 if (do_ip6_fragsin == CONFIG_BOOLEAN_YES || (do_ip6_fragsin == CONFIG_BOOLEAN_AUTO &&
2247 (ip6stat.ip6s_reassembled || ip6stat.ip6s_fragdropped ||
2248 ip6stat.ip6s_fragtimeout || ip6stat.ip6s_fragments))) {
2249 do_ip6_fragsin = CONFIG_BOOLEAN_YES;
2251 static RRDSET *st = NULL;
2252 static RRDDIM *rd_ok = NULL, *rd_failed = NULL, *rd_timeout = NULL, *rd_all = NULL;
2254 if (unlikely(!st)) {
2255 st = rrdset_create_localhost("ipv6",
2260 "IPv6 Fragments Reassembly",
2267 rrdset_flag_set(st, RRDSET_FLAG_DETAIL);
2269 rd_ok = rrddim_add(st, "ok", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
2270 rd_failed = rrddim_add(st, "failed", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
2271 rd_timeout = rrddim_add(st, "timeout", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
2272 rd_all = rrddim_add(st, "all", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
2276 rrddim_set_by_pointer(st, rd_ok, ip6stat.ip6s_reassembled);
2277 rrddim_set_by_pointer(st, rd_failed, ip6stat.ip6s_fragdropped);
2278 rrddim_set_by_pointer(st, rd_timeout, ip6stat.ip6s_fragtimeout);
2279 rrddim_set_by_pointer(st, rd_all, ip6stat.ip6s_fragments);
2283 // --------------------------------------------------------------------
2285 if (do_ip6_errors == CONFIG_BOOLEAN_YES || (do_ip6_errors == CONFIG_BOOLEAN_AUTO && (
2286 ip6stat.ip6s_toosmall ||
2287 ip6stat.ip6s_odropped ||
2288 ip6stat.ip6s_badoptions ||
2289 ip6stat.ip6s_badvers ||
2290 ip6stat.ip6s_exthdrtoolong ||
2291 ip6stat.ip6s_sources_none ||
2292 ip6stat.ip6s_tooshort ||
2293 ip6stat.ip6s_cantforward ||
2294 ip6stat.ip6s_noroute))) {
2295 do_ip6_errors = CONFIG_BOOLEAN_YES;
2297 static RRDSET *st = NULL;
2298 static RRDDIM *rd_in_discards = NULL, *rd_out_discards = NULL,
2299 *rd_in_hdr_errors = NULL, *rd_in_addr_errors = NULL, *rd_in_truncated_pkts = NULL,
2300 *rd_in_no_routes = NULL, *rd_out_no_routes = NULL;
2302 if (unlikely(!st)) {
2303 st = rrdset_create_localhost("ipv6",
2315 rrdset_flag_set(st, RRDSET_FLAG_DETAIL);
2317 rd_in_discards = rrddim_add(st, "InDiscards", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
2318 rd_out_discards = rrddim_add(st, "OutDiscards", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
2319 rd_in_hdr_errors = rrddim_add(st, "InHdrErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
2320 rd_in_addr_errors = rrddim_add(st, "InAddrErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
2321 rd_in_truncated_pkts = rrddim_add(st, "InTruncatedPkts", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
2322 rd_in_no_routes = rrddim_add(st, "InNoRoutes", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
2323 rd_out_no_routes = rrddim_add(st, "OutNoRoutes", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
2327 rrddim_set_by_pointer(st, rd_in_discards, ip6stat.ip6s_toosmall);
2328 rrddim_set_by_pointer(st, rd_out_discards, ip6stat.ip6s_odropped);
2329 rrddim_set_by_pointer(st, rd_in_hdr_errors, ip6stat.ip6s_badoptions + ip6stat.ip6s_badvers +
2330 ip6stat.ip6s_exthdrtoolong);
2331 rrddim_set_by_pointer(st, rd_in_addr_errors, ip6stat.ip6s_sources_none);
2332 rrddim_set_by_pointer(st, rd_in_truncated_pkts, ip6stat.ip6s_tooshort);
2333 rrddim_set_by_pointer(st, rd_in_no_routes, ip6stat.ip6s_cantforward);
2334 rrddim_set_by_pointer(st, rd_out_no_routes, ip6stat.ip6s_noroute);
2339 error("DISABLED: net.inet6.ip6.stats module");
2346 // --------------------------------------------------------------------------------------------------------------------
2347 // net.inet6.icmp6.stats
2349 int do_net_inet6_icmp6_stats(int update_every, usec_t dt) {
2350 static int do_icmp6 = -1, do_icmp6_redir = -1, do_icmp6_errors = -1, do_icmp6_echos = -1, do_icmp6_router = -1,
2351 do_icmp6_neighbor = -1, do_icmp6_types = -1;
2353 if (unlikely(do_icmp6 == -1)) {
2354 do_icmp6 = config_get_boolean_ondemand("plugin:freebsd:net.inet6.icmp6.stats", "icmp",
2355 CONFIG_BOOLEAN_AUTO);
2356 do_icmp6_redir = config_get_boolean_ondemand("plugin:freebsd:net.inet6.icmp6.stats", "icmp redirects",
2357 CONFIG_BOOLEAN_AUTO);
2358 do_icmp6_errors = config_get_boolean_ondemand("plugin:freebsd:net.inet6.icmp6.stats", "icmp errors",
2359 CONFIG_BOOLEAN_AUTO);
2360 do_icmp6_echos = config_get_boolean_ondemand("plugin:freebsd:net.inet6.icmp6.stats", "icmp echos",
2361 CONFIG_BOOLEAN_AUTO);
2362 do_icmp6_router = config_get_boolean_ondemand("plugin:freebsd:net.inet6.icmp6.stats", "icmp router",
2363 CONFIG_BOOLEAN_AUTO);
2364 do_icmp6_neighbor = config_get_boolean_ondemand("plugin:freebsd:net.inet6.icmp6.stats", "icmp neighbor",
2365 CONFIG_BOOLEAN_AUTO);
2366 do_icmp6_types = config_get_boolean_ondemand("plugin:freebsd:net.inet6.icmp6.stats", "icmp types",
2367 CONFIG_BOOLEAN_AUTO);
2370 if (likely(do_icmp6 || do_icmp6_redir || do_icmp6_errors || do_icmp6_echos || do_icmp6_router || do_icmp6_neighbor || do_icmp6_types)) {
2371 static int mib[4] = {0, 0, 0, 0};
2372 struct icmp6stat icmp6stat;
2374 if (unlikely(GETSYSCTL_SIMPLE("net.inet6.icmp6.stats", mib, icmp6stat))) {
2376 error("DISABLED: ipv6.icmp chart");
2378 error("DISABLED: ipv6.icmpredir chart");
2379 do_icmp6_errors = 0;
2380 error("DISABLED: ipv6.icmperrors chart");
2382 error("DISABLED: ipv6.icmpechos chart");
2383 do_icmp6_router = 0;
2384 error("DISABLED: ipv6.icmprouter chart");
2385 do_icmp6_neighbor = 0;
2386 error("DISABLED: ipv6.icmpneighbor chart");
2388 error("DISABLED: ipv6.icmptypes chart");
2389 error("DISABLED: net.inet6.icmp6.stats module");
2393 struct icmp6_total {
2396 } icmp6_total = {0, 0};
2398 for (i = 0; i <= ICMP6_MAXTYPE; i++) {
2399 icmp6_total.msgs_in += icmp6stat.icp6s_inhist[i];
2400 icmp6_total.msgs_out += icmp6stat.icp6s_outhist[i];
2402 icmp6_total.msgs_in += icmp6stat.icp6s_badcode + icmp6stat.icp6s_badlen + icmp6stat.icp6s_checksum + icmp6stat.icp6s_tooshort;
2404 // --------------------------------------------------------------------
2406 if (do_icmp6 == CONFIG_BOOLEAN_YES || (do_icmp6 == CONFIG_BOOLEAN_AUTO && (icmp6_total.msgs_in || icmp6_total.msgs_out))) {
2407 do_icmp6 = CONFIG_BOOLEAN_YES;
2409 static RRDSET *st = NULL;
2410 static RRDDIM *rd_received = NULL, *rd_sent = NULL;
2412 if (unlikely(!st)) {
2413 st = rrdset_create_localhost("ipv6",
2418 "IPv6 ICMP Messages",
2425 rd_received = rrddim_add(st, "received", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
2426 rd_sent = rrddim_add(st, "sent", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
2430 rrddim_set_by_pointer(st, rd_received, icmp6_total.msgs_out);
2431 rrddim_set_by_pointer(st, rd_sent, icmp6_total.msgs_in);
2436 // --------------------------------------------------------------------
2438 if (do_icmp6_redir == CONFIG_BOOLEAN_YES || (do_icmp6_redir == CONFIG_BOOLEAN_AUTO && (icmp6stat.icp6s_inhist[ND_REDIRECT] || icmp6stat.icp6s_outhist[ND_REDIRECT]))) {
2439 do_icmp6_redir = CONFIG_BOOLEAN_YES;
2441 static RRDSET *st = NULL;
2442 static RRDDIM *rd_received = NULL, *rd_sent = NULL;
2444 if (unlikely(!st)) {
2445 st = rrdset_create_localhost("ipv6",
2450 "IPv6 ICMP Redirects",
2457 rd_received = rrddim_add(st, "received", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
2458 rd_sent = rrddim_add(st, "sent", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
2462 rrddim_set_by_pointer(st, rd_received, icmp6stat.icp6s_outhist[ND_REDIRECT]);
2463 rrddim_set_by_pointer(st, rd_sent, icmp6stat.icp6s_inhist[ND_REDIRECT]);
2467 // --------------------------------------------------------------------
2469 if (do_icmp6_errors == CONFIG_BOOLEAN_YES || (do_icmp6_errors == CONFIG_BOOLEAN_AUTO && (
2470 icmp6stat.icp6s_badcode ||
2471 icmp6stat.icp6s_badlen ||
2472 icmp6stat.icp6s_checksum ||
2473 icmp6stat.icp6s_tooshort ||
2474 icmp6stat.icp6s_error ||
2475 icmp6stat.icp6s_inhist[ICMP6_DST_UNREACH] ||
2476 icmp6stat.icp6s_inhist[ICMP6_TIME_EXCEEDED] ||
2477 icmp6stat.icp6s_inhist[ICMP6_PARAM_PROB] ||
2478 icmp6stat.icp6s_outhist[ICMP6_DST_UNREACH] ||
2479 icmp6stat.icp6s_outhist[ICMP6_TIME_EXCEEDED] ||
2480 icmp6stat.icp6s_outhist[ICMP6_PARAM_PROB]))) {
2481 do_icmp6_errors = CONFIG_BOOLEAN_YES;
2483 static RRDSET *st = NULL;
2484 static RRDDIM *rd_in_errors = NULL, *rd_out_errors = NULL, *rd_in_csum_errors = NULL,
2485 *rd_in_dest_unreachs = NULL, *rd_in_pkt_too_bigs = NULL, *rd_in_time_excds = NULL,
2486 *rd_in_parm_problems = NULL, *rd_out_dest_unreachs = NULL, *rd_out_time_excds = NULL,
2487 *rd_out_parm_problems = NULL;
2489 if (unlikely(!st)) {
2490 st = rrdset_create_localhost("ipv6",
2501 rd_in_errors = rrddim_add(st, "InErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
2502 rd_out_errors = rrddim_add(st, "OutErrors", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
2503 rd_in_csum_errors = rrddim_add(st, "InCsumErrors", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
2504 rd_in_dest_unreachs = rrddim_add(st, "InDestUnreachs", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
2505 rd_in_pkt_too_bigs = rrddim_add(st, "InPktTooBigs", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
2506 rd_in_time_excds = rrddim_add(st, "InTimeExcds", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
2507 rd_in_parm_problems = rrddim_add(st, "InParmProblems", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
2508 rd_out_dest_unreachs = rrddim_add(st, "OutDestUnreachs", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
2509 rd_out_time_excds = rrddim_add(st, "OutTimeExcds", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
2510 rd_out_parm_problems = rrddim_add(st, "OutParmProblems", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
2514 rrddim_set_by_pointer(st, rd_in_errors, icmp6stat.icp6s_badcode + icmp6stat.icp6s_badlen +
2515 icmp6stat.icp6s_checksum + icmp6stat.icp6s_tooshort);
2516 rrddim_set_by_pointer(st, rd_out_errors, icmp6stat.icp6s_error);
2517 rrddim_set_by_pointer(st, rd_in_csum_errors, icmp6stat.icp6s_checksum);
2518 rrddim_set_by_pointer(st, rd_in_dest_unreachs, icmp6stat.icp6s_inhist[ICMP6_DST_UNREACH]);
2519 rrddim_set_by_pointer(st, rd_in_pkt_too_bigs, icmp6stat.icp6s_badlen);
2520 rrddim_set_by_pointer(st, rd_in_time_excds, icmp6stat.icp6s_inhist[ICMP6_TIME_EXCEEDED]);
2521 rrddim_set_by_pointer(st, rd_in_parm_problems, icmp6stat.icp6s_inhist[ICMP6_PARAM_PROB]);
2522 rrddim_set_by_pointer(st, rd_out_dest_unreachs, icmp6stat.icp6s_outhist[ICMP6_DST_UNREACH]);
2523 rrddim_set_by_pointer(st, rd_out_time_excds, icmp6stat.icp6s_outhist[ICMP6_TIME_EXCEEDED]);
2524 rrddim_set_by_pointer(st, rd_out_parm_problems, icmp6stat.icp6s_outhist[ICMP6_PARAM_PROB]);
2528 // --------------------------------------------------------------------
2530 if (do_icmp6_echos == CONFIG_BOOLEAN_YES || (do_icmp6_echos == CONFIG_BOOLEAN_AUTO && (
2531 icmp6stat.icp6s_inhist[ICMP6_ECHO_REQUEST] ||
2532 icmp6stat.icp6s_outhist[ICMP6_ECHO_REQUEST] ||
2533 icmp6stat.icp6s_inhist[ICMP6_ECHO_REPLY] ||
2534 icmp6stat.icp6s_outhist[ICMP6_ECHO_REPLY]))) {
2535 do_icmp6_echos = CONFIG_BOOLEAN_YES;
2537 static RRDSET *st = NULL;
2538 static RRDDIM *rd_in = NULL, *rd_out = NULL, *rd_in_replies = NULL, *rd_out_replies = NULL;
2540 if (unlikely(!st)) {
2541 st = rrdset_create_localhost("ipv6",
2553 rd_in = rrddim_add(st, "InEchos", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
2554 rd_out = rrddim_add(st, "OutEchos", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
2555 rd_in_replies = rrddim_add(st, "InEchoReplies", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
2556 rd_out_replies = rrddim_add(st, "OutEchoReplies", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
2560 rrddim_set_by_pointer(st, rd_in, icmp6stat.icp6s_inhist[ICMP6_ECHO_REQUEST]);
2561 rrddim_set_by_pointer(st, rd_out, icmp6stat.icp6s_outhist[ICMP6_ECHO_REQUEST]);
2562 rrddim_set_by_pointer(st, rd_in_replies, icmp6stat.icp6s_inhist[ICMP6_ECHO_REPLY]);
2563 rrddim_set_by_pointer(st, rd_out_replies, icmp6stat.icp6s_outhist[ICMP6_ECHO_REPLY]);
2567 // --------------------------------------------------------------------
2569 if (do_icmp6_router == CONFIG_BOOLEAN_YES || (do_icmp6_router == CONFIG_BOOLEAN_AUTO && (
2570 icmp6stat.icp6s_inhist[ND_ROUTER_SOLICIT] ||
2571 icmp6stat.icp6s_outhist[ND_ROUTER_SOLICIT] ||
2572 icmp6stat.icp6s_inhist[ND_ROUTER_ADVERT] ||
2573 icmp6stat.icp6s_outhist[ND_ROUTER_ADVERT]))) {
2574 do_icmp6_router = CONFIG_BOOLEAN_YES;
2576 static RRDSET *st = NULL;
2577 static RRDDIM *rd_in_solicits = NULL, *rd_out_solicits = NULL,
2578 *rd_in_advertisements = NULL, *rd_out_advertisements = NULL;
2580 if (unlikely(!st)) {
2581 st = rrdset_create_localhost("ipv6",
2586 "IPv6 Router Messages",
2593 rd_in_solicits = rrddim_add(st, "InSolicits", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
2594 rd_out_solicits = rrddim_add(st, "OutSolicits", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
2595 rd_in_advertisements = rrddim_add(st, "InAdvertisements", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
2596 rd_out_advertisements = rrddim_add(st, "OutAdvertisements", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
2600 rrddim_set_by_pointer(st, rd_in_solicits, icmp6stat.icp6s_inhist[ND_ROUTER_SOLICIT]);
2601 rrddim_set_by_pointer(st, rd_out_solicits, icmp6stat.icp6s_outhist[ND_ROUTER_SOLICIT]);
2602 rrddim_set_by_pointer(st, rd_in_advertisements, icmp6stat.icp6s_inhist[ND_ROUTER_ADVERT]);
2603 rrddim_set_by_pointer(st, rd_out_advertisements, icmp6stat.icp6s_outhist[ND_ROUTER_ADVERT]);
2607 // --------------------------------------------------------------------
2609 if (do_icmp6_neighbor == CONFIG_BOOLEAN_YES || (do_icmp6_neighbor == CONFIG_BOOLEAN_AUTO && (
2610 icmp6stat.icp6s_inhist[ND_NEIGHBOR_SOLICIT] ||
2611 icmp6stat.icp6s_outhist[ND_NEIGHBOR_SOLICIT] ||
2612 icmp6stat.icp6s_inhist[ND_NEIGHBOR_ADVERT] ||
2613 icmp6stat.icp6s_outhist[ND_NEIGHBOR_ADVERT]))) {
2614 do_icmp6_neighbor = CONFIG_BOOLEAN_YES;
2616 static RRDSET *st = NULL;
2617 static RRDDIM *rd_in_solicits = NULL, *rd_out_solicits = NULL,
2618 *rd_in_advertisements = NULL, *rd_out_advertisements = NULL;
2620 if (unlikely(!st)) {
2621 st = rrdset_create_localhost("ipv6",
2626 "IPv6 Neighbor Messages",
2633 rd_in_solicits = rrddim_add(st, "InSolicits", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
2634 rd_out_solicits = rrddim_add(st, "OutSolicits", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
2635 rd_in_advertisements = rrddim_add(st, "InAdvertisements", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
2636 rd_out_advertisements = rrddim_add(st, "OutAdvertisements", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
2640 rrddim_set_by_pointer(st, rd_in_solicits, icmp6stat.icp6s_inhist[ND_NEIGHBOR_SOLICIT]);
2641 rrddim_set_by_pointer(st, rd_out_solicits, icmp6stat.icp6s_outhist[ND_NEIGHBOR_SOLICIT]);
2642 rrddim_set_by_pointer(st, rd_in_advertisements, icmp6stat.icp6s_inhist[ND_NEIGHBOR_ADVERT]);
2643 rrddim_set_by_pointer(st, rd_out_advertisements, icmp6stat.icp6s_outhist[ND_NEIGHBOR_ADVERT]);
2647 // --------------------------------------------------------------------
2649 if (do_icmp6_types == CONFIG_BOOLEAN_YES || (do_icmp6_types == CONFIG_BOOLEAN_AUTO && (
2650 icmp6stat.icp6s_inhist[1] ||
2651 icmp6stat.icp6s_inhist[128] ||
2652 icmp6stat.icp6s_inhist[129] ||
2653 icmp6stat.icp6s_inhist[136] ||
2654 icmp6stat.icp6s_outhist[1] ||
2655 icmp6stat.icp6s_outhist[128] ||
2656 icmp6stat.icp6s_outhist[129] ||
2657 icmp6stat.icp6s_outhist[133] ||
2658 icmp6stat.icp6s_outhist[135] ||
2659 icmp6stat.icp6s_outhist[136]))) {
2660 do_icmp6_types = CONFIG_BOOLEAN_YES;
2662 static RRDSET *st = NULL;
2663 static RRDDIM *rd_in_1 = NULL, *rd_in_128 = NULL, *rd_in_129 = NULL, *rd_in_136 = NULL,
2664 *rd_out_1 = NULL, *rd_out_128 = NULL, *rd_out_129 = NULL, *rd_out_133 = NULL,
2665 *rd_out_135 = NULL, *rd_out_143 = NULL;
2667 if (unlikely(!st)) {
2668 st = rrdset_create_localhost("ipv6",
2680 rd_in_1 = rrddim_add(st, "InType1", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
2681 rd_in_128 = rrddim_add(st, "InType128", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
2682 rd_in_129 = rrddim_add(st, "InType129", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
2683 rd_in_136 = rrddim_add(st, "InType136", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
2684 rd_out_1 = rrddim_add(st, "OutType1", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
2685 rd_out_128 = rrddim_add(st, "OutType128", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
2686 rd_out_129 = rrddim_add(st, "OutType129", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
2687 rd_out_133 = rrddim_add(st, "OutType133", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
2688 rd_out_135 = rrddim_add(st, "OutType135", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
2689 rd_out_143 = rrddim_add(st, "OutType143", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
2693 rrddim_set_by_pointer(st, rd_in_1, icmp6stat.icp6s_inhist[1]);
2694 rrddim_set_by_pointer(st, rd_in_128, icmp6stat.icp6s_inhist[128]);
2695 rrddim_set_by_pointer(st, rd_in_129, icmp6stat.icp6s_inhist[129]);
2696 rrddim_set_by_pointer(st, rd_in_136, icmp6stat.icp6s_inhist[136]);
2697 rrddim_set_by_pointer(st, rd_out_1, icmp6stat.icp6s_outhist[1]);
2698 rrddim_set_by_pointer(st, rd_out_128, icmp6stat.icp6s_outhist[128]);
2699 rrddim_set_by_pointer(st, rd_out_129, icmp6stat.icp6s_outhist[129]);
2700 rrddim_set_by_pointer(st, rd_out_133, icmp6stat.icp6s_outhist[133]);
2701 rrddim_set_by_pointer(st, rd_out_135, icmp6stat.icp6s_outhist[135]);
2702 rrddim_set_by_pointer(st, rd_out_143, icmp6stat.icp6s_outhist[143]);
2707 error("DISABLED: net.inet6.icmp6.stats module");
2714 // --------------------------------------------------------------------------------------------------------------------
2717 int do_getmntinfo(int update_every, usec_t dt) {
2719 #define DELAULT_EXLUDED_PATHS "/proc/*"
2720 // taken from gnulib/mountlist.c and shortened to FreeBSD related fstypes
2721 #define DEFAULT_EXCLUDED_FILESYSTEMS "autofs procfs subfs devfs none"
2722 #define CONFIG_SECTION_GETMNTINFO "plugin:freebsd:getmntinfo"
2724 static int do_space = -1, do_inodes = -1;
2726 if (unlikely(do_space == -1)) {
2727 do_space = config_get_boolean_ondemand(CONFIG_SECTION_GETMNTINFO, "space usage for all disks", CONFIG_BOOLEAN_AUTO);
2728 do_inodes = config_get_boolean_ondemand(CONFIG_SECTION_GETMNTINFO, "inodes usage for all disks", CONFIG_BOOLEAN_AUTO);
2731 if (likely(do_space || do_inodes)) {
2732 struct statfs *mntbuf;
2735 // there is no mount info in sysctl MIBs
2736 if (unlikely(!(mntsize = getmntinfo(&mntbuf, MNT_NOWAIT)))) {
2737 error("FREEBSD: getmntinfo() failed");
2739 error("DISABLED: disk_space.* charts");
2741 error("DISABLED: disk_inodes.* charts");
2742 error("DISABLED: getmntinfo module");
2745 // Data to be stored in DICTIONARY mount_points.
2746 // This DICTIONARY is used to lookup the settings of the mount point on each iteration.
2747 struct mount_point_metadata {
2751 size_t collected; // the number of times this has been collected
2753 // charts and dimensions
2756 RRDDIM *rd_space_used;
2757 RRDDIM *rd_space_avail;
2758 RRDDIM *rd_space_reserved;
2761 RRDDIM *rd_inodes_used;
2762 RRDDIM *rd_inodes_avail;
2764 static DICTIONARY *mount_points = NULL;
2765 static SIMPLE_PATTERN *excluded_mountpoints = NULL;
2766 static SIMPLE_PATTERN *excluded_filesystems = NULL;
2769 if(unlikely(!mount_points)) {
2771 excluded_mountpoints = simple_pattern_create(
2772 config_get(CONFIG_SECTION_GETMNTINFO, "exclude space metrics on paths",
2773 DELAULT_EXLUDED_PATHS),
2774 SIMPLE_PATTERN_EXACT
2777 excluded_filesystems = simple_pattern_create(
2778 config_get(CONFIG_SECTION_GETMNTINFO, "exclude space metrics on filesystems",
2779 DEFAULT_EXCLUDED_FILESYSTEMS),
2780 SIMPLE_PATTERN_EXACT
2783 mount_points = dictionary_create(DICTIONARY_FLAG_SINGLE_THREADED);
2786 for (i = 0; i < mntsize; i++) {
2788 char title[4096 + 1];
2789 int def_space, def_inodes, iter_space, iter_inodes;
2791 struct mount_point_metadata *m = dictionary_get(mount_points, mntbuf[i].f_mntonname);
2793 char var_name[4096 + 1];
2794 snprintfz(var_name, 4096, "%s:%s", CONFIG_SECTION_GETMNTINFO, mntbuf[i].f_mntonname);
2796 def_space = do_space;
2797 def_inodes = do_space;
2799 if(unlikely(simple_pattern_matches(excluded_mountpoints, mntbuf[i].f_mntonname))) {
2800 def_space = CONFIG_BOOLEAN_NO;
2801 def_inodes = CONFIG_BOOLEAN_NO;
2804 if(unlikely(simple_pattern_matches(excluded_filesystems, mntbuf[i].f_fstypename))) {
2805 def_space = CONFIG_BOOLEAN_NO;
2806 def_inodes = CONFIG_BOOLEAN_NO;
2809 iter_space = config_get_boolean_ondemand(var_name, "space usage", def_space);
2810 iter_inodes = config_get_boolean_ondemand(var_name, "inodes usage", def_inodes);
2812 struct mount_point_metadata mp = {
2813 .do_space = iter_space,
2814 .do_inodes = iter_inodes,
2819 .rd_space_avail = NULL,
2820 .rd_space_used = NULL,
2821 .rd_space_reserved = NULL,
2824 .rd_inodes_avail = NULL,
2825 .rd_inodes_used = NULL,
2828 m = dictionary_set(mount_points, mntbuf[i].f_mntonname, &mp, sizeof(struct mount_point_metadata));
2831 if(unlikely(m->do_space == CONFIG_BOOLEAN_NO && m->do_inodes == CONFIG_BOOLEAN_NO))
2834 if(unlikely(mntbuf[i].f_flags & MNT_RDONLY && !m->collected))
2837 // --------------------------------------------------------------------------
2841 if (m->do_space == CONFIG_BOOLEAN_YES || (m->do_space == CONFIG_BOOLEAN_AUTO && (mntbuf[i].f_blocks > 2))) {
2842 if (unlikely(!m->st_space)) {
2843 snprintfz(title, 4096, "Disk Space Usage for %s [%s]",
2844 mntbuf[i].f_mntonname, mntbuf[i].f_mntfromname);
2845 m->st_space = rrdset_create_localhost("disk_space",
2846 mntbuf[i].f_mntonname,
2848 mntbuf[i].f_mntonname,
2857 m->rd_space_avail = rrddim_add(m->st_space, "avail", NULL,
2858 mntbuf[i].f_bsize, GIGA_FACTOR, RRD_ALGORITHM_ABSOLUTE);
2859 m->rd_space_used = rrddim_add(m->st_space, "used", NULL,
2860 mntbuf[i].f_bsize, GIGA_FACTOR, RRD_ALGORITHM_ABSOLUTE);
2861 m->rd_space_reserved = rrddim_add(m->st_space, "reserved_for_root", "reserved for root",
2862 mntbuf[i].f_bsize, GIGA_FACTOR, RRD_ALGORITHM_ABSOLUTE);
2864 rrdset_next(m->st_space);
2866 rrddim_set_by_pointer(m->st_space, m->rd_space_avail, (collected_number) mntbuf[i].f_bavail);
2867 rrddim_set_by_pointer(m->st_space, m->rd_space_used, (collected_number) (mntbuf[i].f_blocks -
2868 mntbuf[i].f_bfree));
2869 rrddim_set_by_pointer(m->st_space, m->rd_space_reserved, (collected_number) (mntbuf[i].f_bfree -
2870 mntbuf[i].f_bavail));
2871 rrdset_done(m->st_space);
2876 // --------------------------------------------------------------------------
2878 if (m->do_inodes == CONFIG_BOOLEAN_YES || (m->do_inodes == CONFIG_BOOLEAN_AUTO && (mntbuf[i].f_files > 1))) {
2879 if (unlikely(!m->st_inodes)) {
2880 snprintfz(title, 4096, "Disk Files (inodes) Usage for %s [%s]",
2881 mntbuf[i].f_mntonname, mntbuf[i].f_mntfromname);
2882 m->st_inodes = rrdset_create_localhost("disk_inodes",
2883 mntbuf[i].f_mntonname,
2885 mntbuf[i].f_mntonname,
2894 m->rd_inodes_avail = rrddim_add(m->st_inodes, "avail", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
2895 m->rd_inodes_used = rrddim_add(m->st_inodes, "used", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
2897 rrdset_next(m->st_inodes);
2899 rrddim_set_by_pointer(m->st_inodes, m->rd_inodes_avail, (collected_number) mntbuf[i].f_ffree);
2900 rrddim_set_by_pointer(m->st_inodes, m->rd_inodes_used, (collected_number) (mntbuf[i].f_files -
2901 mntbuf[i].f_ffree));
2902 rrdset_done(m->st_inodes);
2907 if(likely(rendered))
2912 error("DISABLED: getmntinfo module");
2919 // --------------------------------------------------------------------------------------------------------------------
2922 int do_getifaddrs(int update_every, usec_t dt) {
2924 #define DELAULT_EXLUDED_INTERFACES "lo*"
2925 #define CONFIG_SECTION_GETIFADDRS "plugin:freebsd:getifaddrs"
2927 static int do_bandwidth_ipv4 = -1, do_bandwidth_ipv6 = -1, do_bandwidth = -1, do_packets = -1,
2928 do_errors = -1, do_drops = -1, do_events = -1;
2930 if (unlikely(do_bandwidth_ipv4 == -1)) {
2931 do_bandwidth_ipv4 = config_get_boolean_ondemand(CONFIG_SECTION_GETIFADDRS, "total bandwidth for ipv4 interfaces",
2932 CONFIG_BOOLEAN_AUTO);
2933 do_bandwidth_ipv6 = config_get_boolean_ondemand(CONFIG_SECTION_GETIFADDRS, "total bandwidth for ipv6 interfaces",
2934 CONFIG_BOOLEAN_AUTO);
2935 do_bandwidth = config_get_boolean_ondemand(CONFIG_SECTION_GETIFADDRS, "bandwidth for all interfaces",
2936 CONFIG_BOOLEAN_AUTO);
2937 do_packets = config_get_boolean_ondemand(CONFIG_SECTION_GETIFADDRS, "packets for all interfaces",
2938 CONFIG_BOOLEAN_AUTO);
2939 do_errors = config_get_boolean_ondemand(CONFIG_SECTION_GETIFADDRS, "errors for all interfaces",
2940 CONFIG_BOOLEAN_AUTO);
2941 do_drops = config_get_boolean_ondemand(CONFIG_SECTION_GETIFADDRS, "drops for all interfaces",
2942 CONFIG_BOOLEAN_AUTO);
2943 do_events = config_get_boolean_ondemand(CONFIG_SECTION_GETIFADDRS, "collisions for all interfaces",
2944 CONFIG_BOOLEAN_AUTO);
2947 if (likely(do_bandwidth_ipv4 || do_bandwidth_ipv6 || do_bandwidth || do_packets || do_errors ||
2948 do_drops || do_events)) {
2949 struct ifaddrs *ifap;
2951 if (unlikely(getifaddrs(&ifap))) {
2952 error("FREEBSD: getifaddrs() failed");
2953 do_bandwidth_ipv4 = 0;
2954 error("DISABLED: system.ipv4 chart");
2955 do_bandwidth_ipv6 = 0;
2956 error("DISABLED: system.ipv6 chart");
2958 error("DISABLED: net.* charts");
2960 error("DISABLED: net_packets.* charts");
2962 error("DISABLED: net_errors.* charts");
2964 error("DISABLED: net_drops.* charts");
2966 error("DISABLED: net_events.* charts");
2967 error("DISABLED: getifaddrs module");
2970 #define IFA_DATA(s) (((struct if_data *)ifa->ifa_data)->ifi_ ## s)
2971 struct ifaddrs *ifa;
2977 // --------------------------------------------------------------------
2979 if (likely(do_bandwidth_ipv4)) {
2980 iftot.ift_ibytes = iftot.ift_obytes = 0;
2981 for (ifa = ifap; ifa; ifa = ifa->ifa_next) {
2982 if (ifa->ifa_addr->sa_family != AF_INET)
2984 iftot.ift_ibytes += IFA_DATA(ibytes);
2985 iftot.ift_obytes += IFA_DATA(obytes);
2988 static RRDSET *st = NULL;
2989 static RRDDIM *rd_in = NULL, *rd_out = NULL;
2991 if (unlikely(!st)) {
2992 st = rrdset_create_localhost("system",
3004 rd_in = rrddim_add(st, "InOctets", "received", 8, KILO_FACTOR, RRD_ALGORITHM_INCREMENTAL);
3005 rd_out = rrddim_add(st, "OutOctets", "sent", -8, KILO_FACTOR, RRD_ALGORITHM_INCREMENTAL);
3009 rrddim_set_by_pointer(st, rd_in, iftot.ift_ibytes);
3010 rrddim_set_by_pointer(st, rd_out, iftot.ift_obytes);
3014 // --------------------------------------------------------------------
3016 if (likely(do_bandwidth_ipv6)) {
3017 iftot.ift_ibytes = iftot.ift_obytes = 0;
3018 for (ifa = ifap; ifa; ifa = ifa->ifa_next) {
3019 if (ifa->ifa_addr->sa_family != AF_INET6)
3021 iftot.ift_ibytes += IFA_DATA(ibytes);
3022 iftot.ift_obytes += IFA_DATA(obytes);
3025 static RRDSET *st = NULL;
3026 static RRDDIM *rd_in = NULL, *rd_out = NULL;
3028 if (unlikely(!st)) {
3029 st = rrdset_create_localhost("system",
3041 rd_in = rrddim_add(st, "received", NULL, 8, KILO_FACTOR, RRD_ALGORITHM_INCREMENTAL);
3042 rd_out = rrddim_add(st, "sent", NULL, -8, KILO_FACTOR, RRD_ALGORITHM_INCREMENTAL);
3046 rrddim_set_by_pointer(st, rd_in, iftot.ift_ibytes);
3047 rrddim_set_by_pointer(st, rd_out, iftot.ift_obytes);
3051 // --------------------------------------------------------------------
3053 // Data to be stored in DICTIONARY interfaces.
3054 // This DICTIONARY is used to lookup the settings of the interfaces on each iteration.
3055 struct interfaces_metadata {
3062 // charts and dimensions
3064 RRDSET *st_bandwidth;
3065 RRDDIM *rd_bandwidth_in;
3066 RRDDIM *rd_bandwidth_out;
3069 RRDDIM *rd_packets_in;
3070 RRDDIM *rd_packets_out;
3071 RRDDIM *rd_packets_m_in;
3072 RRDDIM *rd_packets_m_out;
3075 RRDDIM *rd_errors_in;
3076 RRDDIM *rd_errors_out;
3079 RRDDIM *rd_drops_in;
3080 RRDDIM *rd_drops_out;
3083 RRDDIM *rd_events_coll;
3085 static DICTIONARY *interfaces = NULL;
3086 static SIMPLE_PATTERN *excluded_interfaces = NULL;
3088 if(unlikely(!interfaces)) {
3090 excluded_interfaces = simple_pattern_create(
3091 config_get(CONFIG_SECTION_GETIFADDRS, "disable by default interfaces matching",
3092 DELAULT_EXLUDED_INTERFACES)
3093 , SIMPLE_PATTERN_EXACT
3096 interfaces = dictionary_create(DICTIONARY_FLAG_SINGLE_THREADED);
3099 for (ifa = ifap; ifa; ifa = ifa->ifa_next) {
3100 if (ifa->ifa_addr->sa_family != AF_LINK)
3103 int def_bandwidth, def_packets, def_errors, def_drops, def_events,
3104 iter_bandwidth, iter_packets, iter_errors, iter_drops, iter_events;
3106 struct interfaces_metadata *ifm = dictionary_get(interfaces, ifa->ifa_name);
3107 if(unlikely(!ifm)) {
3108 char var_name[4096 + 1];
3109 snprintfz(var_name, 4096, "%s:%s", CONFIG_SECTION_GETIFADDRS, ifa->ifa_name);
3111 def_bandwidth = do_bandwidth;
3112 def_packets = do_packets;
3113 def_errors = do_errors;
3114 def_drops = do_drops;
3115 def_events = do_events;
3117 if(unlikely(simple_pattern_matches(excluded_interfaces, ifa->ifa_name))) {
3118 def_bandwidth = CONFIG_BOOLEAN_NO;
3119 def_packets = CONFIG_BOOLEAN_NO;
3120 def_errors = CONFIG_BOOLEAN_NO;
3121 def_drops = CONFIG_BOOLEAN_NO;
3122 def_events = CONFIG_BOOLEAN_NO;
3125 iter_bandwidth = config_get_boolean_ondemand(var_name, "bandwidth", def_bandwidth);
3126 iter_packets = config_get_boolean_ondemand(var_name, "packets", def_packets);
3127 iter_errors = config_get_boolean_ondemand(var_name, "errors", def_errors);
3128 iter_drops = config_get_boolean_ondemand(var_name, "drops", def_drops);
3129 iter_events = config_get_boolean_ondemand(var_name, "events", def_events);
3131 struct interfaces_metadata ifmp = {
3132 .do_bandwidth = iter_bandwidth,
3133 .do_packets = iter_packets,
3134 .do_errors = iter_errors,
3135 .do_drops = iter_drops,
3136 .do_events = iter_events,
3138 .st_bandwidth = NULL,
3139 .rd_bandwidth_in = NULL,
3140 .rd_bandwidth_out = NULL,
3143 .rd_packets_in = NULL,
3144 .rd_packets_out = NULL,
3145 .rd_packets_m_in = NULL,
3146 .rd_packets_m_out = NULL,
3149 .rd_errors_in = NULL,
3150 .rd_errors_out = NULL,
3153 .rd_drops_in = NULL,
3154 .rd_drops_out = NULL,
3157 .rd_events_coll = NULL,
3160 ifm = dictionary_set(interfaces, ifa->ifa_name, &ifmp, sizeof(struct interfaces_metadata));
3163 // --------------------------------------------------------------------
3165 if (ifm->do_bandwidth == CONFIG_BOOLEAN_YES || (ifm->do_bandwidth == CONFIG_BOOLEAN_AUTO &&
3166 (IFA_DATA(ibytes) || IFA_DATA(obytes)))) {
3167 if (unlikely(!ifm->st_bandwidth)) {
3168 ifm->st_bandwidth = rrdset_create_localhost("net",
3180 ifm->rd_bandwidth_in = rrddim_add(ifm->st_bandwidth, "received", NULL, 8, KILO_FACTOR,
3181 RRD_ALGORITHM_INCREMENTAL);
3182 ifm->rd_bandwidth_out = rrddim_add(ifm->st_bandwidth, "sent", NULL, -8, KILO_FACTOR,
3183 RRD_ALGORITHM_INCREMENTAL);
3185 rrdset_next(ifm->st_bandwidth);
3187 rrddim_set_by_pointer(ifm->st_bandwidth, ifm->rd_bandwidth_in, IFA_DATA(ibytes));
3188 rrddim_set_by_pointer(ifm->st_bandwidth, ifm->rd_bandwidth_out, IFA_DATA(obytes));
3189 rrdset_done(ifm->st_bandwidth);
3192 // --------------------------------------------------------------------
3194 if (ifm->do_packets == CONFIG_BOOLEAN_YES || (ifm->do_packets == CONFIG_BOOLEAN_AUTO &&
3195 (IFA_DATA(ipackets) || IFA_DATA(opackets) || IFA_DATA(imcasts) || IFA_DATA(omcasts)))) {
3196 if (unlikely(!ifm->st_packets)) {
3197 ifm->st_packets = rrdset_create_localhost("net_packets",
3209 rrdset_flag_set(ifm->st_packets, RRDSET_FLAG_DETAIL);
3211 ifm->rd_packets_in = rrddim_add(ifm->st_packets, "received", NULL, 1, 1,
3212 RRD_ALGORITHM_INCREMENTAL);
3213 ifm->rd_packets_out = rrddim_add(ifm->st_packets, "sent", NULL, -1, 1,
3214 RRD_ALGORITHM_INCREMENTAL);
3215 ifm->rd_packets_m_in = rrddim_add(ifm->st_packets, "multicast_received", NULL, 1, 1,
3216 RRD_ALGORITHM_INCREMENTAL);
3217 ifm->rd_packets_m_out = rrddim_add(ifm->st_packets, "multicast_sent", NULL, -1, 1,
3218 RRD_ALGORITHM_INCREMENTAL);
3220 rrdset_next(ifm->st_packets);
3222 rrddim_set_by_pointer(ifm->st_packets, ifm->rd_packets_in, IFA_DATA(ipackets));
3223 rrddim_set_by_pointer(ifm->st_packets, ifm->rd_packets_out, IFA_DATA(opackets));
3224 rrddim_set_by_pointer(ifm->st_packets, ifm->rd_packets_m_in, IFA_DATA(imcasts));
3225 rrddim_set_by_pointer(ifm->st_packets, ifm->rd_packets_m_out, IFA_DATA(omcasts));
3226 rrdset_done(ifm->st_packets);
3229 // --------------------------------------------------------------------
3231 if (ifm->do_errors == CONFIG_BOOLEAN_YES || (ifm->do_errors == CONFIG_BOOLEAN_AUTO &&
3232 (IFA_DATA(ierrors) || IFA_DATA(oerrors)))) {
3233 if (unlikely(!ifm->st_errors)) {
3234 ifm->st_errors = rrdset_create_localhost("net_errors",
3246 rrdset_flag_set(ifm->st_errors, RRDSET_FLAG_DETAIL);
3248 ifm->rd_errors_in = rrddim_add(ifm->st_errors, "inbound", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
3249 ifm->rd_errors_out = rrddim_add(ifm->st_errors, "outbound", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
3251 rrdset_next(ifm->st_errors);
3253 rrddim_set_by_pointer(ifm->st_errors, ifm->rd_errors_in, IFA_DATA(ierrors));
3254 rrddim_set_by_pointer(ifm->st_errors, ifm->rd_errors_out, IFA_DATA(oerrors));
3255 rrdset_done(ifm->st_errors);
3257 // --------------------------------------------------------------------
3259 if (ifm->do_drops == CONFIG_BOOLEAN_YES || (ifm->do_drops == CONFIG_BOOLEAN_AUTO &&
3260 (IFA_DATA(iqdrops) || IFA_DATA(oqdrops)))) {
3261 if (unlikely(!ifm->st_drops)) {
3262 ifm->st_drops = rrdset_create_localhost("net_drops",
3274 rrdset_flag_set(ifm->st_drops, RRDSET_FLAG_DETAIL);
3276 ifm->rd_drops_in = rrddim_add(ifm->st_drops, "inbound", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
3277 #if __FreeBSD__ >= 11
3278 ifm->rd_drops_out = rrddim_add(ifm->st_drops, "outbound", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
3281 rrdset_next(ifm->st_drops);
3283 rrddim_set_by_pointer(ifm->st_drops, ifm->rd_drops_in, IFA_DATA(iqdrops));
3284 #if __FreeBSD__ >= 11
3285 rrddim_set_by_pointer(ifm->st_drops, ifm->rd_drops_out, IFA_DATA(oqdrops));
3287 rrdset_done(ifm->st_drops);
3290 // --------------------------------------------------------------------
3292 if (ifm->do_events == CONFIG_BOOLEAN_YES || (ifm->do_events == CONFIG_BOOLEAN_AUTO &&
3293 IFA_DATA(collisions))) {
3294 if (unlikely(!ifm->st_events)) {
3295 ifm->st_events = rrdset_create_localhost("net_events",
3300 "Network Interface Events",
3307 rrdset_flag_set(ifm->st_events, RRDSET_FLAG_DETAIL);
3309 ifm->rd_events_coll = rrddim_add(ifm->st_events, "collisions", NULL, -1, 1,
3310 RRD_ALGORITHM_INCREMENTAL);
3312 rrdset_next(ifm->st_events);
3314 rrddim_set_by_pointer(ifm->st_events, ifm->rd_events_coll, IFA_DATA(collisions));
3315 rrdset_done(ifm->st_events);
3322 error("DISABLED: getifaddrs module");
3329 // --------------------------------------------------------------------------------------------------------------------
3332 int do_kern_devstat(int update_every, usec_t dt) {
3334 #define DELAULT_EXLUDED_DISKS ""
3335 #define CONFIG_SECTION_KERN_DEVSTAT "plugin:freebsd:kern.devstat"
3336 #define BINTIME_SCALE 5.42101086242752217003726400434970855712890625e-17 // this is 1000/2^64
3338 static int enable_pass_devices = -1, do_system_io = -1, do_io = -1, do_ops = -1, do_qops = -1, do_util = -1,
3339 do_iotime = -1, do_await = -1, do_avagsz = -1, do_svctm = -1;
3341 if (unlikely(enable_pass_devices == -1)) {
3342 enable_pass_devices = config_get_boolean_ondemand(CONFIG_SECTION_KERN_DEVSTAT,
3343 "performance metrics for pass devices", CONFIG_BOOLEAN_AUTO);
3345 do_system_io = config_get_boolean_ondemand(CONFIG_SECTION_KERN_DEVSTAT, "total bandwidth for all disks",
3346 CONFIG_BOOLEAN_YES);
3348 do_io = config_get_boolean_ondemand(CONFIG_SECTION_KERN_DEVSTAT, "bandwidth for all disks",
3349 CONFIG_BOOLEAN_AUTO);
3350 do_ops = config_get_boolean_ondemand(CONFIG_SECTION_KERN_DEVSTAT, "operations for all disks",
3351 CONFIG_BOOLEAN_AUTO);
3352 do_qops = config_get_boolean_ondemand(CONFIG_SECTION_KERN_DEVSTAT, "queued operations for all disks",
3353 CONFIG_BOOLEAN_AUTO);
3354 do_util = config_get_boolean_ondemand(CONFIG_SECTION_KERN_DEVSTAT, "utilization percentage for all disks",
3355 CONFIG_BOOLEAN_AUTO);
3356 do_iotime = config_get_boolean_ondemand(CONFIG_SECTION_KERN_DEVSTAT, "i/o time for all disks",
3357 CONFIG_BOOLEAN_AUTO);
3358 do_await = config_get_boolean_ondemand(CONFIG_SECTION_KERN_DEVSTAT, "average completed i/o time for all disks",
3359 CONFIG_BOOLEAN_AUTO);
3360 do_avagsz = config_get_boolean_ondemand(CONFIG_SECTION_KERN_DEVSTAT, "average completed i/o bandwidth for all disks",
3361 CONFIG_BOOLEAN_AUTO);
3362 do_svctm = config_get_boolean_ondemand(CONFIG_SECTION_KERN_DEVSTAT, "average service time for all disks",
3363 CONFIG_BOOLEAN_AUTO);
3366 if (likely(do_system_io || do_io || do_ops || do_qops || do_util || do_iotime || do_await || do_avagsz || do_svctm)) {
3367 static int mib_numdevs[3] = {0, 0, 0};
3369 int common_error = 0;
3371 if (unlikely(GETSYSCTL_SIMPLE("kern.devstat.numdevs", mib_numdevs, numdevs))) {
3374 static int mib_devstat[3] = {0, 0, 0};
3375 static void *devstat_data = NULL;
3377 devstat_data = reallocz(devstat_data, sizeof(long) + sizeof(struct devstat) * numdevs); // there is generation number before devstat structures
3378 if (unlikely(GETSYSCTL_WSIZE("kern.devstat.all", mib_devstat, devstat_data,
3379 sizeof(long) + sizeof(struct devstat) * numdevs))) {
3382 struct devstat *dstat;
3384 collected_number total_disk_kbytes_read = 0;
3385 collected_number total_disk_kbytes_write = 0;
3387 // Data to be stored in DICTIONARY disks.
3388 // This DICTIONARY is used to lookup the settings of the disks on each iteration.
3389 struct disks_metadata {
3400 // data for differential charts
3403 collected_number bytes_read;
3404 collected_number bytes_write;
3405 collected_number operations_read;
3406 collected_number operations_write;
3407 collected_number duration_read_ms;
3408 collected_number duration_write_ms;
3409 collected_number busy_time_ms;
3412 // charts and dimensions
3429 RRDDIM *rd_iotime_in;
3430 RRDDIM *rd_iotime_out;
3433 RRDDIM *rd_await_in;
3434 RRDDIM *rd_await_out;
3437 RRDDIM *rd_avagsz_in;
3438 RRDDIM *rd_avagsz_out;
3444 static DICTIONARY *disks = NULL;
3445 static SIMPLE_PATTERN *excluded_disks = NULL;
3447 if(unlikely(!disks)) {
3449 excluded_disks = simple_pattern_create(
3450 config_get(CONFIG_SECTION_KERN_DEVSTAT, "disable by default disks matching",
3451 DELAULT_EXLUDED_DISKS)
3452 , SIMPLE_PATTERN_EXACT
3455 disks = dictionary_create(DICTIONARY_FLAG_SINGLE_THREADED);
3458 dstat = devstat_data + sizeof(long); // skip generation number
3460 for (i = 0; i < numdevs; i++) {
3461 if (unlikely(!do_system_io)) {
3462 if (((dstat[i].device_type & DEVSTAT_TYPE_MASK) == DEVSTAT_TYPE_DIRECT) || ((dstat[i].device_type & DEVSTAT_TYPE_MASK) == DEVSTAT_TYPE_STORARRAY)) {
3463 total_disk_kbytes_read += dstat[i].bytes[DEVSTAT_READ] / KILO_FACTOR;
3464 total_disk_kbytes_write += dstat[i].bytes[DEVSTAT_WRITE] / KILO_FACTOR;
3468 if (unlikely(!enable_pass_devices))
3469 if (dstat[i].device_type & DEVSTAT_TYPE_PASS == DEVSTAT_TYPE_PASS)
3472 if (((dstat[i].device_type & DEVSTAT_TYPE_MASK) == DEVSTAT_TYPE_DIRECT) || ((dstat[i].device_type & DEVSTAT_TYPE_MASK) == DEVSTAT_TYPE_STORARRAY)) {
3473 char disk[DEVSTAT_NAME_LEN + MAX_INT_DIGITS + 1];
3474 int def_io, def_ops, def_qops, def_util, def_iotime, def_await, def_avagsz, def_svctm,
3475 iter_io, iter_ops, iter_qops, iter_util, iter_iotime, iter_await, iter_avagsz, iter_svctm;
3477 collected_number duration_read_ms;
3478 collected_number duration_write_ms;
3479 collected_number busy_time_ms;
3482 sprintf(disk, "%s%d", dstat[i].device_name, dstat[i].unit_number);
3484 struct disks_metadata *dm = dictionary_get(disks, disk);
3486 char var_name[4096 + 1];
3487 snprintfz(var_name, 4096, "%s:%s", CONFIG_SECTION_KERN_DEVSTAT, disk);
3493 def_iotime = do_iotime;
3494 def_await = do_await;
3495 def_avagsz = do_avagsz;
3496 def_svctm = do_svctm;
3498 if(unlikely(simple_pattern_matches(excluded_disks, disk))) {
3499 def_io = CONFIG_BOOLEAN_NO;
3500 def_ops = CONFIG_BOOLEAN_NO;
3501 def_qops = CONFIG_BOOLEAN_NO;
3502 def_util = CONFIG_BOOLEAN_NO;
3503 def_iotime = CONFIG_BOOLEAN_NO;
3504 def_await = CONFIG_BOOLEAN_NO;
3505 def_avagsz = CONFIG_BOOLEAN_NO;
3506 def_svctm = CONFIG_BOOLEAN_NO;
3509 iter_io = config_get_boolean_ondemand(var_name, "bandwidth", def_io);
3510 iter_ops = config_get_boolean_ondemand(var_name, "operations", def_ops);
3511 iter_qops = config_get_boolean_ondemand(var_name, "queued operations", def_qops);
3512 iter_util = config_get_boolean_ondemand(var_name, "utilization percentage", def_util);
3513 iter_iotime = config_get_boolean_ondemand(var_name, "i/o time", def_iotime);
3514 iter_await = config_get_boolean_ondemand(var_name, "average completed i/o time", def_await);
3515 iter_avagsz = config_get_boolean_ondemand(var_name, "average completed i/o bandwidth",
3517 iter_svctm = config_get_boolean_ondemand(var_name, "average service time", def_svctm);
3519 struct disks_metadata dmp = {
3522 .do_qops = iter_qops,
3523 .do_util = iter_util,
3524 .do_iotime = iter_iotime,
3525 .do_await = iter_await,
3526 .do_avagsz = iter_avagsz,
3527 .do_svctm = iter_svctm,
3529 // initialise data for differential charts
3531 .prev_dstat.bytes_read = dstat[i].bytes[DEVSTAT_READ],
3532 .prev_dstat.bytes_write = dstat[i].bytes[DEVSTAT_WRITE],
3533 .prev_dstat.operations_read = dstat[i].operations[DEVSTAT_READ],
3534 .prev_dstat.operations_write = dstat[i].operations[DEVSTAT_WRITE],
3535 .prev_dstat.duration_read_ms = dstat[i].duration[DEVSTAT_READ].sec * 1000
3536 + dstat[i].duration[DEVSTAT_READ].frac * BINTIME_SCALE,
3537 .prev_dstat.duration_write_ms = dstat[i].duration[DEVSTAT_WRITE].sec * 1000
3538 + dstat[i].duration[DEVSTAT_READ].frac * BINTIME_SCALE,
3539 .prev_dstat.busy_time_ms = dstat[i].busy_time.sec * 1000
3540 + dstat[i].busy_time.frac * BINTIME_SCALE,
3557 .rd_iotime_in = NULL,
3558 .rd_iotime_out = NULL,
3561 .rd_await_in = NULL,
3562 .rd_await_out = NULL,
3565 .rd_avagsz_in = NULL,
3566 .rd_avagsz_out = NULL,
3572 dm = dictionary_set(disks, disk, &dmp, sizeof(struct disks_metadata));
3575 cur_dstat.duration_read_ms = dstat[i].duration[DEVSTAT_READ].sec * 1000
3576 + dstat[i].duration[DEVSTAT_READ].frac * BINTIME_SCALE;
3577 cur_dstat.duration_write_ms = dstat[i].duration[DEVSTAT_WRITE].sec * 1000
3578 + dstat[i].duration[DEVSTAT_READ].frac * BINTIME_SCALE;
3579 cur_dstat.busy_time_ms = dstat[i].busy_time.sec * 1000 + dstat[i].busy_time.frac * BINTIME_SCALE;
3581 // --------------------------------------------------------------------
3583 if(dm->do_io == CONFIG_BOOLEAN_YES || (dm->do_io == CONFIG_BOOLEAN_AUTO &&
3584 (dstat[i].bytes[DEVSTAT_READ] || dstat[i].bytes[DEVSTAT_WRITE]))) {
3585 if (unlikely(!dm->st_io)) {
3586 dm->st_io = rrdset_create_localhost("disk",
3591 "Disk I/O Bandwidth",
3598 dm->rd_io_in = rrddim_add(dm->st_io, "reads", NULL, 1, KILO_FACTOR,
3599 RRD_ALGORITHM_INCREMENTAL);
3600 dm->rd_io_out = rrddim_add(dm->st_io, "writes", NULL, -1, KILO_FACTOR,
3601 RRD_ALGORITHM_INCREMENTAL);
3603 rrdset_next(dm->st_io);
3605 rrddim_set_by_pointer(dm->st_io, dm->rd_io_in, dstat[i].bytes[DEVSTAT_READ]);
3606 rrddim_set_by_pointer(dm->st_io, dm->rd_io_out, dstat[i].bytes[DEVSTAT_WRITE]);
3607 rrdset_done(dm->st_io);
3610 // --------------------------------------------------------------------
3612 if(dm->do_ops == CONFIG_BOOLEAN_YES || (dm->do_ops == CONFIG_BOOLEAN_AUTO &&
3613 (dstat[i].operations[DEVSTAT_READ] || dstat[i].operations[DEVSTAT_WRITE]))) {
3614 if (unlikely(!dm->st_ops)) {
3615 dm->st_ops = rrdset_create_localhost("disk_ops",
3620 "Disk Completed I/O Operations",
3627 rrdset_flag_set(dm->st_ops, RRDSET_FLAG_DETAIL);
3629 dm->rd_ops_in = rrddim_add(dm->st_ops, "reads", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
3630 dm->rd_ops_out = rrddim_add(dm->st_ops, "writes", NULL, -1, 1,
3631 RRD_ALGORITHM_INCREMENTAL);
3633 rrdset_next(dm->st_ops);
3635 rrddim_set_by_pointer(dm->st_ops, dm->rd_ops_in, dstat[i].operations[DEVSTAT_READ]);
3636 rrddim_set_by_pointer(dm->st_ops, dm->rd_ops_out, dstat[i].operations[DEVSTAT_WRITE]);
3637 rrdset_done(dm->st_ops);
3640 // --------------------------------------------------------------------
3642 if(dm->do_qops == CONFIG_BOOLEAN_YES || (dm->do_qops == CONFIG_BOOLEAN_AUTO &&
3643 (dstat[i].start_count || dstat[i].end_count))) {
3644 if (unlikely(!dm->st_qops)) {
3645 dm->st_qops = rrdset_create_localhost("disk_qops",
3650 "Disk Current I/O Operations",
3657 rrdset_flag_set(dm->st_qops, RRDSET_FLAG_DETAIL);
3659 dm->rd_qops = rrddim_add(dm->st_qops, "operations", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
3661 rrdset_next(dm->st_qops);
3663 rrddim_set_by_pointer(dm->st_qops, dm->rd_qops, dstat[i].start_count - dstat[i].end_count);
3664 rrdset_done(dm->st_qops);
3667 // --------------------------------------------------------------------
3669 if(dm->do_util == CONFIG_BOOLEAN_YES || (dm->do_util == CONFIG_BOOLEAN_AUTO &&
3670 cur_dstat.busy_time_ms)) {
3671 if (unlikely(!dm->st_util)) {
3672 dm->st_util = rrdset_create_localhost("disk_util",
3677 "Disk Utilization Time",
3678 "% of time working",
3684 rrdset_flag_set(dm->st_util, RRDSET_FLAG_DETAIL);
3686 dm->rd_util = rrddim_add(dm->st_util, "utilization", NULL, 1, 10,
3687 RRD_ALGORITHM_INCREMENTAL);
3689 rrdset_next(dm->st_util);
3691 rrddim_set_by_pointer(dm->st_util, dm->rd_util, cur_dstat.busy_time_ms);
3692 rrdset_done(dm->st_util);
3695 // --------------------------------------------------------------------
3697 if(dm->do_iotime == CONFIG_BOOLEAN_YES || (dm->do_iotime == CONFIG_BOOLEAN_AUTO &&
3698 (cur_dstat.duration_read_ms || cur_dstat.duration_write_ms))) {
3699 if (unlikely(!dm->st_iotime)) {
3700 dm->st_iotime = rrdset_create_localhost("disk_iotime",
3705 "Disk Total I/O Time",
3712 rrdset_flag_set(dm->st_iotime, RRDSET_FLAG_DETAIL);
3714 dm->rd_iotime_in = rrddim_add(dm->st_iotime, "reads", NULL, 1, 1,
3715 RRD_ALGORITHM_INCREMENTAL);
3716 dm->rd_iotime_out = rrddim_add(dm->st_iotime, "writes", NULL, -1, 1,
3717 RRD_ALGORITHM_INCREMENTAL);
3719 rrdset_next(dm->st_iotime);
3721 rrddim_set_by_pointer(dm->st_iotime, dm->rd_iotime_in, cur_dstat.duration_read_ms);
3722 rrddim_set_by_pointer(dm->st_iotime, dm->rd_iotime_out, cur_dstat.duration_write_ms);
3723 rrdset_done(dm->st_iotime);
3726 // --------------------------------------------------------------------
3727 // calculate differential charts
3728 // only if this is not the first time we run
3732 // --------------------------------------------------------------------
3734 if(dm->do_await == CONFIG_BOOLEAN_YES || (dm->do_await == CONFIG_BOOLEAN_AUTO &&
3735 (dstat[i].operations[DEVSTAT_READ] || dstat[i].operations[DEVSTAT_WRITE]))) {
3736 if (unlikely(!dm->st_await)) {
3737 dm->st_await = rrdset_create_localhost("disk_await",
3742 "Average Completed I/O Operation Time",
3749 rrdset_flag_set(dm->st_await, RRDSET_FLAG_DETAIL);
3751 dm->rd_await_in = rrddim_add(dm->st_await, "reads", NULL, 1, 1,
3752 RRD_ALGORITHM_ABSOLUTE);
3753 dm->rd_await_out = rrddim_add(dm->st_await, "writes", NULL, -1, 1,
3754 RRD_ALGORITHM_ABSOLUTE);
3756 rrdset_next(dm->st_await);
3758 rrddim_set_by_pointer(dm->st_await, dm->rd_await_in,
3759 (dstat[i].operations[DEVSTAT_READ] -
3760 dm->prev_dstat.operations_read) ?
3761 (cur_dstat.duration_read_ms - dm->prev_dstat.duration_read_ms) /
3762 (dstat[i].operations[DEVSTAT_READ] -
3763 dm->prev_dstat.operations_read) :
3765 rrddim_set_by_pointer(dm->st_await, dm->rd_await_out,
3766 (dstat[i].operations[DEVSTAT_WRITE] -
3767 dm->prev_dstat.operations_write) ?
3768 (cur_dstat.duration_write_ms - dm->prev_dstat.duration_write_ms) /
3769 (dstat[i].operations[DEVSTAT_WRITE] -
3770 dm->prev_dstat.operations_write) :
3772 rrdset_done(dm->st_await);
3775 // --------------------------------------------------------------------
3777 if(dm->do_avagsz == CONFIG_BOOLEAN_YES || (dm->do_avagsz == CONFIG_BOOLEAN_AUTO &&
3778 (dstat[i].operations[DEVSTAT_READ] || dstat[i].operations[DEVSTAT_WRITE]))) {
3779 if (unlikely(!dm->st_avagsz)) {
3780 dm->st_avagsz = rrdset_create_localhost("disk_avgsz",
3785 "Average Completed I/O Operation Bandwidth",
3786 "kilobytes per operation",
3792 rrdset_flag_set(dm->st_avagsz, RRDSET_FLAG_DETAIL);
3794 dm->rd_avagsz_in = rrddim_add(dm->st_avagsz, "reads", NULL, 1, KILO_FACTOR,
3795 RRD_ALGORITHM_ABSOLUTE);
3796 dm->rd_avagsz_out = rrddim_add(dm->st_avagsz, "writes", NULL, -1, KILO_FACTOR,
3797 RRD_ALGORITHM_ABSOLUTE);
3799 rrdset_next(dm->st_avagsz);
3801 rrddim_set_by_pointer(dm->st_avagsz, dm->rd_avagsz_in,
3802 (dstat[i].operations[DEVSTAT_READ] -
3803 dm->prev_dstat.operations_read) ?
3804 (dstat[i].bytes[DEVSTAT_READ] - dm->prev_dstat.bytes_read) /
3805 (dstat[i].operations[DEVSTAT_READ] -
3806 dm->prev_dstat.operations_read) :
3808 rrddim_set_by_pointer(dm->st_avagsz, dm->rd_avagsz_out,
3809 (dstat[i].operations[DEVSTAT_WRITE] -
3810 dm->prev_dstat.operations_write) ?
3811 (dstat[i].bytes[DEVSTAT_WRITE] - dm->prev_dstat.bytes_write) /
3812 (dstat[i].operations[DEVSTAT_WRITE] -
3813 dm->prev_dstat.operations_write) :
3815 rrdset_done(dm->st_avagsz);
3818 // --------------------------------------------------------------------
3820 if(dm->do_svctm == CONFIG_BOOLEAN_YES || (dm->do_svctm == CONFIG_BOOLEAN_AUTO &&
3821 (dstat[i].operations[DEVSTAT_READ] || dstat[i].operations[DEVSTAT_WRITE]))) {
3822 if (unlikely(!dm->st_svctm)) {
3823 dm->st_svctm = rrdset_create_localhost("disk_svctm",
3828 "Average Service Time",
3835 rrdset_flag_set(dm->st_svctm, RRDSET_FLAG_DETAIL);
3837 dm->rd_svctm = rrddim_add(dm->st_svctm, "svctm", NULL, 1, 1,
3838 RRD_ALGORITHM_ABSOLUTE);
3840 rrdset_next(dm->st_svctm);
3842 rrddim_set_by_pointer(dm->st_svctm, dm->rd_svctm,
3843 ((dstat[i].operations[DEVSTAT_READ] - dm->prev_dstat.operations_read) +
3844 (dstat[i].operations[DEVSTAT_WRITE] - dm->prev_dstat.operations_write)) ?
3845 (cur_dstat.busy_time_ms - dm->prev_dstat.busy_time_ms) /
3846 ((dstat[i].operations[DEVSTAT_READ] - dm->prev_dstat.operations_read) +
3847 (dstat[i].operations[DEVSTAT_WRITE] - dm->prev_dstat.operations_write)) :
3849 rrdset_done(dm->st_svctm);
3852 // --------------------------------------------------------------------
3854 dm->prev_dstat.bytes_read = dstat[i].bytes[DEVSTAT_READ];
3855 dm->prev_dstat.bytes_write = dstat[i].bytes[DEVSTAT_WRITE];
3856 dm->prev_dstat.operations_read = dstat[i].operations[DEVSTAT_READ];
3857 dm->prev_dstat.operations_write = dstat[i].operations[DEVSTAT_WRITE];
3858 dm->prev_dstat.duration_read_ms = cur_dstat.duration_read_ms;
3859 dm->prev_dstat.duration_write_ms = cur_dstat.duration_write_ms;
3860 dm->prev_dstat.busy_time_ms = cur_dstat.busy_time_ms;
3865 // --------------------------------------------------------------------
3867 if (unlikely(!do_system_io)) {
3868 static RRDSET *st = NULL;
3869 static RRDDIM *rd_in = NULL, *rd_out = NULL;
3871 st = rrdset_find_bytype_localhost("system", "io");
3872 if (unlikely(!st)) {
3873 st = rrdset_create_localhost("system",
3885 rd_in = rrddim_add(st, "in", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
3886 rd_out = rrddim_add(st, "out", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
3890 rrddim_set_by_pointer(st, rd_in, total_disk_kbytes_read);
3891 rrddim_set_by_pointer(st, rd_out, total_disk_kbytes_write);
3896 if (unlikely(common_error)) {
3898 error("DISABLED: system.io chart");
3900 error("DISABLED: disk.* charts");
3902 error("DISABLED: disk_ops.* charts");
3904 error("DISABLED: disk_qops.* charts");
3906 error("DISABLED: disk_util.* charts");
3908 error("DISABLED: disk_iotime.* charts");
3910 error("DISABLED: disk_await.* charts");
3912 error("DISABLED: disk_avgsz.* charts");
3914 error("DISABLED: disk_svctm.* charts");
3915 error("DISABLED: kern.devstat module");
3919 error("DISABLED: kern.devstat module");