1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-12-23 19:39:06 +00:00

smp support?

git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky@211 7f574dfc-610e-0410-a909-a81674777703
This commit is contained in:
Brenden Matthews 2005-08-27 10:10:31 +00:00
parent af6435c957
commit e3f5429f9d
2 changed files with 42 additions and 16 deletions

View File

@ -1038,18 +1038,41 @@ if (s[0] == '#') {
END OBJ(buffers, INFO_BUFFERS)
END OBJ(cached, INFO_BUFFERS)
END OBJ(cpu, INFO_CPU)
if (arg) {
if (sscanf(arg, "%i", &obj->data.cpu_index) < 1) {
ERR("$cpu takes an int as an arg");
if (arg) {
if (sscanf(arg, "%i", &obj->data.cpu_index) < 1) {
ERR("$cpu takes an int as an arg");
}
} else {
obj->data.cpu_index = 0;
}
END OBJ(cpubar, INFO_CPU)
if (arg) {
if (sscanf(arg, "%i", &obj->data.cpu_index) < 1) {
if (sscanf(arg, "%i %*s", &obj->data.cpu_index) < 1) {
ERR("$cpu takes an int as an arg");
} else {
char buf[128];
sscanf(arg, "%*i %127s", buf);
(void) scan_bar(buf, &obj->a, &obj->b);
}
}
printf("got %i\n", obj->data.cpu_index);
} else {
obj->data.cpu_index = 0;
}
END OBJ(cpubar, INFO_CPU)
(void) scan_bar(arg, &obj->data.pair.a, &obj->data.pair.b);
END OBJ(cpugraph, INFO_CPU)
(void) scan_graph(arg, &obj->a, &obj->b, &obj->c, &obj->d, &obj->e);
if (arg) {
if (sscanf(arg, "%i", &obj->data.cpu_index) < 1) {
if (sscanf(arg, "%i %*s", &obj->data.cpu_index) < 1) {
ERR("$cpu takes an int as an arg");
} else {
char buf[128];
sscanf(arg, "%*i %127s", buf);
(void) scan_graph(buf, &obj->a, &obj->b, &obj->c, &obj->d, &obj->e);
}
}
} else {
obj->data.cpu_index = 0;
}
END OBJ(diskio, INFO_DISKIO)
END OBJ(diskiograph, INFO_DISKIO) (void) scan_graph(arg, &obj->a, &obj->b, &obj->c, &obj->d, &obj->e);
END OBJ(color, 0)
@ -1778,7 +1801,7 @@ static void generate_text()
human_readable(cur->cached * 1024, p, 255);
}
OBJ(cpu) {
if (obj->data.cpu_index > (info.cpu_count - 1)) {
if (obj->data.cpu_index > info.cpu_count) {
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!");
}
@ -1793,8 +1816,8 @@ static void generate_text()
100.0));
}
OBJ(cpubar) {
new_bar(p, obj->data.pair.a,
obj->data.pair.b,
new_bar(p, obj->a,
obj->b,
(int) (cur->cpu_usage[0] * 255.0));
}
OBJ(cpugraph) {

View File

@ -355,7 +355,6 @@ void get_cpu_count()
}
}
info.cpu_usage = malloc(info.cpu_count * sizeof(float));
printf("cpu count is %i\n", info.cpu_count);
}
@ -371,7 +370,11 @@ inline static void update_stat()
cpu_setup = 1;
}
if (cpu == NULL) {
if (info.cpu_count > 1) {
cpu = malloc((info.cpu_count + 1) * sizeof(struct cpu_info));
} else {
cpu = malloc(info.cpu_count * sizeof(struct cpu_info));
}
}
if (stat_fp == NULL) {
stat_fp = open_file("/proc/stat", &rep);
@ -389,14 +392,16 @@ inline static void update_stat()
if (strncmp(buf, "procs_running ", 14) == 0) {
sscanf(buf, "%*s %d", &info.run_procs);
info.mask |= (1 << INFO_RUN_PROCS);
} else if (strncmp(buf, "cpu ", 4) == 0) {
sscanf(buf, "%*s %u %u %u", &(cpu[index].cpu_user), &(cpu[index].cpu_nice), &(cpu[index].cpu_system));
index++;
info.mask |= (1 << INFO_CPU);
} else if (strncmp(buf, "cpu", 3) == 0 && isdigit(buf[3]) && index < info.cpu_count) {
sscanf(buf, "%*s %u %u %u", &(cpu[index].cpu_user), &(cpu[index].cpu_nice),
&(cpu[index].cpu_system));
sscanf(buf, "%*s %u %u %u", &(cpu[index].cpu_user), &(cpu[index].cpu_nice), &(cpu[index].cpu_system));
index++;
info.mask |= (1 << INFO_CPU);
}
}
for (index = 0; index < info.cpu_count; index++) {
double delta;
delta = current_update_time - last_update_time;
@ -414,7 +419,6 @@ inline static void update_stat()
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;
for (i = info.cpu_avg_samples; i > 1; i--)
@ -1201,7 +1205,6 @@ void update_diskio()
* cd-roms and floppies, and summ them up
*/
current = 0;
strcmp(buf, "fasdf");
while (!feof(fp)) {
fgets(buf, 512, fp);
col_count = sscanf(buf, "%u %u %*s %*u %*u %u %*u %*u %*u %u",