Archive for the 'linux' Category

“Internet slow” on Ubuntu Karmic Koala (9.10)

Sunday, November 8th, 2009

“Internet slow” means actually “DNS slow”. After upgrading to Ubuntu 9.10 I experienced a strange and very annoying lag in DNS resolution. Running dig in a shell worked like a charm. But Firefox, Synaptic and everything else was hanging at DNS resolution.

To make a long story short (you probably read a lot of forum threads about this): Our Karmic Koala uses IPv6 for DNS queries and only if this fails it falls back to IPv4. A lot of home routers do not support IPv6 DNS queries. DOH!

Resolutions:

1. Firefox only: Disable IPv6 support by typing “about:config” into your location bar, then search for ipv6 and disable it by clicking on the line.

2. Disable IPv6 entirely: If you do not need IPv6-Support (I don’t) you could disable it completely and everything is up to speed again. How do I do this?

collectd + drraw.cgi - zoom into your graphs like you used to with cacti

Wednesday, September 16th, 2009

I fell in love with collectd and drraw.cgi (a front-end to collectd). This combination is great: Fast, simple and yet sufficient.

But there was one thing I missed in drraw that I loved in cacti: Zooming. (This is how it looks like in cacti)

So I went on and hacked it into drraw.cgi using jQuery. This is how it looks like:

drraw_zoom.png

Download the patch (6kb).

A note: For simplicity’s sake I just included the jQuery lib hosted at Google APIs. If this is a problem for you, just download a copy, put it on your webserver and adjust the line in the patched drraw.cgi.

Have fun with it! Comments and improvements are always welcome!

Linux: Executables on a Samba/CIFS Share

Sunday, August 30th, 2009

Just a quick note: Don’t mount a cifs share with flag directio if you want to execute binaries that reside on that share.

Otherwise you will get the following error:

<command>: cannot execute binary file

Took me 2 hours to find out.

Aggregate Traffic Used From a Combined Apache Logfile

Tuesday, May 8th, 2007

Today I just wanted to know the traffic sent out by one of our apaches for a certain client. Our administrator came up with the following code that did it - awesome!

#!/bin/sh
for file in [path to your logifes]/*.bz2;
do
    echo -n " $(basename $file) " >> ~/traffic.out;
    bzcat $file | awk ‘BEGIN{ regex="^/clientFolder/";summe=0;} { if (match($7,regex) && $9 == 200) {summe=summe+$10}} END {print summe/1024/1024}’ >> ~/traffic.out ;
done

This script will go through all logfiles and sum up the bytes transfered for all files in the clientFolder.

Typing Special Keys under Linux

Monday, May 7th, 2007

Some special characters like ~ (tilde) cannot be typed by simply pressing the key combination. This is true at least for german keyboard layouts and Ubuntu 6.10 (Edgy Eft) and 7.04 (Feisty Fawn).

To prevent this behaviour and display the character upon the first stroke add the following to you /etc/X11/xorg.conf under the section Input Device for identifier Generic Keyboard:

Option "XkbVariant"  "nodeadkeys"

My section looks like this:

Section "InputDevice"
        Identifier      "Generic Keyboard"
        Driver          "kbd"
        Option          "CoreKeyboard"
        Option          "XkbRules"      "xorg"
        Option          "XkbModel"      "pc105"
        Option          "XkbLayout"     "de"
        Option          "XkbVariant"    "nodeadkeys"
EndSection

How to change encoding of a file?

Sunday, May 6th, 2007

Another chapter of the book “Encoding is hell” ;) Today I noticed that some files in one of our projects suddenly have been converted to UTF-8 where they should have been in ISO-8859-1. Ok, short question: How to convert it back?

Short Answer
Use iconv like this:

iconv –from-code=UTF-8 –to-code=ISO-8859-1 inputfile.txt > outputfile.txt