diff options
author | Emmanuel Vasilakis <mrzammler@mm.st> | 2023-12-07 16:39:32 +0200 |
---|---|---|
committer | Tasos Katsoulas <12612986+tkatsoulas@users.noreply.github.com> | 2023-12-12 17:25:00 +0200 |
commit | efa9d109c9c6bb7afac52f9e4b9431f7c5e785ef (patch) | |
tree | acb7660454c70718a09a0f01ed4a2e8d29b231de | |
parent | 47bacfab3bb03aa0a49aabe80a44174265b3a5ee (diff) |
Fix for AMD GPU drm different format proc file (#16561)
(cherry picked from commit e9732229374d13ffc507ba9f7e77e01a4d78179c)
-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); |