[Xfce4-commits] <xfce4-cpugraph-plugin:master> Fix reading cpu data on FreeBSD
Florian Rivoal
noreply at xfce.org
Sat Jul 24 18:38:01 CEST 2010
Updating branch refs/heads/master
to 406553c8d2a5a984038d2ec845e0a98271a14a40 (commit)
from 72b960fbb3efe667fc448447e745c4594928eb31 (commit)
commit 406553c8d2a5a984038d2ec845e0a98271a14a40
Author: Florian Rivoal <frivoal at gmail.com>
Date: Sun Jul 25 01:09:28 2010 +0900
Fix reading cpu data on FreeBSD
The data reading logic was broken, and now it should be sane. This fixes
Bug 6530.
panel-plugin/os.c | 21 +++++----------------
1 files changed, 5 insertions(+), 16 deletions(-)
diff --git a/panel-plugin/os.c b/panel-plugin/os.c
index 20535f4..0dfb445 100644
--- a/panel-plugin/os.c
+++ b/panel-plugin/os.c
@@ -110,28 +110,17 @@ guint detect_cpu_number()
gboolean read_cpu_data( CpuData *data, guint nb_cpu)
{
- guint user, nice, sys, bsdidle, idle;
- guint used, total;
- gint cp_time[CPUSTATES];
+ glong used, total;
+ glong cp_time[CPUSTATES];
gsize len = sizeof( cp_time );
- guint usage;
-
if( sysctlbyname( "kern.cp_time", &cp_time, &len, NULL, 0 ) < 0 )
- {
return FALSE;
- }
-
- user = cp_time[CP_USER];
- nice = cp_time[CP_NICE];
- sys = cp_time[CP_SYS];
- bsdidle = cp_time[CP_IDLE];
- idle = cp_time[CP_IDLE];
- used = user+nice+sys;
- total = used+bsdidle;
+ used = cp_time[CP_USER] + cp_time[CP_NICE] + cp_time[CP_SYS] + cp_time[CP_INTR];
+ total = used + cp_time[CP_IDLE];
if( (total - data[0].previous_total) != 0 )
- data[0].load = (CPU_SCALE * (used - data[0].previous_total))/(total - data[0].previous_total);
+ data[0].load = (CPU_SCALE * (used - data[0].previous_used))/(total - data[0].previous_total);
else
data[0].load = 0;
More information about the Xfce4-commits
mailing list