Category: Linux

Munin: This RRD was created on another architecture – migrating between 32 and 64bit systems

When I was moving Senpuu.net to a new location, I've wanted to preserve my Munin stats (since my new server have almost identical configuration they will be very useful to me). Unfortunately moving RRD files between different architectures is not possible. To copy Munin data to a new server with a different architecture, we need to use rrdtool (dump and restore).

# Error example from /var/log/munin/munin-node.log
This RRD was created on another architecture

rrd dump and restore

Lets quote a man for rrdtool:

Dump:

Dump the contents of an RRD in plain ASCII. In connection with restore you can use this to move an RRD from one computer architecture to another.

Restore:

Restore an RRD in XML format to a binary RRD.

Now everything looks better. We can easily dump RRD files to XML, move them to the other server and then easily restore them to RRD format.

To dump all RRD files for given node, you need to get (as root) to RRD files dir (by default it should be somewhere near /var/lib/munin) and execute following code:

cd /var/lib/munin/senpuu
# Create a dir for RRD dumps
mkdir ./../rrd_dump
 for i in ./*.rrd;do rrdtool dump $i ./../rrd_dump/$i.xml;done

The above code will create XML dumps in appropriate directory. When this is finished, you need to download all the files and upload them to your new server. Then execute:

# Execute this on a new server
cd /var/lib/munin/rrd_dump
for i in ./*.xml; do rrdtool restore "$i" "../senpuu/${i%.xml}"; done

after this you might reset munin-node just to be sure that everything will work fine:

/etc/init.d/munin-node restart

Now you should have your old charts up and running.

Running a script on startup before X starts in Ubuntu Linux

I have two xorg.conf files that I use, depending on where I am. Lately I got sick of switching them manually like this:

sudo cp /etc/X11/xorg.conf.h /etc/X11/xorg.conf
sudo pkill X

So I decided to add switching script to rc.local file. Unfortunately rc.local seems to start after all other services. Of course this would work with sudo pkill X included. But to be honest, killing X every time I turn on my computer is a bit lame.

Run levels to the rescue

You can read about run levels here. I'll just tell you that you need to check your current run level by running this command:

runlevel

You'll get something like this:

[~]$ runlevel 
N 2
[~]$ 

My Ubuntu is by default using run level 2. So now I know that I need to hookup before X starts in this run level. To do this, you need to create a script in /etc/rc2.d/ directory. If you do a ls -al in any or RC dirs, you'll see that all the scripts there are just symlinks to /etc/init.d/ scripts. It is convenient to store all of them there, because they might be reused in other run levels.

Naming convention

All scripts (aliases) that should be executed in given run level, have a 'SNUMBER' prefix. S probably states for "Start" and number determines the order in which all the scripts well be executed (well there is also LSB that might "disrupt" the specified order but fortunately not in our case).

Example of rc2.d:

lrwxrwxrwx   1 root root    15 2012-04-25 16:42 S20mysql -> ../init.d/mysql
lrwxrwxrwx   1 root root    15 2011-06-29 09:55 S20nginx -> ../init.d/nginx
lrwxrwxrwx   1 root root    17 2011-11-14 21:25 S20postfix -> ../init.d/postfix
lrwxrwxrwx   1 root root    22 2011-06-29 02:03 S20redis-server -> ../init.d/redis-server
lrwxrwxrwx   1 root root    16 2012-04-28 21:51 S20tcpspy -> ../init.d/tcpspy
lrwxrwxrwx   1 root root    17 2011-06-22 01:18 S20vboxdrv -> ../init.d/vboxdrv
lrwxrwxrwx   1 root root    17 2011-06-21 22:40 S20winbind -> ../init.d/winbind
lrwxrwxrwx   1 root root    19 2011-06-22 00:05 S25bluetooth -> ../init.d/bluetooth
lrwxrwxrwx   1 root root    20 2011-06-22 00:05 S50pulseaudio -> ../init.d/pulseaudio
lrwxrwxrwx   1 root root    15 2011-06-22 00:05 S50rsync -> ../init.d/rsync
lrwxrwxrwx   1 root root    15 2011-06-22 00:05 S50saned -> ../init.d/saned
lrwxrwxrwx   1 root root    19 2011-06-22 00:05 S70dns-clean -> ../init.d/dns-clean
lrwxrwxrwx   1 root root    18 2011-06-22 00:05 S70pppd-dns -> ../init.d/pppd-dns
lrwxrwxrwx   1 root root    14 2012-05-27 19:33 S75sudo -> ../init.d/sudo
lrwxrwxrwx   1 root root    17 2011-06-21 22:39 S91apache2 -> ../init.d/apache2
lrwxrwxrwx   1 root root    22 2011-06-22 00:05 S99acpi-support -> ../init.d/acpi-support
lrwxrwxrwx   1 root root    21 2011-06-22 00:05 S99grub-common -> ../init.d/grub-common
lrwxrwxrwx   1 root root    18 2011-06-22 00:05 S99ondemand -> ../init.d/ondemand
lrwxrwxrwx   1 root root    18 2011-06-22 00:05 S99rc.local -> ../init.d/rc.local

X conf switchin script

I've named this script 'xselector' and I've placed it in /etc/init.d with rest of scripts. Remember to give this script execution rights!

#!/bin/sh
video_home(){
  rm /etc/X11/xorg.conf
  cp /etc/X11/xorg.conf.dom /etc/X11/xorg.conf
}

video_work(){
  rm /etc/X11/xorg.conf
  cp /etc/X11/xorg.conf.praca /etc/X11/xorg.conf
}

DAY=$(date +"%u")
HOUR=$(date +"%H")

# If this is a work day
if [ "$DAY" -lt 6 ]; then
  # And these are hours when I'm @ work
  if [ "$HOUR" -gt 7 -a "$HOUR" -lt 18 ]; then
    video_work
  else
    video_home
  fi
else
  video_home
fi

After we create our script we just need to add it like this:

sudo ln -s /etc/init.d/xselector /etc/rc2.d/S15xselector

Copyright © 2025 Closer to Code

Theme by Anders NorenUp ↑