Ετοιμασίες για το Fosscomm 2009

Μιας και άρχισα να ετοιμάζομαι για το Fosscomm 2009 πήρα το .kml από το χάρτη (google map) που έχουν φτιάξει τα παιδιά του ΑΤΕΙ Λάρισας και τον μετέτρεψα σε format κατάλληλο για το Destinator μου.

Για όποιον άλλο θέλει να έχει τα σημεία στο Destinator του: Fosscomm 2009 Destinator (.dat) POI

Ελπίζω να μαζέψει αρκετό κόσμο η εκδήλωση 🙂

Υ.Γ. Μην ξεχάσετε να φέρετε εκτυπωμένο το gpg key σας μιας και στα διαλείμματα κάθε μέρας θα γίνει GPG Keysigning Party

iftraffic.pl: perl script to measure in/out traffic in realtime

During some QoS tests on Linux I needed to measure the traffic of the system in realtime without being able to compile any new software on it. The system had already perl installed so I googled to find a script that could monitor in/out traffic of an interface. The first script I found was this: http://perlmonks.org/?node_id=635792

While it’s actually doing what it says, it only runs just once. I wanted the script to run for a period of time. So I changed it a bit.
Here’s the outcome:
#!/usr/bin/perl
my $dev=$ARGV[0];
sub get_measures {
my $data = `cat /proc/net/dev | grep "$dev" | head -n1`;
$data =~ /$dev\:(\d+)\D+\d+\D+\d+\D+\d+\D+\d+\D+\d+\D+\d+\D+\d+\D+(\d+)\D+/;
my $recv = int($1/1024);
my $sent= int($2/1024);
return ($recv,$sent);
}
my @m1 = get_measures;
while(1) {
sleep 1;
my @m2 = get_measures;
my @rates = ($m2[0] - $m1[0], $m2[1]-$m1[1]);
foreach ('received' , ' transmit') {
printf "$_ rate:%sKB",shift @rates;
}
print "\n";
@m1=@m2;
}

I’ve changed it so that it’s:
a) running continuously until someone presses ctrl+c to stop it,
b) parsing the /proc/net/dev output instead of the ifconfig output. I think this is more efficient/fast than parsing the ifconfig output.

Sample output:

$iftraffic.pl eth0
received rate:1564KB transmit rate:71KB
received rate:1316KB transmit rate:44KB
received rate:1415KB transmit rate:48KB
received rate:1579KB transmit rate:76KB

I am sure that someone with more insight into perl than me can make it even more efficient.

You can also download a version with comments that I made so that one can make the script run for X number of repetitions instead of running until someone stops it.
Download: iftraffic.pl

Some statistics on linux-greek-users mailing list and forum.hellug.gr

Out of boredom I decided to parse the Linux-Greek-Users (LGU) archives and create some graphs. Then I wrote a few more oneliners to deduct some numbers out of the archives. These numbers may or may not mean anything to someone, it’s entirely up to the reader.. Since the archives contain some amount of spam (not too much though) one must take that into consideration as well while reading the numbers I extracted below…

First thing I did was to download the index file containing the links to the monthly archives since February 1997:
wget http://lists.hellug.gr/pipermail/linux-greek-users/

Then download each month’s archive:
for i in `grep date index.html | cut -d"\"" -f2`; do foo=`echo $i|cut -d"/" -f1`; wget http://lists.hellug.gr/pipermail/linux-greek-users/$i -O $foo-date.html ; done
(more…)

delete all empty directories using xargs

I was trying to figure out one 1-liner to delete all empty directories in a tree.
The following should do it’s job:
%find -type d -empty | xargs rm -rvf

BUT! While this works for directories with “regular” filenames, it doesn’t work when there are special characters inside the filename. Consider this for example:

%ls -1
test 1
test2
test _ 3
%find -type d -empty
./test 1
./test2
./test _ 3
%find -type d -empty | xargs rm -rvf
removed directory: `./test2'
%find -type d -empty
./test 1
./test _ 3

Only directory “test2” was deleted. To delete the rest of the directories when they contain “special” characters like whitespace and quotes one needs to modify the command like this:

%find -type d -empty -print0 | xargs -0 rm -rvf
removed directory: `./test 1'
removed directory: `./test _ 3 '

🙂

command exit status on zsh using RPROMPT

I’ve just updated by .zshrc so that I can get the exit status of commands on a “right prompt” using zsh’s RPROMPT variable. Exit status appears only if the value is non-zero.

Example usage:
zsh-rpropmpt-exit-codes

You can find my zshrc and more dot files that I use in my Pages/My dot files

HOWTO remotely install debian over gentoo without physical access

The Task
Last year, me and comzeradd set up a Gentoo server for HELLUG according to our plot to help Gentoo conquer the world. Unfortunately Gentoo is out of HELLUG’s administration policy, all servers must be Debian. We didn’t know that, so after a small flame :), we decided that we should take back the server to somebody’s home and re-install Debian over it, the problem was that the server was located at University of Athens campus which is a bit far from downtown Athens where comzeradd lives. I also live 500km away so we were pretty much stuck. Months passed and nobody actually had enough free time to go to UOA‘s campus and take the server to their house. …In the meantime manji joined us as an extra root for the server.

One Saturday night while chatting at IRC (what else could we be doing on saturday night ??) we had an inspiration, why not install Debian remotely, without taking the server home. Even if everything got eventually borked it couldn’t get any worse than going there, taking the server home and fixing it, just like we would do any way. So we gathered on a new IRC channel with some more friends that are really good with Debian and started the conversion progress.

The Server
The interesting part about the server was that it had 2x250Gb IDE disks. The Gentoo setup had these disks partitioned to 4 software raid devices + swap partitions.
(more…)

commandlinefu.com random entry parser

I’ve written a small perl script to parse random entries from the extremely usefull commandlinefu.com website. Quoting from their site:

Command-Line-Fu is the place to record those command-line gems that you return to again and again.

The script code is very “clean”. I can almost say that it’s written in a very python-ish way.
Sample output:%./cfu.pl
CMD: for (( i = 0; i < 100; i++ )); do echo "$i"; done
URL=http://www.commandlinefu.com/commands/view/735/perform-a-c-style-loop-in-bash. Title=Perform a C-style loop in Bash.
Description: Print 0 through 99, each on a separate line.
%./cfu.pl
CMD: rsync -av -e ssh user@host:/path/to/file.txt .
URL=http://www.commandlinefu.com/commands/view/20/synchronise-a-file-from-a-remote-server Title=Synchronise a file from a remote server
Description: You will be prompted for a password unless you have your public keys set-up.

You can get it from here: commandlinefu.com random entry parser perl script

As far as I’ve tested, it works out of the box on default perl installations of Debian, Gentoo and Mac OS X.

Severely degraded harddisk performance on sata_sil by athcool

I am writing this post to provide some statistics on athcool + sata_sil usage. The results are horrible.

Athcool is a small utility, enabling/disabling Powersaving mode for AMD Athlon/Duron processors.
The homepage of the utility has a big fat warning as well:

WARNING: Depending on your motherboard and/or hardware components, enabling powersaving mode may cause:

* noisy or distorted sound playback
* a slowdown in harddisk performance
* system locks or instability

The Gentoo ebuild also has these warnings:

ewarn “WARNING: Depending on your motherboard and/or hardware components,”
ewarn “enabling powersaving mode may cause:”
ewarn ” * noisy or distorted sound playback”
ewarn ” * a slowdown in harddisk performance”
ewarn ” * system locks or unpredictable behavior”
ewarn ” * file system corruption”
ewarn “If you met those problems, you should not use athcool. Please use”
ewarn “athcool AT YOUR OWN RISK!”

Ignoring all these warning I was using athcool for years on my old desktop box filled with 2 IDE disks. Never had any real problem at all, except for a some performance loss. The problem appeared when I first used a sata disk on motherboard’s, Gigabyte GA-7VAXP-A Ulta, sata controller which uses the sata_sil module.
(more…)

Convert greek characters from latin1 mysql database fields to pure utf8

The Problem
To sum it up, the case is this: many many many web applications were programmed so that they used latin1 collation for their fields inside mysql databases. But most users now use utf8 from within their browsers. What happens is that utf8 characters are getting stored inside latin1 fields, which in return produces chaos! A huge web application that used that kind of madness was WordPress. Luckily (or not) WordPress now uses utf8 everywhere. I’ve known many many many people that got so frustrated when they tried to move from their old WordPress installation to a newer one because all their greek posts couldn’t be exported “easily”, I won’t say “properly” because there are always solutions to problems like this, but all the solutions were not straightforward at all, that they finally dumped the idea of moving the posts and started a new blog.

This is a HUGE problem for many greek (and not only) users and I hope I now have an elegant(?) solution to it.
(more…)

How much can misconfigured wordpress plugins stall your server’s performance

A couple of days ago I’ve met a guy who has a high traffic blog about tech stuff. The guy was telling me that he has hosting problems and that his blog is getting slower and slower by the day. I’ve offered to help him by providing hosting for him in one of the servers that I administer. After making the transition from his old hosting to my server, which was not an easy thing to do due to latin1 to utf8 conversions that had to be made – it deserves a post of it’s own, I started to notice increased load on my server. Sure his blog had heavy traffic…but could it be that bad ?
(more…)

Applications Meme

Following the request of comzeradd

answer the following questions with less than 50 words each (mind, only desktop/gui applications):
1. which desktop manager do you use more often ?
2. which desktop application you would not like to see implemented again on linux? and why?
3. which desktop application you definitely would like to see implemented on linux? describe it briefly or point out to a similar application.
4. write the name of the last project (not the very best, the last!) that made you wish to thank their developers so you can thank them now! 🙂

5.(optional) Link the blogs of 1-3 people you’d like to take part to this meme. (no more than three). you can skip this question if you like.

and here are my answers:

1. fluxbox
2. Audio players
3. I don’t have a single desktop application that I use on any other OS and I think it needs implementing on Linux, sure there are applications like CAD and serious audio/video editing for professionals missing, but I am sure that from the psychological point of view, if MS Office worked on linux a lot of people would feel much more comfortable switching to it. Just like what happens with MacOSX.
4. keepassX: excellent cross-platform tool to manage one’s passwords
5. stsimb, agorf, adamo

macports error

While trying to update the installed progs, I got errors like:

Error: Target org.macports.build returned: shell command " cd "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_textproc_libiconv/work/libiconv-1.12" && make CC= -f Makefile.devel && make all " returned error 2
Command output: O lib/genaliases.c -o genaliases
make: O: Command not found
make: [lib/aliases.h] Error 127 (ignored)
./genaliases > lib/aliases.gperf 3> canonical.sh 4> canonical_local.sh
/bin/sh: ./genaliases: No such file or directory
make: *** [lib/aliases.h] Error 127

The reason was that I was using an old macports version, 1.6.0 instead of 1.7.0. A supo port selfupdate fixed the problem. I hope that in the future macports will be upgradable through normal upgrades like gentoo’s portage and debian’s apt-get tools do so we don’t need to “selfupdate” every once in a while…

MacOSX: Vodafone Mobile Connect not opening

Today I had a very unpleasant surprise with my Vodafone Mobile Connect on Mac OS X. After a normal laptop standby, the application refused to open. Upon starting the application it peaked at 100% cpu usage but no gui ever appeared. I had to kill the application after a while…No messages at the console either. The solution was to (re)move the /Library/Application Support/nova media and /Library/Application Support/Vodafone folders to another location.

This way you lose your stats (data transfered, time used) but at least you can get back on the net…pheeeewwww

a small tip for more efficient command line usage on debian

Debian is one of the few distros that you can’t search the bash history backward or forward for past commands by default.
To change that behaviour you need to uncomment two lines inside /etc/inputrc.

Change:

# alternate mappings for "page up" and "page down" to search the history
# "\e[5~": history-search-backward
# "\e[6~": history-search-forward

To:

# alternate mappings for "page up" and "page down" to search the history
"\e[5~": history-search-backward
"\e[6~": history-search-forward

Example usage:
To search through your old commands that started with “ssh” (e.g. ssh -p 551 koko@lala.gr, ssh foo@bar.gr, ssh test@koko.gr -L1111:1.2.3.4:9876), just type ssh and hit PgUp, you will see the previous ssh commands appearing on the command line.
$ ssh[PgUp] transforms to $ ssh -p 551 koko@lala.gr hit PgUp again and it transforms to
$ ssh foo@bar.gr PgUp and it becomes $ ssh test@koko.gr -L1111:1.2.3.4:9876

Help needed on apache2 segfaults

Dear Internet,

I need your help!
I have a debian stable (4.0) server with apache2 (Version: 2.2.3-4+etch6) running which is hosting more than 10 different sites. The problem is that in the apache2 error log I can see a lot of segfaults. All sites though continue to work properly and nobody has ever complained about them.

Some logs:

[Tue Feb 03 18:30:36 2009] [notice] child pid 1353 exit signal Segmentation fault (11)
[Tue Feb 03 18:30:37 2009] [notice] child pid 29343 exit signal Segmentation fault (11)
[Tue Feb 03 18:30:37 2009] [notice] child pid 1350 exit signal Segmentation fault (11)
[Tue Feb 03 18:30:38 2009] [notice] child pid 1349 exit signal Segmentation fault (11)
[Tue Feb 03 18:30:38 2009] [notice] child pid 1352 exit signal Segmentation fault (11)
[Tue Feb 03 18:30:39 2009] [notice] child pid 1354 exit signal Segmentation fault (11)
[Tue Feb 03 18:30:41 2009] [notice] child pid 1380 exit signal Segmentation fault (11)
[Tue Feb 03 18:30:42 2009] [notice] child pid 1378 exit signal Segmentation fault (11)
[Tue Feb 03 18:30:42 2009] [notice] child pid 1714 exit signal Segmentation fault (11)
[Tue Feb 03 18:30:44 2009] [notice] child pid 1715 exit signal Segmentation fault (11)
[Tue Feb 03 18:30:44 2009] [notice] child pid 1718 exit signal Segmentation fault (11)
[Tue Feb 03 18:30:45 2009] [notice] child pid 1720 exit signal Segmentation fault (11)
[Tue Feb 03 18:30:45 2009] [notice] child pid 1721 exit signal Segmentation fault (11)
[Tue Feb 03 18:30:46 2009] [notice] child pid 1723 exit signal Segmentation fault (11)
[Tue Feb 03 18:30:47 2009] [notice] child pid 1724 exit signal Segmentation fault (11)
[Tue Feb 03 18:30:47 2009] [notice] child pid 1725 exit signal Segmentation fault (11)
[Tue Feb 03 18:30:49 2009] [notice] child pid 1726 exit signal Segmentation fault (11)
[Tue Feb 03 18:30:49 2009] [notice] child pid 1728 exit signal Segmentation fault (11)
[Tue Feb 03 18:30:50 2009] [notice] child pid 1729 exit signal Segmentation fault (11)
[Tue Feb 03 18:30:50 2009] [notice] child pid 1730 exit signal Segmentation fault (11)
[Tue Feb 03 18:30:51 2009] [notice] child pid 1358 exit signal Segmentation fault (11)
[Tue Feb 03 18:30:51 2009] [notice] child pid 1733 exit signal Segmentation fault (11)

In order to find out what causes the segfaults I have enabled the following options:
inside /etc/apache2/apache2.conf
CoreDumpDirectory /tmp-apache/
$ ls -Fla / | grep tmp-apache
drwxrwxrwx 2 www-data www-data 4096 2009-01-31 11:01 tmp-apache/

I have changed the ulimit settings inside /etc/security/limits.conf
* soft core unlimited
* hard core unlimited

I have even added a ulimit -c unlimited setting inside /etc/init.d/apache2.
But still I get no core dumps inside /tmp-apache2/ from the segfaulting children.
If I manually kill -11 apache.pid then I can see a core file inside /tmp-apache/

I have only seen one or two core dumps generated by apache and using gdb I could see that they both “blamed” a function of /usr/lib/apache2/modules/libphp5.so. In my quest to find which site/code causes the segfaults I have recompiled apache2 to enable mod_whatkilledus. But no core dump was created in /tmp-apache/ for more than a week even if the segfaults keep happening.

I have reduced my modules, removed mod_python, mod_perl, etc and still these segfaults keep occuring but no core dumps. I suspect that the only time I got a core was when a parent and not a child process segfaulted. I don’t think that my apache2 children dump core when they segfault.

Is there anything I could have done and I haven’t done it ? Is there a way I can force apache2 children to dump core or any other way to determine what causes these segfaults ? All these without of course closing down the sites one by one to see when the segfaults stop…

Thanks in advance to anyone that replies!

P.S. blog’s database is making some tricks…I hope it’s ok now and the post is fully published