X-Git-Url: https://arthur.barton.de/gitweb/?p=netdata.git;a=blobdiff_plain;f=src%2Ffreebsd_sysctl.c;h=8fc851481ea292b326c7488b85d40693533b3661;hp=174be91f69851a3187128ac4447addcb2e7e26bf;hb=ed8dc0b42705e8bce0d7f37f003c1fef6821c39f;hpb=8af280907530e1bcfffd4c8ed38fb311de64f0ab diff --git a/src/freebsd_sysctl.c b/src/freebsd_sysctl.c index 174be91f..8fc85148 100644 --- a/src/freebsd_sysctl.c +++ b/src/freebsd_sysctl.c @@ -326,8 +326,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)) { @@ -375,7 +380,7 @@ int do_kern_cp_times(int update_every, usec_t dt) { int do_hw_intcnt(int update_every, usec_t dt) { static int mib_hw_intrcnt[2] = {0, 0}; - size_t intrcnt_size; + size_t intrcnt_size = sizeof(mib_hw_intrcnt); int i; if (unlikely(GETSYSCTL_SIZE("hw.intrcnt", mib_hw_intrcnt, intrcnt_size))) { @@ -1236,7 +1241,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; @@ -1277,7 +1282,7 @@ int do_net_isr(int update_every, usec_t dt) { return 1; } else { 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) { @@ -1344,8 +1349,13 @@ 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; - 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); @@ -3458,7 +3468,7 @@ int do_kern_devstat(int update_every, usec_t dt) { dstat = devstat_data + sizeof(long); // skip generation number for (i = 0; i < numdevs; i++) { - if (unlikely(!do_system_io)) { + 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; @@ -3466,7 +3476,7 @@ int do_kern_devstat(int update_every, usec_t dt) { } if (unlikely(!enable_pass_devices)) - if (dstat[i].device_type & DEVSTAT_TYPE_PASS == DEVSTAT_TYPE_PASS) + 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)) { @@ -3864,11 +3874,10 @@ int do_kern_devstat(int update_every, usec_t dt) { // -------------------------------------------------------------------- - if (unlikely(!do_system_io)) { + if (likely(do_system_io)) { static RRDSET *st = NULL; static RRDDIM *rd_in = NULL, *rd_out = NULL; - st = rrdset_find_bytype_localhost("system", "io"); if (unlikely(!st)) { st = rrdset_create_localhost("system", "io",