[INFO] - Tools for Migrating to From Windows/Linux/UNIX

If you figure out how to do something interesting/cool in Cacti and want to share it with the community, please post your experience here.

Moderators: Moderators, Developers

Post Reply
Author
Message
rrogier
Posts: 1
Joined: Sat Dec 15, 2007 7:56 pm
Location: Lake Forest, IL

[INFO] - Tools for Migrating to From Windows/Linux/UNIX

#1 Post by rrogier » Sat Dec 15, 2007 8:49 pm

Hi All,
This is my first post, but I've been actively reading for several months. I've tried searching the fora for the solution below but couldn't find it completely. I decided to put this together in hopes that it will help someone else. If this is elsewhere out there, please accept my apologies.
I recently decided to switch my Cacti server from CentOS 5 to Windows. This was done primarily because others in my organization have more experience with Windows and they need to administer this too. I had a lot of data in my Linux instance that I did not want to loose. Figuring out how to move the SQL data from one server to the other was pretty easy and in reality moving the rrd files one by one was easy but I had 26 hosts and over 230 rrd files so I really didn't want to do all of these by hand. I looked for some scripts and found a couple that helped go from Windows to Linux (http://forums.cacti.net/post-78443.html) but none to go back. I also found that just changing the windows script to restore from dump didn't help since the restore command needs to have the .rrd extension specified at the end. I have had experience in many of my jobs with writing scripts to make my jobs easier so I embarked on this task.
I have attached a zip with two files. First is the windows script to import the xml files. I wrote it in WScript so all you should need to do is run Importrrd.vbs from the command line. You will need to edit the script to change the variables at the top to reflect your install. The second file is a bash script to dump all the rrds from the linux cacti instance and then tar them up. All you need to do is update the variables at the top of the file with the location of your install and then make the file executable. When you run the file, it will dump all the rrds out to the directory you chose, tar them up and then clean them up from the directory.
While I've used this several times on my system with success, I won't be responsible if it causes issues with your system. My next thing to try is to create this using Windows PowerShell. The scripting is much simpler with PS but since it's newer to me it will take me longer. Once I have the PS script done, I'll post it too for those interested. If you have problems, let me know and I'll try to help you with them.
Attachments
RRDConversion.zip
Linux bash and Windows WScript scripts for rrd conversion.
(989 Bytes) Downloaded 1142 times

User avatar
TheWitness
Developer
Posts: 14817
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

#2 Post by TheWitness » Sun Dec 16, 2007 6:02 am

Thanks for the script. I will move this post to the "How To" section of the forums.

TheWitness
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of MacTrack, Boost, CLog, SpikeKill, Platform RTM, DSStats, maintainer of Spine, lot's of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Central Plugin Repository
Central Templates Repository


I'm still out there people. Getting excited for Cacti 1.2. I think it will be a great release.

0.o
Posts: 9
Joined: Mon Nov 26, 2007 10:09 am

#3 Post by 0.o » Mon Feb 04, 2008 7:54 pm

I too wrote a small shell script to import/dump rrd to and from xml. It is very simple. If you execute it in the top of the directory where your rrd files are stored, it will dump them to xml and remove the rrd.

Code: Select all

#!/bin/sh

ECHO="echo -e"

rrdump ()
{
	for rrd in `find . -type f -name "*.rrd"`
		do
			xml=`echo $rrd | sed 's/.rrd//g'`
			rrdtool dump $rrd > $xml.xml
			rm $rrd
		done
}	

xmlimport ()
{
	for xml in `find . -type f -name "*.xml"`
        do
                rrd=`echo $xml | sed 's/.xml//g'`
                rrdtool restore $xml $rrd.rrd
                rm $xml
        done
}


case "$1" in
        dump)
                rrdump
		;;
        import)
                xmlimport
                ;;
        *)
                $ECHO "$0 takes one of two arguments\n"
		$ECHO "$0 dump -- dumps contents to xml\n"
		$ECHO "$0 import -- imports xml files to rrd\n"
                ;;
esac

User avatar
TheWitness
Developer
Posts: 14817
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

#4 Post by TheWitness » Mon Feb 04, 2008 9:15 pm

Thought that I would add to this, before I forgot. Below are two scripts. The first takes your RRD files (from a single directory) and dumps them to XML, the second takes your XML files and imports them to new RRD files.

This both scripts are meant to run at the same time for moving between 32bit and 64bit systems.

So, it works this way:

On server A export a temporary file sytem so it can be mounted on the other system (server B).

On the second system (server B) create a directory and then mount the other systems (server A) temporary file system.

On the "new system" (server B) run makerrd.sh. This script waits to see XML files appear on the temporary file system.

On the old system (server A), where have the old RRD files, run the makexml.sh script. Once it starts, your new system (server B) will start to convert the XML's to RRD files. It can be pretty fast on a Gigabit ethernet system and can allow you to migrate from an old box to a new box without skipping a beat.

Regards,

TheWitness
Attachments
makerrd.sh
(4.88 KiB) Downloaded 804 times
makexml.sh
(3.99 KiB) Downloaded 787 times
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of MacTrack, Boost, CLog, SpikeKill, Platform RTM, DSStats, maintainer of Spine, lot's of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Central Plugin Repository
Central Templates Repository


I'm still out there people. Getting excited for Cacti 1.2. I think it will be a great release.

User avatar
east_cost
Posts: 35
Joined: Tue Jan 22, 2008 5:33 am

#5 Post by east_cost » Tue Nov 25, 2008 3:15 am

hii

when i run the scripts on both source/destination i get the errors

# sh makerrd_355.sh
: command not founde 2:
: command not founde 6:
': not a valid identifierxport: `BASE_DIR
: command not founde 9:
'akerrd_355.sh: line 36: syntax error near unexpected token `{
'akerrd_355.sh: line 36: `get_xml_source_directory () {


and

#sh makexml_175.sh
: command not founde 2:
: command not founde 6:
': not a valid identifierxport: `BASE_DIR
: command not founde 9:
'akexml_175.sh: line 36: syntax error near unexpected token `{
'akexml_175.sh: line 36: `get_rrd_source_directory () {


??? what may be the problem ??

User avatar
TheWitness
Developer
Posts: 14817
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

#6 Post by TheWitness » Tue Nov 25, 2008 6:20 am

They are korn shell. You might want to convert them to bash.
Last edited by TheWitness on Tue Nov 25, 2008 7:24 am, edited 1 time in total.
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of MacTrack, Boost, CLog, SpikeKill, Platform RTM, DSStats, maintainer of Spine, lot's of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Central Plugin Repository
Central Templates Repository


I'm still out there people. Getting excited for Cacti 1.2. I think it will be a great release.

User avatar
east_cost
Posts: 35
Joined: Tue Jan 22, 2008 5:33 am

#7 Post by east_cost » Tue Nov 25, 2008 6:55 am

how .. i dont know how this works ??

User avatar
TheWitness
Developer
Posts: 14817
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

#8 Post by TheWitness » Tue Nov 25, 2008 7:27 am

Run dos2Unix on the files.
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of MacTrack, Boost, CLog, SpikeKill, Platform RTM, DSStats, maintainer of Spine, lot's of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Central Plugin Repository
Central Templates Repository


I'm still out there people. Getting excited for Cacti 1.2. I think it will be a great release.

User avatar
east_cost
Posts: 35
Joined: Tue Jan 22, 2008 5:33 am

#9 Post by east_cost » Wed Nov 26, 2008 12:52 am

thanks for the post ..!! done it

Post Reply