X-Git-Url: https://arthur.barton.de/gitweb/?a=blobdiff_plain;f=src%2Fproc_net_dev.c;h=bb1e4c0fac1b387e075da17b918a2be1865a4d98;hb=577dbe94496479256311a8c84909c36123b7a406;hp=f37e2fe4abcfc64181b9af7a2626f7e8a73246d2;hpb=d7a1f3c8494e0546fc4c31d22b390a87ea9bd21a;p=netdata.git diff --git a/src/proc_net_dev.c b/src/proc_net_dev.c index f37e2fe4..bb1e4c0f 100644 --- a/src/proc_net_dev.c +++ b/src/proc_net_dev.c @@ -18,23 +18,23 @@ struct netdev { int do_events; // data collected - unsigned long long rbytes; - unsigned long long rpackets; - unsigned long long rerrors; - unsigned long long rdrops; - unsigned long long rfifo; - unsigned long long rframe; - unsigned long long rcompressed; - unsigned long long rmulticast; - - unsigned long long tbytes; - unsigned long long tpackets; - unsigned long long terrors; - unsigned long long tdrops; - unsigned long long tfifo; - unsigned long long tcollisions; - unsigned long long tcarrier; - unsigned long long tcompressed; + kernel_uint_t rbytes; + kernel_uint_t rpackets; + kernel_uint_t rerrors; + kernel_uint_t rdrops; + kernel_uint_t rfifo; + kernel_uint_t rframe; + kernel_uint_t rcompressed; + kernel_uint_t rmulticast; + + kernel_uint_t tbytes; + kernel_uint_t tpackets; + kernel_uint_t terrors; + kernel_uint_t tdrops; + kernel_uint_t tfifo; + kernel_uint_t tcollisions; + kernel_uint_t tcarrier; + kernel_uint_t tcompressed; // charts RRDSET *st_bandwidth; @@ -111,7 +111,6 @@ static struct netdev *get_netdev(const char *name) { int do_proc_net_dev(int update_every, usec_t dt) { (void)dt; - static SIMPLE_PATTERN *disabled_list = NULL; static procfile *ff = NULL; static int enable_new_interfaces = -1; @@ -135,7 +134,7 @@ int do_proc_net_dev(int update_every, usec_t dt) { if(unlikely(!ff)) { char filename[FILENAME_MAX + 1]; - snprintfz(filename, FILENAME_MAX, "%s%s", global_host_prefix, "/proc/net/dev"); + snprintfz(filename, FILENAME_MAX, "%s%s", netdata_configured_host_prefix, "/proc/net/dev"); ff = procfile_open(config_get("plugin:proc:/proc/net/dev", "filename to monitor", filename), " \t,:|", PROCFILE_FLAG_DEFAULT); if(unlikely(!ff)) return 1; } @@ -143,7 +142,7 @@ int do_proc_net_dev(int update_every, usec_t dt) { ff = procfile_readall(ff); if(unlikely(!ff)) return 0; // we return 0, so that we will retry to open it next time - uint32_t lines = procfile_lines(ff), l; + size_t lines = procfile_lines(ff), l; for(l = 2; l < lines ;l++) { // require 17 words on each line if(unlikely(procfile_linewords(ff, l) < 17)) continue; @@ -168,35 +167,54 @@ int do_proc_net_dev(int update_every, usec_t dt) { if(d->enabled == CONFIG_ONDEMAND_NO) continue; - d->do_bandwidth = config_get_boolean_ondemand(var_name, "bandwidth", do_bandwidth); - d->do_packets = config_get_boolean_ondemand(var_name, "packets", do_packets); - d->do_errors = config_get_boolean_ondemand(var_name, "errors", do_errors); - d->do_drops = config_get_boolean_ondemand(var_name, "drops", do_drops); - d->do_fifo = config_get_boolean_ondemand(var_name, "fifo", do_fifo); + d->do_bandwidth = config_get_boolean_ondemand(var_name, "bandwidth", do_bandwidth); + d->do_packets = config_get_boolean_ondemand(var_name, "packets", do_packets); + d->do_errors = config_get_boolean_ondemand(var_name, "errors", do_errors); + d->do_drops = config_get_boolean_ondemand(var_name, "drops", do_drops); + d->do_fifo = config_get_boolean_ondemand(var_name, "fifo", do_fifo); d->do_compressed = config_get_boolean_ondemand(var_name, "compressed", do_compressed); - d->do_events = config_get_boolean_ondemand(var_name, "events", do_events); + d->do_events = config_get_boolean_ondemand(var_name, "events", do_events); } if(unlikely(!d->enabled)) continue; - d->rbytes = str2ull(procfile_lineword(ff, l, 1)); - d->rpackets = str2ull(procfile_lineword(ff, l, 2)); - d->rerrors = str2ull(procfile_lineword(ff, l, 3)); - d->rdrops = str2ull(procfile_lineword(ff, l, 4)); - d->rfifo = str2ull(procfile_lineword(ff, l, 5)); - d->rframe = str2ull(procfile_lineword(ff, l, 6)); - d->rcompressed = str2ull(procfile_lineword(ff, l, 7)); - d->rmulticast = str2ull(procfile_lineword(ff, l, 8)); - - d->tbytes = str2ull(procfile_lineword(ff, l, 9)); - d->tpackets = str2ull(procfile_lineword(ff, l, 10)); - d->terrors = str2ull(procfile_lineword(ff, l, 11)); - d->tdrops = str2ull(procfile_lineword(ff, l, 12)); - d->tfifo = str2ull(procfile_lineword(ff, l, 13)); - d->tcollisions = str2ull(procfile_lineword(ff, l, 14)); - d->tcarrier = str2ull(procfile_lineword(ff, l, 15)); - d->tcompressed = str2ull(procfile_lineword(ff, l, 16)); + if(likely(d->do_bandwidth != CONFIG_ONDEMAND_NO)) { + d->rbytes = str2kernel_uint_t(procfile_lineword(ff, l, 1)); + d->tbytes = str2kernel_uint_t(procfile_lineword(ff, l, 9)); + } + + if(likely(d->do_packets != CONFIG_ONDEMAND_NO)) { + d->rpackets = str2kernel_uint_t(procfile_lineword(ff, l, 2)); + d->rmulticast = str2kernel_uint_t(procfile_lineword(ff, l, 8)); + d->tpackets = str2kernel_uint_t(procfile_lineword(ff, l, 10)); + } + + if(likely(d->do_errors != CONFIG_ONDEMAND_NO)) { + d->rerrors = str2kernel_uint_t(procfile_lineword(ff, l, 3)); + d->terrors = str2kernel_uint_t(procfile_lineword(ff, l, 11)); + } + + if(likely(d->do_drops != CONFIG_ONDEMAND_NO)) { + d->rdrops = str2kernel_uint_t(procfile_lineword(ff, l, 4)); + d->tdrops = str2kernel_uint_t(procfile_lineword(ff, l, 12)); + } + + if(likely(d->do_fifo != CONFIG_ONDEMAND_NO)) { + d->rfifo = str2kernel_uint_t(procfile_lineword(ff, l, 5)); + d->tfifo = str2kernel_uint_t(procfile_lineword(ff, l, 13)); + } + + if(likely(d->do_compressed != CONFIG_ONDEMAND_NO)) { + d->rcompressed = str2kernel_uint_t(procfile_lineword(ff, l, 7)); + d->tcompressed = str2kernel_uint_t(procfile_lineword(ff, l, 16)); + } + + if(likely(d->do_events != CONFIG_ONDEMAND_NO)) { + d->rframe = str2kernel_uint_t(procfile_lineword(ff, l, 6)); + d->tcollisions = str2kernel_uint_t(procfile_lineword(ff, l, 14)); + d->tcarrier = str2kernel_uint_t(procfile_lineword(ff, l, 15)); + } // --------------------------------------------------------------------