468x60d

Jun 16
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

I’ve been wanting to set up a virtual host, with mod_rewrite on my system for a while, so I could have a local copy of my blog with Permalinks, for playing around, and despite a few hiccups, have finally got round to setting it up and implementing it successfully.

Apache Software Foundation Logo

Creating a Virtual Host

Note: The Apache installation in Ubuntu is actually controlled by the file /etc/apache2/apache2.conf with /etc/apache2/httpd.conf being a secondary config file loaded after apache2.conf. It’s advisable to leave apache2.conf alone, and make any server-wide changes to httpd.conf. The Ubuntu Apache installation also goes a step further by allowing site-specific configuration files, which are located in the directory /etc/apache2/sites-available. One already exists, and is called “default”, which controls the web root, /var/www. To activate any new sites created in this directory, we just create new file in this directory, then create a symbolic link to it in the /etc/apache2/sites-enabled directory. When Apache starts, it scans the apache2.conf, httpd.conf files, and also the /etc/apache2/sites-enabled directory for any links to config files in /etc/apache2/sites-available. If the link isn’t there, the configuration isn’t loaded.

For this tutorial, we’ll be creating a new config file in /etc/apache2/sites-available and activating it by creating to it in /etc/apache2/sites-enabled - apache2.conf and httpd.conf will not be touched.

Ok, I wanted to create a Virtual Host called 64bitjungledev.com, and also be able to view the site on my local installation when I point my browser to 64bitjungledev.com. The first thing I did was create a directory for the new Virtual Host to reside in. I was feeling particularly lazy, so just created it in the /var/www directory, and changed the owner of the new directory to my user name and group (so I could add/edit files etc.) I know, I know, I should create it in my home directory - but everything with “/var/www/ can be substituted for “/home/USERNAME/html/”. Anyway, in a Terminal, I executed:

sudo mkdir /var/www/64bitjungledev
sudo chown myuser:mygroup /var/www/64bitjungledev

Then, I created a new config file in the /etc/apache2/sites-available to contain the configuration information for my new Virtual Host. In a Terminal, I executed the following:

cd /etc/apache2/sites-available
gksu gedit 64bitjungledev.com

This creates a new file called 64bitjungledev.com in the directory and opens it in a text editor. In this new file, I dumped:

<VirtualHost *>
ServerName 64bitjungledev.com
ServerAlias www.64bitjungledev.com
DocumentRoot /var/www/64bitjungledev
DirectoryIndex index.php
<Directory /var/www/64bitjungledev>
AllowOverride all
Options Indexes FollowSymLinks MultiViews
Order allow,deny
Allow from 127.0.0.1
</Directory>
CustomLog /var/log/apache2/64bitjungledev.com-access.log combined
</VirtualHost>

This is basically telling Apache that we want it to host a new site, called 64bitjungledev.com, and all it’s files will be located in /var/www/64bitjungledev. “Allow from 127.0.0.1″ tells Apache that only my computer can access it, and “AllowOverride all” tells Apache that the site can use .htaccess files that contain Apache declarations that can override these settings. The CustomLog declaration is telling Apache to create an access log file for this site in /var/log/apache2/64bitjungledev.com-access.log and the “combined” tells it to include two extra fields of information in the log file - The “Referer” (sic) HTTP request header, and The User-Agent HTTP request header. Probably superfluous considering all trafic will be refered from my local machine, and the only agent accessing the site is Firefox! You can change “combined” to “common”, which doesn;t include these two fields.

Anyway, I digress… There are two methods to enabling the new site - create a symbolic link in /etc/apache2/sites-enabled to this new file, or, have Ubuntu do it for us:

cd /etc/apache2/sites-available
sudo a2ensite 64bitjungledev.com

Will do exactly the same as:

sudo ln -s /etc/apache2/sites-available/64bitjungledev.com /etc/apache2/sites-enabled/64bitjungledev.com

To disable the site, we can run:

sudo rm /etc/apache2/sites-enabled/64bitjungledev.com

Or:

sudo a2dissite 64bitjungledev.com

The result is the same. In order for the URL 64bitjungledev.com to work in my browser, I just had to change the hosts file, so my computer looks for 64bitjungledev.com on my machine as opposed to looking it up via DNS:

gksu gedit /etc/hosts

I changed the line

127.0.0.1 localhost

to:

127.0.0.1 localhost 64bitjungledev.com www.64bitjungledev.com

Saved, and closed the file. Now, I had to restart Apache for the new changes to take affect:

sudo /etc/init.d/apache2 reload

I created a test file in the document root:

gedit /var/www/64bitjungledev/index.php

Containing the old faithful:

<?php
phpinfo();
?>

and pointed my browser to www.64bitjungledev.com. Success! Now for mod_rewrite…

Enabling mod_rewrite

First, to enable the Apache module, mod_rewrite (which is disabled on a default Hardy install), I had to create a symbolic link to the module file, so in a Terminal, I ran:

sudo ln -s /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled/rewrite.load

The Apache installation in Ubuntu has many different configuration files, and uses this modular approach to activae/deactivate them. The rewrite.load file simply contains the load module declaration which would normally be placed in the httpd.conf file:

$more /etc/apache2/mods-available/rewrite.load
LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so

When Apache starts in Ubuntu, it checks the /etc/apache2/mods-enabled directory for links to available modules, and loads the modules it finds. Creating the link above can also be achieved by running:

sudo a2enmod rewrite

which is basically a short-cut approach to creating the link in /etc/apache2/mods-enabled, similar to the a2ensite used above - and, similarly:

sudo a2dismod rewrite

will have the same effect as:

sudo rm /etc/apache2/mods-enabled/rewrite.load

That’s pretty much it. The only additional thing I had to do, was make a slight change to the /etc/apache2/sites-available/default file, which, as mentioned above, is the default Apache configuration file for /var/www. So, I opened it up:

gksu gedit /etc/apache2/sites-available/default

And changed the “AllowOverride” declaration to “all” for both the / and /var/www directories. I just needed to restart Apache once again:

sudo /etc/init.d/apache2 reload

Testing mod_rewrite

Before going ahead and installing a local copy of 64bitjungle, I wanted to test if the system was working. I needed two files for this - a .htaccess file, and a PHP file. The .htaccess file contains the test RewriteRule for Apache to process the URL redirection of “clean” URLs to the PHP script, so that www.64bitjungledev.com/xyz/somedata will actually point to www.64bitjungle.com/thescript.php?thevariable=somedata. So, in a Terminal, I created the .htaccess file first:

gedit /var/www/64bitjungledev/.htaccess

And wrote a simple Apache RewriteRule, in addition to telling Apache to switch on the rewrite engine:

<IfModule mod_rewrite.c>
RewriteEngine On
#test rule
RewriteRule ^xyz/([^/\.]+)/?$ thescript.php?thevariable=$1 [L]
</IfModule>

This is basically telling Apache to switch on the RewriteEngine if mod_rewrite is loaded. The rather scrappy-but-suffices-for-testing RewriteRule basically tells Apache to “grab every character in the clean URL after xyz/ and store it in a temporaty variable, then forward it to thescript.php with thevariable set to the stuff just stored”.

A very simple PHP script can be written and used to test if the data is being passed properly:

gedit /var/www/64bitjungledev/thescript.php

which can contain simply:

<?php
echo $_GET['thevariable'];
?>

After restarting Apache, pointing my browser to www.64bitjungledev.com/xyz/DoesItWork now outputs “DoesItWork”, www.64bitjungledev.com/xyz/anything1234 ouputs “anything1234″ etc. The fun just doesn’t stop…!

With mod_rewrite successfully installed, and working for this new domain, I can now install a local version of 64bitjungle.com to play with. I haven’t actually done that yet though…

References:


written by Hodge \\ tags: , , ,

May 31
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

Update, 17/08/08: There is no longer any need to switch to the Experimental branch, if you are using the following Microdia cameras:

0c45:6027, 0c45:608f, 0c45:60ec, 0c45:60fe, 0c45:60c0, 0c45:613b, 0c45:613c, 0c45:624e, 0c45:624f, 0c45:6242, 0c45:6253, 0c45:6260, 0c45:6270, 0c45:627b, 0c45:8105

Keep up to date on the current supported webcams: http://groups.google.com/group/microdia/web/project-status?hl=en

The webcam (Acer Orbicam) on my Acer Aspire 5052 has been somewhat of a bane - with no drivers available, it has been one of the last stumbling blocks of getting all of my hardware working in Linux (the Ubuntu 8.04 Distro, Hardy Heron, in my case). That is until I ambled across, quite by accident, the Microdia Google Group. These guys are the epitome of Open Source development in action - a group of widely distributed people who are collaborating to solve a common problem: to get the Microdia webcams supported under Linux. And they’re doing a fantastic job so far.

Note: I should first mention that the drivers are still heavily under development, and although they are not (for some webcams) to the point where they can be used for Skype, for example, major progress has been made, and there is now finally communication with my webcam, to the point where I can successfully output video to mplayer. Therefore, this post is not quite yet a HowTo on getting a Microdia webcam fully function, but a step towards helping people installing and testing the drivers under development.

So, here’s how I’ve got to the stage of seeing myself in mplayer…

Information Gathering

Firstly, I had to determine i) whether or not my Webcam was in fact a Microdia camera, and ii) the model number, so in a Terminan, I ran:

lsusb

Which output, amongst other information about the rest of my USB devices:

Bus 003 Device 002: ID 0c45:6260 Microdia

confirming that my Acer Orbicam is a Microdia device. The two hex values 0c45:6260 represent the Vendor ID and Product ID respectively - 0c45 being Microdia, and 6260 the Product itself. In order to create my meagre contribution to the Microdia Group, I had to gather some more information about the device’s bridge and sensor. Firstly, I needed the USB Device Descriptors, which were obtained by running:

sudo lsusb -d 0c45:6260 -v > ~/Desktop/0c45_6260_device_descriptors.txt

I then needed to discover the Bridge and Sensor types, which thankfully could be found in the Windows driver file, snp2std.inf:

%USBPCamDesc% = SN.USBPCamVGA,USB\VID_0c45&PID_6260 ; SN9C201 + OV7670ISP

Which tells me:
Bridge: SN9C201
Sensor: OV7670

The full guide to gathering information for your webcam can be found at the Microdia group, here.

Driver Compiling and Installing

The driver code is controlled by git, which I installed by running:

sudo apt-get install git-core gitk git-gui git-doc curl

Also, before downloading and installing the drivers, I ran:

sudo apt-get install kernel-package linux-source build-essential

To grab the Linux source etc. Once finished, I created a directory to set up my local git repository and downloaded the driver code:

cd ~/Documents
mkdir webcam
cd webcam
git clone http://repo.or.cz/r/microdia.git

The final command executes git, and tells it to clone the remote repository. The files are downloaded to a sub directory called microdia, from which I ran the rest of the commands:

cd microdia

Note: If you have any of the following Microdia cameras, you’ll need to switch to the Experimental branch:

6242, 624e, 624f, 6270, 627b, 62bb, 145f:013d, 045e:00f4

Switch to the Experimental branch by running:

git checkout --track -b v4l2-experimental origin/v4l2-experimental

I then compiled the code:

make

and received this error, but it’s not important:

make: ctags: Command not found
make: *** [ctags] Error 127

Once compiled, the module can be inserted to the kernel for testing:

sudo insmod ./microdia.ko

I also received the following error:

insmod: error inserting ‘microdia.ko’: -1 Unknown symbol in module

so had to run the following first:

sudo modprobe videodev
sudo modprobe compat-ioctl32

and then I could insert the module:

sudo insmod ./microdia.ko

Finally, to test, I ran:

mplayer tv:// -tv noaudio:driver=v4l2:width=640:height=480:outfmt=yuy2:device=/dev/video0:fps=30

you may need to change /dev/video0 to /dev/video1 - also, if you don’t have mplayer, it needs installing:

sudo apt-get install mplayer

The only thing is… it’s currently a mirror image, hehehe:

References

  1. Microdia, Google Group
  2. Full list of currently supported (and unsupported) Microdia Webcams
  3. How to gather information on your webcam
  4. Using git with Microdia
  5. Testing the Microdia driver
  6. PATCH: v4l-experimental support for 6260 (3rd try) Thread

written by Hodge \\ tags: , , ,

May 12
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

Skype. Skype, skype, skype… Say it enough times, and it sounds like a nonsensical sound. Mind you, say any word repeatedly, enough times, and it ceases to sound like a real word and becomes gibberish, randomly rolling between toungue and palate like a peanut in a tin can. Try it. “Flannel” is a great word to experiment with, although after 30 seconds of repeating it, you’ll probably question your sanity…

But anyway, this post isn’t about language, it’s about how I got Skype installed, and customized the look and feel of the GUI. I’ll not bore you with the details on what Skype is, and what it does - most people know already, and most likely found this page by searching for “Installing Skype on 64 Bit Ubunutu”, or some such string. If not, you can check out the Skype website.

First things first - as of writing this post, there is no 64 Bit version of Skype available for Linux. Thankfully, it is possible to install 32 Bit applications in 64 Bit Ubuntu with the correct libraries:

sudo apt-get install ia32-libs

ia32-libs is available through the Universe repositories, which can be activated by going to System -> Administration -> Software Sources and checking the “Universe” option.

Having installed the correct libraries, I downloaded the deb package (generic download page here), and saved it to my Desktop. Since it is a 32 bit application, dpkg requires prodding with the –force-architecture and –force-depends options:

cd ~/Desktop
sudo dpkg --install --force-architecture --force-depends skype-debian_2.0.0.68-1_i386.deb

(The current version is 2.0.0.68-1 - if you have downloaded a later version, you’ll need to replace the version number in the file name with the current version. If, like me, you’re lazy, you can copy and paste everything up to and including “skype” then press the Tab key… the Terminal will fill in the rest of the file name).

That’s pretty much it. Skype can be found under Applications -> Internet -> Skype.

Since Skype is a Qt application, it is possible to customise the interface using an application called qtconfig. For Completeness I also installed the msttcorefonts package, which installs a few, well, core MS True Type fonts, such as Times, Courier, etc.

sudo apt-get install msttcorefonts
sudo fc-cache -fv

Running fc-cache will rebuild the Font cache to include the newly installed fonts. Restarting X by pressing Ctrl+Alt+Backspace will also do the trick. With this done, I installed the Qt Config application:

sudo apt-get install qt3-qtconfig

To give the Qt applications a “Gnomeish” look, there is a theme called Polymer available:

sudo apt-get install polymer

With these installed, it is possible to run the Qt Config tool from either System -> Preferences -> Qt3 Configuration, or by executing qtconfig in a terminal. The first tab - Appearance - allows us to select the Polymer theme, by changing “Select GUI Style” to Polymer:

The second tab, “Fonts” allows control over how Qt displays text. Skype can be made more readable and friendly, by increasing the font size to 10 Points, and changing the font family to Sans Serif:

Save the changes with either File -> Save or Ctrl+S, exit, and start Skype (or any Qt application) to see the changes.

That’s it!

References:


written by Hodge \\ tags: , ,

May 11
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

I noticed today that a bunch of applications, and even some web sites were displaying interesting fonts, making the application/web site unusable and unreadable - most notably QT applications. The text rendered like an interesting cross between Hindu and Arabic. This issue just so happened to crop up shortly after transferring a bunch of fonts over from my Windozzze partition to Linux:

cd /media/hda1/WINDOWS/Fonts
cp * ~/.fonts
sudo fc-cache -fv

Basically, there seemed to be a conflict between the fonts already installed in Linux, and the fonts I had just transferred over. So, I removed all the fonts, and copied over just the True Type Fonts and Open Type Fonts:

cd ~/.fonts
rm *.*
cd /media/hda1/WINDOWS/Fonts
cp *.ttf *.TTF *.otf *.OTF ~/.fonts
sudo fc-cache -fv

So far so good - the funky script has been replaced with readable text. I guess I’ll have to move the rest one-by-one to find the miscreant font…


written by Hodge \\ tags: ,

Apr 30
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

I wanted to see if I could take advantage of my Dual Core CPU during boot time, by enabling concurrent init.d scripts, in the hope this could improve (an already pretty fast) boot time. The implementation is pretty simple - first, I backed up /etc/init.d/rc

cd /etc/init.d/
sudo cp rc rc.BAK

then set about editing /etc/init.d/rc

gksu gedit /etc/init.d/rc

Actually, there isn’t much to edit - I just needed to change:

CONCURRENCY=none

to:

CONCURRENCY=shell

on line 24, save the file, and reboot. However, when I rebooted, there was a gnarly error caused by HAL (Hardware Abstraction Layer) failing to initialise. After some digging, I found a bug report, and a solution. The cause of the problem, and the solution is actually quite simple. At run level 2, HAL and DBus are set to start at the same time - in the /etc/rc2.d/ directory, both symbolic links have the same S12 prefix (S12hal and S12dbus):

ls -l
...snip...
lrwxrwxrwx 1 root root 14 2008-04-26 00:52 S12dbus -> ../init.d/dbus
lrwxrwxrwx 1 root root 13 2008-04-25 18:58 S12hal -> ../init.d/hal
...snip...

which causes a problem with concurrent init.d scripts, since they are now executed at the same time. HAL initialises slightly faster than DBus, but requires DBus in order to initialise, hence the “failed to initialize” error. The solution is equally simple. As suggested in the bug report, I changed the execution order of HAL. I had to do this via the recovery console, but so long as you don’t reboot after saving the /etc/init.d/rc file, it can be done via the GUI terminal:

sudo mv /etc/rc2.d/S12hal /etc/rc2.d/S13hal
sudo reboot

This time, there was no problem, and no error, since it ensures that DBus (S12dbus) initialises before HAL (S13hal).

If I still get problems in the future, I can always restore the old version of /etc/init.d/rc:

cd /etc/init.d
sudo cp rc.BAK rc

Coupled with boot profiling, this does speed up my boot time by shaving an extra few seconds away.


written by Hodge \\ tags: , , ,

Apr 28
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

Like most other Ubuntu users, I recently upgraded to 8.04 (Hardy Heron), but numerous power cuts, and a sketchy internet connection screwed up the upgrade process, resulting in a horribly drawn out process of reinstalling a fresh copy of 7.10, downloading and installing the updates, and finally the alternate CD for 8.04… but that’s another story for another time…

During this process, I found that the Ubuntu archive repository, http://archive.ubuntu.com/ubuntu/ was somewhat slower than usual. Thankfully, there are many mirrors available to download from - most are up to date with the latest packages. https://launchpad.net/ubuntu/+archivemirrors has an extensive list, so I looked for one with an “Up to Date” status, and edited my sources.list:

gksu gedit /etc/apt/sources.list

commented out the current archive site:

#deb http://archive.ubuntu.com/ubuntu/ hardy main universe multiverse restricted
#deb http://archive.ubuntu.com/ubuntu/ hardy-updates main universe multiverse restricted

and added the mirror:

deb http://ubuntu.positive-internet.com/ubuntu/ hardy main universe multiverse restricted
deb http://ubuntu.positive-internet.com/ubuntu/ hardy-updates main universe multiverse restricted

After saving the file, and starting the Update Manager, I simply had to click “Check” to retrieve the update information from the mirror. Alternatively, this can be done with the “Reload” button in the Synaptic Package Manager.

Simple, but effective, leading to much faster downloads, and you can always revert back to using archive.ubuntu.com by uncommenting the entries in sources.list, and commenting out/deleting the mirror entries.


written by Hodge \\ tags: ,

Apr 27
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

Sorry if you were expecting a substantial research report, but there really is no need for an in depth technical evaluation and comparison. No need to waste your time with specifications and benchmark results. No funky table with the pros and cons of each operating system. All you need do, is watch the following video.

Even if it’s satire, it’s more than enough reason to switch to Linux…

You need to a flashplayer enabled browser to view this YouTube video

Cringe


written by Hodge \\ tags: , , ,

Mar 27
1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 5 out of 5)
Loading ... Loading ...

OK, this is a bit of a cheeky post, since I’m merely extending a previous post “Conky on Ubuntu 64 Bit - .conkyrc” - or elaborating on it - to clarify setting up .conkyrc for Dual Core Processors - specifically for my AMD Turion 64 X2. I’ve had a few requests specifically about this, so here goes…

Now, the part of my .conkyrc file that deals with my Dual Core looks like this:

${color #42AE4A}Usage (Avg):${color #42AE4A} ${freq_dyn_g}Ghz ${color lightgrey}${cpu cpu0}% ${alignr}${color #42AE4A}${cpubar cpu0 5,80}
${color #42AE4A}Usage (Core 1):${color #42AE4A} ${freq_dyn_g cpu1}Ghz ${color lightgrey}${cpu cpu1}% ${alignr}${color #42AE4A}${cpubar cpu1 5,80}
${color #42AE4A}Usage (Core 2):${color #42AE4A} ${freq_dyn_g cpu2}Ghz ${color lightgrey}${cpu cpu2}% ${alignr}${color #42AE4A}${cpubar cpu2 5,80}
${color #42AE4A}Average
${cpugraph cpu0 42AE4A eeeeee}
${color #42AE4A}Core 1 $alignr Core 2
${color #42AE4A}${cpugraph cpu1 25,120 42AE4A eeeeee} ${color #42AE4A} $alignr${color #42AE4A}${cpugraph cpu2 25,120 42AE4A eeeeee}
${color #42AE4A}Processes:${color lightgrey} $processes ${color #42AE4A}Run:${color lightgrey} $running_processes ${color #42AE4A}CPU Temp:${color lightgrey} ${execi 1100 cat /proc/acpi/thermal_zone/THRM/temperature | grep -o “[0-9]* C”}
${color #42AE4A}Core 1 Temp: ${color lightgrey}${execi 8 sensors | grep -A 1 ‘Core0′ | cut -c13-16 | sed ‘/^$/d’} C ${color #42AE4A}Core 2 Temp: ${color lightgrey}${execi 8 sensors | grep -A 1 ‘Core1′ | cut -c13-16 | sed ‘/^$/d’} C

This outputs the following to Conky:

Conky Dual Core CPU Output

Stripping out all the formatting, and colouring gives this:

Usage (Avg): ${freq_dyn_g}Ghz ${cpu cpu0}% ${alignr}${cpubar cpu0 5,80}
Usage (Core 1): ${freq_dyn_g cpu1}Ghz ${cpu cpu1}% ${alignr}${cpubar cpu1 5,80}
Usage (Core 2): ${freq_dyn_g cpu2}Ghz ${cpu cpu2}% ${alignr}${cpubar cpu2 5,80}
Average
${cpugraph cpu0 42AE4A eeeeee}
Core 1 $alignr Core 2
${cpugraph cpu1 25,120 42AE4A eeeeee} $alignr${cpugraph cpu2 25,120 42AE4A eeeeee}
Processes: $processes Run: $running_processes CPU Temp: ${execi 1100 cat /proc/acpi/thermal_zone/THRM/temperature | grep -o “[0-9]* C”}
Core 1 Temp: ${execi 8 sensors | grep -A 1 ‘Core0′ | cut -c13-16 | sed ‘/^$/d’} C Core 2 Temp: ${execi 8 sensors | grep -A 1 ‘Core1′ | cut -c13-16 | sed ‘/^$/d’} C

Now the walk through. The first line, Usage (Avg): ${freq_dyn_g}Ghz ${cpu cpu0}% ${alignr}${cpubar cpu0 5,80} gives the Average clock speed usage for both cores - ${freq_dyn_g} with no parameters, will output the current clock speed usage for the CPU as a whole. Passing cpu0 as a parameter to ${cpu} will output the overall CPU % used, and similarly, passing cpu0 to ${cpubar} will draw the overall % used graph (the parameters 5,80 are just for the height and width.

Now, by passing cpu1 or cpu2 to ${freq_dny_g}, ${cpu} and ${cpubar} Conky will output the same data but for each individual core. This can be extended by passing cpuN where N is the core number, for quad core etc. this could be cpu3 cpu4. So, the first three lines:

Usage (Avg): ${freq_dyn_g}Ghz ${cpu cpu0}% ${alignr}${cpubar cpu0 5,80}
Usage (Core 1): ${freq_dyn_g cpu1}Ghz ${cpu cpu1}% ${alignr}${cpubar cpu1 5,80}
Usage (Core 2): ${freq_dyn_g cpu2}Ghz ${cpu cpu2}% ${alignr}${cpubar cpu2 5,80}

Outputs:

Conky Dual Core CPU Usage

The next lines of the file deal with throughput/usage graphs, ${cpugraph cpu0 42AE4A eeeeee} being the average for the CPU as a whole, since cpu0 is passed as a parameter. 42AE4A and eeeeee are just colour parameters to create a gradient overlay on the graph. As before, passing cpu1 and cpu2 will draw the graphs for the individual cores. The additional parameters, 25,120 are again just height and width parameters.

So, the lines

Average
${cpugraph cpu0 42AE4A eeeeee}
Core 1 $alignr Core 2
${cpugraph cpu1 25,120 42AE4A eeeeee} $alignr${cpugraph cpu2 25,120 42AE4A eeeeee}

Will output:

Conky Dual Core CPU Throughput Graphs

Finally, I have a bunch of other data output, such as total processes, processes running, and CPU temperature. The first line outputs general information about the CPU as a whole:

Processes: $processes Run: $running_processes CPU Temp: ${execi 1100 cat /proc/acpi/thermal_zone/THRM/temperature | grep -o "[0-9]* C”}

$processes outputs the total number of processes, while $running_processes outputs the number of currently running processes on the CPU. To output the overall temperature, I had to call the execi function, and do some tweaking of the output to get the number, so ${execi 1100 cat /proc/acpi/thermal_zone/THRM/temperature | grep -o “[0-9]* C”} basically outputs /proc/acpi/thermal_zone/THRM/temperature, pipes the output through grep which searches for the regular expression ‘[0-9]* C’ (which matches a string of numbers followed by a space followed by an upper-case C), and thus outputs just the temperature value - e.g. “45 C”.

To output the temperature of each Core, I once again run the execi function on a couple of piped shell commands, and pipe the output through other shell commands to get the number I want:

Core 1 Temp: ${execi 8 sensors | grep -A 1 'Core0' | cut -c13-16 | sed '/^$/d'} C Core 2 Temp: ${execi 8 sensors | grep -A 1 'Core1' | cut -c13-16 | sed '/^$/d'} C

Basically what is happening here is I’m running the shell command sensors, piping to grep to search for the string “Core0“, piing this output to cut to trim it, and finally editing out some of the crap I don’t want by piping to sed. This is just repeated for Core1. You may need to customise the output from sensors, by greping, cutting and seding different stuff - experiment by opening a terminal, and running sensors, then just pipe it through the grep, cut, and sed commands until you get the data you want.

So, the final lines together:

Processes: $processes Run: $running_processes CPU Temp: ${execi 1100 cat /proc/acpi/thermal_zone/THRM/temperature | grep -o "[0-9]* C”}
Core 1 Temp: ${execi 8 sensors | grep -A 1 ‘Core0′ | cut -c13-16 | sed ‘/^$/d’} C Core 2 Temp: ${execi 8 sensors | grep -A 1 ‘Core1′ | cut -c13-16 | sed ‘/^$/d’} C

Output:

Conky Dual Core CPU Misc Info

Of course, this should work on any Linux distro with Conky installed.

Hope that helps someone.


written by Hodge \\ tags: , , , , ,

Mar 11
1 Star2 Stars3 Stars4 Stars5 Stars (3 votes, average: 4.67 out of 5)
Loading ... Loading ...

BOINC Statistics output to ConkySince my previous article about Conky, Conky on Ubunty 64 Bit - .conkyrc, I’ve been playing around with trying to get Conky to output some BOINC (SETI@Home data), and through a little digging, found a couple of very useful resources. The first being BOINC’s own client_status.xml file, located on Ubunutu in /var/lib/boinc-client/client_status.xml, which contains a lot of information about BOINC projects, Work Units, Status and so on. The second being a command line application, again built into BOINC - boinc_cmd. boinc_cmd can be executed with a bunch of parameters, such as –get_simple_gui_info and –get_project_status which output to the Terminal a lot of information about Projects and Work Units.

To output BOINC data via Conky, it’s possible to call the boinc_cmd in .conkyrc and strip down the information with grep and sed etc:

${execi 10 boinc_cmd --get_simple_gui_info | grep -m 1 "fraction done:" | tail -n 1 - | sed -e 's/ fraction done: //'}
${execi 10 boinc_cmd --get_simple_gui_info | grep -m 2 "fraction done:" | tail -n 1 - | sed -e 's/ fraction done: //'}

…and so on for each piece of data required for output, but this is pretty labourious, and makes for a rather ugly .conkyrc, so I’ve written a really quick and dirty Perl Script (it’s not pleasant to look at, and needs a LOT of work, so it’s more of a pre Alpha-Alpha! I’m not sure how, or if it will work with multiple projects, since I only have SETI@HOME installed…) - which actually retrieves all the data from the client_status.xml file. The (archived) script, boinc.pl can be downloaded here (and viewed below - just copy and paste the text into a file, and save it as “boinc.pl” if the download doesn’t work for you). It’s also posted over at the Ubuntu Forums. I’ve called it in .conkyrc by adding one simple line:

BOINC:
${color lightgrey}${execi 10 perl ~/ConkyScripts/boinc/boinc.pl}

OK, so that’s actually two lines, but the first line doesn’t really do anything except output the text “BOINC:” to Conky, so it doesn’t count - but it’s much cleaner than potentially dozens of lines, right? The script itself is in my ~/ConkyScripts/boinc directory and has been made executable:

sudo chmod a+x boinc.pl

Here’s the script so far - it’s VERY much Work In Progress, but it outputs the data as shown in the image above:

Edit 15/03/08: I’ve updated the code, so hopefully it’ll work with multiple projects:

#!/usr/bin/perl

$BoincStatePath="/var/lib/boinc-client";
$BoincClientStateFile="client_state.xml";
$StateFile="$BoincStatePath/$BoincClientStateFile";

open(INFO, $StateFile);
@lines = <INFO>;
close(INFO);
sub strip_tags($);

sub convert_time_to_string($);
sub estimate_time_remaining;
$projectCount = 0;
$wuCount = 0;
$wuActive = 0;
$wuActiveTask = 0;

foreach $line (@lines) {

   if ($line =~ /<master_url>/) {
      $projectMasterURL[$projectCount] = strip_tags($line);
   }

   if ($line =~ /<project_name>/) {
      $projectName[$projectCount] = strip_tags($line);
      $projectCount++;
   }

   if ($line =~ /<workunit>/) {
      $wuCount++;
   }

   if ($line =~ /<active_task_state>1/) {
      $wuActive++;
   }

   if ($line =~ /<active_task>/) {
      $wuActiveTask++;
   }

   if ($line =~ /<result_name>/) {
      $wuName[$wuActiveTask] = strip_tags($line);
   }

   if ($line =~ /<fraction_done>/) {
      $wuPercent[$wuActiveTask] = strip_tags($line) * 100;
   }

   if ($line =~ /<project_master_url>/) {
      $wuMasterURL[$wuActiveTask] = strip_tags($line);
   }

   if ($line =~ /<current_cpu_time>/) {
      $wuCPUTime[$wuActiveTask] = convert_time_to_string(strip_tags($line));
      $wuCPUTimeRaw[$wuActiveTask] = strip_tags($line);
   }

}

print "No. Work Units: ".$wuCount.", Active WU: ".$wuActive."\n";

for($i = 0; $i <= $projectCount; ++$i) {
   print $projectName[$i];
   for ($j = 1; $j <= $wuActiveTask; ++$j) {
      if($projectMasterURL[$i] eq $wuMasterURL[$j]) {
         print "WU ".$j.": ".$wuName[$j];
         $estTime = convert_time_to_string(estimate_time_remaining($wuCPUTimeRaw[$j],$wuPercent[$j]));
         print "CPU Time: ".$wuCPUTime[$j]." Time Remaining: ".$estTime."\n";
         print $wuPercent[$j]."% Complete\n";
      }
   }
}

sub strip_tags($) {
   my $string = shift;
   $string =~ s/<(.*?)>//gi;
   $string =~ s/ //gi;
   return $string;
}

sub convert_time_to_string($) {
   $cpuTime = int($_[0]);
   #Calculate the number of days
   if ($cpuTime > 86400) {
      $timeDays = $cpuTime/(24*60*60).":";
   } else {
      $timeDays = "";
   }

   #Calculate the number of hours and minutes
   $timeHours = ($cpuTime/(60*60))%24;
   $timeMinutes = ($cpuTime/60)%60;
   $timeSeconds = $cpuTime%60;
   $cpuTimeString = $timeDays.$timeHours.":".$timeMinutes.":".$timeSeconds;

   return $cpuTimeString;
}

sub estimate_time_remaining {
   $cpuTime = $_[0];
   $currentPercent = $_[1];
   $onePercentTime = $cpuTime/$currentPercent;
   $totalTime = $onePercentTime * 100;
   $estimatedTimeReminaing = $totalTime - $cpuTime;
   return $estimatedTimeReminaing;
}

written by Hodge \\ tags: , , , , ,

Mar 09
1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 2 out of 5)
Loading ... Loading ...

Conky ScreenshotI recently installed Conky, which is a highly configurable and “light weight system monitor”. As with many packages, it’s available via the Ubuntu Repositories:

sudo apt-get install conky

The default installation outputs some pretty useful information about the system - CPU usage, RAM/Swap usage, HD IO, HDD space and so on, and there are also some awesome scripts available to pull in other information to the display. The data monitored by Conky is controlled by the .conkyrc file locate in the user Home directory ~/.conkyrc. Opening and editing, or creating this file if it doesn’t exist (Applications -> Accessories -> Text Editor then Save As .conkyrc in the home directory), .conkyrc allows full control of how Conky gathers and displays information. The first section of the file, controls how the physical aspects of Conky is handled - the window size, transparency, position on the desctop etc., and the second part of the file takes a number of variables - both built in to Conky (which gather information such as RAM usage, etc.), and via exec, execi and texeci commands.

The Conky website has a great references on the configuration settings, available variables, and the man page.

I’ve also recently written a post which deals specifically with setting up Dual Core processors - Conky: Dual Core Processors in .conkyrc

As previously mentioned, in addition to Conky’s built in variables, it is possible to execute external shell commands, and even Perl/Python etc. scripts, and have the output sent to Conky for processing. I currently have two scripts installed, both obtained from Ubuntu Forums:

Conky Gmail Revisited, written by lvleph, is a Perl script, which logs into your Gmail account, and checks for new mail periodically (the interval of which is actually controlled via the .conkyrc). The Perl script is easy to download and use. Once I saved the script to ~/ConkyScripts/gmail/gmail.pl I just had to modify the script to enter my Gmail username and password, and make it executable

cd ~/ConkyScripts/gmail/
sudo chmod a+x gmail.pl

I could then call the script from my .conkyrc:

You have ${texeci 360 perl ~/ConkyScripts/gmail/gmail.pl n} new gmail(s).

texeci is a Conky command, to which I passed the parameters 360 (an interval in seconds which the script should run), and the shell command to execute - in this case, perl ~/ConkyScripts/gmail/gmail.pl n (the n is actually a parameter passed to the gmail.pl script!). The original forum post has a great list of installation instructions, thanks to lvleph.

I also added

${execi 360 perl ~/ConkyScripts/gmail/gmail.pl s}

to .conkyrc which calls the script again, but with “s” as the parameter, to output any new email subjects to Conky.

Conky Weather Revisited V2, also written by lvleph, grabs local weather information. It even comes with its own Weather Font! Again, it’s easy to download and incorporate into the .conkyrc file (I recommend the version from Page 3 of the forum thread - just remember to download the font from the front page). Again, I saved this to its own directory ~/ConkyScripts/weather/weather.pl and it was just a matter of calling the script from the .conkyrc as before. Running

./weather.pl

in a terminal window outputs the possible parameters which can be passed to the script - the most important being the area code/city code - in my case THXX0027, for Mae Hongson. Again, the original forum post has a great list of installation instructions, thanks to lvleph.

I’ve also recently written a Perl script, which allows BOINC data to be viewed via Conky. See my recent post on BOINC and SETI@Home with Conky, on Ubuntu.

Desktop with Conky

So, here’s my full .conkyrc file, for anyone who’s interested, which outputs the image above - try and tested on an Acer Aspire 5052, with AMD Turion 64 X2 (Dual Core) Processor:

# set to yes if you want Conky to be forked in the background
background no
cpu_avg_samples 2
net_avg_samples 2
out_to_console no
# Use Xft?
use_xft yes
# Xft font when Xft is enabled
xftfont Bitstream Vera Sans Mono:size=8
# Text alpha when using Xft
xftalpha 0.8
on_bottom yes
# Update interval in seconds
update_interval 1
# Create own window instead of using desktop (required in nautilus)
own_window yes
own_window_transparent yes
own_window_type override
# Use double buffering (reduces flicker, may not work for everyone)
double_buffer yes
# Minimum size of text area
minimum_size 260 5
maximum_width 260
# Draw shades?
draw_shades no
# Draw outlines?
draw_outline no
# Draw borders around text
draw_borders no
# Stippled borders?
stippled_borders no
# border margins
border_margin 4
# border width
border_width 1
# Default colors and also border colors
default_color white
default_shade_color white
default_outline_color white
# Text alignment, other possible values are commented
gap_x 15
gap_y 30
alignment top_right
# Gap between borders of screen and text
# Add spaces to keep things from moving about? This only affects certain objects.
use_spacer no
# Subtract file system buffers from used memory?
no_buffers yes
# set to yes if you want all text to be in uppercase
uppercase no
# boinc (seti) dir
seti_dir /usr/lib/boinc-app-seti/setiathome_enhanced
TEXT
${color #42AE4A}$sysname $kernel $machine - $nodename
${color #42AE4A}Uptime:${color lightgrey} $uptime ${color #42AE4A} Load:${color lightgrey} $loadavg
${color lightgrey}${hr}
${color #42AE4A}Usage (Avg):${color #42AE4A} ${freq_dyn_g}Ghz ${color lightgrey}${cpu cpu0}% ${alignr}${color #42AE4A}${cpubar cpu0 5,80}
${color #42AE4A}Usage (Core 1):${color #42AE4A} ${freq_dyn_g cpu1}Ghz ${color lightgrey}${cpu cpu1}% ${alignr}${color #42AE4A}${cpubar cpu1 5,80}
${color #42AE4A}Usage (Core 2):${color #42AE4A} ${freq_dyn_g cpu2}Ghz ${color lightgrey}${cpu cpu2}% ${alignr}${color #42AE4A}${cpubar cpu2 5,80}
${color #42AE4A}Average
${cpugraph cpu0 42AE4A eeeeee}
${color #42AE4A}Core 1 $alignr Core 2
${color #42AE4A}${cpugraph cpu1 25,120 42AE4A eeeeee} ${color #42AE4A} $alignr${color #42AE4A}${cpugraph cpu2 25,120 42AE4A eeeeee}
${color #42AE4A}Processes:${color lightgrey} $processes ${color #42AE4A}Run:${color lightgrey} $running_processes ${color #42AE4A}CPU Temp:${color lightgrey} ${execi 1100 cat /proc/acpi/thermal_zone/THRM/temperature | grep 'temperature:' | sed -e 's/temperature: //'}
${color #42AE4A}Core 1 Temp: ${color lightgrey}${execi 8 sensors | grep -A 1 'Core0' | cut -c13-16 | sed '/^$/d'} C ${color #42AE4A}Core 2 Temp: ${color lightgrey}${execi 8 sensors | grep -A 1 'Core1' | cut -c13-16 | sed '/^$/d'} C
${color lightgrey}${hr}
${color #42AE4A}CPU Usage PID CPU% MEM%
${color lightgrey} ${top name 1} ${top pid 1} ${top cpu 1} ${top mem 1}
${color #42AE4A} ${top name 2} ${top pid 2} ${top cpu 2} ${top mem 2}
${color #42AE4A} ${top name 3} ${top pid 3} ${top cpu 3} ${top mem 3}
${color #42AE4A}Mem Usage
${color lightgrey} ${top_mem name 1} ${top_mem pid 1} ${top_mem cpu 1} ${top_mem mem 1}
${color #42AE4A} ${top_mem name 2} ${top_mem pid 2} ${top_mem cpu 2} ${top_mem mem 2}
${color #42AE4A} ${top_mem name 3} ${top_mem pid 3} ${top_mem cpu 3} ${top_mem mem 3}
${color lightgrey}${hr}
${color #42AE4A}RAM:${color lightgrey} $mem/$memmax ($memperc%) ${alignr}${color #42AE4A}${membar 5,100}
${color #42AE4A}SWAP:${color lightgrey} $swap/$swapmax ($swapperc%) ${alignr}${color #42AE4A}${swapbar 5,100}
${color #42AE4A}HD IO: ${color lightgrey}${diskio}
${color #42AE4A}${diskiograph 42AE4A eeeeee}
${color #42AE4A}Hard Disk Space:
${color #42AE4A} Root ${color lightgrey}${fs_used /}/${fs_size /}${alignr}${color #42AE4A}${fs_bar 5,120 /}
${color #42AE4A} Win ${color lightgrey}${fs_used /media/hda1}/${fs_size /media/hda1}${alignr}${color #42AE4A}${fs_bar 5,120 /media/hda1}
${color #42AE4A} Data ${color lightgrey}${fs_used /media/hda5}/${fs_size /media/hda5}${alignr}${color #42AE4A}${fs_bar 5,120 /media/hda5}
${color lightgrey}${hr}
${color #42AE4A}Network: ${color lightgrey}${addr eth0}
${color #42AE4A}Down:${color lightgrey} ${downspeed eth0} k/s $alignr${color #42AE4A} Up:${color lightgrey} ${upspeed eth0} k/s
${color #42AE4A}${downspeedgraph eth0 27,120 42AE4A eeeeee 180} $alignr${color #42AE4A}${upspeedgraph eth0 27,120 42AE4A eeeeee 25}
${color lightgrey}${totaldown eth0} $alignr${color lightgrey}${totalup eth0}
${color #42AE4A}Power: ${color lightgrey}${execi 2 acpi | sed -e 's/ .*: //'}
${color #42AE4A}You have ${color lightgrey}${texeci 360 perl ~/ConkyScripts/gmail/gmail.pl n} ${color #42AE4A}new gmail(s).
${color lightgrey}${execi 360 perl ~/ConkyScripts/gmail/gmail.pl s}
${color #42AE4A}$font${alignc}Mae Hongson Weather
${color #42AE4A}$font${alignc}Today
${alignc}${voffset -5}${color lightgrey}${font weather:size=30}${execi 3600 perl ~/ConkyScripts/weather/weather.pl THXX0027 c cp}${font}$color${voffset -15}${offset 10}${color lightgrey}${execi 3600 perl ~/ConkyScripts/weather/weather.pl THXX0027 c c}
${voffset 5}${color #42AE4A}$font${alignc}5 Day Forcast
${voffset -5}${font weather:size=30}${alignc}${offset -45}${execi 3600 perl ~/ConkyScripts/weather/weather.pl THXX0027 c 1p}${offset 25}${color orange}${execi 3600 perl ~/ConkyScripts/weather/weather.pl THXX0027 c 2p}${offset 25}${color cyan}${execi 3600 perl ~/ConkyScripts/weather/weather.pl THXX0027 c 3p}${offset 24}${color green}${execi 3600 perl ~/ConkyScripts/weather/weather.pl THXX0027 c 4p}${offset 23}${color red}${execi 3600 perl ~/ConkyScripts/weather/weather.pl THXX0027 c 5p}${font}$color
${alignc}${offset -15}${execi 3600 perl ~/ConkyScripts/weather/weather.pl THXX0027 c 1}${offset 10}${execi 3600 perl ~/ConkyScripts/weather/weather.pl THXX0027 c 2}${offset 10}${execi 3600 perl ~/ConkyScripts/weather/weather.pl THXX0027 c 3}${offset 10}${execi 3600 perl ~/ConkyScripts/weather/weather.pl THXX0027 c 4}${offset 10}${execi 3600 perl ~/ConkyScripts/weather/weather.pl THXX0027 c 5}

The “Post your .conkyrc files w/ screenshots” thread over at Ubuntu Forums has many other .conkyrc examples to peruse.


written by Hodge \\ tags: , , ,