How To: Migrate Cacti to another host

I’ve been using cacti for network stat collection for years. In that time I’ve had to move cacti from one linux server to another. Keeping all the historical rrd data was of top priority. I just did another migration this morning. My notes were the key. I’m going to share them with you here.

A few things are assumed:

To start a quick outline of what needs to be done:

  • install cacti on the new machine and verify that it is working!
  • stop the poller on both cacti installs
  • copy the old database to the new one
  • copy your scripts and resources folders from the old to new (if you have any custom scripts)
  • convert all old rrd files to xml files
  • move/copy the xml files to the new cacti
  • convert the xml files back to rrd format
  • turn on the poller and test!

Why do the old rrd files need to be turned into xml files? rrdtool doesn’t like rrd files made on different machines. Even if they are identical machines/OSes. rrdtool is kind enough to allow you to export/import using the xml files to get around this.

General Steps

Make note of which cacti machine each command needs to run on! Context is very important!

After installing the new cacti, make sure it’s working.

Next get samba setup on the old cacti machine and share the whole cacti folder. Security shouldn’t be an issue so you can share without the need for credentials.

Mount the rra folder on the new cacti machine, I used this command:

mount -t cifs //kny_netmon/root/var/www/cacti/rra /mnt/oldcacti

Copy over your scripts and resources folders from the old cacti to the new cacti. This should be done from the new cacti machine.

You can do the sql database export several ways. I chose to export the database on the old machine. I used this command:

mysqldump --user=root --password=password cacti > /var/www/cacti/newcacti.sql

If you want to do the sql export from the new machine you can do it like this (the resulting sql file will still be on the old cacti machine though):

ssh root@kny_netmon mysqldump --user=root --password=password cacti > /var/www/cacti/newcacti.sql

Next, import the database to the new cacti database, remember you’re on the new cacti machine for this command.

mysql cacti < /mnt/oldcacti/newcacti.sql

On the old cacti machine, do the xml export. Run this from the rra folder!:

for i in *.rrd; do rrdtool dump $i > $i.xml; done

On the new cacti machine, copy the xml files to the rra folder:

 rsync -avz --exclude=*.rrd /mnt/oldcacti/ /var/www/cacti/rra

We don’t want the old rrd files so they’re excluded.

When the copy is done, on the new cacti convert the xml files back to rrd files:

for i in /var/www/cacti/rra/*.xml; do A=`echo $i|sed 's/.xml//'`; rrdtool restore -f $i $A; done

Remove the old xml files from the new and old cacti:

rm /var/www/cacti/rra/*.xml -f

Now here’s the wacky part. In all my years I’ve setup cacti on Windows, CentOS, Debian, Ubuntu and MacOS. Permissions are ALWAYS an issue in the rra folder. I haven’t discovered the proper permissions so I just chmod them 777 and it seems to work. So unless you know the proper permissions just chmod them 777:

chmod 777 -R /var/www/cacti/*

 

I do the whole folder just in case….I know it’s BAD security but all my cacti installs are on private networks.

Start up the poller on the new cacti and start watching your log files and graphs. They should work!

My only issue on my last migration was that my snmp host only respond to certain IP addresses so I had to add the new cacti machines address. Otherwise it picked up where it left off.

Notes

For the sake of this “tutorial” I didn’t present any scripts.

when I do this “live” I’m able to literally get all this done in less than 5 minutes. Know why that’s important? Of course you do! The poller runs every 5 minutes.

If you can start at the end of the old cacti pollers cycle you can be ready for the next cycle on the new cacti. Pretty neat!

Don’t be afraid to test the procedure. All the copying/updating on the new cacti overwrites its settings. Each time you run this procedure you’re picking up the new/updated data from the old cacti.

You *could* leave the poller running on the old cacti if you want. I did, just making sure that the xml export was done in less than 5 minutes. I have about 900 rrd files so it’s fairly quick.

 

Good luck!

 

 

 

Setup the Dag RPM Repository for Red Hat Enterprise Linux on CentOS

I use the Dag RPM Repository for Red Hat Enterprise Linux repo to install nice little extras like Cacti and htop. Here’s how to add it to CentOS so you can use it with yum.

Edit/Create the repo file:

vi /etc/yum.repos.d/dag.repo

Add this to the repo file:

[dag]
 name=Dag RPM Repository for Red Hat Enterprise Linux
 baseurl=http://apt.sw.be/redhat/el$releasever/en/$basearch/dag
 gpgcheck=0
 enabled=1
 protect=0

Afterwards yum will pull from this repo too.

 

 

Samba: How to share files for your LAN without user/password

Samba: How to share files for your LAN without user/password

This is a quick and dirty method to set samba to allow read-only file sharing  as guest (without be prompted for a password).

Because users won’t be prompted for a user/password, this is meant to be installed in a LAN where all hosts and users are trusted.

I’m assuming you’ve already installed samba via your favorite method.

Because we are going to make samba security insecure, make sure only your local network can access samba service.

To do so, open and edit /etc/samba/smb.conf

and set interfaces to lo and your local network interface.

interfaces = lo eth1
bind interfaces only = true

Next, change the samba default security variable: security and make sure it is set to share instead of user and that guest account is enabled:

security = share
...
...
guest account = nobody

Next,  we can create a share to be accessible to guest users:

[Guest Share]
        comment = Guest access share
        path = /path/to/dir/to/share
        browseable = yes
        read only = yes
        guest ok = yes

 

Save the file and restart samba.

 

LCC v5 is almost ready

Lots of code changes and some hardware. Here’s some of them:

  • Added ShiftBright RGB LED to pins D2, D12 and D13
  • Added code for ShiftBright
  • Updated DEBUG routines
  • Day overhead handling is updated to wait longer before turning off
  • Added yellow and red LED indications for day overhead conditions
  • Night cold conditions are mirrors of day as appropriate
  • Switch 1 is now only for UV lights
  • Switch 2 is only for heat- in my case the heat rock is on all the time and the heat lamp is switched
  • Cleaned some functions of unneeded statements

Version 5 should be released soon. It’s still not running live yet. If you want an advance copy let me know.

New York Sidewalk Etiquette

I hope this doesn’t turn into a rant, my main purpose is to educate all of you who don’t know the rules of the sidewalk, especially in cities (NYC in particular) where walking is a main mode of transportation.

I really don’t feel like enough people take sidewalk etiquette seriously. The New York Times wrote in 2002:

First, walking rules are like driving rules.

”Stay to the right is the golden, No. 1 rule,” said Chris Avila, 29, who has lived in the city for nine years.

Everyone in the USA drives on the right. Even if you don’t have a car or a drivers license you know this. KEEP RIGHT!

Further in the same article:

”People who stop short really get me,” said Carla Melman, 26, a lifelong New Yorker. She said it was the equivalent of a car wreck on the Long Island Expressway on a Hamptons weekend.

If you need to stop an collect your thoughts or what not, PULL OVER. The rest of us need to keep going! Listen, I need to stop and think on the sidewalk all the time. I pull over, looking over each shoulder first to make sure I’m not cutting others off.

In another piece in the NYT they extol the inconsiderateness of walking texters. Can you really cross a street, avoid other walkers AND text? 99% of you can’t. Pull over and text.

How serious is this problem with sidewalk etiquette? Wikipedia has an article on it. Yes. It’s that bad people.

Borderstan.com has an article about it. Their big irritation? Large groups of people making impenetrable walls. Break it up people! Especially you tourists who have no idea where you’re going!

Here’s a good article about etiquette for “considerate” New York tourists. They spell out the same things. A GOOD tourists learns how to blend in.

A few more:

 

I am certainly not alone in this. There are LOTS of articles from many different places on how to behave on the sidewalk- from car rental places to major news papers. The locals (generally) know the rules. I know SOME who clearly don’t. So lets recap:

  1. Walk on the right. Just like driving.
  2. Don’t stop suddenly. If you need to stop, pull over.
  3. Don’t text and walk and certainly don’t read a book (I’ve seen it!). Pull over.
  4. Keeps pets on a short leash
  5. No skateboards or bikes. If it’s 2am ok, maybe then.
  6. Break up groups. No walking 5 abreast just because you’re all together. Some of us want to pass you.
  7. Don’t step on heels.
  8. If you need to cross the path of oncoming walkers, look for a clearing. See #2.
  9. Don’t cut others off. Look to your sides before changing your position in the stream.
  10. Don’t wander all over the sidewalk randomly. See #1, #2 and #3.

There are probably hundreds of others we could add to the recap. Let me know what they are.

Why are Camera Lenses Round and Film Square?

This is a thinking project. I’ve asked The Straight Dope and not heard back yet… I’m sure I know or can come close to the answer but lets talk it out and see where it goes.

For our purposes we need some definitions:

  • Square = Any object of square, rectangular, boxy or cube likeness. Corners are always 90 degrees.
  • Circle = Any object of circular, oval, spherical or generally round like shape, regardless of deformation on a planar axis (lens shape). Has no corners.
  • Clear = Any material that is optically clear; as in it allows the visible spectrum of light to pass through it.
  • Film = Any image receiving material. This could be old style polyesterPETnitrocellulose or cellulose acetate light sensitive film or new style electronic optical sensors like CCD and CMOS.

So why is a camera lens round and the film square? Why not round film? Why did it get setup like this?

Lenses

In order to focus and direct light the object or medium doing this has to be clear (duh!). This ability isn’t exclusive to round objects though. Windows are square. Windows are round. Some windows are both square and round. Same goes for eye wear. They’re all optically clear, but the shapes vary from square to round.

To focus light, the clear object needs to be distorted (convex or concave if you like). You can see this with old school eye wear.  Remember the coke bottle jokes? A cross section of the lens was more of a shallow bowl shape. Today this is less so, but the lens is definitely distorted.

Taking a closer look at a focusing lens though shows me something interesting- as you get towards the outer edges of the lens, its ability to keep the image in focus fades. Take a look at a magnifying glass. They’re usually convex on the outsides and the only part of the image in focus is what’s in the middle. The more it magnifies the more distorted the image is as you look farther from the center.

If we had film that was round, the outer edges would most likely be out of focus. BUT! If the film was smaller than the image cast by the lens the film would only capture what was in focus.

Makes sense. Right?

Film

Film is square. CCD (charged coupled devices) and CMOS devices are the electronic versions of film. But they’re still square. Why?

Well from an electronic perspective I can tell you that the matrix of dots that make up the CCD and CMOS chips makes sense. A matrix is square or cubic. Think of a spreadsheet. Each pixel in the matrix (cell) has an address. Spreadsheets have letters on the x and numbers on the y axis. CCD matricies are similar. The combination of x and y allow each pixel (cell) to be addresses individually. This makes sense. Old school chemically developed film doesn’t have to deal with this, but it did have to be coated evenly with the photo sensitive material. So why did they start out square?

Here’s my guess. Humans like square objects:

  • they stack perfectly
  • they are easy to handle
  • they store well
  • they organize well
  • straight lines seem to be easier to make and cut as opposed to arcs or circles
  • the written word has typically been on square like tablets
  • humans tend to read in lines- lines are straight (how hard would a book be to read if the text was along a circular path from outside in??)
  • paintings and drawings seem to lend themselves to square canvases
  • they’re not round

From a design and engineering perspective the square (or plate that is square) seems to make sense too. Engineers like to make machines use  round things for moving parts and square parts to hold the round ones. For example look inside a laser printer or any printer for that matter:

Laser printer mechanics

See all the round stuff? Guess what holds it in place? Big squares of metal or plastic. Maybe engineers and inventors have always thought this way. I can’t find an answer to that. I’d love to see another take on this.

So back to film. It’s square. Traditional film was a roll (really big rectangle or long square…) divided into frames. Really really old film was on plates. Square plates. One single square plate per frame. Present day “film” sensors are square. They output square images. Those images are made of square pixels. Square.

Printing or developing film has always been on paper. Paper is square. Printers (the machines, not the people) like square paper. Ever tried to use a round sheet of paper in a printer?

Mechanically it seems to make sense to use squares to print on.

The Conundrum

So we know that light focuses best through distorted round clear things. We know that humans, machines, math and computing devices like squares. I guess light will just have to be the odd one here. (I know math likes circles too, but squares seem to be easier to calculate. They have good symmetry (ok so do circles). Call me lazy.)

Lenses focus the light onto square film. But wait. The incoming image isn’t square. It’s round. Sadly, some of the image is lost. Happily, the lost parts of the image are the ones from the outer edges of the lens that are out of focus. Remember earlier:

Taking a closer look at a focusing lens though shows me something interesting- as you get towards the outer edges of the lens, its ability to keep the image in focus fades. Take a look at a magnifying glass. They’re usually convex on the outsides and the only part of the image in focus is what’s in the middle. The more it magnifies the more distorted the image is as you look farther from the center.

I guess I just answered my conundrum.

My Conclusion

Lenses are round because they focus light better than a square. Round lenses are most likely easier to manufacture than a square lens that is, well, rounded.

Film is square because it is easiest for humans and machines to manipulate. Paper has always been square. Printing has always been done on squares. Old film on plates was square because it was originally done on glass. Which was already square for windows (I assume….). Machines like squares.

Square film also conveniently solves the issue of round lenses distorting the outer parts of the image. The film is only exposed to the most focused center of the incoming light. Call it auto cropping. It seems as though cropping an image is just built into the design. Whether the cropping was intentional or not, it worked and it happened long before we had digital cropping tools.

 

Comments?  I’d love to hear them. Did I screw up something? Let me know!