]> git.itanic.dy.fi Git - rrdd/commitdiff
database.h.example: Add macro for generating rrd source and archives
authorTimo Kokkonen <kaapeli@itanic.dy.fi>
Sun, 27 Mar 2011 20:16:24 +0000 (23:16 +0300)
committerTimo Kokkonen <kaapeli@itanic.dy.fi>
Sun, 27 Mar 2011 20:16:24 +0000 (23:16 +0300)
This reduces significantly the numer of lines in the database.h file.
It also improves readability significantly due to reduced line number
count.

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

index 211da19720b62206d126e950e83f27eecd79616b..be86afc20edfc0b0cd4f51e362f62abcb6e3180f 100644 (file)
@@ -249,202 +249,70 @@ static struct rrd_image *systemp_images[] = {
        0
 };
 
-struct rrd_data_source cpumem_sources[] = {
-       {
-               .name = "User",
-               .type = "COUNTER",
-               .heartbeat = 240,
-               .min = 0,
-               .max = 1200,
-       },
-       {
-               .name = "Nice",
-               .type = "COUNTER",
-               .heartbeat = 240,
-               .min = 0,
-               .max = 1200,
-       },
-       {
-               .name = "Sys",
-               .type = "COUNTER",
-               .heartbeat = 240,
-               .min = 0,
-               .max = 1200,
-       },
-       {
-               .name = "Idle",
-               .type = "COUNTER",
-               .heartbeat = 240,
-               .min = 0,
-               .max = 1200,
-       },
-       {
-               .name = "Wait",
-               .type = "COUNTER",
-               .heartbeat = 240,
-               .min = 0,
-               .max = 1200,
-       },
-       {
-               .name = "IRQ",
-               .type = "COUNTER",
-               .heartbeat = 240,
-               .min = 0,
-               .max = 1200,
-       },
-       {
-               .name = "SoftIRQ",
-               .type = "COUNTER",
-               .heartbeat = 240,
-               .min = 0,
-               .max = 1200,
-       },
-       {
-               .name = "Free",
-               .type = "GAUGE",
-               .heartbeat = 240,
-               .min = 0,
-               .max = 32768,
-       },
-       {
-               .name = "Buffers",
-               .type = "GAUGE",
-               .heartbeat = 240,
-               .min = 0,
-               .max = 32768,
-       },
-       {
-               .name = "Cached",
-               .type = "GAUGE",
-               .heartbeat = 240,
-               .min = 0,
-               .max = 32768,
-       },
-       {
-               .name = "Active",
-               .type = "GAUGE",
-               .heartbeat = 240,
-               .min = 0,
-               .max = 32768,
-       },
-       {
-               .name = "Inactive",
-               .type = "GAUGE",
-               .heartbeat = 240,
-               .min = 0,
-               .max = 32768,
-       },
-       {
-               .name = "SwapFree",
-               .type = "GAUGE",
-               .heartbeat = 240,
-               .min = 0,
-               .max = 32768,
-       },
-       {
-               .name = "Anon",
-               .type = "GAUGE",
-               .heartbeat = 240,
-               .min = 0,
-               .max = 32768,
-       },
-       {
-               .name = "Slab",
-               .type = "GAUGE",
-               .heartbeat = 240,
-               .min = 0,
-               .max = 32768,
-       },
-       {
-               .name = "Tables",
-               .type = "GAUGE",
-               .heartbeat = 240,
-               .min = 0,
-               .max = 32768,
+
+#define SOURCE_ENTRY(_name, _type, _heartbeat, _min, _max) \
+       {                                                  \
+               .name = _name,                             \
+               .type = _type,                             \
+               .heartbeat = _heartbeat,                   \
+               .min = _min,                               \
+               .max = _max,                               \
        },
-       {
-               .name = "Swap",
-               .type = "GAUGE",
-               .heartbeat = 240,
-               .min = 0,
-               .max = 32768,
+
+#define ARCHIVE_ENTRY(_type, _xff, _steps, _rows) \
+       {                                         \
+               .type = _type,                    \
+               .xff = _xff,                      \
+               .steps = _steps,                  \
+               .rows = _rows,                    \
        },
+
+struct rrd_data_source cpumem_sources[] = {
+       SOURCE_ENTRY("User",    "COUNTER", 240, 0, 1200)
+       SOURCE_ENTRY("Nice",    "COUNTER", 240, 0, 1200)
+       SOURCE_ENTRY("Sys",     "COUNTER", 240, 0, 1200)
+       SOURCE_ENTRY("Idle",    "COUNTER", 240, 0, 1200)
+       SOURCE_ENTRY("Wait",    "COUNTER", 240, 0, 1200)
+       SOURCE_ENTRY("IRQ",     "COUNTER", 240, 0, 1200)
+       SOURCE_ENTRY("SoftIRQ", "COUNTER", 240, 0, 1200)
+       SOURCE_ENTRY("Free",    "GAUGE", 240, 0, 32768)
+       SOURCE_ENTRY("Buffers", "GAUGE", 240, 0, 32768)
+       SOURCE_ENTRY("Cached",  "GAUGE", 240, 0, 32768)
+       SOURCE_ENTRY("Active",  "GAUGE", 240, 0, 32768)
+       SOURCE_ENTRY("Inactive","GAUGE", 240, 0, 32768)
+       SOURCE_ENTRY("SwapFree","GAUGE", 240, 0, 32768)
+       SOURCE_ENTRY("Anon",    "GAUGE", 240, 0, 32768)
+       SOURCE_ENTRY("Slab",    "GAUGE", 240, 0, 32768)
+       SOURCE_ENTRY("Tables",  "GAUGE", 240, 0, 32768)
+       SOURCE_ENTRY("Swap",    "GAUGE", 240, 0, 32768)
        {},
 };
 
 struct rrd_archive cpumem_archives[] = {
-       {
-               .type = "AVERAGE",
-               .xff = 0.5,
-               .steps = 1,
-               .rows = 720,
-       },
-       {
-               .type = "AVERAGE",
-               .xff = 0.5,
-               .steps = 7,
-               .rows = 720,
-       },
-       {
-               .type = "AVERAGE",
-               .xff = 0.5,
-               .steps = 31,
-               .rows = 720,
-       },
-       {
-               .type = "AVERAGE",
-               .xff = 0.5,
-               .steps = 365,
-               .rows = 720,
-       },
-       {
-               .type = "MIN",
-               .xff = 0.5,
-               .steps = 1,
-               .rows = 720,
-       },
-       {
-               .type = "MIN",
-               .xff = 0.5,
-               .steps = 7,
-               .rows = 720,
-       },
-       {
-               .type = "MIN",
-               .xff = 0.5,
-               .steps = 31,
-               .rows = 720,
-       },
-       {
-               .type = "MIN",
-               .xff = 0.5,
-               .steps = 365,
-               .rows = 720,
-       },
-       {
-               .type = "MAX",
-               .xff = 0.5,
-               .steps = 1,
-               .rows = 720,
-       },
-       {
-               .type = "MAX",
-               .xff = 0.5,
-               .steps = 7,
-               .rows = 720,
-       },
-       {
-               .type = "MAX",
-               .xff = 0.5,
-               .steps = 31,
-               .rows = 720,
-       },
-       {
-               .type = "MAX",
-               .xff = 0.5,
-               .steps = 365,
-               .rows = 720,
-       },
+       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)
+       {},
+};
+
+struct rrd_data_source network_sources[] = {
+       SOURCE_ENTRY("eth0rxb", "COUNTER", 240, 0, 120000000000)
+       SOURCE_ENTRY("eth0rxp", "COUNTER", 240, 0, 120000000000)
+       SOURCE_ENTRY("eth0txb", "COUNTER", 240, 0, 120000000000)
+       SOURCE_ENTRY("eth0txp", "COUNTER", 240, 0, 120000000000)
+       SOURCE_ENTRY("eth1rxb", "COUNTER", 240, 0, 120000000000)
+       SOURCE_ENTRY("eth1rxp", "COUNTER", 240, 0, 120000000000)
+       SOURCE_ENTRY("eth1txb", "COUNTER", 240, 0, 120000000000)
+       SOURCE_ENTRY("eth1txp", "COUNTER", 240, 0, 120000000000)
        {},
 };