]> arthur.barton.de Git - netdata.git/blobdiff - src/proc_net_ip_vs_stats.c
build: migrate to autotools
[netdata.git] / src / proc_net_ip_vs_stats.c
index 077569dba5dcb4e62755c81e6ecb269d4241dcfa..18114af2270da647389e64bdaafd12f056220ca8 100755 (executable)
@@ -1,8 +1,11 @@
-#include <inttypes.h>
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 #include <stdio.h>
 #include <stdlib.h>
 
-#include "config.h"
+#include "common.h"
+#include "appconfig.h"
 #include "procfile.h"
 #include "rrd.h"
 #include "plugin_proc.h"
@@ -20,7 +23,11 @@ int do_proc_net_ip_vs_stats(int update_every, unsigned long long dt) {
 
        if(dt) {};
 
-       if(!ff) ff = procfile_open("/proc/net/ip_vs_stats", " \t,:|");
+       if(!ff) {
+               char filename[FILENAME_MAX + 1];
+               snprintf(filename, FILENAME_MAX, "%s%s", global_host_prefix, "/proc/net/ip_vs_stats");
+               ff = procfile_open(config_get("plugin:proc:/proc/net/ip_vs_stats", "filename to monitor", filename), " \t,:|", PROCFILE_FLAG_DEFAULT);
+       }
        if(!ff) return 1;
 
        ff = procfile_readall(ff);
@@ -34,61 +41,61 @@ int do_proc_net_ip_vs_stats(int update_every, unsigned long long dt) {
 
        unsigned long long entries, InPackets, OutPackets, InBytes, OutBytes;
 
-       entries         = strtoull(procfile_lineword(ff, 2, 0), NULL, 10);
-       InPackets       = strtoull(procfile_lineword(ff, 2, 1), NULL, 10);
-       OutPackets      = strtoull(procfile_lineword(ff, 2, 2), NULL, 10);
-       InBytes         = strtoull(procfile_lineword(ff, 2, 3), NULL, 10);
-       OutBytes        = strtoull(procfile_lineword(ff, 2, 4), NULL, 10);
+       entries         = strtoull(procfile_lineword(ff, 2, 0), NULL, 16);
+       InPackets       = strtoull(procfile_lineword(ff, 2, 1), NULL, 16);
+       OutPackets      = strtoull(procfile_lineword(ff, 2, 2), NULL, 16);
+       InBytes         = strtoull(procfile_lineword(ff, 2, 3), NULL, 16);
+       OutBytes        = strtoull(procfile_lineword(ff, 2, 4), NULL, 16);
 
-       RRD_STATS *st;
+       RRDSET *st;
 
        // --------------------------------------------------------------------
 
        if(do_sockets) {
-               st = rrd_stats_find(RRD_TYPE_NET_IPVS ".sockets");
+               st = rrdset_find(RRD_TYPE_NET_IPVS ".sockets");
                if(!st) {
-                       st = rrd_stats_create(RRD_TYPE_NET_IPVS, "sockets", NULL, RRD_TYPE_NET_IPVS, "IPVS New Connections", "connections/s", 1001, update_every, CHART_TYPE_LINE);
+                       st = rrdset_create(RRD_TYPE_NET_IPVS, "sockets", NULL, RRD_TYPE_NET_IPVS, "IPVS New Connections", "connections/s", 1001, update_every, RRDSET_TYPE_LINE);
 
-                       rrd_stats_dimension_add(st, "connections", NULL, 1, 1 * update_every, RRD_DIMENSION_INCREMENTAL);
+                       rrddim_add(st, "connections", NULL, 1, 1 * update_every, RRDDIM_INCREMENTAL);
                }
-               else rrd_stats_next(st);
+               else rrdset_next(st);
 
-               rrd_stats_dimension_set(st, "connections", entries);
-               rrd_stats_done(st);
+               rrddim_set(st, "connections", entries);
+               rrdset_done(st);
        }
 
        // --------------------------------------------------------------------
        
        if(do_packets) {
-               st = rrd_stats_find(RRD_TYPE_NET_IPVS ".packets");
+               st = rrdset_find(RRD_TYPE_NET_IPVS ".packets");
                if(!st) {
-                       st = rrd_stats_create(RRD_TYPE_NET_IPVS, "packets", NULL, RRD_TYPE_NET_IPVS, "IPVS Packets", "packets/s", 1002, update_every, CHART_TYPE_LINE);
+                       st = rrdset_create(RRD_TYPE_NET_IPVS, "packets", NULL, RRD_TYPE_NET_IPVS, "IPVS Packets", "packets/s", 1002, update_every, RRDSET_TYPE_LINE);
 
-                       rrd_stats_dimension_add(st, "received", NULL, 1, 1 * update_every, RRD_DIMENSION_INCREMENTAL);
-                       rrd_stats_dimension_add(st, "sent", NULL, -1, 1 * update_every, RRD_DIMENSION_INCREMENTAL);
+                       rrddim_add(st, "received", NULL, 1, 1 * update_every, RRDDIM_INCREMENTAL);
+                       rrddim_add(st, "sent", NULL, -1, 1 * update_every, RRDDIM_INCREMENTAL);
                }
-               else rrd_stats_next(st);
+               else rrdset_next(st);
 
-               rrd_stats_dimension_set(st, "received", InPackets);
-               rrd_stats_dimension_set(st, "sent", OutPackets);
-               rrd_stats_done(st);
+               rrddim_set(st, "received", InPackets);
+               rrddim_set(st, "sent", OutPackets);
+               rrdset_done(st);
        }
 
        // --------------------------------------------------------------------
        
        if(do_bandwidth) {
-               st = rrd_stats_find(RRD_TYPE_NET_IPVS ".net");
+               st = rrdset_find(RRD_TYPE_NET_IPVS ".net");
                if(!st) {
-                       st = rrd_stats_create(RRD_TYPE_NET_IPVS, "net", NULL, RRD_TYPE_NET_IPVS, "IPVS Bandwidth", "kilobits/s", 1000, update_every, CHART_TYPE_AREA);
+                       st = rrdset_create(RRD_TYPE_NET_IPVS, "net", NULL, RRD_TYPE_NET_IPVS, "IPVS Bandwidth", "kilobits/s", 1000, update_every, RRDSET_TYPE_AREA);
 
-                       rrd_stats_dimension_add(st, "received", NULL, 8, 1024 * update_every, RRD_DIMENSION_INCREMENTAL);
-                       rrd_stats_dimension_add(st, "sent", NULL, -8, 1024 * update_every, RRD_DIMENSION_INCREMENTAL);
+                       rrddim_add(st, "received", NULL, 8, 1024 * update_every, RRDDIM_INCREMENTAL);
+                       rrddim_add(st, "sent", NULL, -8, 1024 * update_every, RRDDIM_INCREMENTAL);
                }
-               else rrd_stats_next(st);
+               else rrdset_next(st);
 
-               rrd_stats_dimension_set(st, "received", InBytes);
-               rrd_stats_dimension_set(st, "sent", OutBytes);
-               rrd_stats_done(st);
+               rrddim_set(st, "received", InBytes);
+               rrddim_set(st, "sent", OutBytes);
+               rrdset_done(st);
        }
 
        return 0;