diff options
author | Emmanuel Vasilakis <mrzammler@mm.st> | 2023-12-07 16:39:32 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-07 16:39:32 +0200 |
commit | e9732229374d13ffc507ba9f7e77e01a4d78179c (patch) | |
tree | 4d1736e24296cc056b01df5673f3e79b22a9aad2 /collectors | |
parent | 85d3e67cdbb7e72a62f667235addc840f8a74d98 (diff) |
Fix for AMD GPU drm different format proc file (#16561)
Diffstat (limited to 'collectors')
-rw-r--r-- | collectors/proc.plugin/sys_class_drm.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/collectors/proc.plugin/sys_class_drm.c b/collectors/proc.plugin/sys_class_drm.c index 175304c1be..3ed1fb8757 100644 --- a/collectors/proc.plugin/sys_class_drm.c +++ b/collectors/proc.plugin/sys_class_drm.c @@ -648,13 +648,17 @@ static int read_clk_freq_file(procfile **p_ff, const char *const pathname, colle *p_ff = procfile_open(pathname, NULL, PROCFILE_FLAG_NO_ERROR_ON_FILE_IO); if(unlikely(!*p_ff)) return -2; } - + if(unlikely(NULL == (*p_ff = procfile_readall(*p_ff)))) return -3; for(size_t l = 0; l < procfile_lines(*p_ff) ; l++) { + char *str_with_units = NULL; + if((*p_ff)->lines->lines[l].words >= 3 && !strcmp(procfile_lineword((*p_ff), l, 2), "*")) //format: X: collected_number * + str_with_units = procfile_lineword((*p_ff), l, 1); + else if ((*p_ff)->lines->lines[l].words == 2 && !strcmp(procfile_lineword((*p_ff), l, 1), "*")) //format: collected_number * + str_with_units = procfile_lineword((*p_ff), l, 0); - if((*p_ff)->lines->lines[l].words >= 3 && !strcmp(procfile_lineword((*p_ff), l, 2), "*")){ - char *str_with_units = procfile_lineword((*p_ff), l, 1); + if (str_with_units) { char *delim = strchr(str_with_units, 'M'); char str_without_units[10]; memcpy(str_without_units, str_with_units, delim - str_with_units); |