Skip to content

Entries from June 2013.

Setting up trac on Debian

Trac is an issue tracking system with integrated Wiki that is highly customisable and offers big flexibility. One can use it to handle software projects (but it's not the only application for such type of system).

Having correctly pre-packaged version for your operating system is an advantage - you can setup it more quickly by reusing predefined environment and matching software versions.

OS packages installation

First of all, let's install some basic OS packages on Debian wheezy. # apt-get install apache2

apt-get install trac

apt-get install libapache2-mod-python

apt-get install trac-wysiwyg

apt-get install trac-subtickets

We have installed the HTTP server software, the trac itself (will all dependencies handled by OS packaing system), Apache2 module to run Python scripts server-side, wysiwyg plugin (sometimes it's just easier to edit tables in WYSIWYG mode) and subtickets capability (allows to make hierarchical tickets).

Trac setup

When trac binaries are installed we can create trac workdir and add permissions for admin user:

$ trac-admin /home/www-data/mysite initenv
$ trac-admin /home/www-data/mysite permission add dcieslak TRAC_ADMIN

If some plugins have been installed in workdir:

$ trac-admin /home/www-data/mysite upgrade

Apache setup

In order to be able to authorize in track we have to create auth database with sample user "dcieslak", we will use "digest" method to encrypt passwords exchanged between browser and server (even if no https is used): $ htdigest -c /home/www-data/mysite/mysite.htpasswd mysite dcieslak

Finally, we will setup Apache config (/etc/apache2/sites-enabled/mysite-trac.conf):

<Location /mysite>
  SetHandler mod_python
  PythonHandler trac.web.modpython_frontend
  PythonInterpreter main
  PythonOption TracEnv /home/www-data/mysite
  PythonOption TracUriRoot /mysite
  SetEnv PYTHON_EGG_CACHE /tmp

  AuthType Digest
  AuthName "mysite"
  AuthUserFile /home/www-data/mysite/mysite.htpasswd
  Require valid-user
</Location>

And make changes effective:

# /etc/init.d/apache2 restart

With above setup you will be able to login to your new Trac installation by calling the following address from your browser:

http://YOUR-SERVER-IP/mysite

Find most CPU-hungry threads under Linux

It's pretty easy to find CPU usage per process (top, ps), but If you want to find top CPU users per thread there's a method:

$ awk '{printf "TID: %6u  %8u %8u %8u \t %s \n", $1, $14, $15, $14+$15, $2;}' /proc/*/task/*/stat | sort -n -k 5 | tail -10
TID:   3600     33700    11461    45161      (metacity) 
TID:   3612     38053     7716    45769      (nautilus) 
TID:   3634     65079        0    65079      (dconf 
TID:   3601     64168     4997    69165      (gnome-panel) 
TID:  17298    137525    15650   153175      (firefox) 
TID:   3840    168736    21351   190087      (skype) 
TID:  11622     76119   150472   226591      (multiload-apple) 
TID:   3616    492076    53810   545886      (gnome-terminal) 
TID:   3617    370649   220327   590976      (skype) 
TID:   1072    626086  1031732  1657818      (Xorg)

Results are sorted by cumulated CPU usage (user + system).