]> git.itanic.dy.fi Git - rrdd/commitdiff
database.h.example: Add network statistics
authorTimo Kokkonen <kaapeli@itanic.dy.fi>
Sun, 27 Mar 2011 20:19:34 +0000 (23:19 +0300)
committerTimo Kokkonen <kaapeli@itanic.dy.fi>
Sun, 27 Mar 2011 20:19:34 +0000 (23:19 +0300)
Read statistics for eth0 and eth0

Signed-off-by: Timo Kokkonen <kaapeli@itanic.dy.fi>
database.h.example

index be86afc20edfc0b0cd4f51e362f62abcb6e3180f..80788708787b056c0abc4f627b3d24079394b208 100644 (file)
@@ -5,7 +5,7 @@
 #include "scheduler.h"
 #include "parser.h"
 
-const char blank[] = "COMMENT:           ";
+const char blank[] = "COMMENT:       ";
 #define numfmt " % 8.2lf "
 
 #define SYSINFO_PATH           "/home/kaapeli/rrdd/sysinfo/"
@@ -14,6 +14,8 @@ const char blank[] = "COMMENT:           ";
 
 #define SYSTEMP_RRD_PATH       "/root/systemp/systemp.rrd"
 
+#define NETWORK_RRD_PATH       SYSINFO_PATH "network.rrd"
+
 const char *cputext[] = {
        "DEF:us=" SYSINFO_RRD_PATH ":User:AVERAGE",
        "DEF:ni=" SYSINFO_RRD_PATH ":Nice:AVERAGE",
@@ -130,6 +132,50 @@ const char *memtext[] = {
        0
 };
 
+const char *eth0text[] = {
+       "DEF:rxb=" NETWORK_RRD_PATH ":eth0rxb:AVERAGE",
+       "DEF:txb=" NETWORK_RRD_PATH ":eth0txb:AVERAGE",
+       "COMMENT:\\n",
+       blank,
+       "COMMENT:                          "
+       "MIN            MAX             AVG             Last\\n",
+       blank,
+       "LINE1:rxb#0000FF:eth0 rx bytes        ",
+       "GPRINT:rxb:MIN:  %5.0lf B",
+       "GPRINT:rxb:MAX:     %5.0lf B",
+       "GPRINT:rxb:AVERAGE:      %5.0lf B",
+       "GPRINT:rxb:LAST:      %5.0lf B\\n",
+       blank,
+       "LINE1:txb#00FF00:eth0 tx bytes        ",
+       "GPRINT:txb:MIN:  %5.0lf B",
+       "GPRINT:txb:MAX:     %5.0lf B",
+       "GPRINT:txb:AVERAGE:      %5.0lf B",
+       "GPRINT:txb:LAST:      %5.0lf B\\n",
+       0
+};
+
+const char *eth1text[] = {
+       "DEF:rxb=" NETWORK_RRD_PATH ":eth1rxb:AVERAGE",
+       "DEF:txb=" NETWORK_RRD_PATH ":eth1txb:AVERAGE",
+       "COMMENT:\\n",
+       blank,
+       "COMMENT:                          "
+       "MIN            MAX             AVG             Last\\n",
+       blank,
+       "LINE1:rxb#0000FF:eth1 rx bytes        ",
+       "GPRINT:rxb:MIN:  %5.0lf B",
+       "GPRINT:rxb:MAX:     %5.0lf B",
+       "GPRINT:rxb:AVERAGE:      %5.0lf B",
+       "GPRINT:rxb:LAST:      %5.0lf B\\n",
+       blank,
+       "LINE1:txb#00FF00:eth1 tx bytes        ",
+       "GPRINT:txb:MIN:  %5.0lf B",
+       "GPRINT:txb:MAX:     %5.0lf B",
+       "GPRINT:txb:AVERAGE:      %5.0lf B",
+       "GPRINT:txb:LAST:      %5.0lf B\\n",
+       0
+};
+
 const char *systemptext[] = {
        "DEF:sda_c=" SYSTEMP_RRD_PATH ":sda:AVERAGE",
        "DEF:SYS_c=" SYSTEMP_RRD_PATH ":SYS:AVERAGE",
@@ -177,6 +223,18 @@ const char *memoptions[] = {
        0
 };
 
+const char *eth0options[] = {
+       "--alt-autoscale",
+       "--vertical-label", "Bytes",
+       0
+};
+
+const char *eth1options[] = {
+       "--alt-autoscale",
+       "--vertical-label", "Bytes",
+       0
+};
+
 const char *systempoptions[] = {
        "--alt-autoscale",
        "--vertical-label", "Temp °C",
@@ -228,6 +286,8 @@ const char *systempoptions[] = {
 DEFINE_IMAGE(cpu,      "/home/kaapeli/rrdd/sysinfo/images/cpu", 720, 480);
 DEFINE_IMAGE(mem,      "/home/kaapeli/rrdd/sysinfo/images/mem", 720, 480);
 DEFINE_IMAGE(systemp,  "/home/kaapeli/rrdd/sysinfo/images/systemp", 720, 480);
+DEFINE_IMAGE(eth0,     "/home/kaapeli/rrdd/sysinfo/images/eth0", 720, 200);
+DEFINE_IMAGE(eth1,     "/home/kaapeli/rrdd/sysinfo/images/eth1", 720, 200);
 
 static struct rrd_image *cpu_mem_images[] = {
        &cpudaily,
@@ -241,6 +301,18 @@ static struct rrd_image *cpu_mem_images[] = {
        0
 };
 
+static struct rrd_image *network_images[] = {
+       &eth0daily,
+       &eth0weekly,
+       &eth0monthly,
+       &eth0yearly,
+       &eth1daily,
+       &eth1weekly,
+       &eth1monthly,
+       &eth1yearly,
+       NULL,
+};
+
 static struct rrd_image *systemp_images[] = {
        &systempdaily,
        &systempweekly,
@@ -316,6 +388,22 @@ struct rrd_data_source network_sources[] = {
        {},
 };
 
+struct rrd_archive network_archives[] = {
+       ARCHIVE_ENTRY("AVERAGE", 0.5, 1, 720)
+       ARCHIVE_ENTRY("AVERAGE", 0.5, 7, 720)
+       ARCHIVE_ENTRY("AVERAGE", 0.5, 31, 720)
+       ARCHIVE_ENTRY("AVERAGE", 0.5, 365, 720)
+       ARCHIVE_ENTRY("MIN", 0.5, 1, 720)
+       ARCHIVE_ENTRY("MIN", 0.5, 7, 720)
+       ARCHIVE_ENTRY("MIN", 0.5, 31, 720)
+       ARCHIVE_ENTRY("MIN", 0.5, 365, 720)
+       ARCHIVE_ENTRY("MAX", 0.5, 1, 720)
+       ARCHIVE_ENTRY("MAX", 0.5, 7, 720)
+       ARCHIVE_ENTRY("MAX", 0.5, 31, 720)
+       ARCHIVE_ENTRY("MAX", 0.5, 365, 720)
+       {},
+};
+
 static struct rrd_database cpumem_rrd = {
        .filename       = SYSINFO_RRD_PATH,
        .interval       = 120,
@@ -334,9 +422,27 @@ static struct rrd_database systemp_rrd = {
        .name           = "systemp",
 };
 
+char *network_interfaces[] = {
+       "eth0",
+       "eth1",
+       NULL,
+};
+
+static struct rrd_database network_rrd = {
+       .name           = "network",
+       .filename       = NETWORK_RRD_PATH,
+       .interval       = 120,
+       .parse          = netstats_parser,
+       .sources        = network_sources,
+       .archives       = network_archives,
+       .parser_data    = network_interfaces,
+       .images         = network_images,
+};
+
 static struct rrd_database *all_rrds[] = {
        &cpumem_rrd,
        &systemp_rrd,
+       &network_rrd,
        0
 };