[pve-devel] [PATCH cluster 1/1] Add new rrd version for VM disk operations

Tobias Böhm tb at robhost.de
Mon Jun 19 12:09:39 CEST 2017


To support disk read/write operations for VMs the rrd needs new DS for the
two new metrics. In order to not lose old data a new rrd version pve5.0-vm
is introduced.

Signed-off-by: Tobias Böhm <tb at robhost.de>
---
 data/src/status.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)

diff --git a/data/src/status.c b/data/src/status.c
index 030c003..f05fcb6 100644
--- a/data/src/status.c
+++ b/data/src/status.c
@@ -862,6 +862,34 @@ static const char *rrd_def_vm[] = {
 	NULL,
 };
 
+static const char *rrd_def_vm50[] = {
+	"DS:maxcpu:GAUGE:120:0:U",
+	"DS:cpu:GAUGE:120:0:U",
+	"DS:maxmem:GAUGE:120:0:U",
+	"DS:mem:GAUGE:120:0:U",
+	"DS:maxdisk:GAUGE:120:0:U",
+	"DS:disk:GAUGE:120:0:U",
+	"DS:netin:DERIVE:120:0:U",
+	"DS:netout:DERIVE:120:0:U",
+	"DS:diskread:DERIVE:120:0:U",
+	"DS:diskwrite:DERIVE:120:0:U",
+	"DS:ioread:DERIVE:120:0:U",
+	"DS:iowrite:DERIVE:120:0:U",
+
+	"RRA:AVERAGE:0.5:1:70", // 1 min avg - one hour
+	"RRA:AVERAGE:0.5:30:70", // 30 min avg - one day
+	"RRA:AVERAGE:0.5:180:70", // 3 hour avg - one week
+	"RRA:AVERAGE:0.5:720:70", // 12 hour avg - one month
+	"RRA:AVERAGE:0.5:10080:70", // 7 day avg - ony year
+
+	"RRA:MAX:0.5:1:70", // 1 min max - one hour
+	"RRA:MAX:0.5:30:70", // 30 min max - one day
+	"RRA:MAX:0.5:180:70",  // 3 hour max - one week
+	"RRA:MAX:0.5:720:70", // 12 hour max - one month
+	"RRA:MAX:0.5:10080:70", // 7 day max - ony year
+	NULL,
+};
+
 static const char *rrd_def_storage[] = {
 	"DS:total:GAUGE:120:0:U",
 	"DS:used:GAUGE:120:0:U",
@@ -983,6 +1011,27 @@ update_rrd_data(
 			create_rrd_file(filename, argcount, rrd_def_vm);
 		}
 
+	} else if (strncmp(key, "pve5.0-vm/", 10) == 0) {
+		const char *vmid;
+
+		vmid = key + 10;
+		skip = 4;
+
+		if (strchr(vmid, '/') != NULL)
+			goto keyerror;
+
+		if (strlen(vmid) < 1)
+			goto keyerror;
+
+		filename = g_strdup_printf(RRDDIR "/%s/%s", "pve5.0-vm", vmid);
+
+		if (!g_file_test(filename, G_FILE_TEST_EXISTS)) {
+
+			mkdir(RRDDIR "/pve5.0-vm", 0755);
+			int argcount = sizeof(rrd_def_vm50)/sizeof(void*) - 1;
+			create_rrd_file(filename, argcount, rrd_def_vm50);
+		}
+
 	} else if (strncmp(key, "pve2-storage/", 13) == 0) {
 		const char *node = key + 13;
 
-- 
2.11.0




More information about the pve-devel mailing list