]> git.itanic.dy.fi Git - rrdd/commitdiff
database.h: Add time variable to DEFINE_IMAGE macro
authorTimo Kokkonen <kaapeli@itanic.dy.fi>
Sat, 3 Sep 2011 07:49:34 +0000 (10:49 +0300)
committerTimo Kokkonen <kaapeli@itanic.dy.fi>
Sat, 3 Sep 2011 07:54:11 +0000 (10:54 +0300)
It will make it possible to conviniently define how many
days/weeks/months/years to draw in the image. It is no longer needed
to have the unit fixed to 1.

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

index 1c3476e6e43d0b2639bc6595a786bcd269a3e209..522fb985ccda1bf2caaf9f41d3bd270e7a55f71c 100644 (file)
@@ -246,12 +246,12 @@ const char *systempoptions[] = {
        0
 };
 
-#define DEFINE_IMAGE(rrdname, _filename, _width, _height)              \
+#define DEFINE_IMAGE(rrdname, _filename, _width, _height, time)                \
        static struct rrd_image rrdname ## daily = {                    \
                .image_filename = _filename "_daily.png",               \
                .width = _width,                                        \
                .height = _height,                                      \
-               .timestart = "end-1d",                                  \
+               .timestart = "end-" #time "d",                          \
                .timeend = "now",                                       \
                .imageformat = "PNG",                                   \
                .options = (char **)&rrdname ## options,                \
@@ -261,7 +261,7 @@ const char *systempoptions[] = {
                .image_filename = _filename "_weekly.png",              \
                .width = _width,                                        \
                .height = _height,                                      \
-               .timestart = "end-1w",                                  \
+               .timestart = "end-" #time "w",                          \
                .timeend = "now",                                       \
                .imageformat = "PNG",                                   \
                .options = (char **)&rrdname ## options,                \
@@ -271,7 +271,7 @@ const char *systempoptions[] = {
                .image_filename = _filename "_monthly.png",             \
                .width = _width,                                        \
                .height = _height,                                      \
-               .timestart = "end-1m",                                  \
+               .timestart = "end-" #time "m",                          \
                .timeend = "now",                                       \
                .imageformat = "PNG",                                   \
                .options = (char **)&rrdname ## options,                \
@@ -281,18 +281,18 @@ const char *systempoptions[] = {
                .image_filename = _filename "_yearly.png",              \
                .width = _width,                                        \
                .height = _height,                                      \
-               .timestart = "end-1y",                                  \
+               .timestart = "end-" #time "y",                          \
                .timeend = "now",                                       \
                .imageformat = "PNG",                                   \
                .options = (char **)&rrdname ## options,                \
                .text = (char **)&rrdname ## text,                      \
        };
 
-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);
+DEFINE_IMAGE(cpu,      "/home/kaapeli/rrdd/sysinfo/images/cpu", 720, 480, 1);
+DEFINE_IMAGE(mem,      "/home/kaapeli/rrdd/sysinfo/images/mem", 720, 480, 1);
+DEFINE_IMAGE(systemp,  "/home/kaapeli/rrdd/sysinfo/images/systemp", 720,480,1);
+DEFINE_IMAGE(eth0,     "/home/kaapeli/rrdd/sysinfo/images/eth0", 720, 200, 1);
+DEFINE_IMAGE(eth1,     "/home/kaapeli/rrdd/sysinfo/images/eth1", 720, 200, 1);
 
 static struct rrd_image *cpu_mem_images[] = {
        &cpudaily,