#include "scheduler.h"
#include "parser.h"
-const char blank[] = "COMMENT: ";
+const char blank[] = "COMMENT: ";
#define numfmt " % 8.2lf "
-#define SYSINFO_PATH "/home/kaapeli/sysinfo/"
+#define SYSINFO_PATH "/home/kaapeli/rrdd/sysinfo/"
#define SYSINFO_RRD_PATH SYSINFO_PATH "sysinfo.rrd"
#define SYSINFO_IMAGES_PATH SYSINFO_PATH "images/"
+#define POWER_PATH "/home/kaapeli/rrdd/power/"
+#define POWER_RRD_PATH POWER_PATH "power.rrd"
+#define POWER_IMAGES_PATH POWER_PATH "images/"
+
#define SYSTEMP_RRD_PATH "/root/systemp/systemp.rrd"
const char *cputext[] = {
0
};
+const char *powertext[] = {
+ "DEF:vesiv=" POWER_RRD_PATH ":vesivoima:AVERAGE",
+ "DEF:ydinv=" POWER_RRD_PATH ":ydinvoima:AVERAGE",
+ "DEF:lauhd=" POWER_RRD_PATH ":lauhdevoima:AVERAGE",
+ "DEF:kauko=" POWER_RRD_PATH ":kaukolampo:AVERAGE",
+ "DEF:teoll=" POWER_RRD_PATH ":teollisuus:AVERAGE",
+ "DEF:muutu=" POWER_RRD_PATH ":muu:AVERAGE",
+ "DEF:huipp=" POWER_RRD_PATH ":huippuvoima:AVERAGE",
+ "DEF:tuont=" POWER_RRD_PATH ":tuonti:AVERAGE",
+ "COMMENT:\\n",
+ blank,
+ "COMMENT: "
+ "MIN MAX AVG Last\\n",
+ blank,
+ "AREA:tuont#000000:Tuonti ",
+ "GPRINT:tuont:MIN:" numfmt,
+ "GPRINT:tuont:MAX:" numfmt,
+ "GPRINT:tuont:AVERAGE:" numfmt,
+ "GPRINT:tuont:LAST:" numfmt "\\n",
+ "COMMENT: \\n",
+ blank,
+ "STACK:muutu#808080:Muu ",
+ "GPRINT:huipp:MIN:" numfmt,
+ "GPRINT:huipp:MAX:" numfmt,
+ "GPRINT:huipp:AVERAGE:" numfmt,
+ "GPRINT:huipp:LAST:" numfmt "\\n",
+ "COMMENT: \\n",
+ blank,
+ "STACK:vesiv#0000ff:Vesivoima ",
+ "GPRINT:vesiv:MIN:" numfmt,
+ "GPRINT:vesiv:MAX:" numfmt,
+ "GPRINT:vesiv:AVERAGE:" numfmt,
+ "GPRINT:vesiv:LAST:" numfmt "\\n",
+ "COMMENT: \\n",
+ blank,
+ "STACK:lauhd#ff0000:Lauhdevoima ",
+ "GPRINT:lauhd:MIN:" numfmt,
+ "GPRINT:lauhd:MAX:" numfmt,
+ "GPRINT:lauhd:AVERAGE:" numfmt,
+ "GPRINT:lauhd:LAST:" numfmt "\\n",
+ "COMMENT: \\n",
+ blank,
+ "STACK:kauko#00ff00:Kaukolämpö ",
+ "GPRINT:kauko:MIN:" numfmt,
+ "GPRINT:kauko:MAX:" numfmt,
+ "GPRINT:kauko:AVERAGE:" numfmt,
+ "GPRINT:kauko:LAST:" numfmt "\\n",
+ "COMMENT: \\n",
+ blank,
+ "STACK:teoll#ff00ff:Teollisuus ",
+ "GPRINT:teoll:MIN:" numfmt,
+ "GPRINT:teoll:MAX:" numfmt,
+ "GPRINT:teoll:AVERAGE:" numfmt,
+ "GPRINT:teoll:LAST:" numfmt "\\n",
+ "COMMENT: \\n",
+ blank,
+ "STACK:huipp#ff0000:Huippuvoima ",
+ "GPRINT:huipp:MIN:" numfmt,
+ "GPRINT:huipp:MAX:" numfmt,
+ "GPRINT:huipp:AVERAGE:" numfmt,
+ "GPRINT:huipp:LAST:" numfmt "\\n",
+ "COMMENT: \\n",
+ blank,
+ "STACK:ydinv#ffff00:Ydinvoima ",
+ "GPRINT:ydinv:MIN:" numfmt,
+ "GPRINT:ydinv:MAX:" numfmt,
+ "GPRINT:ydinv:AVERAGE:" numfmt,
+ "GPRINT:ydinv:LAST:" numfmt "\\n",
+ "COMMENT: \\n",
+ 0
+};
+
const char *cpuoptions[] = {
"--alt-autoscale-max",
+ "--lower-limit", "0",
"--vertical-label",
"CPU Tics",
0
const char *memoptions[] = {
"--alt-autoscale-max",
+ "--lower-limit", "0",
"--vertical-label",
"Mem usage (MB)",
"--units-exponent", "0",
0
};
+const char *poweroptions[] = {
+ "--alt-autoscale-max",
+ "--lower-limit", "0",
+ "--vertical-label",
+ "Teho (MW)",
+ "--units-exponent", "0",
+ 0
+};
+
static struct rrd_image cpudaily = {
.image_filename = SYSINFO_IMAGES_PATH "cpu_daily.png",
.width = 720,
.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 = 200,
+ .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 = 200,
+ .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 = 200,
+ .timestart = "end-1y",
+ .timeend = "now",
+ .imageformat = "PNG",
+ .options = (char **)&poweroptions,
+ .text = (char **)&powertext
+};
+
static struct rrd_image *cpu_mem_images[] = {
&cpudaily,
&cpuweekly,
0
};
+static struct rrd_image *power_images[] = {
+ &powerdaily,
+ &powerweekly,
+ &powermonthly,
+ &poweryearly,
+ 0
+};
+
struct rrd_data_source cpumem_sources[] = {
{
.name = "User",
.min = 0,
.max = 1200,
},
+ {
+ .name = "Nice",
+ .type = "COUNTER",
+ .heartbeat = 240,
+ .min = 0,
+ .max = 1200,
+ },
{
.name = "Sys",
.type = "COUNTER",
.name = "cpumem",
};
+char *power_parse_cmdline[] = {
+ "./parse_power.sh",
+ "",
+ NULL,
+};
+
static struct rrd_database power_rrd = {
.name = "power",
- .filename = "./power.rrd",
- .interval = 300,
+ .filename = POWER_RRD_PATH,
+ .interval = 180,
.sources = power_sources,
.archives = power_archives,
+ .parse = script_parser,
+ .parser_data = power_parse_cmdline,
+ .images = power_images,
};
static struct rrd_database systemp_rrd = {
.interval = 300,
.parse = NULL,
+ .filename = NULL,
.images = (struct rrd_image **)&systemp_images,
.name = "systemp",
};