1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2025-02-03 04:28:35 +00:00

smp support?

git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky@209 7f574dfc-610e-0410-a909-a81674777703
This commit is contained in:
Brenden Matthews 2005-08-27 09:43:28 +00:00
parent 46193ed06c
commit 22d6007f79
2 changed files with 8 additions and 5 deletions

View File

@ -1042,8 +1042,9 @@ if (s[0] == '#') {
if (sscanf(arg, "%i", &obj->data.cpu_index) < 1) {
ERR("$cpu takes an int as an arg");
}
printf("got %i\n", obj->data.cpu_index);
} else {
obj->data.cpu_index = 1;
obj->data.cpu_index = 0;
}
END OBJ(cpubar, INFO_CPU)
(void) scan_bar(arg, &obj->data.pair.a, &obj->data.pair.b);
@ -1777,7 +1778,8 @@ static void generate_text()
human_readable(cur->cached * 1024, p, 255);
}
OBJ(cpu) {
if (obj->data.cpu_index > info.cpu_count) {
if (obj->data.cpu_index > (info.cpu_count - 1)) {
printf("obj->data.cpu_index %i info.cpu_count %i", obj->data.cpu_index, info.cpu_count);
CRIT_ERR("attempting to use more CPUs then you have!");
}
if (!use_spacer)

View File

@ -338,7 +338,7 @@ void get_cpu_count()
{
char buf[256];
if (stat_fp == NULL)
stat_fp = open_file("/tmp/testcpu", &rep);
stat_fp = open_file("/proc/stat", &rep);
else
fseek(stat_fp, 0, SEEK_SET);
if (stat_fp == NULL)
@ -375,7 +375,7 @@ inline static void update_stat()
cpu = malloc(info.cpu_count * sizeof(struct cpu_info));
}
if (stat_fp == NULL)
stat_fp = open_file("/tmp/testcpu", &rep);
stat_fp = open_file("/proc/stat", &rep);
else
fseek(stat_fp, 0, SEEK_SET);
if (stat_fp == NULL)
@ -408,8 +408,9 @@ inline static void update_stat()
cpu[index].cpu_val[0] =
(cpu[index].cpu_user + cpu[index].cpu_nice + cpu[index].cpu_system -
cpu[index].last_cpu_sum) / delta / (double) cpu[index].clock_ticks;
for (i = 0; i < info.cpu_avg_samples; i++)
for (i = 0; i < info.cpu_avg_samples; i++) {
curtmp += cpu[index].cpu_val[i];
}
printf("setting usage to %f\n", curtmp / info.cpu_avg_samples);
info.cpu_usage[index] = curtmp / info.cpu_avg_samples;
cpu[index].last_cpu_sum = cpu[index].cpu_user + cpu[index].cpu_nice + cpu[index].cpu_system;