Windows DNS record update Script

Script | Friday June 26 2009 10:42 am | Comments (0)

Do you have a Windows DNS? and you need to add 300 A record on it… So do I!

In order do quickly do so, I wrote a small script: dnsupdate

you just need a txt file next to it called dnsupdate.txt populated by NAME,IP_ADDRESS (only 1 per line), and the script will go through the list and add an A entry for each of them.

Hope this will be useful for someone else :D

Linux is running too fast…

VMware, linux | Monday June 15 2009 11:50 am | Comments (3)

If you still use VMware GSX and/or VMware server 1, and some of your guest are Linux, you may have already encountered this issue. This might seems not useful as those VMware products are quite old now, but when it’s on production, you don’t really get rid of something easily :D

The clock of the system is always de-sync even with a ntp server configured on it. This is a big issue when you run automated script with cron, and you’re system backup is done at 10am instead of 5am… That’s because your CPU clock is running too fast or too slowly. This is a known issue on those product as they don’t support host power management features on Linux properly.

To sort this out, you just to do the following:

you first need to know your CPU speed

~cat /proc/cpuinfo | grep MHz

cpu MHz         : 3601.737

edit the file /etc/vmware/config and add

host.cpukHz = 3601737
host.noTSC = TRUE
ptsc.noTSC = TRUE

host.cpukHz change depending the output of the fisrt command. It’s basically the CPU speed in Hz.

if not already done, you need to install the VMware tools on the guest and configure the time synchronisation. You can do it either by editing a file or in the options of the VM tools in a graphical interface.
The file to edit is the .vmx file and the line to add is tools.syncTime = “TRUE”

Once it’s all done, you’ll have to reboot the guest and restart VMware on the host.

If the problem is not fixed, this may be addressed by disabling power management altogether. This can be done by adding “apm=off acpi=off noapic” to the boot entry of the host’s /etc/grub.conf file.

Capacity Management for QNAP NAS

Script, linux | Friday June 12 2009 6:15 pm | Comments (0)

I’ve got 2 TS-409 NAS appliance from QNAP. They are configured in raid5 and data are synchronised between them. As there is no possibilities to monitor the disk usage (no SNMP or any other things like that), I decided to create a little script which send an email when the disk usage reach 90%

This is not a big deal as it only contain few lines and is really straightforward, but I actually spent 2 hours to figure out how I could send this bloody email… Again, nothing difficult, just that I started in the wrong direction. i wanted to send it through a telnet connection on port 25 of the mail server… The only problem is that it was fine on any linux with a proper telnet binary, but the telnet implementation on busybox is different and doesn’t work when I try to telnet the smtp port of our exchange… So I just used ssmtp, already included and it works like a charm.

The script could obviously report a lot more but that’s what I’ve been asked :D

#!/bin/sh

FROM="FROM: Nas1@xxx.yyy"
TO="someone@xxx.yyy"
RCPT="TO: $TO"
SUB="Subject: Test Alert"
BODY="The NAS is filled at XXX%"

dfresult=`df -h /dev/md0 | grep /dev`
position=`expr index "$dfresult" %`
let position=$position-3

if [ ! ${dfresult:$position:1} == "" ];then
   value=${dfresult:$position:2}
   if [ $value -ge 90 ];then
      BODY=${BODY/XXX/$value}
      (echo "$RCPT";echo "$FROM";echo "$SUB";echo "";echo "$BODY") | ssmtp $TO
   else
      echo "not critical"
   fi
else
   echo "less than 10%"
fi

exit 0

It wouldn’t be difficult to add few more things like add how many GB left, and things like that but I’ll let you do it :D

Kernel Korner: 2.6.30 out

linux | Wednesday June 10 2009 4:16 pm | Comments (0)

Here we are! The new kernel has been released today after 8 release candidate and bring some interesting new features along driver update and bugfix. I won’t go into details but here are the main thinks:

  • - Improvement on Ext3/4
  • - The file system NILFS (New Implementation of a Log-structured File System) has entered in the mainline. Developped by the Japanese company NTT, this FS improve writs on the detriment of reads. the general performances seems even better than BTRFS though
  • - Exofs (Extended Object File System) is an other “new” FS for SCSI disks, who is based on object and metadata instead of low level blocks an sectors and is developed by SUN
  • - POHMELFS (Parallel Optimized Host Message Exchange Layered File System) is again a new FS, but it’s purpose is having a high performances network file system (like NFS, CIFS, …) but with paralleled access to nodes.
  • - FS-Cache has finally been ported on the kernel and allow to improve network file systems performances by caching the data.
  • - TOMOYO is the new security module created to be much easier to manage than SELinux.
  • - IBM has pushed a set of patch to port Integrity management in the kernel. This provide some sort of assurance that the files on the system have not been messed with.
  • - The mutex code has been amended to introduce a new mechanism in it. the patch changes mutex contention behaviour such that it will sometimes busy wait on acquisition to move its behaviour closer to that of spinlocks.
  • - Reliable Datagram Sockets (RDS) protocol is now supported and improve clusters performances by bringing improvement on process when the talks to other processes on the cluster.
  • - The asynchronous function call infrastructure is now activated. It allows to query storage devices asynchronously on kernel boot, which makes it quicker.
  • - The new MicroBlaze architecture is now suported
  • - The integrity controle on block devices introduced on 2.6.27 has been extended to raid configurations.
  • - The kernel can be compressed with bzip2 and lzma algorithms to gain between 10% and 33% of the gziped sizw
  • - Improvements on dm-crypt for multi-core CPUs
  • - Harware acceleration AES encryption for futur Intel Westmere CPU
  • - Support for AMD/ATI R6xx/R7xx graphic cards
  • - Extend of the 4GB ram limit for ARM architecture
  • - General improvements of ftrace (Linux Dtrace like)
  • - Enhancement of cpufreq
  • - SSP (Secure Simple Pairing) for bluetooth 2.1 is now suported
  • - Enhancement of SSD drives performances through the implementation of the TRIM command
  • - Support of the SEGA Dreamcast console improved
  • - Driver update for ALSA (1.0.20) and V4L

As you can see there is quite a few new thinks about file systems. I might post something about all that as it’s been a quite busy area lately with EXT4, Btrfs, …
The Kernel 2.6.30 represents 11912 patches and one million and half lines of code modified, which makes it a quite big development cycle.

More details about the new drivers
This is just a quick look at what’s new on the Kernel, you can get much more informations there

PuTTy Connection Manager

linux, tools | Wednesday June 10 2009 12:03 pm | Comments (1)

I recently found a tool that help me a lot on my duties at work! It’s called PuTTy Connection Manager. No it’s not just the putty that everyone knows. It’s an application that actually come on top of putty to enhance it. As you can see below, the main feature is tabs. But don’t tell me, if you are an unfortunate user of putty like me (not that putty is not good but I’d prefer to use a Linux OS at work. Therefore, I wouldn’t have to use putty…), that you never thought that putty would be much better with tabs!!!

PuTTy Connection manager

PuTTy Connection manager

PuTTy Connection Manager require the .NET framwork V2 and Encryption library 0.6.0.0 if you want to encrypt your database.

Unfortunately, the project (French :D) seems to be dead and it’s not open sources… But it got to a point where I don’t really need much more features and there is no important bug. If you know any PuTTy-like tools better than this one, and preferably still alive, let me know, it might be interesting :D

You can download the latest version here
And the website is here

Quick reminder to enable kernel dump on rhel4

linux | Tuesday June 9 2009 4:15 pm | Comments (5)

Nothing new here but I’ll use this post as a quick reminder to enable kernel dump on red hat enterprise 4. Quite useful when you don’t know why your box keep crashing this week when it was perfectly fine for the last 2 years :D

Red Hat historically use netdump in order to save a kernel dump file but since RHEL 4, they introduced diskdump. Which is good as I don’t want to bother set-up a netdump server (even if there is few interesting thinks in favour of netdump, like “what if your system doesn’t recover…”). You can easily understand the main difference between them… The first one create the file over the network using a server (like if you have a syslog server) while the other one use a local disk.
Here the few steps to follow:

Everything should be already installed, but in case it’s not on your system:

# up2date crash diskdumputils

crash is an utility used to analyse the dump file.

Check the loaded kernel modules, if not already loaded, then do it.

# lsmod | grep diskdump
# modprob diskdump

Configure what partition you want to use. 2 choices: 1st you have a partition only for this purpose, 2nd you can use a swap partition. if you don’t use a swap partition, you’ll have to format it. The size of the partition you choose must be at least the size of your ram.

# cat /proc/swaps
# vi /etc/sysconfig/diskdump

You can specify more than one partition if you separate them by ‘:’

DEVICE=/dev/sda4:/dev/sda5

If you didn’t choose a swap partition, then you have to format your device in order use it as a dump device.

# service diskdump initialformat

Tell your system to start diskdump automatically at the next reboot and start it.

# chkconfig diskdump on
# service diskdump start

If you get a warning, it may just means that your partition is not good (wrong partition specified in /etc/sysconfig/diskdump, or forgot to format, …)

check that the module works fine. the output must be something like the following:

# cat /proc/diskdump

# sample_rate: 8
# block_order: 2
# fallback_on_err: 1
# allow_risky_dumps: 1
# dump_level: 0
# compress: 0
# total_blocks: 2097059
#
sda4 4401810 4192965
sda5 8594838 4192902

When a crash occures, the data from the disk dump partition are not directly readable. You need to gather them in a file on a readable partition. This is done with the following command:

# savecore -vD /dev/sda4

You can add this command to /etc/rc.local if you want to run it automatically after a crash.

This is it! Next time your kernel crashes, you’ll get a file called vmcore stored in /var/crash/127.0.0.1-\/. If for any reason the dump is not complete, the file will then be named vmcore-incomplete

You can test if it works fine by doing one of the following things. It will result on you server crashing therfore creating a dumpfile.

# Alt-SysRq-C or
# echo c > /proc/sysrq-trigger or
# echo 1 > /proc/sys/kernel/sysrq

you can also quickly compile the following code [cc -c -I/usr/src/linux/include panic.c]
and load this nice module :D [insmod panic.o]

#### panic.c #####

#define __KERNEL__
# MODULE
# include init_module(void)

int init_module (void)
	{
	panic(" panic has been called");
	return 0;
	}

now in order to analyse your dump, crash require the kernel debuginfo package corresponding to the kernel you are running. You can find it there. Then you need to install it.

wget http://updates.redhat.com/enterprise/4AS/en/os/Debuginfo/i386/RPMS/
kernel-debuginfo-2.6.9-89.EL.i686.rpm && \
     su -c "rpm -Uvh kernel-debuginfo-2.6.9-89.EL.i686.rpm"

After your kernel panic and a reboot, you can now run crash with the following arguments (vmlinux_path vmcore_path).

# crash /usr/lib/debug/lib/modules/2.6.9-89.EL/vmlinux \
        /var/crash/127.0.0.1-2009-06-07-14\:44/vmcore

OUTPUT
      KERNEL: /usr/lib/debug/lib/modules/2.6.9-89.EL/vmlinux
    DUMPFILE: /var/crash/127.0.0.1-2009-06-07-14:44/vmcore
        CPUS: 1
        DATE: Tue Jun  8 15:02:44 2009
      UPTIME: 00:51:24
LOAD AVERAGE: 0.05, 0.05, 0.00
       TASKS: 81
    NODENAME: rhxxx.test.xxx.org.uk
     RELEASE: 2.6.9-89.EL
     VERSION: #1 Fri Feb 24 16:44:51 EST 2006
     MACHINE: i686  (3600 Mhz)
      MEMORY: 1.5 GB
         PID: 3514
     COMMAND: "crash"
        TASK: f562ecd0  [THREAD_INFO: f4b7d000]
         CPU: 0
       STATE: TASK_RUNNING (ACTIVE)

I leave you find out all the things you can do with crash (try a “man crash” or help once you ran crash) but the command ‘log’ and ’sys’ will be the one you are going to use the most.

you can find much more details here
Enjoy :D

Stencils VMware

VMware | Friday June 5 2009 1:34 pm | Comments (0)

I needed to create a couple of diagram of the VM infrastructure we’ve got, but as usual for some specific things you want to design, I had first to spend a couple of hours googling to find some nice stencils for visio. I found some very nice one, and some template on other blogs or website, but I didn’t manage to find what I wanted for few of them,  so I decided to create those who where missing. I ended up with 3 different cathegories. Hardware, virtualisation and other. Most of them are the real VMware drawing.

I also attached 3 template, as I found them nice and interesting. I modified them a little bit by using different stencils. I’m sure they will be useful for a lot of people.

For those who don’t have Visio (MS proprietary sory…) I’ll attach the PNG to use with any other alternative like Kivio, DIA or OpenOffice Draw. I first wanted to create a specific set of stencils for those 3 aplications (Kivio and DIA stencils are compatible), but it’s an horrible thing to do, I don’t have time to spend hours and hours doing stencils. Then I wanted to use the SVG format. perfect for this kind of things. Unfortunately, when you try to import a SVG in DIA, it doesn’t work… even if this is a “supported” format! There is a bug reported since 2006 still not corrected… So the easiest thing is to use PNG images. I attached them and at least it works even for visio! (the visio stencils are attached as well).

It’s pretty hard to find a good open source diagram software. When Draw is more like a Drawing software, a mix between Publisher and Visio, Kivio has got a lack of funcionalities, and DIA is buggy, not supported corectly by the gnome team, and hasn’t got much more functionalities than Kivio… This is shame, DIA is quite good and would have had the potencial to compete with visio. Anyway, my stencils are yet to be complete, and I will add some more later on.
You can download them with the links below:

VI3 Template
Virtualization Stencils
PNG files

The original visio teplate were found in the blog p2vd.com
Some of the stencils were found in veeam.com, and one or two in vmguru.com

Hello world!

Uncategorized | Wednesday June 3 2009 6:38 pm | Comments (0)

Welcome to my brand new blog. I’ll try to talk about IT in general, but probably more specially about Linux, and VMware.

I’ve been using Linux as main OS for 3 years, maybe a bit more. Ubuntu most of the time for the desktop. Debian or Red Hat for servers. I’m an open source fellow, and even when I have to use windows, I try to stick to my ideas, always open source first :D

VMware as a second subjet might be a bit surprising after what you’ve just read, as it’s not an open source product and there is Xen to compete against it. Yes, but I think VMware is a much more complete product. It not for no reason that they are leader on the virtualization market!

Anyway, as I have to work on an heterogeneous environment, I’ll probably also post about Windows and some other things. So why “Linux os for me” as a name for this blog then? If you don’t just speak about Linux… Just because I like the pun :D Linux is an OS, but you could read it “Linux is for me” as well. And this is my favourite subject anyway…

Enjoy!!!