Quick and dirty script to add devices to cacti

Templates, scripts for templates, scripts and requests for templates.

Moderators: Developers, Moderators

Post Reply
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

The scripts were never officially supported by The Cacti Group. But as they are really useful, we implemented same functionality with cacti 087. Find cli scripts in the cli directory. Docs are available the the third link of my signature
Reinhard
Rael
Cacti User
Posts: 129
Joined: Thu Apr 05, 2007 9:28 am

Post by Rael »

add_tree.php doesn't seem to work?

proj/netops/cacti/php/bin/php add_tree.php --type=node --node-type=host --tree-id=200 --host-id=214

It returns that it successfully added it, but I look on cacti and don't see it?
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

Please post output of

Code: Select all

php -q add_tree.php --list-nodes --tree-id=200
You may scratch confidential information
Reinhard
Rael
Cacti User
Posts: 129
Joined: Thu Apr 05, 2007 9:28 am

Post by Rael »

I think I figured it out. I'll test again and see.

I was adding --type=node instead of --type=Graph Template
User avatar
timi
Cacti User
Posts: 240
Joined: Wed Nov 09, 2005 8:35 am
Location: Timisoara, Romania
Contact:

Post by timi »

the problem is that if you have lots of ds then you need to add some indexes to your tables, else it would take hours to add a device into cacti ...

becouse some rows from this select

Code: Select all

 "SELECT DISTINCT
                data_input_fields.data_name AS `name`,
                data_input_fields.name AS `description`,
                data_input_data.value AS `default`,
                data_template_data.data_template_id,
                data_input_fields.id AS `data_input_field_id`
                FROM data_input_data
                INNER JOIN (((data_template_rrd
                INNER JOIN (graph_templates
                INNER JOIN graph_templates_item
                ON graph_templates.id = graph_templates_item.graph_template_id)
                ON data_template_rrd.id = graph_templates_item.task_item_id)
                INNER JOIN data_template_data
                ON data_template_rrd.data_template_id=data_template_data.data_template_id)
                INNER JOIN data_input_fields
                ON data_template_data.data_input_id=data_input_fields.data_input_id)
                ON (data_input_data.data_template_data_id = data_template_data.id)
                AND (data_input_data.data_input_field_id = data_input_fields.id)
                WHERE (((graph_templates.id)=$templateId)
                AND ((data_input_data.t_value)='on')
                AND ((data_input_fields.input_output)='in'))"
which is in api_automation_tools.php are not indexed.
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

Yes, there's already a feature request for this. Will be incorporated in next release
Reinhard
User avatar
timi
Cacti User
Posts: 240
Joined: Wed Nov 09, 2005 8:35 am
Location: Timisoara, Romania
Contact:

Post by timi »

here is a little script in perl to add a cisco router/switch in cacti using the php scripts from cli directory, it currently add only fastethernet , gigabit , tenge and portchannels interfaces, if anybody needs more let me know ...

rename cisco.pl.txt to cisco.pl, move it to cli/
run ./cisco.pl device_name ip_address

read the comments...
Attachments
cisco.pl.txt
(15.46 KiB) Downloaded 565 times
seichimaru
Posts: 6
Joined: Mon Jul 02, 2007 8:19 pm
Contact:

ds graphs are not updating...

Post by seichimaru »

hi,

im still having a hard time figuring out why does my ds graphs(interface traffic) are not updating although all my cg graphs(ping latency test) are working.

the logs says:
01/02/2008 03:26:32 PM - SPINE: Poller[0] Host[2] DS[10] WARNING: Result from SNMP not valid. Partial Result: ...
01/02/2008 03:26:32 PM - SPINE: Poller[0] Host[2] DS[10] WARNING: Result from SNMP not valid. Partial Result: ...

i already looked almost everywhere in this forum and i haven't found any possible problem associated with mine...am i the only one experiencing this?

i hope to hear from you guys soon...

jeff
seichimaru
Posts: 6
Joined: Mon Jul 02, 2007 8:19 pm
Contact:

ds graphs are not updating...part 2

Post by seichimaru »

Hi,

In addition to my previous post, I will post here some mysterious things i encountered,

I add all my devices using the php scripts found on the cli directory, and it all went ok without any error. I checked my cacti db and all my host was added.
But still the ds graphs are not updating.

When i checked at the "Device>Test Router 1>*Create Graph for this host"
this is what i found (pls see attachment below).

Note: I already added this Test Router 1 using the php scripts inside the cli directory

I think those lines at the eth0 and ets0a interfaces are supposed to be colored gray and unselectable (there shouldn't be any checkbox at the end of the line) since i already added this interface using the scripts.

i badly need your help, guys.patiently waiting for a reply

p.s. after i selected the lines in the attached files, the cacti created a duplicate graph and those duplicate graphs are updating, really strange. it seems the add_graphs.php is the culprit but i have no evidence to support my claim. :-?

jeff
Attachments
figure 1
figure 1
cacti-error.JPG (131.88 KiB) Viewed 9532 times
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Re: ds graphs are not updating...

Post by gandalf »

seichimaru wrote:hi,

im still having a hard time figuring out why does my ds graphs(interface traffic) are not updating although all my cg graphs(ping latency test) are working.

the logs says:
01/02/2008 03:26:32 PM - SPINE: Poller[0] Host[2] DS[10] WARNING: Result from SNMP not valid. Partial Result: ...
01/02/2008 03:26:32 PM - SPINE: Poller[0] Host[2] DS[10] WARNING: Result from SNMP not valid. Partial Result: ...

i already looked almost everywhere in this forum and i haven't found any possible problem associated with mine...am i the only one experiencing this?

i hope to hear from you guys soon...

jeff
This is, when I should have dropped in. You may reproduce this by deleting the working graphs along with their datasources. Then, please read second link of my signature to find the cause of this error.
Well, I do understand if you don't want to loose your graphs ...
Reinhard
Rael
Cacti User
Posts: 129
Joined: Thu Apr 05, 2007 9:28 am

Post by Rael »

gandalf wrote:Please post output of

Code: Select all

php -q add_tree.php --list-nodes --tree-id=200
You may scratch confidential information
Reinhard
Yea, still having issues.

add_tree.php --type=node --node-type=host --tree-id=264 --host-id=213 --host-group-style=1

Reports:

Added Node node-id: (266)

However when I go into cacti it doesn't show up.

Known Tree Nodes:
type id text
Host 266 eccas567.xxxxx.xxxx.com Graph Template


WTF?! :)
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

Rael, I removed some confidential data from your posting. Please run

Code: Select all

php -q add_tree.php --list-trees|grep 264
Does tree 264 has a parent-tree?
Reinhard
seichimaru
Posts: 6
Joined: Mon Jul 02, 2007 8:19 pm
Contact:

Re: ds graphs are not updating...

Post by seichimaru »

gandalf wrote:
seichimaru wrote:hi,

im still having a hard time figuring out why does my ds graphs(interface traffic) are not updating although all my cg graphs(ping latency test) are working.

the logs says:
01/02/2008 03:26:32 PM - SPINE: Poller[0] Host[2] DS[10] WARNING: Result from SNMP not valid. Partial Result: ...
01/02/2008 03:26:32 PM - SPINE: Poller[0] Host[2] DS[10] WARNING: Result from SNMP not valid. Partial Result: ...

i already looked almost everywhere in this forum and i haven't found any possible problem associated with mine...am i the only one experiencing this?

i hope to hear from you guys soon...

jeff
This is, when I should have dropped in. You may reproduce this by deleting the working graphs along with their datasources. Then, please read second link of my signature to find the cause of this error.
Well, I do understand if you don't want to loose your graphs ...
Reinhard
Sir Gandalf,

Good day!
I manage to resolve my issues with this partial results. I'll keep in my your suggestion and advice.

Thanks! :D
melanie_pfefer
Posts: 5
Joined: Wed Feb 27, 2008 4:55 pm

Post by melanie_pfefer »

I downloaded the tool of this thread.

add_device.php gives an error:

./add_device.php 1 zeus zeus public 2 disable

Warning: include_once(/lib/utility.php): failed to open stream: No such file or directory in /home/cactiuser/add_device.php on line 13

Warning: include_once(): Failed opening '/lib/utility.php' for inclusion (include_path='.:/usr/local/lib/php') in /home/cactiuser/add_device.php on line 13

Warning: include_once(/lib/api_data_source.php): failed to open stream: No such file or directory in /home/cactiuser/add_device.php on line 14

Warning: include_once(): Failed opening '/lib/api_data_source.php' for inclusion (include_path='.:/usr/local/lib/php') in /home/cactiuser/add_device.php on line 14

Warning: include_once(/lib/api_graph.php): failed to open stream: No such file or directory in /home/cactiuser/add_device.php on line 15

Warning: include_once(): Failed opening '/lib/api_graph.php' for inclusion (include_path='.:/usr/local/lib/php') in /home/cactiuser/add_device.php on line 15

Warning: include_once(/lib/snmp.php): failed to open stream: No such file or directory in /home/cactiuser/add_device.php on line 16

Warning: include_once(): Failed opening '/lib/snmp.php' for inclusion (include_path='.:/usr/local/lib/php') in /home/cactiuser/add_device.php on line 16

Warning: include_once(/lib/data_query.php): failed to open stream: No such file or directory in /home/cactiuser/add_device.php on line 17

Warning: include_once(): Failed opening '/lib/data_query.php' for inclusion (include_path='.:/usr/local/lib/php') in /home/cactiuser/add_device.php on line 17

Warning: include_once(/lib/api_device.php): failed to open stream: No such file or directory in /home/cactiuser/add_device.php on line 18

Warning: include_once(): Failed opening '/lib/api_device.php' for inclusion (include_path='.:/usr/local/lib/php') in /home/cactiuser/add_device.php on line 18

Fatal error: Call to undefined function db_fetch_assoc() in /home/cactiuser/add_device.php on line 26
User avatar
BSOD2600
Cacti Moderator
Posts: 12171
Joined: Sat May 08, 2004 12:44 pm
Location: USA

Post by BSOD2600 »

melanie_pfefer wrote:I downloaded the tool of this thread.

add_device.php gives an error
Why use this tool when the scripts in cacti 0.8.7.x do the majority of it now?
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest