Interface migration

Post general support questions here that do not specifically fall into the Linux or Windows categories.

Moderators: Developers, Moderators

Post Reply
PoGo
Posts: 2
Joined: Mon Dec 05, 2011 9:49 am

Interface migration

Post by PoGo »

Hello,

Quite often, there is a interface migration on several switches on my infrastructure, for example the interface GigabitEthernet1/2 becomes GibabitEthernet1/3.
The thing is that I have to update our Cacti according to this change with two constraints :
  • keeping the previous history of the interface
  • keeping the same graph id (we are generating reports by downloading pngs according the the graph id)
I manage to find a trick with the database, by doing the following SQL requests :

Code: Select all

DELETE FROM poller_item WHERE local_data_id='$RRD_ID'"
UPDATE data_local SET snmp_index='$SNMP_ID' WHERE id='$RRD_ID'"
UPDATE graph_local SET snmp_index='$SNMP_ID' WHERE id='$GRAPH_ID'"
Where :
  • $RRD_ID = the data source id associated to the RRD
  • $SNMP_ID = the new SNMP_ID found in the table "host_snmp_cache"
  • $GRAPH_ID = the graph associated to the data source
After this change, I just have to launch the following php scripts to rename the graph and data source name, and update the poller cache with the new interface to poll :

Code: Select all

php cli/poller_data_sources_reapply_names.php --id=$HOST_ID
php cli/poller_graphs_reapply_names.php -id=$HOST_ID
php cli/rebuild_poller_cache.php
This trick was working well until I figured out that if I refresh the SNMP cache of the host through the web interface "host.php?action=query_reload&id=1&host_id=xxx" or through the cli "poller_reindex_hosts.php --id=xxx", all my changes are lost and back to the previous configuration.

I'm pretty sure I missed to update a table entry with the new SNMP index but I have not yet found it.

Is anyone facing the same problem or is there a better/cleaner way to do it ?
Thank you in advance for your answer.
User avatar
TheWitness
Developer
Posts: 17061
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Re: Interface migration

Post by TheWitness »

What you are doing is not supported. The best thing to do is insure that your Indexing is correct and that all the Indexes are unique. If you go messing with things, who know what will happen.

I'm afraid that I can ill afford to help you on this one. Maybe another dev has a bit more will-power than I.

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

Life is an adventure, let yours begin with Cacti!

Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages


For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
PoGo
Posts: 2
Joined: Mon Dec 05, 2011 9:49 am

Re: Interface migration

Post by PoGo »

Hello TheWitness,

First, thank you for your answer.
I bet that what I'm trying to do is a little bit "off-limit", but this is a feature I'm really need and I cannot see (for now) a better way to do it.
TheWitness wrote:The best thing to do is insure that your Indexing is correct and that all the Indexes are unique.
To be sure I understood your reply, when you speak about 'Index' it's not the snmp_index, but the SQL index of the table right ?
If so, how can I make sure that all the indexes are unique ?

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

Re: Interface migration

Post by TheWitness »

No, Cacti chooses a 'sort_key' based upon a unique index. When a 'reindex' event takes place it will rekey the 'snmp' index to the primary key and keep the graphs associated with the correct primary key automatically. Let's take an example:

You have a a network interface with say ifIndex 1 and ifIndex 2. They are for ifNames, the chosen sort field, Eth0/1 and Eth0/2.

ifIndex 1 = Eth0/1
ifIndex 2 = Eth0/2

Then, you add a new NIC and after reboot all of a sudden you now have 4 ifIndexes (ignoring loopback and such)

ifIndex 1 = Eth1/1
ifIndex 2 = Eth1/2
ifIndex 3 = Eth0/1
ifIndex 4 = Eth0/2

So, you can see that Eth0/1 and Eth0/2 moved from ifIndex 1 and ifIndex 2. However, to install the new network card, you had to power down the server. As such, the 'uptime' counter in SNMP returned to 0 upon restart which triggered an 'uptime goes backward' reindex operation where Cacti detected the change in the snmp indexes for the sort field ifName and properly adjusted the index for the graphs for these two interfaces.

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

Life is an adventure, let yours begin with Cacti!

Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages


For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
Post Reply

Who is online

Users browsing this forum: No registered users and 8 guests