Quick and dirty script to add devices to cacti
Moderators: Developers, Moderators
Must have scripts !
That script set is wonderful and powerful. And I do not find them so "quick and dirty".
I really think that scripts must be included in cacti !
I really think that scripts must be included in cacti !
Issue with multiple data sources graph creation
Hello,
I'm trying to create "ucd/net Available Disk Space" with the command:
add_graphs.php --graph-type cg --graph-template-id 3 --host-id 8
--snmp-query-id 2 --snmp-query-type-id 6 --snmp-field dskPath --snmp-value "/"
--graph-title "grenade - Disk Space - /"
Where:
Known Graph Templates:(id, name)
3 ucd/net - Available Disk Space
Known SNMP Queries:(id, name)
2 ucd/net - Get Monitored Partitions
Known SNMP Query Types:(id, name)
6 Available/Used Disk Space
Two datasources are created for the graph but their custom data fields (index type, index value and output type ID) are not set automatically - in addition, the datasource name is "|host_description| - Hard Drive Space" instead of "|host_description| - Partion - |query_dskDevice|"
I'm trying to create "ucd/net Available Disk Space" with the command:
add_graphs.php --graph-type cg --graph-template-id 3 --host-id 8
--snmp-query-id 2 --snmp-query-type-id 6 --snmp-field dskPath --snmp-value "/"
--graph-title "grenade - Disk Space - /"
Where:
Known Graph Templates:(id, name)
3 ucd/net - Available Disk Space
Known SNMP Queries:(id, name)
2 ucd/net - Get Monitored Partitions
Known SNMP Query Types:(id, name)
6 Available/Used Disk Space
Two datasources are created for the graph but their custom data fields (index type, index value and output type ID) are not set automatically - in addition, the datasource name is "|host_description| - Hard Drive Space" instead of "|host_description| - Partion - |query_dskDevice|"
Last edited by ymartin59 on Mon Feb 20, 2006 6:17 am, edited 1 time in total.
Re: Issue with multiple data sources graph creation
Sorry, I made a big mistake... graph-type must be 'ds' !! It works perfectly.ymartin59 wrote: I'm trying to create "ucd/net Available Disk Space" with the command:
add_graphs.php --graph-type cg --graph-template-id 3 --host-id 8
--snmp-query-id 2 --snmp-query-type-id 6 --snmp-field dskPath --snmp-value "/"
--graph-title "grenade - Disk Space - /"
Any plans to update add_device script to support snmpv3?
The current version of cacti only supports AuthNoPriv. In the environment I support, we enforced an AuthPriv snmpv3 policy on our servers. To enable cacti to work properly, an update to $auth_snmp in ./lib/snmp.php was done. The updated syntax for $auth_snmp now looks like this.
$snmp_auth = "-u $username -l authPriv -a MD5 -A $password -x DES -X $password"; /* v3 - username/password */
It would be great to be able to use some of these scripts to save work : )
$snmp_auth = "-u $username -l authPriv -a MD5 -A $password -x DES -X $password"; /* v3 - username/password */
It would be great to be able to use some of these scripts to save work : )
This patch adds the ability for add_graphs.php to tell if a graph exists already even if the type is cg.
Save this to add_graphs.php.patch and run
Code: Select all
--- add_graphs.php Tue Dec 13 05:53:46 2005
+++ add_graphs.php.new Wed Apr 12 18:06:02 2006
@@ -245,6 +245,23 @@
if ($graph_type == "cg")
{
$empty = array(); /* Suggested Values are not been implemented */
+
+ $existsAlready = db_fetch_cell("select id from graph_local where graph_template_id = $templateId AND host_id = $hostId");
+ if (isset($existsAlready) && $existsAlready > 0)
+ {
+ if ($graphTitle != "")
+ {
+ db_execute("update graph_templates_graph set title = \"$graphTitle\" where local_graph_id = $existsAlready");
+ update_graph_title_cache($existsAlready);
+ }
+ $dataSourceId = db_fetch_cell("SELECT DISTINCT data_template_rrd.local_data_id
+ FROM graph_templates_item, data_template_rrd
+ WHERE graph_templates_item.local_graph_id = " . $existsAlready .
+ " AND graph_templates_item.task_item_id = data_template_rrd.id");
+ echo "Not Adding Graph - this graph already exists - graph-id: ($existsAlready) - data-source-id: ($dataSourceId)\n";
+ return(1);
+ }
+
$returnArray = create_complete_graph_from_template($templateId, $hostId, "", $empty);
}
Code: Select all
patch -p0 < add_graphs.php.patch
Travis Morgan
http://bigfiber.net
http://bigfiber.net
-
- Posts: 1
- Joined: Fri Apr 14, 2006 10:01 am
- Location: Grenoble - FRANCE
Awesome!
Thank you so much for writing this.
I just imported 1k devices perfectly!
On to adding graphs now
I just imported 1k devices perfectly!
On to adding graphs now
patch
Here is a patch to prevent adding hosts to the graph tree if they are in the specified tree already.
Save this to add_tree.php.patch and run:
Andrew
Code: Select all
--- add_tree.php Fri Apr 21 16:44:38 2006
+++ add_tree.php.new Fri Apr 21 17:29:35 2006
@@ -208,6 +208,12 @@
$rra_id = 0;
$name = '';
+ $hostNodeExists = db_fetch_cell("SELECT id FROM graph_tree_items WHERE graph_tree_id = $treeId AND host_id = $hostId");
+ if (isset($hostNodeExists))
+ {
+ echo "Not adding host, host-id ($hostId) is already in graph tree ($treeId)\n";
+ return 1;
+ }
if (!isset($hosts[$hostId]))
{
printf("No such host-id (%s) exists. Try --list-hosts\n", $hostId);
Code: Select all
patch -p0 < add_tree.php.patch
A wrapper for Bradley's scripts
Firstly thanks to Bradley et al for the php import scripts. I have written my first ever script (so don't be to harsh - comments for improvements appreciated!) to successfully transfer 1500 devices from CastleRock SNMPc to Cacti. This can be modified to read in pretty much any CSV file and populate Cacti with the Tree, Devices and Graphs all asociated with the relevant Nodes.
One question I have is when creating a CG graph, is there any way to populate the custom fields?
For example for a graph 'Host Availability' in the 'Data Sources' menu in the 'Supplemental Data Template Data' section is a 'Custom Data' field for 'IP Address'. At the moment I have to manually add the address for each device.
One question I have is when creating a CG graph, is there any way to populate the custom fields?
For example for a graph 'Host Availability' in the 'Data Sources' menu in the 'Supplemental Data Template Data' section is a 'Custom Data' field for 'IP Address'. At the moment I have to manually add the address for each device.
- Attachments
-
- import.zip
- Feel free to use/modify this wrapper script for your own use. Do share any improvements though!
- (945 Bytes) Downloaded 1378 times
-
- Posts: 2
- Joined: Mon May 08, 2006 10:44 am
I'm having a problem with this.. It doesn't seem to execute the queries properly when setting up. If I add a host with snmp disk graphs, when I go into the device, instead of the mount points, I see the mount numbers... Any way to fix that?
FreeBSD/RHEL
cacti-0.8.7i, spine 0.8.7i, PIA 3.1+boost 5.1
MySQL 5.5/InnoDB
RRDtool 1.2.27, PHP 5.1.6
cacti-0.8.7i, spine 0.8.7i, PIA 3.1+boost 5.1
MySQL 5.5/InnoDB
RRDtool 1.2.27, PHP 5.1.6
Who is online
Users browsing this forum: No registered users and 3 guests