summaryrefslogtreecommitdiffstats
path: root/collectors/freebsd.plugin
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2021-05-19 12:33:27 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2021-05-19 12:33:27 +0000
commit841395dd16f470e3c051a0a4fff5b91efc983c30 (patch)
tree4115f6eedcddda75067130b80acaff9e51612f49 /collectors/freebsd.plugin
parentAdding upstream version 1.30.1. (diff)
downloadnetdata-841395dd16f470e3c051a0a4fff5b91efc983c30.tar.xz
netdata-841395dd16f470e3c051a0a4fff5b91efc983c30.zip
Adding upstream version 1.31.0.upstream/1.31.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'collectors/freebsd.plugin')
-rw-r--r--collectors/freebsd.plugin/freebsd_devstat.c4
-rw-r--r--collectors/freebsd.plugin/freebsd_getifaddrs.c4
-rw-r--r--collectors/freebsd.plugin/freebsd_getmntinfo.c4
-rw-r--r--collectors/freebsd.plugin/freebsd_sysctl.c4
-rw-r--r--collectors/freebsd.plugin/plugin_freebsd.c226
5 files changed, 139 insertions, 103 deletions
diff --git a/collectors/freebsd.plugin/freebsd_devstat.c b/collectors/freebsd.plugin/freebsd_devstat.c
index 910def59..66a1e61d 100644
--- a/collectors/freebsd.plugin/freebsd_devstat.c
+++ b/collectors/freebsd.plugin/freebsd_devstat.c
@@ -185,7 +185,7 @@ static struct disk *get_disk(const char *name) {
int do_kern_devstat(int update_every, usec_t dt) {
-#define DELAULT_EXLUDED_DISKS ""
+#define DEFAULT_EXCLUDED_DISKS ""
#define CONFIG_SECTION_KERN_DEVSTAT "plugin:freebsd:kern.devstat"
#define BINTIME_SCALE 5.42101086242752217003726400434970855712890625e-17 // this is 1000/2^64
@@ -222,7 +222,7 @@ int do_kern_devstat(int update_every, usec_t dt) {
CONFIG_BOOLEAN_AUTO);
excluded_disks = simple_pattern_create(
- config_get(CONFIG_SECTION_KERN_DEVSTAT, "disable by default disks matching", DELAULT_EXLUDED_DISKS)
+ config_get(CONFIG_SECTION_KERN_DEVSTAT, "disable by default disks matching", DEFAULT_EXCLUDED_DISKS)
, NULL
, SIMPLE_PATTERN_EXACT
);
diff --git a/collectors/freebsd.plugin/freebsd_getifaddrs.c b/collectors/freebsd.plugin/freebsd_getifaddrs.c
index 1437d08f..1a84902d 100644
--- a/collectors/freebsd.plugin/freebsd_getifaddrs.c
+++ b/collectors/freebsd.plugin/freebsd_getifaddrs.c
@@ -143,7 +143,7 @@ static struct cgroup_network_interface *get_network_interface(const char *name)
int do_getifaddrs(int update_every, usec_t dt) {
(void)dt;
-#define DEFAULT_EXLUDED_INTERFACES "lo*"
+#define DEFAULT_EXCLUDED_INTERFACES "lo*"
#define DEFAULT_PHYSICAL_INTERFACES "igb* ix* cxl* em* ixl* ixlv* bge* ixgbe* vtnet* vmx* re*"
#define CONFIG_SECTION_GETIFADDRS "plugin:freebsd:getifaddrs"
@@ -177,7 +177,7 @@ int do_getifaddrs(int update_every, usec_t dt) {
CONFIG_BOOLEAN_AUTO);
excluded_interfaces = simple_pattern_create(
- config_get(CONFIG_SECTION_GETIFADDRS, "disable by default interfaces matching", DEFAULT_EXLUDED_INTERFACES)
+ config_get(CONFIG_SECTION_GETIFADDRS, "disable by default interfaces matching", DEFAULT_EXCLUDED_INTERFACES)
, NULL
, SIMPLE_PATTERN_EXACT
);
diff --git a/collectors/freebsd.plugin/freebsd_getmntinfo.c b/collectors/freebsd.plugin/freebsd_getmntinfo.c
index 58b67a3c..f83a4a0d 100644
--- a/collectors/freebsd.plugin/freebsd_getmntinfo.c
+++ b/collectors/freebsd.plugin/freebsd_getmntinfo.c
@@ -124,7 +124,7 @@ static struct mount_point *get_mount_point(const char *name) {
int do_getmntinfo(int update_every, usec_t dt) {
(void)dt;
-#define DELAULT_EXCLUDED_PATHS "/proc/*"
+#define DEFAULT_EXCLUDED_PATHS "/proc/*"
// taken from gnulib/mountlist.c and shortened to FreeBSD related fstypes
#define DEFAULT_EXCLUDED_FILESYSTEMS "autofs procfs subfs devfs none"
#define CONFIG_SECTION_GETMNTINFO "plugin:freebsd:getmntinfo"
@@ -144,7 +144,7 @@ int do_getmntinfo(int update_every, usec_t dt) {
excluded_mountpoints = simple_pattern_create(
config_get(CONFIG_SECTION_GETMNTINFO, "exclude space metrics on paths",
- DELAULT_EXCLUDED_PATHS)
+ DEFAULT_EXCLUDED_PATHS)
, NULL
, SIMPLE_PATTERN_EXACT
);
diff --git a/collectors/freebsd.plugin/freebsd_sysctl.c b/collectors/freebsd.plugin/freebsd_sysctl.c
index a71ec560..7d48e76d 100644
--- a/collectors/freebsd.plugin/freebsd_sysctl.c
+++ b/collectors/freebsd.plugin/freebsd_sysctl.c
@@ -499,7 +499,7 @@ int do_dev_cpu_temperature(int update_every, usec_t dt) {
"temperature",
NULL,
"temperature",
- "cpu.temperatute",
+ "cpu.temperature",
"Core temperature",
"Celsius",
"freebsd.plugin",
@@ -969,7 +969,7 @@ int do_system_ram(int update_every, usec_t dt) {
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},
mib_cache_count[4] = {0, 0, 0, 0}, mib_vfs_bufspace[2] = {0, 0}, mib_free_count[4] = {0, 0, 0, 0};
vmmeter_t vmmeter_data;
- int vfs_bufspace_count;
+ size_t vfs_bufspace_count;
#if defined(NETDATA_COLLECT_LAUNDRY)
static int mib_laundry_count[4] = {0, 0, 0, 0};
diff --git a/collectors/freebsd.plugin/plugin_freebsd.c b/collectors/freebsd.plugin/plugin_freebsd.c
index bee8395f..17fec412 100644
--- a/collectors/freebsd.plugin/plugin_freebsd.c
+++ b/collectors/freebsd.plugin/plugin_freebsd.c
@@ -15,60 +15,61 @@ static struct freebsd_module {
} freebsd_modules[] = {
- // system metrics
- { .name = "kern.cp_time", .dim = "cp_time", .enabled = 1, .func = do_kern_cp_time },
- { .name = "vm.loadavg", .dim = "loadavg", .enabled = 1, .func = do_vm_loadavg },
- { .name = "system.ram", .dim = "system_ram", .enabled = 1, .func = do_system_ram },
- { .name = "vm.swap_info", .dim = "swap", .enabled = 1, .func = do_vm_swap_info },
- { .name = "vm.stats.vm.v_swappgs", .dim = "swap_io", .enabled = 1, .func = do_vm_stats_sys_v_swappgs },
- { .name = "vm.vmtotal", .dim = "vmtotal", .enabled = 1, .func = do_vm_vmtotal },
- { .name = "vm.stats.vm.v_forks", .dim = "forks", .enabled = 1, .func = do_vm_stats_sys_v_forks },
- { .name = "vm.stats.sys.v_swtch", .dim = "context_swtch", .enabled = 1, .func = do_vm_stats_sys_v_swtch },
- { .name = "hw.intrcnt", .dim = "hw_intr", .enabled = 1, .func = do_hw_intcnt },
- { .name = "vm.stats.sys.v_intr", .dim = "dev_intr", .enabled = 1, .func = do_vm_stats_sys_v_intr },
- { .name = "vm.stats.sys.v_soft", .dim = "soft_intr", .enabled = 1, .func = do_vm_stats_sys_v_soft },
- { .name = "net.isr", .dim = "net_isr", .enabled = 1, .func = do_net_isr },
- { .name = "kern.ipc.sem", .dim = "semaphores", .enabled = 1, .func = do_kern_ipc_sem },
- { .name = "kern.ipc.shm", .dim = "shared_memory", .enabled = 1, .func = do_kern_ipc_shm },
- { .name = "kern.ipc.msq", .dim = "message_queues", .enabled = 1, .func = do_kern_ipc_msq },
- { .name = "uptime", .dim = "uptime", .enabled = 1, .func = do_uptime },
-
- // memory metrics
- { .name = "vm.stats.vm.v_pgfaults", .dim = "pgfaults", .enabled = 1, .func = do_vm_stats_sys_v_pgfaults },
-
- // CPU metrics
- { .name = "kern.cp_times", .dim = "cp_times", .enabled = 1, .func = do_kern_cp_times },
- { .name = "dev.cpu.temperature", .dim = "cpu_temperature", .enabled = 1, .func = do_dev_cpu_temperature },
- { .name = "dev.cpu.0.freq", .dim = "cpu_frequency", .enabled = 1, .func = do_dev_cpu_0_freq },
-
- // disk metrics
- { .name = "kern.devstat", .dim = "kern_devstat", .enabled = 1, .func = do_kern_devstat },
- { .name = "getmntinfo", .dim = "getmntinfo", .enabled = 1, .func = do_getmntinfo },
-
- // network metrics
- { .name = "net.inet.tcp.states", .dim = "tcp_states", .enabled = 1, .func = do_net_inet_tcp_states },
- { .name = "net.inet.tcp.stats", .dim = "tcp_stats", .enabled = 1, .func = do_net_inet_tcp_stats },
- { .name = "net.inet.udp.stats", .dim = "udp_stats", .enabled = 1, .func = do_net_inet_udp_stats },
- { .name = "net.inet.icmp.stats", .dim = "icmp_stats", .enabled = 1, .func = do_net_inet_icmp_stats },
- { .name = "net.inet.ip.stats", .dim = "ip_stats", .enabled = 1, .func = do_net_inet_ip_stats },
- { .name = "net.inet6.ip6.stats", .dim = "ip6_stats", .enabled = 1, .func = do_net_inet6_ip6_stats },
- { .name = "net.inet6.icmp6.stats", .dim = "icmp6_stats", .enabled = 1, .func = do_net_inet6_icmp6_stats },
-
- // network interfaces metrics
- { .name = "getifaddrs", .dim = "getifaddrs", .enabled = 1, .func = do_getifaddrs },
-
- // ZFS metrics
- { .name = "kstat.zfs.misc.arcstats", .dim = "arcstats", .enabled = 1, .func = do_kstat_zfs_misc_arcstats },
- { .name = "kstat.zfs.misc.zio_trim", .dim = "trim", .enabled = 1, .func = do_kstat_zfs_misc_zio_trim },
-
- // ipfw metrics
- { .name = "ipfw", .dim = "ipfw", .enabled = 1, .func = do_ipfw },
-
- // the terminator of this array
- { .name = NULL, .dim = NULL, .enabled = 0, .func = NULL }
+ // system metrics
+ {.name = "kern.cp_time", .dim = "cp_time", .enabled = 1, .func = do_kern_cp_time},
+ {.name = "vm.loadavg", .dim = "loadavg", .enabled = 1, .func = do_vm_loadavg},
+ {.name = "system.ram", .dim = "system_ram", .enabled = 1, .func = do_system_ram},
+ {.name = "vm.swap_info", .dim = "swap", .enabled = 1, .func = do_vm_swap_info},
+ {.name = "vm.stats.vm.v_swappgs", .dim = "swap_io", .enabled = 1, .func = do_vm_stats_sys_v_swappgs},
+ {.name = "vm.vmtotal", .dim = "vmtotal", .enabled = 1, .func = do_vm_vmtotal},
+ {.name = "vm.stats.vm.v_forks", .dim = "forks", .enabled = 1, .func = do_vm_stats_sys_v_forks},
+ {.name = "vm.stats.sys.v_swtch", .dim = "context_swtch", .enabled = 1, .func = do_vm_stats_sys_v_swtch},
+ {.name = "hw.intrcnt", .dim = "hw_intr", .enabled = 1, .func = do_hw_intcnt},
+ {.name = "vm.stats.sys.v_intr", .dim = "dev_intr", .enabled = 1, .func = do_vm_stats_sys_v_intr},
+ {.name = "vm.stats.sys.v_soft", .dim = "soft_intr", .enabled = 1, .func = do_vm_stats_sys_v_soft},
+ {.name = "net.isr", .dim = "net_isr", .enabled = 1, .func = do_net_isr},
+ {.name = "kern.ipc.sem", .dim = "semaphores", .enabled = 1, .func = do_kern_ipc_sem},
+ {.name = "kern.ipc.shm", .dim = "shared_memory", .enabled = 1, .func = do_kern_ipc_shm},
+ {.name = "kern.ipc.msq", .dim = "message_queues", .enabled = 1, .func = do_kern_ipc_msq},
+ {.name = "uptime", .dim = "uptime", .enabled = 1, .func = do_uptime},
+
+ // memory metrics
+ {.name = "vm.stats.vm.v_pgfaults", .dim = "pgfaults", .enabled = 1, .func = do_vm_stats_sys_v_pgfaults},
+
+ // CPU metrics
+ {.name = "kern.cp_times", .dim = "cp_times", .enabled = 1, .func = do_kern_cp_times},
+ {.name = "dev.cpu.temperature", .dim = "cpu_temperature", .enabled = 1, .func = do_dev_cpu_temperature},
+ {.name = "dev.cpu.0.freq", .dim = "cpu_frequency", .enabled = 1, .func = do_dev_cpu_0_freq},
+
+ // disk metrics
+ {.name = "kern.devstat", .dim = "kern_devstat", .enabled = 1, .func = do_kern_devstat},
+ {.name = "getmntinfo", .dim = "getmntinfo", .enabled = 1, .func = do_getmntinfo},
+
+ // network metrics
+ {.name = "net.inet.tcp.states", .dim = "tcp_states", .enabled = 1, .func = do_net_inet_tcp_states},
+ {.name = "net.inet.tcp.stats", .dim = "tcp_stats", .enabled = 1, .func = do_net_inet_tcp_stats},
+ {.name = "net.inet.udp.stats", .dim = "udp_stats", .enabled = 1, .func = do_net_inet_udp_stats},
+ {.name = "net.inet.icmp.stats", .dim = "icmp_stats", .enabled = 1, .func = do_net_inet_icmp_stats},
+ {.name = "net.inet.ip.stats", .dim = "ip_stats", .enabled = 1, .func = do_net_inet_ip_stats},
+ {.name = "net.inet6.ip6.stats", .dim = "ip6_stats", .enabled = 1, .func = do_net_inet6_ip6_stats},
+ {.name = "net.inet6.icmp6.stats", .dim = "icmp6_stats", .enabled = 1, .func = do_net_inet6_icmp6_stats},
+
+ // network interfaces metrics
+ {.name = "getifaddrs", .dim = "getifaddrs", .enabled = 1, .func = do_getifaddrs},
+
+ // ZFS metrics
+ {.name = "kstat.zfs.misc.arcstats", .dim = "arcstats", .enabled = 1, .func = do_kstat_zfs_misc_arcstats},
+ {.name = "kstat.zfs.misc.zio_trim", .dim = "trim", .enabled = 1, .func = do_kstat_zfs_misc_zio_trim},
+
+ // ipfw metrics
+ {.name = "ipfw", .dim = "ipfw", .enabled = 1, .func = do_ipfw},
+
+ // the terminator of this array
+ {.name = NULL, .dim = NULL, .enabled = 0, .func = NULL}
};
-static void freebsd_main_cleanup(void *ptr) {
+static void freebsd_main_cleanup(void *ptr)
+{
struct netdata_static_thread *static_thread = (struct netdata_static_thread *)ptr;
static_thread->enabled = NETDATA_MAIN_THREAD_EXITING;
@@ -77,7 +78,8 @@ static void freebsd_main_cleanup(void *ptr) {
static_thread->enabled = NETDATA_MAIN_THREAD_EXITED;
}
-void *freebsd_main(void *ptr) {
+void *freebsd_main(void *ptr)
+{
netdata_thread_cleanup_push(freebsd_main_cleanup, ptr);
int vdo_cpu_netdata = config_get_boolean("plugin:freebsd", "netdata server resources", 1);
@@ -88,7 +90,7 @@ void *freebsd_main(void *ptr) {
// check the enabled status for each module
int i;
- for(i = 0 ; freebsd_modules[i].name ;i++) {
+ for (i = 0; freebsd_modules[i].name; i++) {
struct freebsd_module *pm = &freebsd_modules[i];
pm->enabled = config_get_boolean("plugin:freebsd", pm->name, pm->enabled);
@@ -100,17 +102,19 @@ void *freebsd_main(void *ptr) {
heartbeat_t hb;
heartbeat_init(&hb);
- while(!netdata_exit) {
+ while (!netdata_exit) {
usec_t hb_dt = heartbeat_next(&hb, step);
usec_t duration = 0ULL;
- if(unlikely(netdata_exit)) break;
+ if (unlikely(netdata_exit))
+ break;
// BEGIN -- the job to be done
- for(i = 0 ; freebsd_modules[i].name ;i++) {
+ for (i = 0; freebsd_modules[i].name; i++) {
struct freebsd_module *pm = &freebsd_modules[i];
- if(unlikely(!pm->enabled)) continue;
+ if (unlikely(!pm->enabled))
+ continue;
debug(D_PROCNETDEV_LOOP, "FREEBSD calling %s.", pm->name);
@@ -118,55 +122,87 @@ void *freebsd_main(void *ptr) {
pm->duration = heartbeat_monotonic_dt_to_now_usec(&hb) - duration;
duration += pm->duration;
- if(unlikely(netdata_exit)) break;
+ if (unlikely(netdata_exit))
+ break;
}
// END -- the job is done
- // --------------------------------------------------------------------
-
- if(vdo_cpu_netdata) {
- static RRDSET *st = NULL;
-
- if(unlikely(!st)) {
- st = rrdset_find_active_bytype_localhost("netdata", "plugin_freebsd_modules");
-
- if(!st) {
- st = rrdset_create_localhost(
- "netdata"
- , "plugin_freebsd_modules"
- , NULL
- , "freebsd"
- , NULL
- , "NetData FreeBSD Plugin Modules Durations"
- , "milliseconds/run"
- , "netdata"
- , "stats"
- , 132001
- , localhost->rrd_update_every
- , RRDSET_TYPE_STACKED
- );
-
- for(i = 0 ; freebsd_modules[i].name ;i++) {
+ if (vdo_cpu_netdata) {
+ static RRDSET *st_cpu_thread = NULL, *st_duration = NULL;
+ static RRDDIM *rd_user = NULL, *rd_system = NULL;
+
+ // ----------------------------------------------------------------
+
+ struct rusage thread;
+ getrusage(RUSAGE_THREAD, &thread);
+
+ if (unlikely(!st_cpu_thread)) {
+ st_cpu_thread = rrdset_create_localhost(
+ "netdata",
+ "plugin_freebsd_cpu",
+ NULL,
+ "freebsd",
+ NULL,
+ "Netdata FreeBSD plugin CPU usage",
+ "milliseconds/s",
+ "freebsd",
+ "stats",
+ 132000,
+ localhost->rrd_update_every,
+ RRDSET_TYPE_STACKED);
+
+ rd_user = rrddim_add(st_cpu_thread, "user", NULL, 1, USEC_PER_MS, RRD_ALGORITHM_INCREMENTAL);
+ rd_system = rrddim_add(st_cpu_thread, "system", NULL, 1, USEC_PER_MS, RRD_ALGORITHM_INCREMENTAL);
+ } else {
+ rrdset_next(st_cpu_thread);
+ }
+
+ rrddim_set_by_pointer(
+ st_cpu_thread, rd_user, thread.ru_utime.tv_sec * USEC_PER_SEC + thread.ru_utime.tv_usec);
+ rrddim_set_by_pointer(
+ st_cpu_thread, rd_system, thread.ru_stime.tv_sec * USEC_PER_SEC + thread.ru_stime.tv_usec);
+ rrdset_done(st_cpu_thread);
+
+ // ----------------------------------------------------------------
+
+ if (unlikely(!st_duration)) {
+ st_duration = rrdset_find_active_bytype_localhost("netdata", "plugin_freebsd_modules");
+
+ if (!st_duration) {
+ st_duration = rrdset_create_localhost(
+ "netdata",
+ "plugin_freebsd_modules",
+ NULL,
+ "freebsd",
+ NULL,
+ "Netdata FreeBSD plugin modules durations",
+ "milliseconds/run",
+ "freebsd",
+ "stats",
+ 132001,
+ localhost->rrd_update_every,
+ RRDSET_TYPE_STACKED);
+
+ for (i = 0; freebsd_modules[i].name; i++) {
struct freebsd_module *pm = &freebsd_modules[i];
- if(unlikely(!pm->enabled)) continue;
+ if (unlikely(!pm->enabled))
+ continue;
- pm->rd = rrddim_add(st, pm->dim, NULL, 1, 1000, RRD_ALGORITHM_ABSOLUTE);
+ pm->rd = rrddim_add(st_duration, pm->dim, NULL, 1, 1000, RRD_ALGORITHM_ABSOLUTE);
}
}
- }
- else rrdset_next(st);
+ } else
+ rrdset_next(st_duration);
- for(i = 0 ; freebsd_modules[i].name ;i++) {
+ for (i = 0; freebsd_modules[i].name; i++) {
struct freebsd_module *pm = &freebsd_modules[i];
- if(unlikely(!pm->enabled)) continue;
+ if (unlikely(!pm->enabled))
+ continue;
- rrddim_set_by_pointer(st, pm->rd, pm->duration);
+ rrddim_set_by_pointer(st_duration, pm->rd, pm->duration);
}
- rrdset_done(st);
-
- global_statistics_charts();
- registry_statistics();
+ rrdset_done(st_duration);
}
}