Andareed
Joined: 07 Nov 2007 Posts: 2
|
Posted: Thu May 22, 2008 7:14 pm Post subject: Automation Scripts |
|
|
I've written a bunch of automation scripts for Cacti. Cacti 0.8.7 added some automation support, but it only supported adding things and required you to know/lookup numeric id's. My scripts require you to only know the device/graph/tree name; partial name/tree matching is also supported. Here's a summary of what's included:
- add_combined_graph.php - creates a stacked graph that graphs a resource (e.g. logged in users) across multiple devices/hosts.
- add_device_and_graphs.php - given a device and template, adds a device and its template-associated graphs.
- add_device_to_tree.php / add_combined_graph.php - given an existing device/graph, add it somewhere in the tree.
- delete_device_and_graphs.php - given a device, delete it and its graphs from cacti.
- delete_device_from_tree.php / delete_graph_from_tree.php - deletes a device/graph from the tree, but does not delete the device/graph internally.
- add_tree.php / delete_tree.php - add or delete a new tree (aka header) somewhere in the tree.
All scripts should be run as root; e.g. sudo ./add_combined_graph.php. Full help is available by appending --help to the command. Here's some examples:
Suppose you had a Linux device/host template configured to graph logged in users, load average, cpu usage, and network bandwidth for a host named foobar3. You might run 'sudo ./add_device_and_graphs.php linux foobar3 hosts/linux'. This would add the "static" graphs (logged in users, load average, and cpu usage), and would prompt you to add each network interface found (e.g. eth0, eth1). The resulting host node would be created under Hosts/Linux.
Suppose you had all your linux hosts under the tree "Hosts/Linux" and you wanted to create a graph of logged in users over all of these hosts, and you wanted to put the resulting graph under the "Hosts" tree. You might run: 'sudo ./add_combined_graph.php 'Logged in Users - Linux Hosts' users hosts linux'.
In terms of performance, I ran the add_device_and_graphs.php script to add about 120 switches (and bandwidth graphs for each interface), and this took around 3 hours.
Download: http://csclub.uwaterloo.ca/~dtbartle/cacti/ |
|