Added watch function
This commit is contained in:
parent
34bbcf7883
commit
4cb9ef42a6
@ -39,6 +39,7 @@ Available options:
|
||||
--reset : Reset all fans to their default mode
|
||||
--sensors : Print sensor readings even if setting a fan speed
|
||||
--compact : Print sensor reading in a compact one-line per card format
|
||||
--watch N : Keep printing output every N seconds
|
||||
```
|
||||
|
||||
### Examples:
|
||||
|
18
evga-icx.c
18
evga-icx.c
@ -20,7 +20,8 @@ static const char helpstring[] = "Available options:\n"
|
||||
" [+/-]N to set that fan to an RPM offset from the GPU-controlled speed\n"
|
||||
"--reset : Reset all fans to their default mode\n"
|
||||
"--sensors : Print sensor readings even if setting a fan speed \n"
|
||||
"--compact : Print sensor reading in a compact one-line per card format\n";
|
||||
"--compact : Print sensor reading in a compact one-line per card format\n"
|
||||
"--watch N : Keep printing output every N seconds\n";
|
||||
|
||||
void print_gpu_info(int gpu_num, struct card_info gpus[], int compact);
|
||||
|
||||
@ -31,6 +32,7 @@ int main (int argc, char **argv)
|
||||
int print_info = 0;
|
||||
int compact = 0;
|
||||
int gpu_num = -1; /* Card to control */
|
||||
int watch = -1;
|
||||
char *fan_speed[ICX3_MAX_FANS] = {NULL};
|
||||
|
||||
/* Input parsing */
|
||||
@ -69,6 +71,14 @@ int main (int argc, char **argv)
|
||||
print_info = 1;
|
||||
} else if (strcmp(argv[i], "--compact") == 0) {
|
||||
compact = 1;
|
||||
} else if (strcmp(argv[i], "--watch") == 0) {
|
||||
i++;
|
||||
if (i < argc) {
|
||||
watch = atoi(argv[i]);
|
||||
} else {
|
||||
printf(helpstring);
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
printf(helpstring);
|
||||
return 0;
|
||||
@ -116,6 +126,7 @@ int main (int argc, char **argv)
|
||||
}
|
||||
|
||||
/* print sensor info */
|
||||
print:
|
||||
if (print_info) {
|
||||
if (gpu_num == -1) {
|
||||
for (int i = 0; i < gpu_count; i++){
|
||||
@ -125,7 +136,10 @@ int main (int argc, char **argv)
|
||||
print_gpu_info(gpu_num, gpus, compact);
|
||||
}
|
||||
}
|
||||
|
||||
if (watch > 0) {
|
||||
sleep(watch);
|
||||
goto print;
|
||||
}
|
||||
}
|
||||
|
||||
void print_gpu_info(int gpu_num, struct card_info gpus[], int compact) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user