]> git.itanic.dy.fi Git - rrdd/commitdiff
database.h.example: Add macro to fill rrd_image structures
authorTimo Kokkonen <kaapeli@itanic.dy.fi>
Sun, 13 Mar 2011 09:27:00 +0000 (11:27 +0200)
committerTimo Kokkonen <kaapeli@itanic.dy.fi>
Sun, 13 Mar 2011 09:27:00 +0000 (11:27 +0200)
This reduces massively the number of lines and makes it much easier to
add new images.

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

index c794fddc852e505736acc08c35ddd2f1d6cc9cc6..211da19720b62206d126e950e83f27eecd79616b 100644 (file)
@@ -183,135 +183,51 @@ const char *systempoptions[] = {
        0
 };
 
-static struct rrd_image cpudaily = {
-       .image_filename = SYSINFO_IMAGES_PATH "cpu_daily.png",
-       .width = 720,
-       .height = 480,
-       .timestart = "end-1d",
-       .timeend = "now",
-       .imageformat = "PNG",
-       .options = (char **)&cpuoptions,
-       .text = (char **)&cputext
-};
-
-static struct rrd_image cpuweekly = {
-       .image_filename = SYSINFO_IMAGES_PATH "cpu_weekly.png",
-       .width = 720,
-       .height = 480,
-       .timestart = "end-1w",
-       .timeend = "now",
-       .imageformat = "PNG",
-       .options = (char **)&cpuoptions,
-       .text = (char **)&cputext
-};
-
-static struct rrd_image cpumonthly = {
-       .image_filename = SYSINFO_IMAGES_PATH "cpu_monthly.png",
-       .width = 720,
-       .height = 480,
-       .timestart = "end-1m",
-       .timeend = "now",
-       .imageformat = "PNG",
-       .options = (char **)&cpuoptions,
-       .text = (char **)&cputext
-};
-
-static struct rrd_image cpuyearly = {
-       .image_filename = SYSINFO_IMAGES_PATH "cpu_yearly.png",
-       .width = 720,
-       .height = 480,
-       .timestart = "end-1y",
-       .timeend = "now",
-       .imageformat = "PNG",
-       .options = (char **)&cpuoptions,
-       .text = (char **)&cputext
-};
-
-static struct rrd_image memdaily = {
-       .image_filename = SYSINFO_IMAGES_PATH "mem_daily.png",
-       .width = 720,
-       .height = 480,
-       .timestart = "end-1d",
-       .timeend = "now",
-       .imageformat = "PNG",
-       .options = (char **)&memoptions,
-       .text = (char **)&memtext
-};
-
-static struct rrd_image memweekly = {
-       .image_filename = SYSINFO_IMAGES_PATH "mem_weekly.png",
-       .width = 720,
-       .height = 480,
-       .timestart = "end-1w",
-       .timeend = "now",
-       .imageformat = "PNG",
-       .options = (char **)&memoptions,
-       .text = (char **)&memtext
-};
-static struct rrd_image memmonthly = {
-       .image_filename = SYSINFO_IMAGES_PATH "mem_monthly.png",
-       .width = 720,
-       .height = 480,
-       .timestart = "end-1m",
-       .timeend = "now",
-       .imageformat = "PNG",
-       .options = (char **)&memoptions,
-       .text = (char **)&memtext
-};
-static struct rrd_image memyearly = {
-       .image_filename = SYSINFO_IMAGES_PATH "mem_yearly.png",
-       .width = 720,
-       .height = 480,
-       .timestart = "end-1y",
-       .timeend = "now",
-       .imageformat = "PNG",
-       .options = (char **)&memoptions,
-       .text = (char **)&memtext
-};
-
-static struct rrd_image systempdaily = {
-       .image_filename = SYSINFO_IMAGES_PATH "systemp_daily.png",
-       .width = 600,
-       .height = 200,
-       .timestart = "end-1d",
-       .timeend = "now",
-       .imageformat = "PNG",
-       .options = (char **)&systempoptions,
-       .text = (char **)&systemptext
-};
+#define DEFINE_IMAGE(rrdname, _filename, _width, _height)              \
+       static struct rrd_image rrdname ## daily = {                    \
+               .image_filename = _filename "_daily.png",               \
+               .width = _width,                                        \
+               .height = _height,                                      \
+               .timestart = "end-1d",                                  \
+               .timeend = "now",                                       \
+               .imageformat = "PNG",                                   \
+               .options = (char **)&rrdname ## options,                \
+               .text = (char **)&rrdname ## text,                      \
+       };                                                              \
+       static struct rrd_image rrdname ## weekly = {                   \
+               .image_filename = _filename "_weekly.png",              \
+               .width = _width,                                        \
+               .height = _height,                                      \
+               .timestart = "end-1w",                                  \
+               .timeend = "now",                                       \
+               .imageformat = "PNG",                                   \
+               .options = (char **)&rrdname ## options,                \
+               .text = (char **)&rrdname ## text,                      \
+       };                                                              \
+       static struct rrd_image rrdname ## monthly = {                  \
+               .image_filename = _filename "_monthly.png",             \
+               .width = _width,                                        \
+               .height = _height,                                      \
+               .timestart = "end-1m",                                  \
+               .timeend = "now",                                       \
+               .imageformat = "PNG",                                   \
+               .options = (char **)&rrdname ## options,                \
+               .text = (char **)&rrdname ## text,                      \
+       };                                                              \
+       static struct rrd_image rrdname ## yearly = {                   \
+               .image_filename = _filename "_yearly.png",              \
+               .width = _width,                                        \
+               .height = _height,                                      \
+               .timestart = "end-1y",                                  \
+               .timeend = "now",                                       \
+               .imageformat = "PNG",                                   \
+               .options = (char **)&rrdname ## options,                \
+               .text = (char **)&rrdname ## text,                      \
+       };
 
-static struct rrd_image systempweekly = {
-       .image_filename = SYSINFO_IMAGES_PATH "systemp_weekly.png",
-       .width = 600,
-       .height = 200,
-       .timestart = "end-1w",
-       .timeend = "now",
-       .imageformat = "PNG",
-       .options = (char **)&systempoptions,
-       .text = (char **)&systemptext
-};
-
-static struct rrd_image systempmonthly = {
-       .image_filename = SYSINFO_IMAGES_PATH "systemp_monthly.png",
-       .width = 600,
-       .height = 200,
-       .timestart = "end-1m",
-       .timeend = "now",
-       .imageformat = "PNG",
-       .options = (char **)&systempoptions,
-       .text = (char **)&systemptext
-};
-
-static struct rrd_image systempyearly = {
-       .image_filename = SYSINFO_IMAGES_PATH "systemp_yearly.png",
-       .width = 600,
-       .height = 200,
-       .timestart = "end-1y",
-       .timeend = "now",
-       .imageformat = "PNG",
-       .options = (char **)&systempoptions,
-       .text = (char **)&systemptext
-};
+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);
 
 static struct rrd_image *cpu_mem_images[] = {
        &cpudaily,