Weblog von matze

Eximstats script

I've written a little bash-script for eximstats. This script runs eximstats so, that it creates a daly/weekly/monthly and yearly report :-)

This script doesn't create an index.html or so, but within a .htaccess "Options +Indexes" this should be no problem :-)

#!/bin/sh

STATSPATH="/path/to/exim/status/output"
EXIMLOG="/var/log/exim/exim_*.log"

##end config
cd $STATSPATH

DAY=`date +"%u"`
WEEK=`date +"%W"`
MONTH=`date +"%m"`
YEAR=`date +"%Y"`

function report(){
    OUTPUT=$1
    MERGEPATTERN=$2
    mkdir -p $OUTPUT
    echo eximstats -html -charts -merge -chartdir $OUTPUT -chartrel $OUTPUT $MERGEPATTERN.html
    eximstats -html -charts -merge -chartdir $OUTPUT -chartrel $OUTPUT $MERGEPATTERN.html > $OUTPUT.html
}

#create daily report
mkdir -p day$DAY
eximstats -html -charts -chartdir day$DAY -chartrel day$DAY $EXIMLOG >day$DAY.html
#update weekly report
report week$MONTH-$WEEK day?
#update monthly report
report month$MONTH week??-??
#uptdate yearly report
report year$YEAR month??

The script is called from logrotate.

/etc/logrotate.d/exim:

/var/log/exim/exim*.log {
        daily
        missingok
        rotate 28
        compress
        delaycompress
        notifempty
        create 640 mail mail
        sharedscripts
        prerotate
                /path/to/eximstats.sh
        postrotate
                /etc/init.d/exim restart > /dev/null
        endscript
}

 

mod_rewrite-hell (-:

Da ich den Blog von /home nach / verschoben und lesbare URLs aktiviert habe musste ich für die alten Links der Form /home/?q=node/1 auf das neue Schema /node/1 einen Redirect einrichten.

Das geht in Apache mit dem Modul mod_rewrite:

.htaccess:
RewriteCond %{REQUEST_URI} ^/home RewriteCond %{QUERY_STRING} [0-9]+
RewriteRule ^(.*)$ /node/%0? [R=301,L]

Apache überprüft zuerst, ob die RewriteRule anwendbar ist, dann werden die RewriteCond überprüft: Die erste RewriteCond testet, ob in REQUEST_URI die ersten zeichen (da ein ^ am Anfang steht) mit /home beginnen.

Die zweite Regel such einfach nach einer Zahl. Und mit der RewriteRule wird dann die URL überschrieben, links steht was überschrieben werden soll ^(.*)$ heißt im Prinzip die komplette URL. Daneben steht mit was überschrieben wird /node/ ist klar, %0 bedeutet der Wert den die Regex eine Zeile vorher ermittelt hat und das Fragezeichen bedeutet, dass keine Parameter mehr angehängt werden sollen.

In den Eckigen klammern stehen noch Parameter zum Redirect, 301 ist der HTTP-Code, L bedeutet, dass keine weiteren RewriteRules mehr abgearbeitet werden. Dann hat noch das Wiki gefehlt, das ist auch in Drupal umgezogen. Die Umleitung für die alten Links war dort aber relativ einfach:

.htaccess:
RewriteRule ^wiki/index.php(.*)$ wiki/$1 [L,R=301]

 

Schnell mal Linux installieren oder testen?

Um mal schnell eine fast beliebige Distribution zu installieren, ohne sich zuerst das komplette, meist ~700MB große Image aus dem Laden zu müssen, kann man GPXE verwenden.

Mit dem Bootloader ist es möglich direkt aus dem Internet eine z.B. Ubuntu-Live-CD zu booten. Vorausgesetzt wird natürlich eine bestehende Internetverbindung, über WLAN wird die Software vermutlich auch nicht ohne weiteres funktionieren. Aber um mal kurz ein Ubuntu in eine Virtuellen Maschine zu installieren... dafür ist die Software ideal geeignet!

In einem kurzen Test habe ich eine Ubuntu-LiveCD gestartet, dabei wurden "nur" ~120MB übertragen bis das System gestartet war. Bei DSL, bei dem Virtualbox leider im Test abgestürzt ist, wäre die übertragene Datenmenge natürlich viel geringer, da das Image nur ~50MB gross ist.

daemon-tools for linux?

A long time ago i searched a tool to mount cd-images like .MDS .ISO .CUE with linux. There was none... only things like mount -o loop were avaiable.

Today i've found cdemu: it does all i want, it only installs a very small kernel module to emulate a Virtual (SCSI) Host Bus Adapter, the rest is done in userspace.

There is also the small GUI gCDEmu to "mount" an image. It is a gnome-panel applet. Thumbs up! :-)

libvirt and virtualbox-ose not working?

I tried to use libvirt and virtualbox-ose, but i only get this error:

$ virsh Fehler: no hypervisor driver available Fehler: Verbindung zum Hypervisor scheiterte

After an "strace -e open virsh" i found, that it can't found VBoxXPCOMC.so. Virtualbox-ose installs into /usr/lib64/virtualbox-ose/ but libvirt searchs in /usr/lib64/virtualbox ...

The solution was to set the env-variable VBOX_APP_HOME before starting virsh:

VBOX_APP_HOME=/usr/lib64/virtualbox-ose virsh

And now it works! :-)

Restore JPGs from a Disk/Partition/Raw Image

To restore files from a partition/usb-stick/... i can recommond PhotoRec.

It runs on most operating-systems: Linux/Windows/MacOS X/Dos/...

It is command-line only but simple to use and it supports currently about 180 file formats.

The software is based on TestDisk which can recover lost partitions.

I used it to restore about 930 pictures from a raw-image of a formated 2GB usb-stick.

Techtree from Spring - Balanced Annihilation 7.01

I've created a techtree from Balanced Annihilation. As you can see... it's a little complex ;-) See the attached PDF. The file was created with graphiz:

dot -Tpdf techtree.dot -o techtree.pdf

The .dot file was created with the AI i'm currently working at, see the source code for more details

AnhangGröße
techtree.pdf57.05 KB
techtree.dot9.28 KB

Why i switched from Xen to KVM

In the last weeks i switched some servers from Xen to KVM. Why?

My big points to switch were:

The bugtracker isn't maintained, a bug i reported about 2 years ago is marked as new! It is fixed, but it doesn't look like the xen-developers have a good contact to the community.

The (Hypervisor-)Xen-support seems to go never into the mainline kernel. KVM is from the early beginning there, this makes different problems: if you want to use xen, you have to use a very old kernel (2.6.18).

KVM is supported by one of the biggest linux distributions: ubuntu.

KVM supports nested virtualization: it allows to run a hypervisor in a guest domain!

Xen seems to be unstable, i had many crashes or kernel panics while installing. I tryed many differnt kernels and configs to get a domU paravirtualized running. When it runs, i had problems too with lvm for example. KVM+Virtio works like a charm and i can use the vanilla-kernel without any problems :)

Seiten

Subscribe to RSS – Weblog von matze