So after a couple of days of fighting with Drupal, I finished this off for some light relief.
Here's a first-cut script that takes a series of SET items from a map, and uses them to populate TARGET, OVERLIBGRAPH, INFOURL and BANDWIDTH.
You have to edit the top of the file to use it right now (it's just a test). It reads in one config, and writes out another new one. I wouldn't recommend writing back to the original, although it should work - this is using the same guts as the editor does to read and write things. You ALSO need to make sure that your editor-config.php exists, and is correct - we use those values to find Cacti.
Because the way INFOURL and OVERLIB work has changed - this script will ONLY work with Weathermap 0.95 and above. Drop it into your weathermap directory, and run it from the command-line
php cacti-integrate.php
The things you need in your map are:
for NODEs, one of these 3:
Code: Select all
SET cacti_id 33
SET hostname Core Router 1
SET address 192.0.2.0
The 'address' must be exactly as Cacti has it. The hostname is the 'description' field in Cacti, exactly as Cacti has it.
for LINKs, you need either
Code: Select all
SET in_interface Gi0/1
SET out_interface Gi0/2
note that the in_interface is on the B router, and the out_interface is on the A router. The interface name can be ifName,ifDescr or ifAlias. So you can use your customer's name if you add that to the description in your routers. It has enough brains to swap over traffic_in and traffic_out if you only define an in_interface.
As long as all your links have at least one interface defined, and that interface is on a node where you added the IP or cacti-id, then it should produce a new config file, with BANDWIDTH (from ifSpeed), OVERLIBGRAPH, INFOURL (both back to Cacti), and TARGET.
You can use special tokens in the INCOMMENT and OUTCOMMENT to avoid repeating information:
Code: Select all
INCOMMENT {link:this:in_interface}
OUTCOMMENT {link:this:out_interface}
Also, for NODEs, it will fill in the missing bits of info (of the 3), and also add a link to the host.php page for that host (not so sure how useful that is), and a TARGET to show cacti's state for that host.
So, next step is to try and retrieve the interface names using SNMP and CDP/LLDP. That relies on the router's own hostname matching the one in Cacti though. And CDP/LLDP.