mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-11-05 21:07:52 +00:00
- Hide i8k stuff under "#ifdef __linux__" since I don't think it present
on non-Linux systems - Fiddle with cpu usage detecting code on FreeBSD. Now it can show usage on all CPUs, but usage for some single CPU on SMP system is not supported (I have no SMP, so it's hard to write/test SMP support for me). git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky@218 7f574dfc-610e-0410-a909-a81674777703
This commit is contained in:
parent
313ef55c14
commit
c336133dea
@ -208,8 +208,10 @@ void update_stuff()
|
||||
if (NEED(INFO_TOP))
|
||||
update_top();
|
||||
|
||||
#if defined(__linux__)
|
||||
if (NEED(INFO_I8K))
|
||||
update_i8k();
|
||||
#endif /* __linux__ */
|
||||
|
||||
#ifdef MLDONKEY
|
||||
if (NEED(INFO_MLDONKEY))
|
||||
|
@ -746,6 +746,7 @@ enum text_object_type {
|
||||
OBJ_alignr,
|
||||
OBJ_alignc,
|
||||
OBJ_i2c,
|
||||
#if defined(__linux__)
|
||||
OBJ_i8k_version,
|
||||
OBJ_i8k_bios,
|
||||
OBJ_i8k_serial,
|
||||
@ -757,6 +758,7 @@ enum text_object_type {
|
||||
OBJ_i8k_right_fan_rpm,
|
||||
OBJ_i8k_ac_status,
|
||||
OBJ_i8k_buttons_status,
|
||||
#endif /* __linux__ */
|
||||
OBJ_if_existing,
|
||||
OBJ_if_mounted,
|
||||
OBJ_if_running,
|
||||
@ -1024,6 +1026,7 @@ if (s[0] == '#') {
|
||||
else
|
||||
strcpy(bat, "BAT0");
|
||||
obj->data.s = strdup(bat);
|
||||
#if defined(__linux__)
|
||||
END OBJ(i8k_version, INFO_I8K)
|
||||
END OBJ(i8k_bios, INFO_I8K)
|
||||
END OBJ(i8k_serial, INFO_I8K)
|
||||
@ -1035,6 +1038,7 @@ if (s[0] == '#') {
|
||||
END OBJ(i8k_right_fan_rpm, INFO_I8K)
|
||||
END OBJ(i8k_ac_status, INFO_I8K)
|
||||
END OBJ(i8k_buttons_status, INFO_I8K)
|
||||
#endif /* __linux__ */
|
||||
END OBJ(buffers, INFO_BUFFERS)
|
||||
END OBJ(cached, INFO_BUFFERS)
|
||||
END OBJ(cpu, INFO_CPU)
|
||||
@ -1825,6 +1829,7 @@ static void generate_text()
|
||||
OBJ(color) {
|
||||
new_fg(p, obj->data.l);
|
||||
}
|
||||
#if defined(__linux__)
|
||||
OBJ(i8k_version) {
|
||||
snprintf(p, n, "%s", i8k.version);
|
||||
}
|
||||
@ -1886,7 +1891,7 @@ static void generate_text()
|
||||
snprintf(p, n, "%s", i8k.buttons_status);
|
||||
|
||||
}
|
||||
|
||||
#endif /* __linux__ */
|
||||
|
||||
#ifdef X11
|
||||
OBJ(font) {
|
||||
|
@ -33,6 +33,7 @@
|
||||
#define MAXSHOWDEVS 16
|
||||
|
||||
u_int64_t diskio_prev = 0;
|
||||
static short cpu_setup = 0;
|
||||
|
||||
static int getsysctl(char *name, void *ptr, size_t len)
|
||||
{
|
||||
@ -265,12 +266,29 @@ struct cpu_load_struct {
|
||||
struct cpu_load_struct fresh = { {0, 0, 0, 0, 0} };
|
||||
long cpu_used, oldtotal, oldused;
|
||||
|
||||
void get_cpu_count()
|
||||
{
|
||||
int cpu_count = 0;
|
||||
|
||||
if (GETSYSCTL("hw.ncpu", cpu_count) == 0)
|
||||
info.cpu_count = cpu_count;
|
||||
|
||||
info.cpu_usage = malloc(info.cpu_count * sizeof(float));
|
||||
if (info.cpu_usage == NULL)
|
||||
CRIT_ERR("malloc");
|
||||
}
|
||||
|
||||
void update_cpu_usage()
|
||||
{
|
||||
long used, total;
|
||||
long cp_time[CPUSTATES];
|
||||
size_t len = sizeof(cp_time);
|
||||
|
||||
if (cpu_setup == 0) {
|
||||
get_cpu_count();
|
||||
cpu_setup = 1;
|
||||
}
|
||||
|
||||
if (sysctlbyname("kern.cp_time", &cp_time, &len, NULL, 0) < 0) {
|
||||
(void) fprintf(stderr, "Cannot get kern.cp_time");
|
||||
}
|
||||
@ -286,11 +304,9 @@ void update_cpu_usage()
|
||||
fresh.load[0] + fresh.load[1] + fresh.load[2] + fresh.load[3];
|
||||
|
||||
if ((total - oldtotal) != 0) {
|
||||
info.cpu_usage =
|
||||
((double) (used - oldused)) / (double) (total -
|
||||
oldtotal);
|
||||
info.cpu_usage[0] = ((double) (used - oldused)) / (double) (total - oldtotal);
|
||||
} else {
|
||||
info.cpu_usage = 0;
|
||||
info.cpu_usage[0] = 0;
|
||||
}
|
||||
|
||||
oldused = used;
|
||||
|
Loading…
Reference in New Issue
Block a user