-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsys_info.c
More file actions
44 lines (28 loc) · 807 Bytes
/
sys_info.c
File metadata and controls
44 lines (28 loc) · 807 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <ncurses.h> //TUI
// CPU Temp
void get_cpu_temp(int *row, int *col) {
int temp_raw;
FILE *f = fopen("/sys/class/thermal/thermal_zone7/temp", "r");
if (f) {
fscanf(f, "%d", &temp_raw);
fclose(f);
}
float celsius = temp_raw / 1000.0;
mvprintw((*row)++, *col, "CPU Temp: %.1f°C", celsius);
}
// Load avg
void get_load_avg(int *row, int *col) {
double load1, load5, load15;
FILE *f = fopen("/proc/loadavg", "r");
if (f) {
fscanf(f, "%lf %lf %lf", &load1, &load5, &load15);
fclose(f);
}
mvprintw((*row)++, *col, "Load Avg: %.2f (1m) %.2f (5m) %.2f (15m)", load1, load5, load15);
}
void get_sys_info(void) {
// to draw
int row=3, col=5;
get_cpu_temp(&row, &col);
get_load_avg(&row, &col);
}