Skip to content

Commit

Permalink
Fix for AMD GPU drm different format proc file (netdata#16561)
Browse files Browse the repository at this point in the history
  • Loading branch information
Emmanuel Vasilakis committed Dec 7, 2023
1 parent 85d3e67 commit e973222
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions collectors/proc.plugin/sys_class_drm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit e973222

Please sign in to comment.