<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -3,6 +3,7 @@
 #include &lt;sys/mount.h&gt;
 #include &lt;sys/time.h&gt;
 #include &lt;sys/sysctl.h&gt;
+#include &lt;sys/dkstat.h&gt;
 
 #include &lt;err.h&gt;
 #include &lt;stdio.h&gt;
@@ -97,7 +98,7 @@ PyObject *get_boottime(PyObject *self, PyObject *args){
     mib[1] = KERN_BOOTTIME;
 
     size = sizeof(boottime);
-    if (sysctl(mib, 2, &amp;boottime, &amp;size, NULL, 0) == -1){
+    if (sysctl(mib, 2, &amp;boottime, &amp;size, NULL, 0) &lt; 0){
         PyErr_SetFromErrno(OException);
         return NULL;
     }
@@ -105,11 +106,37 @@ PyObject *get_boottime(PyObject *self, PyObject *args){
 }
 
 
+PyObject *get_cpustats(PyObject *self, PyObject *args){
+    PyObject *cpudict;
+    size_t size;
+    int mib[2];
+    long cp_time[CPUSTATES];
+
+    size = sizeof(cp_time);
+    mib[0] = CTL_KERN;
+    mib[1] = KERN_CPTIME;
+
+    if (sysctl(mib, 2, cp_time, &amp;size, NULL, 0) &lt; 0){
+        bzero(cp_time, sizeof(cp_time));
+        PyErr_SetFromErrno(OException);
+        return NULL;
+    }
+
+    cpudict = Py_BuildValue(&quot;{s:l}&quot;, &quot;user&quot;, cp_time[CP_USER]);
+    stealingSetItem(cpudict, &quot;nice&quot;, PyLong_FromLong(cp_time[CP_NICE]));
+    stealingSetItem(cpudict, &quot;sys&quot;, PyLong_FromLong(cp_time[CP_SYS]));
+    stealingSetItem(cpudict, &quot;intr&quot;, PyLong_FromLong(cp_time[CP_INTR]));
+    stealingSetItem(cpudict, &quot;idle&quot;, PyLong_FromLong(cp_time[CP_IDLE]));
+    return cpudict;
+}
+
+
 static PyMethodDef SystemMethods[] = {
     {&quot;get_hostname&quot;, get_hostname, METH_VARARGS, &quot;Get hostname.&quot;},
     {&quot;set_hostname&quot;, set_hostname, METH_VARARGS, &quot;Set hostname.&quot;},
     {&quot;get_mntinfo&quot;, get_mntinfo, METH_VARARGS, &quot;Get mount info.&quot;},
     {&quot;get_boottime&quot;, get_boottime, METH_VARARGS, &quot;Get boot time.&quot;},
+    {&quot;get_cpustats&quot;, get_cpustats, METH_VARARGS, &quot;Get CPU stats.&quot;},
     {NULL, NULL, 0, NULL}            /* Sentinel */
 };
 </diff>
      <filename>openbsd/_system.c</filename>
    </modified>
    <modified>
      <diff>@@ -46,6 +46,11 @@ class System(object):
     def boottime(self):
         return datetime.datetime.fromtimestamp(_system.get_boottime())
 
+    @property
+    def cpustats(self):
+        dct = _system.get_cpustats()
+        return dct
+
     def _gethostname(self):
         return _system.get_hostname()
     def _sethostname(self, hostname):</diff>
      <filename>openbsd/system.py</filename>
    </modified>
    <modified>
      <diff>@@ -19,6 +19,9 @@ class uSystem(libpry.AutoTree):
     def test_boottime(self):
         assert self.s.boottime
 
+    def test_cpustats(self):
+        assert self.s.cpustats
+
     if os.geteuid() == 0:
 
         def test_sethostname(self):</diff>
      <filename>test/test_system.py</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>088a20fa470760c13ed4d8689e9021de481c07f4</id>
    </parent>
  </parents>
  <author>
    <name>Dave Harrison</name>
    <email>dave@nullcube.com</email>
  </author>
  <url>http://github.com/cortesi/pyopenbsd/commit/e049a5129e3260875764cca2e4d87afde5e113cb</url>
  <id>e049a5129e3260875764cca2e4d87afde5e113cb</id>
  <committed-date>2008-12-01T04:27:22-08:00</committed-date>
  <authored-date>2008-12-01T04:27:22-08:00</authored-date>
  <message>Add ability to collect cpu stats</message>
  <tree>4e9ea1ca5f81f6c394d323cc2016098863df5043</tree>
  <committer>
    <name>Dave Harrison</name>
    <email>dave@nullcube.com</email>
  </committer>
</commit>
