title: How to run psutil inside a docker container?
body: <p>I am trying to monitor the CPU and Memory of my docker container from within my python application . I am planning to use psutil for this job. I have read on other forums that the <code>/proc</code> can be changed in psutil. </p>
  
  <pre><code>import psutil
  psutil.PROCFS_PATH = 'proc/self'
  psutil.cpu_percent()
  </code></pre>
  
  <p>This gives me the following error:</p>
  
  <pre><code> File "app.py", line 22, in &lt;module&gt;
   web-vote-app_1  |     r = psutil.cpu_percent()
   web-vote-app_1  |   File "/usr/local/lib/python2.7/site-packages/psutil       /__init__.py", line 1773, in cpu_percent
   web-vote-app_1  |     _last_cpu_times = cpu_times()
   web-vote-app_1  |   File "/usr/local/lib/python2.7/site-packages/psutil/__init__.py", line 1645, in cpu_times
   web-vote-app_1  |     return _psplatform.cpu_times() 
   web-vote-app_1  |   File "/usr/local/lib/python2.7/site-packages/psutil/_pslinux.py", line 544, in cpu_times
   web-vote-app_1  |     fields = [float(x) / CLOCK_TICKS for x in fields]
   web-vote-app_1  | ValueError: could not convert string to float: (python)
   web-result_1    |  * Running on http://0.0.0.0:5002/ (Press CTRL+C to quit)
   swarmmicroservicedemov1_web-vote-app_1 exited with code 1
  </code></pre>
  
  <p>Can anyone tell me if its possible to get the same information about the container instead of the host, if so. how ? Thanks</p>