Export complete cacti

Post support questions that directly relate to Linux/Unix operating systems.

Moderators: Developers, Moderators

Axel90
Cacti User
Posts: 139
Joined: Fri Feb 10, 2017 12:41 pm

Export complete cacti

Post by Axel90 »

Hey guys,

there are a lot of people who use cacti.

Please tell me:

When you need to upgrade your operating system where cacti is installed.

for example an ubuntu system.

How do you do this?

is there a possibility to export all cacti data (devices, graphs, ...) and import it on the new operating system?

or how do you do this?
Tichod
Posts: 4
Joined: Tue Jan 23, 2018 8:18 am

Re: Export complete cacti

Post by Tichod »

Hello Axel 90.

I haven't done it yet (just having setup a new Cacti 2 weeks ago), however I have written a backup script that includes instructions for restoration.
My script backups the following items:
- database dump;
- config files;
- XML compressed RRD files.

Here are the non-tested-yet-instructions:
  • prepare a backup server (properly located for SNMP access to the graphed equipments)
  • if necessary: make the appropriate DNS record modification.
  • install packages on server:
    • cacti
    • cacti-spine
    • rrdtool
  • disactivate cacti crontab
  • transfer archives on the backup server
  • review configuration files (database settings especially), then put them in place
  • create database and proper user, then import database dump
  • import RRD files at the correct location (/var/lib/cacti/rra/ for us)
  • activate cacti crontab
Those are certainly not perfect, but given that you obtained no answer yet, I hope they'll help you get a foot in the door.
Axel90
Cacti User
Posts: 139
Joined: Fri Feb 10, 2017 12:41 pm

Re: Export complete cacti

Post by Axel90 »

Hey Tichod,

thank you for your answer!

for example, when I just want to export the devices and all according device-graphs (not the graph data/history itself), can I just perform a database dump and import that dump on my new system with newly installed cacti?

I mean, I got a lot of devices and a lot of graphs, I don't want to configure each of them from scratch, that would last very very long
Tichod
Posts: 4
Joined: Tue Jan 23, 2018 8:18 am

Re: Export complete cacti

Post by Tichod »

Hello Axel90, and sorry for my late answer, I forgot to slect 'Notify me when a reply is posted'.

I haven't tested yet what I suggest, however, I'd say that restoring files and DB dump on the new system could work, and wouldn't break anything, as long as the new system is a clone of the old one, in terms of :
  • Cacti/Spine version
  • filesystem structure: rrd files location,...
If you don't restore rrd files, I can't see how they would be restored automagically. Database doesn't include RRD data itself.

The thing to be extra careful about is database setting to be modified in config files (debian.php and spine.conf for me), in order not to break the prod instance.
User avatar
camerabob
Cacti User
Posts: 386
Joined: Fri Feb 10, 2017 2:45 pm
Location: Long Island, New York, USA
Contact:

Re: Export complete cacti

Post by camerabob »

I just did that on a CentOS 7 box (old: v7 to new:v7.4)

Files to copy from an existing install to another box:
# cd /var/lib/mysql/
From:
# tar -cvf cacti.<date>.tar cacti/ ibdata1 ib_logfile0 ib_logfile1 mysql/
To:
# tar -xvf cacti.<date>.sql.tar

# cd /usr/share/cacti

From:
# tar -cvf cacti.<date>.http.tar plugins/ resource/ scripts/ rra/
To:
# tar -xvf cacti.<date>.http.tar

Also:
# cd /usr/share/cacti
# chown apache cacti/ -R
# chgrp apache cacti/ -R
# chmod 644 cacti/ -R
# chmod +x cacti/ -R

Doing the above and also changing the necessary files (php.ini, httpd.conf, etc.) got me up and running after a bit of tweaking.
Prod: Cacti 1.2.15 @ CentOS Linux release 7.9.2009 (Core) & PHP 5.4.16-48.el7
Maint @ 1.2
Monitor @ 2.3.6
Thold @ 1.2.4

Temp: Cacti 1.2.3 @ CentOS Linux release 7.9.2009 (Core) & PHP 5.4.16-48.el7
Flowview @ 2.1
Mactrack @ 4.2
Maint @ 1.2
Monitor @ 2.3.6
Router Configs @ 1.3.4
Syslog Monitoring @ 2.1
Thold @ 1.2.4
netniV
Cacti Guru User
Posts: 3441
Joined: Sun Aug 27, 2017 12:05 am

Re: Export complete cacti

Post by netniV »

Be careful with that last line. You're making all files executable with it. That's not totally advised from a security point of view.

If you are just trying to ensure that the directories are traversable (+x) then use:

find <cacti_path> -type d -exec chmod +x {} \;

This starts at the cacti path and finds any entries of type directory then executes the chmod against the name found (the curly braces).
Cacti Developer & Release Manager
The Cacti Group

Director
BV IT Solutions Ltd

+--------------------------------------------------------------------------+

Cacti Resources:
Cacti Website (including releases)
Cacti Issues
Cacti Development Releases
Cacti Development Documentation
Axel90
Cacti User
Posts: 139
Joined: Fri Feb 10, 2017 12:41 pm

Re: Export complete cacti

Post by Axel90 »

@camerabob

I exactly followed your procedure.

All devices appear and are in state UP.

I also copied all rrd files.

I can see the rrd files on the new system. However, cacti doesn't continue to fill them with data. (screenshot)

Do you have an idea?
Attachments
rrd.JPG
rrd.JPG (38.65 KiB) Viewed 4189 times
User avatar
camerabob
Cacti User
Posts: 386
Joined: Fri Feb 10, 2017 2:45 pm
Location: Long Island, New York, USA
Contact:

Re: Export complete cacti

Post by camerabob »

Are the RRD directories in the correct locations? If the original install placed them elsewhere that could be an issue. Also double check the permissions on the RRD folders and files again. Make sure the poller is using the correct user name when running.

In the crontab file:
*/5 * * * * <CentOS-web-user> php /usr/share/cacti/poller.php > /dev/null 2>&1 (replace <CentOS-web-user> with your service account, 'apache' for most CentOS installs)
Prod: Cacti 1.2.15 @ CentOS Linux release 7.9.2009 (Core) & PHP 5.4.16-48.el7
Maint @ 1.2
Monitor @ 2.3.6
Thold @ 1.2.4

Temp: Cacti 1.2.3 @ CentOS Linux release 7.9.2009 (Core) & PHP 5.4.16-48.el7
Flowview @ 2.1
Mactrack @ 4.2
Maint @ 1.2
Monitor @ 2.3.6
Router Configs @ 1.3.4
Syslog Monitoring @ 2.1
Thold @ 1.2.4
Axel90
Cacti User
Posts: 139
Joined: Fri Feb 10, 2017 12:41 pm

Re: Export complete cacti

Post by Axel90 »

It's awkward: Some devices work, some devices don't.

The devices that don't work are Ubuntu systems and Windows Server.

My CentOS devices work, though!

my rrd files are in /var/lib/cacti/rra, permissions are OK.

I deleted all graphs of a windows server, deleted the related rrd files, then recreated the graphs.

Cacti created all rrd files again.

But the graphs don't show any values. It's just "-nan".

I did a tcpdump with the destination address of the host, I can see all SNMP Get Requests and Respones.

So cacti definitely pulls the values.

PS: I don't have that crontab entry in /etc/crontab. Neither on my original system. I installed cacti via a ppa.

got a lot of those errors in cacti log:

Code: Select all

2018/05/03 12:11:38 - CMDPHP PHP ERROR WARNING Backtrace: (/poller_commands.php: 112 run_data_query)(/lib/data_query.php: 154 update_poller_cache_from_query)(/lib/utility.php: 103 poller_update_poller_cache_from_buffer)(/lib/utility.php: 541 sizeof)(CactiErrorHandler)(/lib/functions.php: 4585 cacti_debug_backtrace)
2018/05/03 12:11:38 - ERROR PHP WARNING: sizeof(): Parameter must be an array or an object that implements Countable in file: /usr/share/cacti/site/lib/utility.php  on line: 541
netniV
Cacti Guru User
Posts: 3441
Joined: Sun Aug 27, 2017 12:05 am

Re: Export complete cacti

Post by netniV »

You are running PHP 7.2. That is currently untested with Cacti and there are a few known issues one being sizeof() has been changed to return a warning if used against a non-countable item. Therefore, things like false (which a DB query can return if there are no values) are no longer valid with sizeof(). At the moment, I recall only one place I have had to fix that within the poller but there are likely other scenarios too.
Cacti Developer & Release Manager
The Cacti Group

Director
BV IT Solutions Ltd

+--------------------------------------------------------------------------+

Cacti Resources:
Cacti Website (including releases)
Cacti Issues
Cacti Development Releases
Cacti Development Documentation
Axel90
Cacti User
Posts: 139
Joined: Fri Feb 10, 2017 12:41 pm

Re: Export complete cacti

Post by Axel90 »

Do you think that's the problem why the windows and Ubuntu hosts don't work?

I mean, that's very curious.
netniV
Cacti Guru User
Posts: 3441
Joined: Sun Aug 27, 2017 12:05 am

Re: Export complete cacti

Post by netniV »

No. That's a separate issue and more than likely either a firewall or setup issue. Can you SNMPWALK the devices from the command line of the cacti server? If so, it would appear to be something within Cacti (but I doubt it would be). If not, you have a firewall issue which must be resolved on the device in question, or an SNMP issue which means you need to validate all your settings are the same in Cacti as the device and that it is indeed running on the device with the appropriate configuration to allow connections from the Cacti server.
Cacti Developer & Release Manager
The Cacti Group

Director
BV IT Solutions Ltd

+--------------------------------------------------------------------------+

Cacti Resources:
Cacti Website (including releases)
Cacti Issues
Cacti Development Releases
Cacti Development Documentation
User avatar
camerabob
Cacti User
Posts: 386
Joined: Fri Feb 10, 2017 2:45 pm
Location: Long Island, New York, USA
Contact:

Re: Export complete cacti

Post by camerabob »

Does the new host have the same IP address? If not, that may need to be added to ALL HOSTS being polled. In my Windows boxes, I limited SNMP to community string and to polling host as well. Check these.
Prod: Cacti 1.2.15 @ CentOS Linux release 7.9.2009 (Core) & PHP 5.4.16-48.el7
Maint @ 1.2
Monitor @ 2.3.6
Thold @ 1.2.4

Temp: Cacti 1.2.3 @ CentOS Linux release 7.9.2009 (Core) & PHP 5.4.16-48.el7
Flowview @ 2.1
Mactrack @ 4.2
Maint @ 1.2
Monitor @ 2.3.6
Router Configs @ 1.3.4
Syslog Monitoring @ 2.1
Thold @ 1.2.4
Axel90
Cacti User
Posts: 139
Joined: Fri Feb 10, 2017 12:41 pm

Re: Export complete cacti

Post by Axel90 »

The devices are all reachable.
Their state is "UP" and when I enter a device, I get the snmp information.
I also can do a snmpwalk.
Additionally, when I do a tcpdump, I see all snmp values. So cacti definitely gets the values.

I did another thing now:

I reverted the snapshot of the "migration cacti VM".

I set up that VM with Ubuntu 18.04 and did a clean install of cacti from https://launchpad.net/ubuntu/+source/cacti

I didn't do a migration.

I set up two devices, both of them show -nan.

So I think it's either a problem with the cacti version of the ppa, or with Ubuntu 18.04.

What do you suggest to do?
User avatar
camerabob
Cacti User
Posts: 386
Joined: Fri Feb 10, 2017 2:45 pm
Location: Long Island, New York, USA
Contact:

Re: Export complete cacti

Post by camerabob »

That's beyond the scope of my wheelhouse. I'm using CentOS 7.4.

Good luck.
Prod: Cacti 1.2.15 @ CentOS Linux release 7.9.2009 (Core) & PHP 5.4.16-48.el7
Maint @ 1.2
Monitor @ 2.3.6
Thold @ 1.2.4

Temp: Cacti 1.2.3 @ CentOS Linux release 7.9.2009 (Core) & PHP 5.4.16-48.el7
Flowview @ 2.1
Mactrack @ 4.2
Maint @ 1.2
Monitor @ 2.3.6
Router Configs @ 1.3.4
Syslog Monitoring @ 2.1
Thold @ 1.2.4
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests