X-Git-Url: https://arthur.barton.de/gitweb/?a=blobdiff_plain;f=src%2Ffreebsd_sysctl.c;h=77e731033222118f81f09e3905401b7034aad563;hb=4201f21ec70829bd167cdb345b8ee79b1227d4d7;hp=dcad74346023fe96371501c9d165fabaa147d74b;hpb=e86fe357adb9fb88f8e83950c52efaf95800a5ac;p=netdata.git diff --git a/src/freebsd_sysctl.c b/src/freebsd_sysctl.c index dcad7434..77e73103 100644 --- a/src/freebsd_sysctl.c +++ b/src/freebsd_sysctl.c @@ -122,6 +122,7 @@ int do_vm_loadavg(int update_every, usec_t dt){ // vm.vmtotal int do_vm_vmtotal(int update_every, usec_t dt) { + (void)dt; static int do_all_processes = -1, do_processes = -1, do_committed = -1; if (unlikely(do_all_processes == -1)) { @@ -240,6 +241,8 @@ int do_vm_vmtotal(int update_every, usec_t dt) { // kern.cp_time int do_kern_cp_time(int update_every, usec_t dt) { + (void)dt; + if (unlikely(CPUSTATES != 5)) { error("FREEBSD: There are %d CPU states (5 was expected)", CPUSTATES); error("DISABLED: system.cpu chart"); @@ -297,6 +300,8 @@ int do_kern_cp_time(int update_every, usec_t dt) { // kern.cp_times int do_kern_cp_times(int update_every, usec_t dt) { + (void)dt; + if (unlikely(CPUSTATES != 5)) { error("FREEBSD: There are %d CPU states (5 was expected)", CPUSTATES); error("DISABLED: cpu.cpuXX charts"); @@ -326,8 +331,13 @@ int do_kern_cp_times(int update_every, usec_t dt) { RRDDIM *rd_interrupt; RRDDIM *rd_idle; } *all_cpu_charts = NULL; + static int old_number_of_cpus = 0; - all_cpu_charts = reallocz(all_cpu_charts, sizeof(struct cpu_chart) * number_of_cpus); + if(unlikely(number_of_cpus > old_number_of_cpus)) { + all_cpu_charts = reallocz(all_cpu_charts, sizeof(struct cpu_chart) * number_of_cpus); + memset(&all_cpu_charts[old_number_of_cpus], 0, sizeof(struct cpu_chart) * (number_of_cpus - old_number_of_cpus)); + old_number_of_cpus = number_of_cpus; + } for (i = 0; i < number_of_cpus; i++) { if (unlikely(!all_cpu_charts[i].st)) { @@ -374,9 +384,10 @@ int do_kern_cp_times(int update_every, usec_t dt) { // hw.intrcnt int do_hw_intcnt(int update_every, usec_t dt) { + (void)dt; static int mib_hw_intrcnt[2] = {0, 0}; - size_t intrcnt_size; - int i; + size_t intrcnt_size = sizeof(mib_hw_intrcnt); + unsigned long i; if (unlikely(GETSYSCTL_SIZE("hw.intrcnt", mib_hw_intrcnt, intrcnt_size))) { error("DISABLED: system.intr chart"); @@ -482,6 +493,7 @@ int do_hw_intcnt(int update_every, usec_t dt) { // vm.stats.sys.v_intr int do_vm_stats_sys_v_intr(int update_every, usec_t dt) { + (void)dt; static int mib[4] = {0, 0, 0, 0}; u_int int_number; @@ -524,6 +536,7 @@ int do_vm_stats_sys_v_intr(int update_every, usec_t dt) { // vm.stats.sys.v_soft int do_vm_stats_sys_v_soft(int update_every, usec_t dt) { + (void)dt; static int mib[4] = {0, 0, 0, 0}; u_int soft_intr_number; @@ -566,6 +579,7 @@ int do_vm_stats_sys_v_soft(int update_every, usec_t dt) { // vm.stats.sys.v_swtch int do_vm_stats_sys_v_swtch(int update_every, usec_t dt) { + (void)dt; static int mib[4] = {0, 0, 0, 0}; u_int ctxt_number; @@ -608,6 +622,7 @@ int do_vm_stats_sys_v_swtch(int update_every, usec_t dt) { // vm.stats.vm.v_forks int do_vm_stats_sys_v_forks(int update_every, usec_t dt) { + (void)dt; static int mib[4] = {0, 0, 0, 0}; u_int forks_number; @@ -652,6 +667,7 @@ int do_vm_stats_sys_v_forks(int update_every, usec_t dt) { // vm.swap_info int do_vm_swap_info(int update_every, usec_t dt) { + (void)dt; static int mib[3] = {0, 0, 0}; if (unlikely(getsysctl_mib("vm.swap_info", mib, 2))) { @@ -727,6 +743,7 @@ int do_vm_swap_info(int update_every, usec_t dt) { // system.ram int do_system_ram(int update_every, usec_t dt) { + (void)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}; struct vmmeter vmmeter_data; @@ -794,6 +811,7 @@ int do_system_ram(int update_every, usec_t dt) { // vm.stats.vm.v_swappgs int do_vm_stats_sys_v_swappgs(int update_every, usec_t dt) { + (void)dt; static int mib_swappgsin[4] = {0, 0, 0, 0}, mib_swappgsout[4] = {0, 0, 0, 0}; struct vmmeter vmmeter_data; @@ -839,6 +857,7 @@ int do_vm_stats_sys_v_swappgs(int update_every, usec_t dt) { // vm.stats.vm.v_pgfaults int do_vm_stats_sys_v_pgfaults(int update_every, usec_t dt) { + (void)dt; 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}, mib_cow_optim[4] = {0, 0, 0, 0}, mib_intrans[4] = {0, 0, 0, 0}; struct vmmeter vmmeter_data; @@ -897,6 +916,7 @@ int do_vm_stats_sys_v_pgfaults(int update_every, usec_t dt) { // kern.ipc.sem int do_kern_ipc_sem(int update_every, usec_t dt) { + (void)dt; static int mib_semmni[3] = {0, 0, 0}, mib_sema[3] = {0, 0, 0}; struct ipc_sem { int semmni; @@ -942,7 +962,7 @@ int do_kern_ipc_sem(int update_every, usec_t dt) { "IPC Semaphores", "semaphores", 1000, - localhost->rrd_update_every, + update_every, RRDSET_TYPE_AREA ); @@ -964,7 +984,7 @@ int do_kern_ipc_sem(int update_every, usec_t dt) { "IPC Semaphore Arrays", "arrays", 1000, - localhost->rrd_update_every, + update_every, RRDSET_TYPE_AREA ); @@ -984,6 +1004,7 @@ int do_kern_ipc_sem(int update_every, usec_t dt) { // kern.ipc.shm int do_kern_ipc_shm(int update_every, usec_t dt) { + (void)dt; static int mib_shmmni[3] = {0, 0, 0}, mib_shmsegs[3] = {0, 0, 0}; struct ipc_shm { u_long shmmni; @@ -1007,7 +1028,7 @@ int do_kern_ipc_shm(int update_every, usec_t dt) { error("DISABLED: kern.ipc.shmmodule"); return 1; } else { - int i; + unsigned long i; for (i = 0; i < ipc_shm.shmmni; i++) { if (unlikely(ipc_shm_data[i].u.shm_perm.mode & 0x0800)) { @@ -1030,7 +1051,7 @@ int do_kern_ipc_shm(int update_every, usec_t dt) { "IPC Shared Memory Segments", "segments", 1000, - localhost->rrd_update_every, + update_every, RRDSET_TYPE_AREA ); @@ -1052,7 +1073,7 @@ int do_kern_ipc_shm(int update_every, usec_t dt) { "IPC Shared Memory Segments Size", "kilobytes", 1000, - localhost->rrd_update_every, + update_every, RRDSET_TYPE_AREA ); @@ -1072,6 +1093,7 @@ int do_kern_ipc_shm(int update_every, usec_t dt) { // kern.ipc.msq int do_kern_ipc_msq(int update_every, usec_t dt) { + (void)dt; static int mib_msgmni[3] = {0, 0, 0}, mib_msqids[3] = {0, 0, 0}; struct ipc_msq { int msgmni; @@ -1124,7 +1146,7 @@ int do_kern_ipc_msq(int update_every, usec_t dt) { "Number of IPC Message Queues", "queues", 990, - localhost->rrd_update_every, + update_every, RRDSET_TYPE_AREA ); @@ -1146,7 +1168,7 @@ int do_kern_ipc_msq(int update_every, usec_t dt) { "Number of Messages in IPC Message Queues", "messages", 1000, - localhost->rrd_update_every, + update_every, RRDSET_TYPE_AREA ); @@ -1168,7 +1190,7 @@ int do_kern_ipc_msq(int update_every, usec_t dt) { "Size of IPC Message Queues", "bytes", 1100, - localhost->rrd_update_every, + update_every, RRDSET_TYPE_LINE ); @@ -1190,6 +1212,7 @@ int do_kern_ipc_msq(int update_every, usec_t dt) { // uptime int do_uptime(int update_every, usec_t dt) { + (void)dt; struct timespec up_time; clock_gettime(CLOCK_UPTIME, &up_time); @@ -1226,6 +1249,7 @@ int do_uptime(int update_every, usec_t dt) { // net.isr int do_net_isr(int update_every, usec_t dt) { + (void)dt; static int do_netisr = -1, do_netisr_per_core = -1; if (unlikely(do_netisr == -1)) { @@ -1235,8 +1259,7 @@ int do_net_isr(int update_every, usec_t dt) { static int mib_workstream[3] = {0, 0, 0}, mib_work[3] = {0, 0, 0}; int common_error = 0; - int i, n; - size_t netisr_workstream_size, netisr_work_size; + size_t netisr_workstream_size = sizeof(mib_workstream), netisr_work_size = sizeof(mib_work); unsigned long num_netisr_workstreams = 0, num_netisr_works = 0; static struct sysctl_netisr_workstream *netisr_workstream = NULL; static struct sysctl_netisr_work *netisr_work = NULL; @@ -1276,8 +1299,11 @@ int do_net_isr(int update_every, usec_t dt) { error("DISABLED: net.isr module"); return 1; } else { + unsigned long i, n; + int j; + netisr_stats = reallocz(netisr_stats, (number_of_cpus + 1) * sizeof(struct netisr_stats)); - bzero(netisr_stats, (number_of_cpus + 1) * sizeof(struct netisr_stats)); + memset(netisr_stats, 0, (number_of_cpus + 1) * sizeof(struct netisr_stats)); for (i = 0; i < num_netisr_workstreams; i++) { for (n = 0; n < num_netisr_works; n++) { if (netisr_workstream[i].snws_wsid == netisr_work[n].snw_wsid) { @@ -1288,11 +1314,11 @@ int do_net_isr(int update_every, usec_t dt) { } } } - for (i = 0; i < number_of_cpus; i++) { - netisr_stats[number_of_cpus].dispatched += netisr_stats[i].dispatched; - netisr_stats[number_of_cpus].hybrid_dispatched += netisr_stats[i].hybrid_dispatched; - netisr_stats[number_of_cpus].qdrops += netisr_stats[i].qdrops; - netisr_stats[number_of_cpus].queued += netisr_stats[i].queued; + for (j = 0; j < number_of_cpus; j++) { + netisr_stats[number_of_cpus].dispatched += netisr_stats[j].dispatched; + netisr_stats[number_of_cpus].hybrid_dispatched += netisr_stats[j].hybrid_dispatched; + netisr_stats[number_of_cpus].qdrops += netisr_stats[j].qdrops; + netisr_stats[number_of_cpus].queued += netisr_stats[j].queued; } } } else { @@ -1344,8 +1370,14 @@ int do_net_isr(int update_every, usec_t dt) { RRDDIM *rd_qdrops; RRDDIM *rd_queued; } *all_softnet_charts = NULL; + static int old_number_of_cpus = 0; + int i; - all_softnet_charts = reallocz(all_softnet_charts, sizeof(struct softnet_chart) * number_of_cpus); + if(unlikely(number_of_cpus > old_number_of_cpus)) { + all_softnet_charts = reallocz(all_softnet_charts, sizeof(struct softnet_chart) * number_of_cpus); + memset(&all_softnet_charts[old_number_of_cpus], 0, sizeof(struct softnet_chart) * (number_of_cpus - old_number_of_cpus)); + old_number_of_cpus = number_of_cpus; + } for (i = 0; i < number_of_cpus ;i++) { snprintfz(all_softnet_charts[i].netisr_cpuid, MAX_INT_DIGITS + 17, "cpu%d_softnet_stat", i); @@ -1393,6 +1425,7 @@ int do_net_isr(int update_every, usec_t dt) { // net.inet.tcp.states int do_net_inet_tcp_states(int update_every, usec_t dt) { + (void)dt; static int mib[4] = {0, 0, 0, 0}; uint64_t tcps_states[TCP_NSTATES]; @@ -1436,6 +1469,7 @@ int do_net_inet_tcp_states(int update_every, usec_t dt) { // net.inet.tcp.stats int do_net_inet_tcp_stats(int update_every, usec_t dt) { + (void)dt; 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; if (unlikely(do_tcp_packets == -1)) { @@ -1730,6 +1764,7 @@ int do_net_inet_tcp_stats(int update_every, usec_t dt) { // net.inet.udp.stats int do_net_inet_udp_stats(int update_every, usec_t dt) { + (void)dt; static int do_udp_packets = -1, do_udp_errors = -1; if (unlikely(do_udp_packets == -1)) { @@ -1830,6 +1865,7 @@ int do_net_inet_udp_stats(int update_every, usec_t dt) { // net.inet.icmp.stats int do_net_inet_icmp_stats(int update_every, usec_t dt) { + (void)dt; static int do_icmp_packets = -1, do_icmp_errors = -1, do_icmpmsg = -1; if (unlikely(do_icmp_packets == -1)) { @@ -1955,6 +1991,7 @@ int do_net_inet_icmp_stats(int update_every, usec_t dt) { // net.inet.ip.stats int do_net_inet_ip_stats(int update_every, usec_t dt) { + (void)dt; static int do_ip_packets = -1, do_ip_fragsout = -1, do_ip_fragsin = -1, do_ip_errors = -1; if (unlikely(do_ip_packets == -1)) { @@ -2137,6 +2174,7 @@ int do_net_inet_ip_stats(int update_every, usec_t dt) { // net.inet6.ip6.stats int do_net_inet6_ip6_stats(int update_every, usec_t dt) { + (void)dt; static int do_ip6_packets = -1, do_ip6_fragsout = -1, do_ip6_fragsin = -1, do_ip6_errors = -1; if (unlikely(do_ip6_packets == -1)) { @@ -2347,6 +2385,7 @@ int do_net_inet6_ip6_stats(int update_every, usec_t dt) { // net.inet6.icmp6.stats int do_net_inet6_icmp6_stats(int update_every, usec_t dt) { + (void)dt; static int do_icmp6 = -1, do_icmp6_redir = -1, do_icmp6_errors = -1, do_icmp6_echos = -1, do_icmp6_router = -1, do_icmp6_neighbor = -1, do_icmp6_types = -1; @@ -2715,6 +2754,7 @@ int do_net_inet6_icmp6_stats(int update_every, usec_t dt) { // getmntinfo int do_getmntinfo(int update_every, usec_t dt) { + (void)dt; #define DELAULT_EXLUDED_PATHS "/proc/*" // taken from gnulib/mountlist.c and shortened to FreeBSD related fstypes @@ -2750,6 +2790,8 @@ int do_getmntinfo(int update_every, usec_t dt) { size_t collected; // the number of times this has been collected + // charts and dimensions + RRDSET *st_space; RRDDIM *rd_space_used; RRDDIM *rd_space_avail; @@ -2918,6 +2960,7 @@ int do_getmntinfo(int update_every, usec_t dt) { // getifaddrs int do_getifaddrs(int update_every, usec_t dt) { + (void)dt; #define DELAULT_EXLUDED_INTERFACES "lo*" #define CONFIG_SECTION_GETIFADDRS "plugin:freebsd:getifaddrs" @@ -3057,6 +3100,8 @@ int do_getifaddrs(int update_every, usec_t dt) { int do_drops; int do_events; + // charts and dimensions + RRDSET *st_bandwidth; RRDDIM *rd_bandwidth_in; RRDDIM *rd_bandwidth_out; @@ -3253,7 +3298,11 @@ int do_getifaddrs(int update_every, usec_t dt) { // -------------------------------------------------------------------- if (ifm->do_drops == CONFIG_BOOLEAN_YES || (ifm->do_drops == CONFIG_BOOLEAN_AUTO && - (IFA_DATA(iqdrops) || IFA_DATA(oqdrops)))) { + (IFA_DATA(iqdrops) +#if __FreeBSD__ >= 11 + || IFA_DATA(oqdrops) +#endif + ))) { if (unlikely(!ifm->st_drops)) { ifm->st_drops = rrdset_create_localhost("net_drops", ifa->ifa_name, @@ -3326,137 +3375,398 @@ int do_getifaddrs(int update_every, usec_t dt) { // kern.devstat int do_kern_devstat(int update_every, usec_t dt) { - static int do_disk_io = -1; - if (unlikely(do_disk_io == -1)) { - do_disk_io = config_get_boolean("plugin:freebsd:kern.devstat", "stats for all disks", 1); +#define DELAULT_EXLUDED_DISKS "" +#define CONFIG_SECTION_KERN_DEVSTAT "plugin:freebsd:kern.devstat" +#define BINTIME_SCALE 5.42101086242752217003726400434970855712890625e-17 // this is 1000/2^64 + + static int enable_pass_devices = -1, do_system_io = -1, do_io = -1, do_ops = -1, do_qops = -1, do_util = -1, + do_iotime = -1, do_await = -1, do_avagsz = -1, do_svctm = -1; + + if (unlikely(enable_pass_devices == -1)) { + enable_pass_devices = config_get_boolean_ondemand(CONFIG_SECTION_KERN_DEVSTAT, + "performance metrics for pass devices", CONFIG_BOOLEAN_AUTO); + + do_system_io = config_get_boolean_ondemand(CONFIG_SECTION_KERN_DEVSTAT, "total bandwidth for all disks", + CONFIG_BOOLEAN_YES); + + do_io = config_get_boolean_ondemand(CONFIG_SECTION_KERN_DEVSTAT, "bandwidth for all disks", + CONFIG_BOOLEAN_AUTO); + do_ops = config_get_boolean_ondemand(CONFIG_SECTION_KERN_DEVSTAT, "operations for all disks", + CONFIG_BOOLEAN_AUTO); + do_qops = config_get_boolean_ondemand(CONFIG_SECTION_KERN_DEVSTAT, "queued operations for all disks", + CONFIG_BOOLEAN_AUTO); + do_util = config_get_boolean_ondemand(CONFIG_SECTION_KERN_DEVSTAT, "utilization percentage for all disks", + CONFIG_BOOLEAN_AUTO); + do_iotime = config_get_boolean_ondemand(CONFIG_SECTION_KERN_DEVSTAT, "i/o time for all disks", + CONFIG_BOOLEAN_AUTO); + do_await = config_get_boolean_ondemand(CONFIG_SECTION_KERN_DEVSTAT, "average completed i/o time for all disks", + CONFIG_BOOLEAN_AUTO); + do_avagsz = config_get_boolean_ondemand(CONFIG_SECTION_KERN_DEVSTAT, "average completed i/o bandwidth for all disks", + CONFIG_BOOLEAN_AUTO); + do_svctm = config_get_boolean_ondemand(CONFIG_SECTION_KERN_DEVSTAT, "average service time for all disks", + CONFIG_BOOLEAN_AUTO); } - RRDSET *st; - - int i; - - #define RRD_TYPE_DISK "disk" - #define BINTIME_SCALE 5.42101086242752217003726400434970855712890625e-17 // this is 1000/2^64 - int numdevs; - static void *devstat_data = NULL; - struct devstat *dstat; - char disk[DEVSTAT_NAME_LEN + MAX_INT_DIGITS + 1]; - struct cur_dstat { - collected_number duration_read_ms; - collected_number duration_write_ms; - collected_number busy_time_ms; - } cur_dstat; - struct prev_dstat { - collected_number bytes_read; - collected_number bytes_write; - collected_number operations_read; - collected_number operations_write; - collected_number duration_read_ms; - collected_number duration_write_ms; - collected_number busy_time_ms; - } prev_dstat; + if (likely(do_system_io || do_io || do_ops || do_qops || do_util || do_iotime || do_await || do_avagsz || do_svctm)) { + static int mib_numdevs[3] = {0, 0, 0}; + int numdevs; + int common_error = 0; - // -------------------------------------------------------------------- - - if (likely(do_disk_io)) { - if (unlikely(GETSYSCTL_BY_NAME("kern.devstat.numdevs", numdevs))) { - do_disk_io = 0; - error("DISABLED: disk.io"); + if (unlikely(GETSYSCTL_SIMPLE("kern.devstat.numdevs", mib_numdevs, numdevs))) { + common_error = 1; } else { + static int mib_devstat[3] = {0, 0, 0}; + static void *devstat_data = NULL; + devstat_data = reallocz(devstat_data, sizeof(long) + sizeof(struct devstat) * numdevs); // there is generation number before devstat structures - if (unlikely( - getsysctl_by_name("kern.devstat.all", devstat_data, sizeof(long) + sizeof(struct devstat) * numdevs))) { - do_disk_io = 0; - error("DISABLED: disk.io"); + if (unlikely(GETSYSCTL_WSIZE("kern.devstat.all", mib_devstat, devstat_data, + sizeof(long) + sizeof(struct devstat) * numdevs))) { + common_error = 1; } else { - dstat = devstat_data + sizeof(long); // skip generation number + struct devstat *dstat; + int i; collected_number total_disk_kbytes_read = 0; collected_number total_disk_kbytes_write = 0; - for (i = 0; i < numdevs; i++) { - if (((dstat[i].device_type & DEVSTAT_TYPE_MASK) == DEVSTAT_TYPE_DIRECT) || ((dstat[i].device_type & DEVSTAT_TYPE_MASK) == DEVSTAT_TYPE_STORARRAY)) { - sprintf(disk, "%s%d", dstat[i].device_name, dstat[i].unit_number); + // Data to be stored in DICTIONARY disks. + // This DICTIONARY is used to lookup the settings of the disks on each iteration. + struct disks_metadata { + int do_io; + int do_ops; + int do_qops; + int do_util; + int do_iotime; + int do_await; + int do_avagsz; + int do_svctm; - // -------------------------------------------------------------------- - st = rrdset_find_bytype_localhost(RRD_TYPE_DISK, disk); - if (unlikely(!st)) { - st = rrdset_create_localhost(RRD_TYPE_DISK, disk, NULL, disk, "disk.io", "Disk I/O Bandwidth", "kilobytes/s", 2000, update_every, RRDSET_TYPE_AREA); + // data for differential charts - rrddim_add(st, "reads", NULL, 1, 1024, RRD_ALGORITHM_INCREMENTAL); - rrddim_add(st, "writes", NULL, -1, 1024, RRD_ALGORITHM_INCREMENTAL); - } - else rrdset_next(st); + struct prev_dstat { + collected_number bytes_read; + collected_number bytes_write; + collected_number operations_read; + collected_number operations_write; + collected_number duration_read_ms; + collected_number duration_write_ms; + collected_number busy_time_ms; + } prev_dstat; - total_disk_kbytes_read += dstat[i].bytes[DEVSTAT_READ]/KILO_FACTOR; - total_disk_kbytes_write += dstat[i].bytes[DEVSTAT_WRITE]/KILO_FACTOR; - prev_dstat.bytes_read = rrddim_set(st, "reads", dstat[i].bytes[DEVSTAT_READ]); - prev_dstat.bytes_write = rrddim_set(st, "writes", dstat[i].bytes[DEVSTAT_WRITE]); - rrdset_done(st); + // charts and dimensions - // -------------------------------------------------------------------- + RRDSET *st_io; + RRDDIM *rd_io_in; + RRDDIM *rd_io_out; + + RRDSET *st_ops; + RRDDIM *rd_ops_in; + RRDDIM *rd_ops_out; + + RRDSET *st_qops; + RRDDIM *rd_qops; + + RRDSET *st_util; + RRDDIM *rd_util; + + RRDSET *st_iotime; + RRDDIM *rd_iotime_in; + RRDDIM *rd_iotime_out; + + RRDSET *st_await; + RRDDIM *rd_await_in; + RRDDIM *rd_await_out; + + RRDSET *st_avagsz; + RRDDIM *rd_avagsz_in; + RRDDIM *rd_avagsz_out; + + RRDSET *st_svctm; + RRDDIM *rd_svctm; - st = rrdset_find_bytype_localhost("disk_ops", disk); - if (unlikely(!st)) { - st = rrdset_create_localhost("disk_ops", disk, NULL, disk, "disk.ops", "Disk Completed I/O Operations", "operations/s", 2001, update_every, RRDSET_TYPE_LINE); - rrdset_flag_set(st, RRDSET_FLAG_DETAIL); + }; + static DICTIONARY *disks = NULL; + static SIMPLE_PATTERN *excluded_disks = NULL; - rrddim_add(st, "reads", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); - rrddim_add(st, "writes", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); + if(unlikely(!disks)) { + + excluded_disks = simple_pattern_create( + config_get(CONFIG_SECTION_KERN_DEVSTAT, "disable by default disks matching", + DELAULT_EXLUDED_DISKS) + , SIMPLE_PATTERN_EXACT + ); + + disks = dictionary_create(DICTIONARY_FLAG_SINGLE_THREADED); + } + + dstat = devstat_data + sizeof(long); // skip generation number + + for (i = 0; i < numdevs; i++) { + if (likely(do_system_io)) { + if (((dstat[i].device_type & DEVSTAT_TYPE_MASK) == DEVSTAT_TYPE_DIRECT) || ((dstat[i].device_type & DEVSTAT_TYPE_MASK) == DEVSTAT_TYPE_STORARRAY)) { + total_disk_kbytes_read += dstat[i].bytes[DEVSTAT_READ] / KILO_FACTOR; + total_disk_kbytes_write += dstat[i].bytes[DEVSTAT_WRITE] / KILO_FACTOR; } - else rrdset_next(st); + } - prev_dstat.operations_read = rrddim_set(st, "reads", dstat[i].operations[DEVSTAT_READ]); - prev_dstat.operations_write = rrddim_set(st, "writes", dstat[i].operations[DEVSTAT_WRITE]); - rrdset_done(st); + if (unlikely(!enable_pass_devices)) + if ((dstat[i].device_type & DEVSTAT_TYPE_PASS) == DEVSTAT_TYPE_PASS) + continue; - // -------------------------------------------------------------------- + if (((dstat[i].device_type & DEVSTAT_TYPE_MASK) == DEVSTAT_TYPE_DIRECT) || ((dstat[i].device_type & DEVSTAT_TYPE_MASK) == DEVSTAT_TYPE_STORARRAY)) { + char disk[DEVSTAT_NAME_LEN + MAX_INT_DIGITS + 1]; + int def_io, def_ops, def_qops, def_util, def_iotime, def_await, def_avagsz, def_svctm, + iter_io, iter_ops, iter_qops, iter_util, iter_iotime, iter_await, iter_avagsz, iter_svctm; + struct cur_dstat { + collected_number duration_read_ms; + collected_number duration_write_ms; + collected_number busy_time_ms; + } cur_dstat; + + sprintf(disk, "%s%d", dstat[i].device_name, dstat[i].unit_number); - st = rrdset_find_bytype_localhost("disk_qops", disk); - if (unlikely(!st)) { - st = rrdset_create_localhost("disk_qops", disk, NULL, disk, "disk.qops", "Disk Current I/O Operations", "operations", 2002, update_every, RRDSET_TYPE_LINE); - rrdset_flag_set(st, RRDSET_FLAG_DETAIL); + struct disks_metadata *dm = dictionary_get(disks, disk); + if(unlikely(!dm)) { + char var_name[4096 + 1]; + snprintfz(var_name, 4096, "%s:%s", CONFIG_SECTION_KERN_DEVSTAT, disk); + + def_io = do_io; + def_ops = do_ops; + def_qops = do_qops; + def_util = do_util; + def_iotime = do_iotime; + def_await = do_await; + def_avagsz = do_avagsz; + def_svctm = do_svctm; + + if(unlikely(simple_pattern_matches(excluded_disks, disk))) { + def_io = CONFIG_BOOLEAN_NO; + def_ops = CONFIG_BOOLEAN_NO; + def_qops = CONFIG_BOOLEAN_NO; + def_util = CONFIG_BOOLEAN_NO; + def_iotime = CONFIG_BOOLEAN_NO; + def_await = CONFIG_BOOLEAN_NO; + def_avagsz = CONFIG_BOOLEAN_NO; + def_svctm = CONFIG_BOOLEAN_NO; + } - rrddim_add(st, "operations", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE); + iter_io = config_get_boolean_ondemand(var_name, "bandwidth", def_io); + iter_ops = config_get_boolean_ondemand(var_name, "operations", def_ops); + iter_qops = config_get_boolean_ondemand(var_name, "queued operations", def_qops); + iter_util = config_get_boolean_ondemand(var_name, "utilization percentage", def_util); + iter_iotime = config_get_boolean_ondemand(var_name, "i/o time", def_iotime); + iter_await = config_get_boolean_ondemand(var_name, "average completed i/o time", def_await); + iter_avagsz = config_get_boolean_ondemand(var_name, "average completed i/o bandwidth", + def_avagsz); + iter_svctm = config_get_boolean_ondemand(var_name, "average service time", def_svctm); + + struct disks_metadata dmp = { + .do_io = iter_io, + .do_ops = iter_ops, + .do_qops = iter_qops, + .do_util = iter_util, + .do_iotime = iter_iotime, + .do_await = iter_await, + .do_avagsz = iter_avagsz, + .do_svctm = iter_svctm, + + .st_io = NULL, + .rd_io_in = NULL, + .rd_io_out = NULL, + + .st_ops = NULL, + .rd_ops_in = NULL, + .rd_ops_out = NULL, + + .st_qops = NULL, + .rd_qops = NULL, + + .st_util = NULL, + .rd_util = NULL, + + .st_iotime = NULL, + .rd_iotime_in = NULL, + .rd_iotime_out = NULL, + + .st_await = NULL, + .rd_await_in = NULL, + .rd_await_out = NULL, + + .st_avagsz = NULL, + .rd_avagsz_in = NULL, + .rd_avagsz_out = NULL, + + .st_svctm = NULL, + .rd_svctm = NULL, + }; + + // initialise data for differential charts + + dmp.prev_dstat.bytes_read = dstat[i].bytes[DEVSTAT_READ]; + dmp.prev_dstat.bytes_write = dstat[i].bytes[DEVSTAT_WRITE]; + dmp.prev_dstat.operations_read = dstat[i].operations[DEVSTAT_READ]; + dmp.prev_dstat.operations_write = dstat[i].operations[DEVSTAT_WRITE]; + dmp.prev_dstat.duration_read_ms = dstat[i].duration[DEVSTAT_READ].sec * 1000 + + dstat[i].duration[DEVSTAT_READ].frac * BINTIME_SCALE; + dmp.prev_dstat.duration_write_ms = dstat[i].duration[DEVSTAT_WRITE].sec * 1000 + + dstat[i].duration[DEVSTAT_READ].frac * BINTIME_SCALE; + dmp.prev_dstat.busy_time_ms = dstat[i].busy_time.sec * 1000 + + dstat[i].busy_time.frac * BINTIME_SCALE; + + dm = dictionary_set(disks, disk, &dmp, sizeof(struct disks_metadata)); } - else rrdset_next(st); - rrddim_set(st, "operations", dstat[i].start_count - dstat[i].end_count); - rrdset_done(st); + cur_dstat.duration_read_ms = dstat[i].duration[DEVSTAT_READ].sec * 1000 + + dstat[i].duration[DEVSTAT_READ].frac * BINTIME_SCALE; + cur_dstat.duration_write_ms = dstat[i].duration[DEVSTAT_WRITE].sec * 1000 + + dstat[i].duration[DEVSTAT_READ].frac * BINTIME_SCALE; + cur_dstat.busy_time_ms = dstat[i].busy_time.sec * 1000 + dstat[i].busy_time.frac * BINTIME_SCALE; // -------------------------------------------------------------------- - st = rrdset_find_bytype_localhost("disk_util", disk); - if (unlikely(!st)) { - st = rrdset_create_localhost("disk_util", disk, NULL, disk, "disk.util", "Disk Utilization Time", "% of time working", 2004, update_every, RRDSET_TYPE_AREA); - rrdset_flag_set(st, RRDSET_FLAG_DETAIL); + if(dm->do_io == CONFIG_BOOLEAN_YES || (dm->do_io == CONFIG_BOOLEAN_AUTO && + (dstat[i].bytes[DEVSTAT_READ] || dstat[i].bytes[DEVSTAT_WRITE]))) { + if (unlikely(!dm->st_io)) { + dm->st_io = rrdset_create_localhost("disk", + disk, + NULL, + disk, + "disk.io", + "Disk I/O Bandwidth", + "kilobytes/s", + 2000, + update_every, + RRDSET_TYPE_AREA + ); - rrddim_add(st, "utilization", NULL, 1, 10, RRD_ALGORITHM_INCREMENTAL); + dm->rd_io_in = rrddim_add(dm->st_io, "reads", NULL, 1, KILO_FACTOR, + RRD_ALGORITHM_INCREMENTAL); + dm->rd_io_out = rrddim_add(dm->st_io, "writes", NULL, -1, KILO_FACTOR, + RRD_ALGORITHM_INCREMENTAL); + } else + rrdset_next(dm->st_io); + + rrddim_set_by_pointer(dm->st_io, dm->rd_io_in, dstat[i].bytes[DEVSTAT_READ]); + rrddim_set_by_pointer(dm->st_io, dm->rd_io_out, dstat[i].bytes[DEVSTAT_WRITE]); + rrdset_done(dm->st_io); } - else rrdset_next(st); - cur_dstat.busy_time_ms = dstat[i].busy_time.sec * 1000 + dstat[i].busy_time.frac * BINTIME_SCALE; - prev_dstat.busy_time_ms = rrddim_set(st, "utilization", cur_dstat.busy_time_ms); - rrdset_done(st); + // -------------------------------------------------------------------- + + if(dm->do_ops == CONFIG_BOOLEAN_YES || (dm->do_ops == CONFIG_BOOLEAN_AUTO && + (dstat[i].operations[DEVSTAT_READ] || dstat[i].operations[DEVSTAT_WRITE]))) { + if (unlikely(!dm->st_ops)) { + dm->st_ops = rrdset_create_localhost("disk_ops", + disk, + NULL, + disk, + "disk.ops", + "Disk Completed I/O Operations", + "operations/s", + 2001, + update_every, + RRDSET_TYPE_LINE + ); + + rrdset_flag_set(dm->st_ops, RRDSET_FLAG_DETAIL); + + dm->rd_ops_in = rrddim_add(dm->st_ops, "reads", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); + dm->rd_ops_out = rrddim_add(dm->st_ops, "writes", NULL, -1, 1, + RRD_ALGORITHM_INCREMENTAL); + } else + rrdset_next(dm->st_ops); + + rrddim_set_by_pointer(dm->st_ops, dm->rd_ops_in, dstat[i].operations[DEVSTAT_READ]); + rrddim_set_by_pointer(dm->st_ops, dm->rd_ops_out, dstat[i].operations[DEVSTAT_WRITE]); + rrdset_done(dm->st_ops); + } + + // -------------------------------------------------------------------- + + if(dm->do_qops == CONFIG_BOOLEAN_YES || (dm->do_qops == CONFIG_BOOLEAN_AUTO && + (dstat[i].start_count || dstat[i].end_count))) { + if (unlikely(!dm->st_qops)) { + dm->st_qops = rrdset_create_localhost("disk_qops", + disk, + NULL, + disk, + "disk.qops", + "Disk Current I/O Operations", + "operations", + 2002, + update_every, + RRDSET_TYPE_LINE + ); + + rrdset_flag_set(dm->st_qops, RRDSET_FLAG_DETAIL); + + dm->rd_qops = rrddim_add(dm->st_qops, "operations", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE); + } else + rrdset_next(dm->st_qops); + + rrddim_set_by_pointer(dm->st_qops, dm->rd_qops, dstat[i].start_count - dstat[i].end_count); + rrdset_done(dm->st_qops); + } // -------------------------------------------------------------------- - st = rrdset_find_bytype_localhost("disk_iotime", disk); - if (unlikely(!st)) { - st = rrdset_create_localhost("disk_iotime", disk, NULL, disk, "disk.iotime", "Disk Total I/O Time", "milliseconds/s", 2022, update_every, RRDSET_TYPE_LINE); - rrdset_flag_set(st, RRDSET_FLAG_DETAIL); + if(dm->do_util == CONFIG_BOOLEAN_YES || (dm->do_util == CONFIG_BOOLEAN_AUTO && + cur_dstat.busy_time_ms)) { + if (unlikely(!dm->st_util)) { + dm->st_util = rrdset_create_localhost("disk_util", + disk, + NULL, + disk, + "disk.util", + "Disk Utilization Time", + "% of time working", + 2004, + update_every, + RRDSET_TYPE_AREA + ); + + rrdset_flag_set(dm->st_util, RRDSET_FLAG_DETAIL); + + dm->rd_util = rrddim_add(dm->st_util, "utilization", NULL, 1, 10, + RRD_ALGORITHM_INCREMENTAL); + } else + rrdset_next(dm->st_util); - rrddim_add(st, "reads", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); - rrddim_add(st, "writes", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); + rrddim_set_by_pointer(dm->st_util, dm->rd_util, cur_dstat.busy_time_ms); + rrdset_done(dm->st_util); } - else rrdset_next(st); - cur_dstat.duration_read_ms = dstat[i].duration[DEVSTAT_READ].sec * 1000 + dstat[i].duration[DEVSTAT_READ].frac * BINTIME_SCALE; - cur_dstat.duration_write_ms = dstat[i].duration[DEVSTAT_WRITE].sec * 1000 + dstat[i].duration[DEVSTAT_READ].frac * BINTIME_SCALE; - prev_dstat.duration_read_ms = rrddim_set(st, "reads", cur_dstat.duration_read_ms); - prev_dstat.duration_write_ms = rrddim_set(st, "writes", cur_dstat.duration_write_ms); - rrdset_done(st); + // -------------------------------------------------------------------- + + if(dm->do_iotime == CONFIG_BOOLEAN_YES || (dm->do_iotime == CONFIG_BOOLEAN_AUTO && + (cur_dstat.duration_read_ms || cur_dstat.duration_write_ms))) { + if (unlikely(!dm->st_iotime)) { + dm->st_iotime = rrdset_create_localhost("disk_iotime", + disk, + NULL, + disk, + "disk.iotime", + "Disk Total I/O Time", + "milliseconds/s", + 2022, + update_every, + RRDSET_TYPE_LINE + ); + + rrdset_flag_set(dm->st_iotime, RRDSET_FLAG_DETAIL); + + dm->rd_iotime_in = rrddim_add(dm->st_iotime, "reads", NULL, 1, 1, + RRD_ALGORITHM_INCREMENTAL); + dm->rd_iotime_out = rrddim_add(dm->st_iotime, "writes", NULL, -1, 1, + RRD_ALGORITHM_INCREMENTAL); + } else + rrdset_next(dm->st_iotime); + + rrddim_set_by_pointer(dm->st_iotime, dm->rd_iotime_in, cur_dstat.duration_read_ms); + rrddim_set_by_pointer(dm->st_iotime, dm->rd_iotime_out, cur_dstat.duration_write_ms); + rrdset_done(dm->st_iotime); + } // -------------------------------------------------------------------- // calculate differential charts @@ -3466,73 +3776,192 @@ int do_kern_devstat(int update_every, usec_t dt) { // -------------------------------------------------------------------- - st = rrdset_find_bytype_localhost("disk_await", disk); - if (unlikely(!st)) { - st = rrdset_create_localhost("disk_await", disk, NULL, disk, "disk.await", "Average Completed I/O Operation Time", "ms per operation", 2005, update_every, RRDSET_TYPE_LINE); - rrdset_flag_set(st, RRDSET_FLAG_DETAIL); - - rrddim_add(st, "reads", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE); - rrddim_add(st, "writes", NULL, -1, 1, RRD_ALGORITHM_ABSOLUTE); + if(dm->do_await == CONFIG_BOOLEAN_YES || (dm->do_await == CONFIG_BOOLEAN_AUTO && + (dstat[i].operations[DEVSTAT_READ] || dstat[i].operations[DEVSTAT_WRITE]))) { + if (unlikely(!dm->st_await)) { + dm->st_await = rrdset_create_localhost("disk_await", + disk, + NULL, + disk, + "disk.await", + "Average Completed I/O Operation Time", + "ms per operation", + 2005, + update_every, + RRDSET_TYPE_LINE + ); + + rrdset_flag_set(dm->st_await, RRDSET_FLAG_DETAIL); + + dm->rd_await_in = rrddim_add(dm->st_await, "reads", NULL, 1, 1, + RRD_ALGORITHM_ABSOLUTE); + dm->rd_await_out = rrddim_add(dm->st_await, "writes", NULL, -1, 1, + RRD_ALGORITHM_ABSOLUTE); + } else + rrdset_next(dm->st_await); + + rrddim_set_by_pointer(dm->st_await, dm->rd_await_in, + (dstat[i].operations[DEVSTAT_READ] - + dm->prev_dstat.operations_read) ? + (cur_dstat.duration_read_ms - dm->prev_dstat.duration_read_ms) / + (dstat[i].operations[DEVSTAT_READ] - + dm->prev_dstat.operations_read) : + 0); + rrddim_set_by_pointer(dm->st_await, dm->rd_await_out, + (dstat[i].operations[DEVSTAT_WRITE] - + dm->prev_dstat.operations_write) ? + (cur_dstat.duration_write_ms - dm->prev_dstat.duration_write_ms) / + (dstat[i].operations[DEVSTAT_WRITE] - + dm->prev_dstat.operations_write) : + 0); + rrdset_done(dm->st_await); } - else rrdset_next(st); - - rrddim_set(st, "reads", (dstat[i].operations[DEVSTAT_READ] - prev_dstat.operations_read) ? - (cur_dstat.duration_read_ms - prev_dstat.duration_read_ms) / (dstat[i].operations[DEVSTAT_READ] - prev_dstat.operations_read) : 0); - rrddim_set(st, "writes", (dstat[i].operations[DEVSTAT_WRITE] - prev_dstat.operations_write) ? - (cur_dstat.duration_write_ms - prev_dstat.duration_write_ms) / (dstat[i].operations[DEVSTAT_WRITE] - prev_dstat.operations_write) : 0); - rrdset_done(st); // -------------------------------------------------------------------- - st = rrdset_find_bytype_localhost("disk_avgsz", disk); - if (unlikely(!st)) { - st = rrdset_create_localhost("disk_avgsz", disk, NULL, disk, "disk.avgsz", "Average Completed I/O Operation Bandwidth", "kilobytes per operation", 2006, update_every, RRDSET_TYPE_AREA); - rrdset_flag_set(st, RRDSET_FLAG_DETAIL); - - rrddim_add(st, "reads", NULL, 1, 1024, RRD_ALGORITHM_ABSOLUTE); - rrddim_add(st, "writes", NULL, -1, 1024, RRD_ALGORITHM_ABSOLUTE); + if(dm->do_avagsz == CONFIG_BOOLEAN_YES || (dm->do_avagsz == CONFIG_BOOLEAN_AUTO && + (dstat[i].operations[DEVSTAT_READ] || dstat[i].operations[DEVSTAT_WRITE]))) { + if (unlikely(!dm->st_avagsz)) { + dm->st_avagsz = rrdset_create_localhost("disk_avgsz", + disk, + NULL, + disk, + "disk.avgsz", + "Average Completed I/O Operation Bandwidth", + "kilobytes per operation", + 2006, + update_every, + RRDSET_TYPE_AREA + ); + + rrdset_flag_set(dm->st_avagsz, RRDSET_FLAG_DETAIL); + + dm->rd_avagsz_in = rrddim_add(dm->st_avagsz, "reads", NULL, 1, KILO_FACTOR, + RRD_ALGORITHM_ABSOLUTE); + dm->rd_avagsz_out = rrddim_add(dm->st_avagsz, "writes", NULL, -1, KILO_FACTOR, + RRD_ALGORITHM_ABSOLUTE); + } else + rrdset_next(dm->st_avagsz); + + rrddim_set_by_pointer(dm->st_avagsz, dm->rd_avagsz_in, + (dstat[i].operations[DEVSTAT_READ] - + dm->prev_dstat.operations_read) ? + (dstat[i].bytes[DEVSTAT_READ] - dm->prev_dstat.bytes_read) / + (dstat[i].operations[DEVSTAT_READ] - + dm->prev_dstat.operations_read) : + 0); + rrddim_set_by_pointer(dm->st_avagsz, dm->rd_avagsz_out, + (dstat[i].operations[DEVSTAT_WRITE] - + dm->prev_dstat.operations_write) ? + (dstat[i].bytes[DEVSTAT_WRITE] - dm->prev_dstat.bytes_write) / + (dstat[i].operations[DEVSTAT_WRITE] - + dm->prev_dstat.operations_write) : + 0); + rrdset_done(dm->st_avagsz); } - else rrdset_next(st); - - rrddim_set(st, "reads", (dstat[i].operations[DEVSTAT_READ] - prev_dstat.operations_read) ? - (dstat[i].bytes[DEVSTAT_READ] - prev_dstat.bytes_read) / (dstat[i].operations[DEVSTAT_READ] - prev_dstat.operations_read) : 0); - rrddim_set(st, "writes", (dstat[i].operations[DEVSTAT_WRITE] - prev_dstat.operations_write) ? - (dstat[i].bytes[DEVSTAT_WRITE] - prev_dstat.bytes_write) / (dstat[i].operations[DEVSTAT_WRITE] - prev_dstat.operations_write) : 0); - rrdset_done(st); // -------------------------------------------------------------------- - st = rrdset_find_bytype_localhost("disk_svctm", disk); - if (unlikely(!st)) { - st = rrdset_create_localhost("disk_svctm", disk, NULL, disk, "disk.svctm", "Average Service Time", "ms per operation", 2007, update_every, RRDSET_TYPE_LINE); - rrdset_flag_set(st, RRDSET_FLAG_DETAIL); - - rrddim_add(st, "svctm", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE); + if(dm->do_svctm == CONFIG_BOOLEAN_YES || (dm->do_svctm == CONFIG_BOOLEAN_AUTO && + (dstat[i].operations[DEVSTAT_READ] || dstat[i].operations[DEVSTAT_WRITE]))) { + if (unlikely(!dm->st_svctm)) { + dm->st_svctm = rrdset_create_localhost("disk_svctm", + disk, + NULL, + disk, + "disk.svctm", + "Average Service Time", + "ms per operation", + 2007, + update_every, + RRDSET_TYPE_LINE + ); + + rrdset_flag_set(dm->st_svctm, RRDSET_FLAG_DETAIL); + + dm->rd_svctm = rrddim_add(dm->st_svctm, "svctm", NULL, 1, 1, + RRD_ALGORITHM_ABSOLUTE); + } else + rrdset_next(dm->st_svctm); + + rrddim_set_by_pointer(dm->st_svctm, dm->rd_svctm, + ((dstat[i].operations[DEVSTAT_READ] - dm->prev_dstat.operations_read) + + (dstat[i].operations[DEVSTAT_WRITE] - dm->prev_dstat.operations_write)) ? + (cur_dstat.busy_time_ms - dm->prev_dstat.busy_time_ms) / + ((dstat[i].operations[DEVSTAT_READ] - dm->prev_dstat.operations_read) + + (dstat[i].operations[DEVSTAT_WRITE] - dm->prev_dstat.operations_write)) : + 0); + rrdset_done(dm->st_svctm); } - else rrdset_next(st); - rrddim_set(st, "svctm", ((dstat[i].operations[DEVSTAT_READ] - prev_dstat.operations_read) + (dstat[i].operations[DEVSTAT_WRITE] - prev_dstat.operations_write)) ? - (cur_dstat.busy_time_ms - prev_dstat.busy_time_ms) / ((dstat[i].operations[DEVSTAT_READ] - prev_dstat.operations_read) + (dstat[i].operations[DEVSTAT_WRITE] - prev_dstat.operations_write)) : 0); - rrdset_done(st); + // -------------------------------------------------------------------- + + dm->prev_dstat.bytes_read = dstat[i].bytes[DEVSTAT_READ]; + dm->prev_dstat.bytes_write = dstat[i].bytes[DEVSTAT_WRITE]; + dm->prev_dstat.operations_read = dstat[i].operations[DEVSTAT_READ]; + dm->prev_dstat.operations_write = dstat[i].operations[DEVSTAT_WRITE]; + dm->prev_dstat.duration_read_ms = cur_dstat.duration_read_ms; + dm->prev_dstat.duration_write_ms = cur_dstat.duration_write_ms; + dm->prev_dstat.busy_time_ms = cur_dstat.busy_time_ms; } } } // -------------------------------------------------------------------- - st = rrdset_find_bytype_localhost("system", "io"); - if (unlikely(!st)) { - st = rrdset_create_localhost("system", "io", NULL, "disk", NULL, "Disk I/O", "kilobytes/s", 150, update_every, RRDSET_TYPE_AREA); - rrddim_add(st, "in", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); - rrddim_add(st, "out", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); - } - else rrdset_next(st); + if (likely(do_system_io)) { + static RRDSET *st = NULL; + static RRDDIM *rd_in = NULL, *rd_out = NULL; + + if (unlikely(!st)) { + st = rrdset_create_localhost("system", + "io", + NULL, + "disk", + NULL, + "Disk I/O", + "kilobytes/s", + 150, + update_every, + RRDSET_TYPE_AREA + ); - rrddim_set(st, "in", total_disk_kbytes_read); - rrddim_set(st, "out", total_disk_kbytes_write); - rrdset_done(st); + rd_in = rrddim_add(st, "in", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL); + rd_out = rrddim_add(st, "out", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL); + } else + rrdset_next(st); + + rrddim_set_by_pointer(st, rd_in, total_disk_kbytes_read); + rrddim_set_by_pointer(st, rd_out, total_disk_kbytes_write); + rrdset_done(st); + } } } + if (unlikely(common_error)) { + do_system_io = 0; + error("DISABLED: system.io chart"); + do_io = 0; + error("DISABLED: disk.* charts"); + do_ops = 0; + error("DISABLED: disk_ops.* charts"); + do_qops = 0; + error("DISABLED: disk_qops.* charts"); + do_util = 0; + error("DISABLED: disk_util.* charts"); + do_iotime = 0; + error("DISABLED: disk_iotime.* charts"); + do_await = 0; + error("DISABLED: disk_await.* charts"); + do_avagsz = 0; + error("DISABLED: disk_avgsz.* charts"); + do_svctm = 0; + error("DISABLED: disk_svctm.* charts"); + error("DISABLED: kern.devstat module"); + return 1; + } + } else { + error("DISABLED: kern.devstat module"); + return 1; } return 0;