diff options
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | README.md | 8 | ||||
-rw-r--r-- | main.c | 2 | ||||
-rw-r--r-- | netdev.c (renamed from network.c) | 24 | ||||
-rw-r--r-- | test/Makefile | 2 | ||||
-rw-r--r-- | test/netdev_test.c (renamed from test/network_test.c) | 10 |
6 files changed, 24 insertions, 24 deletions
diff --git a/Makefile b/Makefile index 84c9068..c4b0fc6 100644 --- a/Makefile +++ b/Makefile @@ -20,7 +20,7 @@ COLLECTORS += diskstats COLLECTORS += filesystem COLLECTORS += hwmon COLLECTORS += meminfo -COLLECTORS += network +COLLECTORS += netdev COLLECTORS += stat COLLECTORS += textfile COLLECTORS += uname diff --git a/README.md b/README.md index 801fcef..297972c 100644 --- a/README.md +++ b/README.md @@ -82,7 +82,7 @@ including generated metrics, labels and configuration options. | [`filesystem`](#filesystem) | Statistics of mounted filesystems from `statvfs(2)`. | | [`hwmon`](#hwmon) | Temperature, fan and voltage sensors from `/sys/class/hwmon`. | | [`meminfo`](#meminfo) | Memory usage statistics from `/proc/meminfo`. | -| [`network`](#network) | Network device transmit/receive statistics from `/proc/net/dev`. | +| [`netdev`](#netdev) | Network device transmit/receive statistics from `/proc/net/dev`. | | [`stat`](#stat) | Basic statistics from `/proc/stat`. | | [`textfile`](#textfile) | Custom metrics from `.prom` text files dropped in a directory. | | [`uname`](#uname) | Node information returned by the `uname` system call. | @@ -256,7 +256,7 @@ If the line in `/proc/meminfo` has a `kB` suffix, the suffix `_bytes` is also appended to the metric name, and the value multiplied by 1024 to convert it to bytes. -### `network` +### `netdev` Metrics and labels: @@ -282,8 +282,8 @@ included in your `/proc/net/dev` file. A normal set is: | | X | `carrier` | ? | By default, statistics are reported for all network interfaces except -the loopback interface (`lo`). The `--network-include=` and -`--network-exclude=` options can be used to define a comma-separated +the loopback interface (`lo`). The `--netdev-include=` and +`--netdev-exclude=` options can be used to define a comma-separated list of interface names to explicitly include and exclude, respectively. If an include list is set, only those interfaces are included. Otherwise, all interfaces *not* mentioned in the exclude diff --git a/main.c b/main.c index ee20463..43a0917 100644 --- a/main.c +++ b/main.c @@ -32,7 +32,7 @@ #ifndef XCOLLECTORS #define XCOLLECTORS \ X(cpu) X(diskstats) X(filesystem) X(hwmon) \ - X(meminfo) X(network) X(stat) X(textfile) X(uname) + X(meminfo) X(netdev) X(stat) X(textfile) X(uname) #endif #define X(c) extern const struct collector c##_collector; diff --git a/network.c b/netdev.c index 21ff063..b8f20b6 100644 --- a/network.c +++ b/netdev.c @@ -32,24 +32,24 @@ // default list of interfaces to exclude #define DEFAULT_EXCLUDE "lo" -static void *network_init(int argc, char *argv[]); -static void network_collect(scrape_req *req, void *ctx); +static void *netdev_init(int argc, char *argv[]); +static void netdev_collect(scrape_req *req, void *ctx); -const struct collector network_collector = { - .name = "network", - .collect = network_collect, - .init = network_init, +const struct collector netdev_collector = { + .name = "netdev", + .collect = netdev_collect, + .init = netdev_init, .has_args = true, }; -struct network_context { +struct netdev_context { size_t ncolumns; char *columns[MAX_COLUMNS]; struct slist *include; struct slist *exclude; }; -static void *network_init(int argc, char *argv[]) { +static void *netdev_init(int argc, char *argv[]) { // parse header from /proc/net/dev and prepare metric names FILE *f = fopen(PATH("/proc/net/dev"), "r"); @@ -82,7 +82,7 @@ static void *network_init(int argc, char *argv[]) { return 0; } - struct network_context *ctx = malloc(sizeof *ctx); + struct netdev_context *ctx = malloc(sizeof *ctx); if (!ctx) { perror("malloc"); return 0; @@ -128,7 +128,7 @@ static void *network_init(int argc, char *argv[]) { continue; } - fprintf(stderr, "unknown argument for network collector: %s\n", argv[arg]); + fprintf(stderr, "unknown argument for netdev collector: %s\n", argv[arg]); goto cleanup; } @@ -144,8 +144,8 @@ cleanup: return 0; } -static void network_collect(scrape_req *req, void *ctx_ptr) { - struct network_context *ctx = ctx_ptr; +static void netdev_collect(scrape_req *req, void *ctx_ptr) { + struct netdev_context *ctx = ctx_ptr; // buffers diff --git a/test/Makefile b/test/Makefile index 872cfe7..c2bd981 100644 --- a/test/Makefile +++ b/test/Makefile @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -COLLECTOR_TESTS := cpu diskstats filesystem hwmon meminfo network stat textfile uname +COLLECTOR_TESTS := cpu diskstats filesystem hwmon meminfo netdev stat textfile uname COLLECTOR_TEST_PROGS := $(foreach c,$(COLLECTOR_TESTS),$(c)_test) COLLECTOR_TEST_OBJS := $(foreach p,$(COLLECTOR_TEST_PROGS),$(p).o) diff --git a/test/network_test.c b/test/netdev_test.c index 841604c..5db1da6 100644 --- a/test/network_test.c +++ b/test/netdev_test.c @@ -18,9 +18,9 @@ #include "mock_scrape.h" #include "../collector.h" -extern const struct collector network_collector; +extern const struct collector netdev_collector; -TEST(network_metrics) { +TEST(netdev_metrics) { test_write_file( env, "proc/net/dev", @@ -30,8 +30,8 @@ TEST(network_metrics) { " eno1: 12345 1234 12 23 34 45 56 67 98765 9876 98 87 76 65 54 43\n"); scrape_req *req = mock_scrape_start(env); - void *ctx = network_collector.init(0, 0); - network_collector.collect(req, ctx); + void *ctx = netdev_collector.init(0, 0); + netdev_collector.collect(req, ctx); struct label *labels; labels = LABEL_LIST({"device", "eno1"}); @@ -57,6 +57,6 @@ TEST(network_metrics) { TEST_SUITE { TEST_SUITE_START; - RUN_TEST(network_metrics); + RUN_TEST(netdev_metrics); TEST_SUITE_END; } |