]> arthur.barton.de Git - netdata.git/commitdiff
Separate vm.stats.sys.v_soft module
authorVladimir Kobal <vlad@prokk.net>
Wed, 8 Mar 2017 23:59:45 +0000 (01:59 +0200)
committerVladimir Kobal <vlad@prokk.net>
Wed, 8 Mar 2017 23:59:45 +0000 (01:59 +0200)
src/freebsd_sysctl.c
src/plugin_freebsd.c
src/plugin_freebsd.h

index b5174e6e5180e8bb9de703ce23e21b4af9b704db..ed84cb777a3d8baa68ee82b18e7e1a74769717f8 100644 (file)
@@ -522,6 +522,45 @@ int do_vm_stats_sys_v_intr(int update_every, usec_t dt) {
     return 0;
 }
 
+// --------------------------------------------------------------------------------------------------------------------
+// vm.stats.sys.v_soft
+
+int do_vm_stats_sys_v_soft(int update_every, usec_t dt) {
+    static int mib[4] = {0, 0, 0, 0};
+    u_int soft_intr_number;
+
+    if (unlikely(GETSYSCTL_SIMPLE("vm.stats.sys.v_soft", mib, soft_intr_number))) {
+        error("DISABLED: system.dev_intr chart");
+        error("DISABLED: vm.stats.sys.v_soft module");
+        return 1;
+    } else {
+        static RRDSET *st = NULL;
+        static RRDDIM *rd = NULL;
+
+        if (unlikely(!st)) {
+            st = rrdset_create_localhost("system",
+                                         "soft_intr",
+                                         NULL,
+                                         "interrupts",
+                                         NULL,
+                                         "Software Interrupts",
+                                         "interrupts/s",
+                                         1100,
+                                         update_every,
+                                         RRDSET_TYPE_LINE
+            );
+
+            rd = rrddim_add(st, "interrupts", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
+        }
+        else rrdset_next(st);
+
+        rrddim_set_by_pointer(st, rd, soft_intr_number);
+        rrdset_done(st);
+    }
+
+    return 0;
+}
+
 // --------------------------------------------------------------------------------------------------------------------
 // old sources
 
@@ -534,7 +573,7 @@ int do_vm_stats_sys_v_intr(int update_every, usec_t dt) {
 int do_freebsd_sysctl_old(int update_every, usec_t dt) {
     static int do_context = -1, do_forks = -1, do_disk_io = -1, do_swap = -1, do_ram = -1, do_swapio = -1,
         do_pgfaults = -1, do_ipc_semaphores = -1, do_ipc_shared_mem = -1, do_ipc_msg_queues = -1,
-        do_soft_intr = -1, do_netisr = -1, do_netisr_per_core = -1, do_bandwidth = -1,
+        do_netisr = -1, do_netisr_per_core = -1, do_bandwidth = -1,
         do_tcp_sockets = -1, do_tcp_packets = -1, do_tcp_errors = -1, do_tcp_handshake = -1,
         do_ecn = -1, do_tcpext_syscookies = -1, do_tcpext_ofo = -1, do_tcpext_connaborts = -1,
         do_udp_packets = -1, do_udp_errors = -1, do_icmp_packets = -1, do_icmpmsg = -1,
@@ -544,7 +583,6 @@ int do_freebsd_sysctl_old(int update_every, usec_t dt) {
         do_icmp6_neighbor = -1, do_icmp6_types = -1, do_space = -1, do_inodes = -1, do_uptime = -1;
 
     if (unlikely(do_uptime == -1)) {
-        do_soft_intr            = config_get_boolean("plugin:freebsd:sysctl", "software interrupts", 1);
         do_context              = config_get_boolean("plugin:freebsd:sysctl", "context switches", 1);
         do_forks                = config_get_boolean("plugin:freebsd:sysctl", "processes started", 1);
         do_disk_io              = config_get_boolean("plugin:freebsd:sysctl", "stats for all disks", 1);
@@ -723,27 +761,6 @@ int do_freebsd_sysctl_old(int update_every, usec_t dt) {
 
     // --------------------------------------------------------------------
 
-    if (likely(do_soft_intr)) {
-        if (unlikely(GETSYSCTL_BY_NAME("vm.stats.sys.v_soft", u_int_data))) {
-            do_soft_intr = 0;
-            error("DISABLED: system.dev_intr");
-        } else {
-
-            st = rrdset_find_bytype_localhost("system", "soft_intr");
-            if (unlikely(!st)) {
-                st = rrdset_create_localhost("system", "soft_intr", NULL, "interrupts", NULL, "Software Interrupts", "interrupts/s", 1100, update_every, RRDSET_TYPE_LINE);
-
-                rrddim_add(st, "interrupts", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
-            }
-            else rrdset_next(st);
-
-            rrddim_set(st, "interrupts", u_int_data);
-            rrdset_done(st);
-        }
-    }
-
-    // --------------------------------------------------------------------
-
     if (likely(do_context)) {
         if (unlikely(GETSYSCTL_BY_NAME("vm.stats.sys.v_swtch", u_int_data))) {
             do_context = 0;
index 4184039d518c6a03e241d1b7e9b717ce48d125c4..c180aa8f6fd7be9a114196226591b0ccd4f7d779 100644 (file)
@@ -22,6 +22,7 @@ static struct freebsd_module {
         { .name = "kern.cp_times", .dim = "cp_times", .enabled = 1, .func = do_kern_cp_times },
         { .name = "hw.intrcnt", .dim = "hw_intrcnt", .enabled = 1, .func = do_hw_intcnt },
         { .name = "vm.stats.sys.v_intr", .dim = "dev_intrcnt", .enabled = 1, .func = do_vm_stats_sys_v_intr },
+        { .name = "vm.stats.sys.v_soft", .dim = "dev_intrcnt", .enabled = 1, .func = do_vm_stats_sys_v_soft },
 
         // the terminator of this array
         { .name = NULL, .dim = NULL, .enabled = 0, .func = NULL }
index ef5167f66733d1745081458b8595e4b7cf45d898..3d8b09a4d6d5f6d175297cc8ad73545a84902411 100644 (file)
@@ -13,6 +13,7 @@ extern int do_kern_cp_time(int update_every, usec_t dt);
 extern int do_kern_cp_times(int update_every, usec_t dt);
 extern int do_hw_intcnt(int update_every, usec_t dt);
 extern int do_vm_stats_sys_v_intr(int update_every, usec_t dt);
+extern int do_vm_stats_sys_v_soft(int update_every, usec_t dt);
 extern int do_freebsd_sysctl_old(int update_every, usec_t dt);
 
 #define GETSYSCTL_MIB(name, mib) getsysctl_mib(name, mib, sizeof(mib)/sizeof(int))