Archive for June, 2007

Holidays…

So, für 2 Wochen findet man mich hier [1] am relaxen.

[1] maps.google.com

IP-Adressen Lokalisierung

Mit Hilfe von utrace [1] kann man IPs und Hostnames lokalisieren. Dabei wird nicht einfach nur das Land angezeigt, wie auf GeoIP, sondern gleich auf einer GoogleMap angezeigt. Der Dienst ist kostenfrei. Nice

[1] http://www.utrace.de/

Mac-Adresse nach Firmen auflösen

Manchmal möchte man wissen, welches Gerät sich hinter einer Mac-Adresse verbirgt. Nützlich kann dabei der Hersteller der Mac-Adresse sein. Mit dem Service coffer.com [1] findet man dies heraus.

[1] http://www.coffer.com/mac_find/

Event Google Hacking in Bern

Etwas aus der nice-to-know-Abteilung

Heute, Donnerstag, 21. Juni, 19.30 Uhr, Rest. Beaulieu (Erlachstr. 2, 3012 Bern), findet wieder ein LugBE-Off-Event statt, und zwar der Vortrag Google Hacking - Explore the dark side of Google. Herzlich eingeladen sind wie immer alle an, um, ueber und auf linuxUNIXBSDUSW Interessierten. Näheres dazu im Kalender unter http://lugbe.ch/action/events

Backup VMware Virtual Machines without VMware Tools (Update)

Update
Ich habe die Schreibfehler (VMware_VMZ) korrigiert und Logging ergänzt. Zudem wird bei einem Error (z.B. tar bricht ab) versucht, das VMware Image zu starten sofern es noch nicht läuft. Danke an die Kommentatoren!

Hier ein Script um virtuelle VMware Maschinen ohne VMware Tools auf dem Gastsystem zu backupen. Wichtig ist, dass das Host System per SSH auf den Gast zugreifen kann. Hierfür generiert man einen SSH-Key (bzw. public und private keys), dass Passwort lässt man jedoch leer!

# ssh-keygen -t rsa -b 4096

Danach findet man auf dem Hostsystem in:

/root/.ssh/

2 Schlüssel, der Public Key (id_rsa.pub) wird danach auf dem Gastsystem in

/root/.ssh/authorized_keys

hinzugefügt. Das Verteilen des Public Keys muss natürlich für jedes Gastsystem erfolgen.

Nun folgt das eigentliche Backup Script. Dieses Script ist per Mail sehr gesprächig, es empfiehlt sich also eine funktionierendes Mailsystem zu haben :).

#!/bin/sh
###################
# VMWARE BACKUP SCRIPT
#
# Version: 0.2
#
# Description:
# This script is used to stop a vmware image (vmware tools are not needed), tar the contents,
# resume the image, then optionally compress the output.
#
# Requirements:
# Host: sh shell, ssh, mail, vmware-cmd, tar, bzip2 (optional), gzip (optional)
# Guests: sshd, shutdown
#
# Modifications:
# 2007/07/12 Rene Moser, http://www.renemoser.net
# - added logging
# - fixed typing errors
###################
# CONFIG
###################
# Log should be sent to
MAIL_TO="admin@example.com";
# Wait 10 x n seconds for vmware quest shutdown, until we send a failure
TIMEOUT=10;
# Path to log files
LOG="/var/log/vmware-backup.log"
LOG_TMP="/tmp/vmware-backup.log"
###################

# Clear Temp Log
echo "" > $LOG_TMP

function writeLog {
	echo "`date`: $1" >> $LOG
	echo "`date`: $1" >> $LOG_TMP
	echo "`date`: $1"
}

function mailLog {
	echo "$1:

		`cat $LOG_TMP`" |  mail -s "VMware Backup on $HOST: $1" $MAIL_TO;
}

function checkResult {

if [ $? -ne 0 ]
then
        # check if the vm host ist down and if so, try to restart
		###
		STATE=`vmware-cmd $VMWARE_VMX getstate | grep off | wc -l`

        if [ $STATE -eq 1 ]
        then
          writeLog "Starting VMware image: $VMWARE_VMX"
          vmware-cmd $VMWARE_VMX start;
          writeLog "Tried to restart at `date` ..."
        fi

		# send a mail
		###
		mailLog "VMware Backup failed on $HOST: $1"
        exit 1;
fi
}

# Some missing args, exit
###
if [ $# -lt 4 ]
then
        echo "Usage is $0 vmware-dir vmware-vmx-file hostname tarname [bzip,gzip (optional to add compression)]";
        exit 1;
fi

VMWARE_DIR="$1";
VMWARE_VMX="$VMWARE_DIR/$2";
TAR_NAME="$3.tar";
HOST="$4";
COMPRESSION="$5";

writeLog "Virtual Machine Directory $VMWARE_DIR";
writeLog "Virtual Machine VMX File $VMWARE_VMX";
writeLog "Virtual Machines IP or Host is $HOST";
writeLog "Output Tar Name $TAR_NAME";
writeLog "Compression $COMPRESSION";
writeLog "Starting backup at `date`";

STATE=`vmware-cmd $VMWARE_VMX getstate | grep on | wc -l`

# grep for state = on, if its there then stop
###
if [ $STATE -eq 1 ]
then
  writeLog "Shutting down vmware image $VMWARE_VMX";
  ssh root@"$HOST" shutdown -h now;
  checkResult "Unable to ssh to $HOST";
fi

# We try to shutdown the host, so we have to wait until it is halted
###
COUNTER=0;
while true;
do
  STATE=`vmware-cmd $VMWARE_VMX getstate | grep off | wc -l`
  if [ $STATE -eq 1 ]
  then
    writeLog "Virtual Maschine has shut down.";
    break;
  fi

  # Timemout?
  ###
  if [ $COUNTER -eq $TIMEOUT ]
  then
    writeLog "Virtual Maschine shut down failed.";
    writeLog "Could not shut down Virtual Machine $VMWARE_VMX"
	mailLog "VMware Backup failed on $HOST";
    exit;
    break;
  fi

  writeLog "Virtual Maschine is still running, waiting...";
  sleep 10;
  COUNTER=$[$COUNTER+1];
done

sleep 10;

writeLog "Taring VMWare directory $VMWARE_DIR";
tar cvf "$TAR_NAME" "$VMWARE_DIR";

checkResult "Unable to create the file $TAR_NAME";
writeLog "Tar completed"

#Check if the state is off, so restart the guest
###
STATE=`vmware-cmd $VMWARE_VMX getstate | grep off | wc -l`

if [ $STATE -eq 1 ]
then
  writeLog "starting vmware image $VMWARE_VMX";
  vmware-cmd "$VMWARE_VMX" start;
  checkResult "Unable to restart $VMWARE_VMX"
fi

# Which compression?
###
case $COMPRESSION in

        bzip)
                writeLog "Bzip2ing the file"
                bzip2 "$TAR_NAME"
                checkResult "Unable to bzip2 the tar"
        ;;
        #gzip the file
        gzip)
                writeLog "Gzipping file"
                gzip "$TAR_NAME" -f
                checkResult "Unable to Gzip the tar"
        ;;
        #default case, print out tar name
        *)
                writeLog "Output file is $TAR_NAME";
        ;;
esac

STATE=`vmware-cmd $VMWARE_VMX getstate | grep on | wc -l`
writeLog "Finished backup at `date`";

if [ $STATE -eq 1 ]
then
  mailLog "Backup successful"
else
  mailLog "Backup failed"
fi

Dies führt man mittels cronjob auf:

# m h  dom mon dow   command
0 3 * * 1-5 /jobs/vmware-backup.sh /var/lib/vmware/vms/vm0 Debian4.0.vmx /backups/vm0 vm0.example.com gzip
20 3 * * 1-5 /jobs/vmware-backup.sh /var/lib/vmware/vms/vm1 debian4.vmx /backups/vm1 vm1.example.com gzip

Viel Spass. Verbesserungen sind immer willkommen.

VMware Server auf Ubuntu (Update 2)

Update
Auf Ubuntu 6.06 gibt es mit VMware 1.0.3 einige Eigenheiten.

MUI (Webinterface)
Bei einem Neustart startet der Webserver für das MUI nicht mehr. Folgenden Hotfix behebt das Problem:
In /etc/init.d/http.vmware nach dem Kommentaren folgendes eintragen:

mkdir -p /var/run/vmware/httpd
chown www-data:nogroup /var/run/vmware/httpd
chmod 0700 /var/run/vmware/httpd

PAM Fehlermeldung in vmware.log

vmware-authd[7348]: PAM adding faulty module: /lib/security/pam_unix2.so
v18092 vmware-authd[7350]: PAM unable to dlopen(/lib/security/pam_unix2.so)
v18092 vmware-authd[7350]: PAM [dlerror: /lib/security/pam_unix2.so: cannot open shared object file: No such file or directory]

In

 # nano -w /etc/apt/sources.list

das repo universe freischalten, (sprich Kommentarzeichen vor deb entfernen)

 ## Major bug fix updates produced after the final release of the
 ## distribution.
 #deb http://ch.archive.ubuntu.com/ubuntu/ dapper-updates main restricted
 #deb-src http://ch.archive.ubuntu.com/ubuntu/ dapper-updates main restricted
 ...
 #deb http://security.ubuntu.com/ubuntu dapper-security universe
 #deb-src http://security.ubuntu.com/ubuntu dapper-security universe

dann apt update

 # aptitude update

und pam unix2 installieren

 # aptitude install libpam-unix2

Urspünglicher Eintrag
Also, VMware auf Ubuntu 7.04 ist kaputt (manuelle Installation wie auch vom Repository), da VMware einem aufgrund eines Bugs nicht mit der VMware console reinlässt. Man kann dies mit einem Workaround [1] beheben. Ein weiterer unschöner Effekt ist, dass ich es nicht geschafft habe das Webinterface von VMware auf 7.04 zum Laufen zu bewegen.

Mit Ubuntu 6.06 LTS funktioniert die manuelle Installation einwandfrei, wie auch das Webinterface. Eine Anleitung findet man z.B. hier [2], ich habe es zwar nicht nach dieser gemacht, jedoch sind die Schritte nahezu identisch. Die Anleitung installiert auch ein paar Sachen die es eigentlich nicht bräuchte…

[1] Bug report
[2] Howto VMware auf Ubuntu

Microsoft Vista Speech Recognition tested

Amasing Video [1] of Microsoft Vista Speach Recognition: How to script perl easily.

[1] www.youtube.com/v/KyLqUf4cdwc

VMware Server 1.0.3 auf Debian Etch

Eigentlich wollte ich ja schreiben wie gut sich VMware mit Debian Etch verträgt. Doch der Debian Kernel 2.6.18 hat was dagegen.

kernel: rtc: lost some interrupts at 512Hz.
last message repeated 1521 times
last message repeated 3050 times
last message repeated 3050 times
last message repeated 3049 times
last message repeated 3050 times
last message repeated 3050 times
last message repeated 3050 times
last message repeated 3050 times
last message repeated 3050 times
last message repeated 3050 times
last message repeated 3049 times
last message repeated 3050 times
last message repeated 3049 times
last message repeated 3049 times
last message repeated 3050 times
last message repeated 3050 times
last message repeated 3050 times
last message repeated 3050 times
last message repeated 3050 times
last message repeated 1225 times

Tja, und die Debian Devs haben natürlich kein Bedürfnis, da was zu flicken da VMware ja böse, ähm closed Source ist (was keine Anschuldigung sein soll, sondern eine Feststellung). Anscheinend ist nur Kernel 2.6.18 betroffen. Dies werde ich in den nächsten Tagen noch ausprobieren und das Ergebnis hier posten.

Übrigens hat dieser kernel: rtc: lost some interrupts at 512Hz. zur Folge, das auf den virtuellen Maschinen die Zeit (hwclock) immer langsamer geht. Performenceverluste sind nicht auszumachen. Trotzdem ist es hässlich.