]> git.itanic.dy.fi Git - rrdd/commitdiff
itanic: Add macro for generating rrd source and archives
authorTimo Kokkonen <kaapeli@itanic.dy.fi>
Sun, 27 Mar 2011 19:57:57 +0000 (22:57 +0300)
committerTimo Kokkonen <kaapeli@itanic.dy.fi>
Sun, 27 Mar 2011 19:57:57 +0000 (22:57 +0300)
Signed-off-by: Timo Kokkonen <kaapeli@itanic.dy.fi>
database.h

index 560f9c35c21e8b9bd13cddda2208a8f7d491092a..1ce8ab900fca51cffb1ea98fcc52bc7ad6bb2d3d 100644 (file)
@@ -433,386 +433,92 @@ static struct rrd_image *power_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,
+#define SOURCE_ENTRY(_name, _type, _heartbeat, _min, _max) \
+       {                                                  \
+               .name = _name,                             \
+               .type = _type,                             \
+               .heartbeat = _heartbeat,                   \
+               .min = _min,                               \
+               .max = _max,                               \
        },
-       {
-               .name = "Tables",
-               .type = "GAUGE",
-               .heartbeat = 240,
-               .min = 0,
-               .max = 32768,
-       },
-       {
-               .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 power_sources[] = {
-       {
-               .name = "kulutus",
-               .type = "GAUGE",
-               .heartbeat = 360,
-               .min = 0,
-               .max = 3000,
-       },
-       {
-               .name = "tuotanto",
-               .type = "GAUGE",
-               .heartbeat = 360,
-               .min = 0,
-               .max = 3000,
-       },
-       {
-               .name = "vesivoima",
-               .type = "GAUGE",
-               .heartbeat = 360,
-               .min = 0,
-               .max = 3000,
-       },
-       {
-               .name = "ydinvoima",
-               .type = "GAUGE",
-               .heartbeat = 360,
-               .min = 0,
-               .max = 3000,
-       },
-       {
-               .name = "lauhdevoima",
-               .type = "GAUGE",
-               .heartbeat = 360,
-               .min = 0,
-               .max = 3000,
-       },
-       {
-               .name = "kaukolampo",
-               .type = "GAUGE",
-               .heartbeat = 360,
-               .min = 0,
-               .max = 3000,
-       },
-       {
-               .name = "teollisuus",
-               .type = "GAUGE",
-               .heartbeat = 360,
-               .min = 0,
-               .max = 3000,
-       },
-       {
-               .name = "muu",
-               .type = "GAUGE",
-               .heartbeat = 360,
-               .min = 0,
-               .max = 3000,
-       },
-       {
-               .name = "huippuvoima",
-               .type = "GAUGE",
-               .heartbeat = 360,
-               .min = 0,
-               .max = 3000,
-       },
-       {
-               .name = "tuonti",
-               .type = "GAUGE",
-               .heartbeat = 360,
-               .min = -3000,
-               .max = 3000,
-       },
-       {
-               .name = "hinta",
-               .type = "GAUGE",
-               .heartbeat = 360,
-               .min = 0,
-               .max = 3000,
-       },
-       {
-               .name = "ylijaama",
-               .type = "GAUGE",
-               .heartbeat = 360,
-               .min = 0,
-               .max = 3000,
-       },
-       {
-               .name = "ylijaamakumul",
-               .type = "GAUGE",
-               .heartbeat = 360,
-               .min = 0,
-               .max = 3000,
-       },
-       {
-               .name = "taajuus",
-               .type = "GAUGE",
-               .heartbeat = 360,
-               .min = 0,
-               .max = 3000,
-       },
-       {
-               .name = "aikapoikkeama",
-               .type = "GAUGE",
-               .heartbeat = 360,
-               .min = -30,
-               .max = 30,
-       },
+       SOURCE_ENTRY("kulutus", "GAUGE", 360, 0, 3000)
+       SOURCE_ENTRY("tuotanto", "GAUGE", 360, 0, 3000)
+       SOURCE_ENTRY("vesivoima", "GAUGE", 360, 0, 3000)
+       SOURCE_ENTRY("ydinvoima", "GAUGE", 360, 0, 3000)
+       SOURCE_ENTRY("lauhdevoima", "GAUGE", 360, 0, 3000)
+       SOURCE_ENTRY("kaukolampo", "GAUGE", 360, 0, 3000)
+       SOURCE_ENTRY("teollisuus", "GAUGE", 360, 0, 3000)
+       SOURCE_ENTRY("muu", "GAUGE", 360, 0, 3000)
+       SOURCE_ENTRY("huippuvoima", "GAUGE", 360, 0, 3000)
+       SOURCE_ENTRY("tuonti", "GAUGE", 360, -3000, 3000)
+       SOURCE_ENTRY("hinta", "GAUGE", 360, 0, 3000)
+       SOURCE_ENTRY("ylijaama", "GAUGE", 360, 0, 3000)
+       SOURCE_ENTRY("ylijaamakumul", "GAUGE", 360, 0, 3000)
+       SOURCE_ENTRY("taajuus", "GAUGE", 360, 0, 3000)
+       SOURCE_ENTRY("aikapoikkeama", "GAUGE", 360, -30, 30)
+       {},
 };
 
 struct rrd_archive power_archives[] = {
-       {
-               .type = "AVERAGE",
-               .xff = 0.5,
-               .steps = 1,
-               .rows = 480,
-       },
-       {
-               .type = "AVERAGE",
-               .xff = 0.5,
-               .steps = 7,
-               .rows = 480,
-       },
-       {
-               .type = "AVERAGE",
-               .xff = 0.5,
-               .steps = 31,
-               .rows = 480,
-       },
-       {
-               .type = "AVERAGE",
-               .xff = 0.5,
-               .steps = 365,
-               .rows = 480,
-       },
-       {
-               .type = "MIN",
-               .xff = 0.5,
-               .steps = 1,
-               .rows = 480,
-       },
-       {
-               .type = "MIN",
-               .xff = 0.5,
-               .steps = 7,
-               .rows = 480,
-       },
-       {
-               .type = "MIN",
-               .xff = 0.5,
-               .steps = 31,
-               .rows = 480,
-       },
-       {
-               .type = "MIN",
-               .xff = 0.5,
-               .steps = 365,
-               .rows = 480,
-       },
-       {
-               .type = "MAX",
-               .xff = 0.5,
-               .steps = 1,
-               .rows = 480,
-       },
-       {
-               .type = "MAX",
-               .xff = 0.5,
-               .steps = 7,
-               .rows = 480,
-       },
-       {
-               .type = "MAX",
-               .xff = 0.5,
-               .steps = 31,
-               .rows = 480,
-       },
-       {
-               .type = "MAX",
-               .xff = 0.5,
-               .steps = 365,
-               .rows = 480,
-       },
+       ARCHIVE_ENTRY("AVERAGE", 0.5, 1, 480)
+       ARCHIVE_ENTRY("AVERAGE", 0.5, 7, 480)
+       ARCHIVE_ENTRY("AVERAGE", 0.5, 31, 480)
+       ARCHIVE_ENTRY("AVERAGE", 0.5, 365, 480)
+       ARCHIVE_ENTRY("MIN", 0.5, 1, 480)
+       ARCHIVE_ENTRY("MIN", 0.5, 7, 480)
+       ARCHIVE_ENTRY("MIN", 0.5, 31, 480)
+       ARCHIVE_ENTRY("MIN", 0.5, 365, 480)
+       ARCHIVE_ENTRY("MAX", 0.5, 1, 480)
+       ARCHIVE_ENTRY("MAX", 0.5, 7, 480)
+       ARCHIVE_ENTRY("MAX", 0.5, 31, 480)
+       ARCHIVE_ENTRY("MAX", 0.5, 365, 480)
        {},
 };