Cacti (home)ForumsRepositoryDocumentation
Cacti: offical forums and support  

 FAQFAQ   SearchSearch   MemberlistMemberlist    RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in    


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

 
Post new topic   Reply to topic    Cacti Forum Index -> Informational/HOWTO's
Author Message
rrogier



Joined: 15 Dec 2007
Posts: 1
Location: Lake Forest, IL

PostPosted: Sat Dec 15, 2007 8:49 pm    Post subject: [INFO] - Tools for Migrating to From Windows/Linux/UNIX Reply with quote

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.



RRDConversion.zip
 Description:
Linux bash and Windows WScript scripts for rrd conversion.

Download
 Filename:  RRDConversion.zip
 Filesize:  989 Bytes
 Downloaded:  228 Time(s)

Back to top
TheWitness
Developer


Joined: 14 May 2002
Posts: 9736
Location: MI, USA

PostPosted: Sun Dec 16, 2007 6:02 am    Post subject: Reply with quote

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

TheWitness
Back to top
0.o



Joined: 26 Nov 2007
Posts: 8

PostPosted: Mon Feb 04, 2008 7:54 pm    Post subject: Reply with quote

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
Back to top
TheWitness
Developer


Joined: 14 May 2002
Posts: 9736
Location: MI, USA

PostPosted: Mon Feb 04, 2008 9:15 pm    Post subject: Reply with quote

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



makexml.sh
 Description:

Download
 Filename:  makexml.sh
 Filesize:  3.99 KB
 Downloaded:  154 Time(s)


makerrd.sh
 Description:

Download
 Filename:  makerrd.sh
 Filesize:  4.88 KB
 Downloaded:  157 Time(s)

Back to top
east_cost



Joined: 22 Jan 2008
Posts: 35

PostPosted: Tue Nov 25, 2008 3:15 am    Post subject: Reply with quote

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 ??
Back to top
TheWitness
Developer


Joined: 14 May 2002
Posts: 9736
Location: MI, USA

PostPosted: Tue Nov 25, 2008 6:20 am    Post subject: Reply with quote

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
Back to top
east_cost



Joined: 22 Jan 2008
Posts: 35

PostPosted: Tue Nov 25, 2008 6:55 am    Post subject: Reply with quote

how .. i dont know how this works ??
Back to top
TheWitness
Developer


Joined: 14 May 2002
Posts: 9736
Location: MI, USA

PostPosted: Tue Nov 25, 2008 7:27 am    Post subject: Reply with quote

Run dos2Unix on the files.
Back to top
east_cost



Joined: 22 Jan 2008
Posts: 35

PostPosted: Wed Nov 26, 2008 12:52 am    Post subject: Reply with quote

thanks for the post ..!! done it
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Cacti Forum Index -> Informational/HOWTO's All times are GMT - 5 Hours
Page 1 of 1

 



Powered by phpBB © 2001, 2005 phpBB Group