--- /dev/null
+#ifndef _TESTDATA_H
+#define _TESTDATA_H
+
+#include "rrdtool.h"
+#include "scheduler.h"
+#include "parser.h"
+
+const char blank[] = "COMMENT: ";
+#define numfmt " % 8.2lf "
+
+#define SYSINFO_PATH "/home/kaapeli/sysinfo/"
+#define SYSINFO_RRD_PATH SYSINFO_PATH "sysinfo.rrd"
+#define SYSINFO_IMAGES_PATH SYSINFO_PATH "images/"
+
+#define SYSTEMP_RRD_PATH "/root/systemp/systemp.rrd"
+
+const char *cputext[] = {
+ "DEF:us=" SYSINFO_RRD_PATH ":User:AVERAGE",
+ "DEF:ni=" SYSINFO_RRD_PATH ":Nice:AVERAGE",
+ "DEF:sy=" SYSINFO_RRD_PATH ":Sys:AVERAGE",
+ "DEF:id=" SYSINFO_RRD_PATH ":Idle:AVERAGE",
+ "DEF:wa=" SYSINFO_RRD_PATH ":Wait:AVERAGE",
+ "DEF:in=" SYSINFO_RRD_PATH ":IRQ:AVERAGE",
+ "DEF:so=" SYSINFO_RRD_PATH ":SoftIRQ:AVERAGE",
+ "COMMENT:\\n",
+ blank,
+ "COMMENT: "
+ "MIN MAX AVG Last\\n",
+ blank,
+ "AREA:sy#ff0000:System ",
+ "GPRINT:sy:MIN:" numfmt,
+ "GPRINT:sy:MAX:" numfmt,
+ "GPRINT:sy:AVERAGE:" numfmt,
+ "GPRINT:sy:LAST:" numfmt "\\n",
+ blank,
+ "STACK:us#0000ff:User ",
+ "GPRINT:us:MIN:" numfmt,
+ "GPRINT:us:MAX:" numfmt,
+ "GPRINT:us:AVERAGE:" numfmt,
+ "GPRINT:us:LAST:" numfmt "\\n",
+ blank,
+ "STACK:ni#00ff00:Nice ",
+ "GPRINT:ni:MIN:" numfmt,
+ "GPRINT:ni:MAX:" numfmt,
+ "GPRINT:ni:AVERAGE:" numfmt,
+ "GPRINT:ni:LAST:" numfmt "\\n",
+ blank,
+ "STACK:id#ffffff:Idle ",
+ "GPRINT:id:MIN:" numfmt,
+ "GPRINT:id:MAX:" numfmt,
+ "GPRINT:id:AVERAGE:" numfmt,
+ "GPRINT:id:LAST:" numfmt "\\n",
+ blank,
+ "STACK:wa#ff00ff:IO wait ",
+ "GPRINT:wa:MIN:" numfmt,
+ "GPRINT:wa:MAX:" numfmt,
+ "GPRINT:wa:AVERAGE:" numfmt,
+ "GPRINT:wa:LAST:" numfmt "\\n",
+ blank,
+ "STACK:in#ffff00:IRQ ",
+ "GPRINT:in:MIN:" numfmt,
+ "GPRINT:in:MAX:" numfmt,
+ "GPRINT:in:AVERAGE:" numfmt,
+ "GPRINT:in:LAST:" numfmt "\\n",
+ blank,
+ "STACK:so#00ffff:Soft IRQ ",
+ "GPRINT:so:MIN:" numfmt,
+ "GPRINT:so:MAX:" numfmt,
+ "GPRINT:so:AVERAGE:" numfmt,
+ "GPRINT:so:LAST:" numfmt "\\n",
+ "COMMENT: \\n",
+ 0
+};
+
+const char *memtext[] = {
+ "DEF:fr=" SYSINFO_RRD_PATH ":Free:AVERAGE",
+ "DEF:bu=" SYSINFO_RRD_PATH ":Buffers:AVERAGE",
+ "DEF:ca=" SYSINFO_RRD_PATH ":Cached:AVERAGE",
+ "DEF:an=" SYSINFO_RRD_PATH ":Anon:AVERAGE",
+ "DEF:sl=" SYSINFO_RRD_PATH ":Slab:AVERAGE",
+ "DEF:ta=" SYSINFO_RRD_PATH ":Tables:AVERAGE",
+ "DEF:sw=" SYSINFO_RRD_PATH ":Swap:AVERAGE",
+ "COMMENT:\\n",
+ blank,
+ "COMMENT: "
+ "MIN MAX AVG Last\\n",
+ blank,
+ "AREA:bu#ffff00:Buffers ",
+ "GPRINT:bu:MIN:" numfmt,
+ "GPRINT:bu:MAX:" numfmt,
+ "GPRINT:bu:AVERAGE:" numfmt,
+ "GPRINT:bu:LAST:" numfmt "\\n",
+ blank,
+ "STACK:an#000000:AnonPages ",
+ "GPRINT:an:MIN:" numfmt,
+ "GPRINT:an:MAX:" numfmt,
+ "GPRINT:an:AVERAGE:" numfmt,
+ "GPRINT:an:LAST:" numfmt "\\n",
+ blank,
+ "STACK:ca#00ff00:Cached ",
+ "GPRINT:ca:MIN:" numfmt,
+ "GPRINT:ca:MAX:" numfmt,
+ "GPRINT:ca:AVERAGE:" numfmt,
+ "GPRINT:ca:LAST:" numfmt "\\n",
+ blank,
+ "STACK:fr#ffffff:Free ",
+ "GPRINT:fr:MIN:" numfmt,
+ "GPRINT:fr:MAX:" numfmt,
+ "GPRINT:fr:AVERAGE:" numfmt,
+ "GPRINT:fr:LAST:" numfmt "\\n",
+ blank,
+ "STACK:sl#00ffff:Slab ",
+ "GPRINT:sl:MIN:" numfmt,
+ "GPRINT:sl:MAX:" numfmt,
+ "GPRINT:sl:AVERAGE:" numfmt,
+ "GPRINT:sl:LAST:" numfmt "\\n",
+ blank,
+ "STACK:ta#0000ff:PageTables ",
+ "GPRINT:ta:MIN:" numfmt,
+ "GPRINT:ta:MAX:" numfmt,
+ "GPRINT:ta:AVERAGE:" numfmt,
+ "GPRINT:ta:LAST:" numfmt "\\n",
+ blank,
+ "STACK:sw#ff0000:Swap ",
+ "GPRINT:sw:MIN:" numfmt,
+ "GPRINT:sw:MAX:" numfmt,
+ "GPRINT:sw:AVERAGE:" numfmt,
+ "GPRINT:sw:LAST:" numfmt "\\n",
+ "COMMENT: \\n",
+ 0
+};
+
+const char *systemptext[] = {
+ "DEF:sda_c=" SYSTEMP_RRD_PATH ":sda:AVERAGE",
+ "DEF:SYS_c=" SYSTEMP_RRD_PATH ":SYS:AVERAGE",
+ "DEF:CPU_c=" SYSTEMP_RRD_PATH ":CPU:AVERAGE",
+ "COMMENT:\\n",
+ blank,
+ "COMMENT: "
+ "MIN MAX AVG Last\\n",
+ blank,
+ "LINE1:sda_c#0000FF:SAMSUNG HD501LJ ",
+ "GPRINT:sda_c:MIN: %5.2lf °C",
+ "GPRINT:sda_c:MAX: %5.2lf °C",
+ "GPRINT:sda_c:AVERAGE: %5.2lf °C",
+ "GPRINT:sda_c:LAST: %5.2lf °C\\n",
+ blank,
+ "LINE1:SYS_c#00FF00:Sys Temp ",
+ "GPRINT:SYS_c:MIN: %5.2lf °C",
+ "GPRINT:SYS_c:MAX: %5.2lf °C",
+ "GPRINT:SYS_c:AVERAGE: %5.2lf °C",
+ "GPRINT:SYS_c:LAST: %5.2lf °C\\n",
+ blank,
+ "LINE1:CPU_c#FF0000:Intel Core2 Quad ",
+ "GPRINT:CPU_c:MIN: %5.2lf °C",
+ "GPRINT:CPU_c:MAX: %5.2lf °C",
+ "GPRINT:CPU_c:AVERAGE: %5.2lf °C",
+ "GPRINT:CPU_c:LAST: %5.2lf °C\\n",
+ "COMMENT: \\n",
+ 0
+};
+
+const char *cpuoptions[] = {
+ "--alt-autoscale-max",
+ "--vertical-label",
+ "CPU Tics",
+ 0
+};
+
+const char *memoptions[] = {
+ "--alt-autoscale-max",
+ "--vertical-label",
+ "Mem usage (MB)",
+ "--units-exponent", "0",
+ 0
+};
+
+const char *systempoptions[] = {
+ "--alt-autoscale",
+ "--vertical-label", "Temp °C",
+ 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 *cpu_mem_images[] = {
+ &cpudaily,
+ &cpuweekly,
+ &cpumonthly,
+ &cpuyearly,
+ &memdaily,
+ &memweekly,
+ &memmonthly,
+ &memyearly,
+ 0
+};
+
+static struct rrd_image *systemp_images[] = {
+ &systempdaily,
+ &systempweekly,
+ &systempmonthly,
+ &systempyearly,
+ 0
+};
+
+struct rrd_data_source cpumem_sources[] = {
+ {
+ .name = "User",
+ .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,
+ },
+ {
+ .name = "Swap",
+ .type = "GAUGE",
+ .heartbeat = 240,
+ .min = 0,
+ .max = 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,
+ },
+ {},
+};
+
+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 = 0,
+ .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 = 0,
+ .max = 3000,
+ },
+};
+
+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,
+ },
+ {},
+};
+
+static struct rrd_database cpumem_rrd = {
+ .filename = SYSINFO_RRD_PATH,
+ .interval = 120,
+ .parse = cpu_mem_parser,
+ .images = (struct rrd_image **)&cpu_mem_images,
+ .sources = cpumem_sources,
+ .archives = cpumem_archives,
+ .name = "cpumem",
+};
+
+static struct rrd_database power_rrd = {
+ .name = "power",
+ .filename = "./power.rrd",
+ .interval = 300,
+ .sources = power_sources,
+ .archives = power_archives,
+};
+
+static struct rrd_database systemp_rrd = {
+ .interval = 300,
+ .parse = NULL,
+ .images = (struct rrd_image **)&systemp_images,
+ .name = "systemp",
+};
+
+static struct rrd_database *all_rrds[] = {
+ &cpumem_rrd,
+ &systemp_rrd,
+ &power_rrd,
+ 0
+};
+
+#endif