Cacti (home)ForumsDocumentation
Cacti: offical forums and support
It is currently Sat Mar 25, 2017 2:50 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: [INFO] - Tools for Migrating to From Windows/Linux/UNIX
PostPosted: Sat Dec 15, 2007 8:49 pm 
Offline

Joined: Sat Dec 15, 2007 7:56 pm
Posts: 1
Location: Lake Forest, IL
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:
File comment: Linux bash and Windows WScript scripts for rrd conversion.
RRDConversion.zip [989 Bytes]
Downloaded 1023 times
Top
 Profile  
 
 Post subject:
PostPosted: Sun Dec 16, 2007 6:02 am 
Offline
Developer
User avatar

Joined: Tue May 14, 2002 5:08 pm
Posts: 14863
Location: MI, USA
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
Gandalfs Official Debugging Help
Central Plugin Repository
Central Templates Repository


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 04, 2008 7:54 pm 
Offline

Joined: Mon Nov 26, 2007 10:09 am
Posts: 9
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:
#!/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


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 04, 2008 9:15 pm 
Offline
Developer
User avatar

Joined: Tue May 14, 2002 5:08 pm
Posts: 14863
Location: MI, USA
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:
makexml.sh [3.99 KiB]
Downloaded 678 times
makerrd.sh [4.88 KiB]
Downloaded 689 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
Gandalfs Official Debugging Help
Central Plugin Repository
Central Templates Repository
Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 25, 2008 3:15 am 
Offline
User avatar

Joined: Tue Jan 22, 2008 5:33 am
Posts: 35
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 ??


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 25, 2008 6:20 am 
Offline
Developer
User avatar

Joined: Tue May 14, 2002 5:08 pm
Posts: 14863
Location: MI, USA
They are korn shell. You might want to convert them to bash.

_________________
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
Gandalfs Official Debugging Help
Central Plugin Repository
Central Templates Repository


Last edited by TheWitness on Tue Nov 25, 2008 7:24 am, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 25, 2008 6:55 am 
Offline
User avatar

Joined: Tue Jan 22, 2008 5:33 am
Posts: 35
how .. i dont know how this works ??


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 25, 2008 7:27 am 
Offline
Developer
User avatar

Joined: Tue May 14, 2002 5:08 pm
Posts: 14863
Location: MI, USA
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
Gandalfs Official Debugging Help
Central Plugin Repository
Central Templates Repository


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 26, 2008 12:52 am 
Offline
User avatar

Joined: Tue Jan 22, 2008 5:33 am
Posts: 35
thanks for the post ..!! done it


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

Protected by Anti-Spam ACP Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group