6/29/2015

Cacti Bulk Tree Add Command line

If you want to add hundreds on ports in Cacti automatically without point and click on the GUI, do below:

1.  Add a new device using GUI like you normally do.
2. Create your Graph Tree and add your new Tree item for your new device.
3. That's it on the GUI.  The rest you will do by command line to add your hundreds of ports to monitor for that device under your Tree.

Go to:

ssh to your cacti server:

cd /usr/share/cacti/cli

sudo php -q add_tree.php --list-trees
sudo php -q add_tree.php --list-hosts

sudo php -q add_tree.php --list-nodes --tree-id=2 | grep Header  ===get parent-node.

sudo php -q add_tree.php --list-graphs --host-id=20  ---will see the IDs and need this for next step.

for i in {664..781} ;
do sudo php -q add_tree.php --type=node --node-type=graph --tree-id=2 --parent-node=492 --host-id=20 --graph-id=${i};

Another example:

for i in {35..70}
do sudo php -q add_tree.php --type=node --node-type=graph --tree-id=2 --parent-node=1573 --host-id=11 --graph-id=${i};
done