]> git.itanic.dy.fi Git - rrdd/commitdiff
itanic: database.h: Add macro for creating image files
authorTimo Kokkonen <kaapeli@itanic.dy.fi>
Sun, 13 Mar 2011 09:19:49 +0000 (11:19 +0200)
committerTimo Kokkonen <kaapeli@itanic.dy.fi>
Sun, 13 Mar 2011 09:19:49 +0000 (11:19 +0200)
Signed-off-by: Timo Kokkonen <kaapeli@itanic.dy.fi>
database.h

index 14c4b11063772bae03bf38ded249507c6ce85195..eaaf52a511c6f2c57d320d466e2d4e3e70bb5247 100644 (file)
@@ -251,6 +251,36 @@ const char *freqtext[] = {
        "COMMENT: \\n",
 };
 
+const char *deviationtext[] = {
+       "DEF:devi=" POWER_RRD_PATH ":aikapoikkeama:AVERAGE",
+       "COMMENT:\\n",
+       blank,
+       "COMMENT:                   "
+       "MIN          MAX         AVG        Last\\n",
+       blank,
+       "LINE1:devi#0000ff:Aikapoikkeama ",
+       "GPRINT:devi:MIN:" numfmt,
+       "GPRINT:devi:MAX:" numfmt,
+       "GPRINT:devi:AVERAGE:" numfmt,
+       "GPRINT:devi:LAST:" numfmt "\\n",
+       "COMMENT: \\n",
+};
+
+const char *pricetext[] = {
+       "DEF:hinta=" POWER_RRD_PATH ":hinta:AVERAGE",
+       "COMMENT:\\n",
+       blank,
+       "COMMENT:                   "
+       "MIN          MAX         AVG        Last\\n",
+       blank,
+       "LINE1:hinta#0000ff:Hinta         ",
+       "GPRINT:hinta:MIN:" numfmt,
+       "GPRINT:hinta:MAX:" numfmt,
+       "GPRINT:hinta:AVERAGE:" numfmt,
+       "GPRINT:hinta:LAST:" numfmt "\\n",
+       "COMMENT: \\n",
+};
+
 const char *cpuoptions[] = {
        "--alt-autoscale-max",
        "--lower-limit", "0",
@@ -281,6 +311,19 @@ const char *freqoptions[] = {
        0
 };
 
+const char *deviationoptions[] = {
+       "--alt-autoscale",
+       "--vertical-label", "Aikapoikkeama s",
+       "--units-exponent", "-2",
+       0
+};
+
+const char *priceoptions[] = {
+       "--alt-autoscale",
+       "--vertical-label", "Hinta €",
+       0
+};
+
 const char *poweroptions[] = {
        "--alt-autoscale-max",
        "--lower-limit", "0",
@@ -290,223 +333,65 @@ const char *poweroptions[] = {
        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
-};
-
-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
-};
-
-static struct rrd_image powerdaily = {
-       .image_filename = POWER_IMAGES_PATH "power_daily.png",
-       .width = 480,
-       .height = 480,
-       .timestart = "end-1d",
-       .timeend = "now",
-       .imageformat = "PNG",
-       .options = (char **)&poweroptions,
-       .text = (char **)&powertext
-};
-
-static struct rrd_image powerweekly = {
-       .image_filename = POWER_IMAGES_PATH "power_weekly.png",
-       .width = 480,
-       .height = 480,
-       .timestart = "end-1w",
-       .timeend = "now",
-       .imageformat = "PNG",
-       .options = (char **)&poweroptions,
-       .text = (char **)&powertext
-};
-
-static struct rrd_image powermonthly = {
-       .image_filename = POWER_IMAGES_PATH "power_monthly.png",
-       .width = 480,
-       .height = 480,
-       .timestart = "end-1m",
-       .timeend = "now",
-       .imageformat = "PNG",
-       .options = (char **)&poweroptions,
-       .text = (char **)&powertext
-};
-
-static struct rrd_image poweryearly = {
-       .image_filename = POWER_IMAGES_PATH "power_yearly.png",
-       .width = 480,
-       .height = 480,
-       .timestart = "end-1y",
-       .timeend = "now",
-       .imageformat = "PNG",
-       .options = (char **)&poweroptions,
-       .text = (char **)&powertext
-};
-
-static struct rrd_image freqdaily = {
-       .image_filename = POWER_IMAGES_PATH "freq_daily.png",
-       .width = 480,
-       .height = 480,
-       .timestart = "end-1d",
-       .timeend = "now",
-       .imageformat = "PNG",
-       .options = (char **)&freqoptions,
-       .text = (char **)&freqtext
-};
-
-static struct rrd_image freqweekly = {
-       .image_filename = POWER_IMAGES_PATH "freq_weekly.png",
-       .width = 480,
-       .height = 480,
-       .timestart = "end-1w",
-       .timeend = "now",
-       .imageformat = "PNG",
-       .options = (char **)&freqoptions,
-       .text = (char **)&freqtext
-};
-
-static struct rrd_image freqmonthly = {
-       .image_filename = POWER_IMAGES_PATH "freq_monthly.png",
-       .width = 480,
-       .height = 480,
-       .timestart = "end-1m",
-       .timeend = "now",
-       .imageformat = "PNG",
-       .options = (char **)&freqoptions,
-       .text = (char **)&freqtext
-};
-
-static struct rrd_image freqyearly = {
-       .image_filename = POWER_IMAGES_PATH "freq_yearly.png",
-       .width = 480,
-       .height = 480,
-       .timestart = "end-1y",
-       .timeend = "now",
-       .imageformat = "PNG",
-       .options = (char **)&freqoptions,
-       .text = (char **)&freqtext
-};
+#define xstr(s) str(s)
+#define str(s) #s
+
+#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,                      \
+       };
+
+#define CPUPATH        (xstr(SYSINFO_IMAGES_PATH) "cpu" )
+#define MEMPATH        (xstr(SYSINFO_IMAGES_PATH) "mem")
+#define SYSTEMPPATH    (xstr(SYSINFO_IMAGES_PATH) "systemp")
+#define POWERPATH      (xstr(POWER_IMAGES_PATH) "power")
+#define FREQPATH       (xstr(POWER_IMAGES_PATH) "freq")
+#define DEVIATIONPATH  (xstr(POWER_IMAGES_PATH) "deviation")
+
+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(power,    "/home/kaapeli/rrdd/power/images/power", 480, 480);
+DEFINE_IMAGE(freq,     "/home/kaapeli/rrdd/power/images/freq", 480, 480);
+DEFINE_IMAGE(deviation,        "/home/kaapeli/rrdd/power/images/deviation", 480, 480);
+DEFINE_IMAGE(price,    "/home/kaapeli/rrdd/power/images/price", 480, 480);
 
 static struct rrd_image *cpu_mem_images[] = {
        &cpudaily,
@@ -537,6 +422,14 @@ static struct rrd_image *power_images[] = {
        &freqweekly,
        &freqmonthly,
        &freqyearly,
+       &deviationdaily,
+       &deviationweekly,
+       &deviationmonthly,
+       &deviationyearly,
+       &pricedaily,
+       &priceweekly,
+       &pricemonthly,
+       &priceyearly,
        0
 };