Skip to content

Commit

Permalink
Update cpu.c
Browse files Browse the repository at this point in the history
  • Loading branch information
capt-d authored Dec 25, 2016
1 parent 34f132a commit fbc4e33
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions plugins/cpu/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ cpu_get_load_real(struct cpu_stat *cpu, unsigned int core)
stat = fopen("/proc/stat", "r");
if(!stat)
return -1;
sprintf(buf, "%s%u %s", "cpu", core-1, "%lu %lu %lu %lu %lu");
if (fscanf(stat, "cpu %lu %lu %lu %lu %lu", &cpu->u, &cpu->n, &cpu->s,
&cpu->i, &cpu->w));
fclose(stat);
Expand All @@ -62,6 +61,7 @@ cpu_get_load_real(struct cpu_stat *cpu, unsigned int core)
stat = popen(buf, "r");
if (!stat)
return -1;
sprintf(buf, "%s%u %s", "cpu", core-1, "%lu %lu %lu %lu %lu");
fscanf(stat, buf, &cpu->u, &cpu->n, &cpu->s,&cpu->i, &cpu->w);
pclose(stat);
}
Expand Down Expand Up @@ -133,13 +133,13 @@ cpu_get_load(cpu_priv *c)

end:
DBG("total=%f a=%f b=%f\n", total[0], a, b);
if (c->core >= 1)
if (c->core == 0)
{
g_snprintf(buf, sizeof(buf), "<b>Cpu:</b> %d%%", (int)(total[0] * 100));
g_snprintf(buf, sizeof(buf), "<b>Cpu total:</b> %d%%", (int)(total[0] * 100));
}
else
{
g_snprintf(buf, sizeof(buf), "<b>Cpu %u:</b> %d%%", c->core,(int)(total[0] * 100));
g_snprintf(buf, sizeof(buf), "<b>Cpu's core %u:</b> %d%%", c->core,(int)(total[0] * 100));
}
gtk_widget_set_tooltip_markup(((plugin_instance *)c)->pwid, buf);
k->add_tick(&c->chart, total);
Expand Down

0 comments on commit fbc4e33

Please sign in to comment.