For PVE9 there will be additional fields in the metrics that are collected. The new columns/fields are added at the end of the current ones. Therefore, if we get the new format, we need to cut it.
Paths to rrd filenames needed to be set manually to 'pve2-...' and will use the 'node' part instead of the full key, as that could also be 'pve9-...' which does not exists. Signed-off-by: Aaron Lauterer <a.laute...@proxmox.com> --- src/pmxcfs/status.c | 51 ++++++++++++++++++++++++++++++++++++++------- src/pmxcfs/status.h | 2 ++ 2 files changed, 46 insertions(+), 7 deletions(-) diff --git a/src/pmxcfs/status.c b/src/pmxcfs/status.c index 77a18d8..3fdb179 100644 --- a/src/pmxcfs/status.c +++ b/src/pmxcfs/status.c @@ -1236,6 +1236,8 @@ rrd_skip_data( return data; } +static char* rrd_format_update_buffer = NULL; + static void update_rrd_data( const char *key, @@ -1255,9 +1257,15 @@ update_rrd_data( char *filename = NULL; + if (!rrd_format_update_buffer) { + rrd_format_update_buffer = (char*)malloc(RRD_FORMAT_BUFFER_SIZE); + } + int skip = 0; + int data_cutoff = 0; // how many columns after initial skip should be a cut-off - if (strncmp(key, "pve2-node/", 10) == 0) { + if (strncmp(key, "pve2-node/", 10) == 0 || + strncmp(key, "pve9-node/", 10) == 0) { const char *node = key + 10; skip = 2; @@ -1268,7 +1276,11 @@ update_rrd_data( if (strlen(node) < 1) goto keyerror; - filename = g_strdup_printf(RRDDIR "/%s", key); + if (strncmp(key, "pve9-node/", 10) == 0) { + data_cutoff = 13; + } + + filename = g_strdup_printf(RRDDIR "/pve2-node/%s", node); if (!g_file_test(filename, G_FILE_TEST_EXISTS)) { @@ -1277,8 +1289,15 @@ update_rrd_data( create_rrd_file(filename, argcount, rrd_def_node); } - } else if (strncmp(key, "pve2.3-vm/", 10) == 0) { - const char *vmid = key + 10; + } else if (strncmp(key, "pve2.3-vm/", 10) == 0 || + strncmp(key, "pve9-vm/", 8) == 0) { + + const char *vmid; + if (strncmp(key, "pve2.3-vm/", 10) == 0) { + vmid = key + 10; + } else { + vmid = key + 8; + } skip = 4; @@ -1288,6 +1307,10 @@ update_rrd_data( if (strlen(vmid) < 1) goto keyerror; + if (strncmp(key, "pve9-vm/", 8) == 0) { + data_cutoff = 11; + } + filename = g_strdup_printf(RRDDIR "/%s/%s", "pve2-vm", vmid); if (!g_file_test(filename, G_FILE_TEST_EXISTS)) { @@ -1297,7 +1320,8 @@ update_rrd_data( create_rrd_file(filename, argcount, rrd_def_vm); } - } else if (strncmp(key, "pve2-storage/", 13) == 0) { + } else if (strncmp(key, "pve2-storage/", 13) == 0 || + strncmp(key, "pve9-storage/", 13) == 0) { const char *node = key + 13; const char *storage = node; @@ -1315,7 +1339,7 @@ update_rrd_data( if (strlen(storage) < 1) goto keyerror; - filename = g_strdup_printf(RRDDIR "/%s", key); + filename = g_strdup_printf(RRDDIR "/pve2-storage/%s", node); if (!g_file_test(filename, G_FILE_TEST_EXISTS)) { @@ -1335,7 +1359,20 @@ update_rrd_data( const char *dp = skip ? rrd_skip_data(data, skip) : data; - const char *update_args[] = { dp, NULL }; + if (data_cutoff) { + const char *cut = rrd_skip_data(dp, data_cutoff); + const int data_len = cut - dp - 1; // -1 to remove last colon + snprintf(rrd_format_update_buffer, RRD_FORMAT_BUFFER_SIZE, "%.*s", data_len, dp); + } else { + snprintf(rrd_format_update_buffer, RRD_FORMAT_BUFFER_SIZE, "%s", dp); + } + + const char *update_args[] = { rrd_format_update_buffer, NULL }; + + // TODO: remove in non RFC, but useful for debug logging to see if data is handled correctly + // cfs_message("KEY: %s", key); + // cfs_message("DATA: %s", dp); + // cfs_message("BUFFER: %s", rrd_format_update_buffer); if (use_daemon) { int status; diff --git a/src/pmxcfs/status.h b/src/pmxcfs/status.h index 041cb34..1a38f43 100644 --- a/src/pmxcfs/status.h +++ b/src/pmxcfs/status.h @@ -34,6 +34,8 @@ #define CFS_MAX_STATUS_SIZE (32*1024) +#define RRD_FORMAT_BUFFER_SIZE (1024 * 1024) // 1 MiB + typedef struct cfs_clnode cfs_clnode_t; typedef struct cfs_clinfo cfs_clinfo_t; -- 2.39.5 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel