$OpenBSD: patch-ede-panel_applets_cpu-monitor_CpuMonitor_cpp,v 1.2 2014/07/11 21:39:04 pascal Exp $
--- ede-panel/applets/cpu-monitor/CpuMonitor.cpp.orig	Sat Jun 21 23:24:21 2014
+++ ede-panel/applets/cpu-monitor/CpuMonitor.cpp	Fri Jul 11 19:07:04 2014
@@ -36,7 +36,7 @@
 # include <string.h> /* strncmp */
 #endif
 
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__OpenBSD__)
 # include <sys/param.h>
 # include <sys/sysctl.h>
 # if __FreeBSD_version < 500101
@@ -49,7 +49,7 @@
 
 #include "CpuMonitor.h"
 
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__OpenBSD__)
 
 /* The part ripped from top... */
 /*
@@ -481,15 +481,18 @@ void CPUMonitor::get_cpu_info() {
 
 #endif /* have_kstat_h */
 
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__OpenBSD__)
 	size_t len = sizeof(cp_time);
+	int mib[2];
 
 	cpu[samples()-1][IWM_USER] = 0;
 	cpu[samples()-1][IWM_NICE] = 0;
 	cpu[samples()-1][IWM_SYS] = 0;
 	cpu[samples()-1][IWM_IDLE] = 0;
 
-	if (sysctlbyname("kern.cp_time", &cp_time, &len, NULL, 0) == -1)
+	mib[0] = CTL_KERN;
+	mib[1] = KERN_CPTIME;
+	if (sysctl(mib, 2, &cp_time, &len, NULL, 0) == -1)
 		return; /* FIXME : need err handler? */
 
 	percentages(CPUSTATES, cpu_states, cp_time, cp_old, cp_diff);
