Cacti (home)ForumsRepositoryDocumentation
Cacti: offical forums and support  

 FAQFAQ   SearchSearch   MemberlistMemberlist    RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in    


Quick and dirty script to add devices to cacti
Goto page Previous  1, 2, 3, 4, 5, 6, 7, 8  Next
 
Post new topic   Reply to topic    Cacti Forum Index -> Scripts and Templates
Author Message
gandalf
Developer


Joined: 02 Dec 2004
Posts: 12295
Location: Muenster, Germany

PostPosted: Wed Dec 19, 2007 3:30 pm    Post subject: Reply with quote

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
Back to top
Rael
Cacti User


Joined: 05 Apr 2007
Posts: 128

PostPosted: Thu Dec 20, 2007 11:06 am    Post subject: Reply with quote

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?
Back to top
gandalf
Developer


Joined: 02 Dec 2004
Posts: 12295
Location: Muenster, Germany

PostPosted: Thu Dec 20, 2007 3:15 pm    Post subject: Reply with quote

Please post output of
Code:
php -q add_tree.php --list-nodes --tree-id=200
You may scratch confidential information
Reinhard
Back to top
Rael
Cacti User


Joined: 05 Apr 2007
Posts: 128

PostPosted: Fri Dec 21, 2007 9:57 am    Post subject: Reply with quote

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

I was adding --type=node instead of --type=Graph Template
Back to top
timi
Cacti User


Joined: 09 Nov 2005
Posts: 129
Location: Timisoara, Romania

PostPosted: Fri Dec 21, 2007 11:05 am    Post subject: Reply with quote

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 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.
Back to top
gandalf
Developer


Joined: 02 Dec 2004
Posts: 12295
Location: Muenster, Germany

PostPosted: Fri Dec 21, 2007 12:21 pm    Post subject: Reply with quote

Yes, there's already a feature request for this. Will be incorporated in next release
Reinhard
Back to top
timi
Cacti User


Joined: 09 Nov 2005
Posts: 129
Location: Timisoara, Romania

PostPosted: Sun Dec 23, 2007 11:30 am    Post subject: Reply with quote

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...



cisco.pl.txt
 Description:

Download
 Filename:  cisco.pl.txt
 Filesize:  15.46 KB
 Downloaded:  233 Time(s)

Back to top
seichimaru



Joined: 02 Jul 2007
Posts: 6

PostPosted: Wed Jan 02, 2008 2:48 am    Post subject: ds graphs are not updating... Reply with quote

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
Back to top
seichimaru



Joined: 02 Jul 2007
Posts: 6

PostPosted: Wed Jan 02, 2008 4:26 am    Post subject: ds graphs are not updating...part 2 Reply with quote

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



cacti-error.JPG
 Description:
figure 1
 Filesize:  131.88 KB
 Viewed:  2963 Time(s)

cacti-error.JPG


Back to top
gandalf
Developer


Joined: 02 Dec 2004
Posts: 12295
Location: Muenster, Germany

PostPosted: Thu Jan 03, 2008 1:52 pm    Post subject: Re: ds graphs are not updating... Reply with quote

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
Back to top
Rael
Cacti User


Joined: 05 Apr 2007
Posts: 128

PostPosted: Fri Jan 11, 2008 12:05 pm    Post subject: Reply with quote

gandalf wrote:
Please post output of
Code:
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?!
Back to top
gandalf
Developer


Joined: 02 Dec 2004
Posts: 12295
Location: Muenster, Germany

PostPosted: Mon Jan 14, 2008 12:32 pm    Post subject: Reply with quote

Rael, I removed some confidential data from your posting. Please run
Code:
php -q add_tree.php --list-trees|grep 264
Does tree 264 has a parent-tree?
Reinhard
Back to top
seichimaru



Joined: 02 Jul 2007
Posts: 6

PostPosted: Wed Jan 16, 2008 2:28 am    Post subject: Re: ds graphs are not updating... Reply with quote

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!
Back to top
melanie_pfefer



Joined: 27 Feb 2008
Posts: 5

PostPosted: Wed Feb 27, 2008 4:57 pm    Post subject: Reply with quote

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
Back to top
BSOD2600
Cacti Moderator


Joined: 08 May 2004
Posts: 6791
Location: WA, USA

PostPosted: Wed Feb 27, 2008 5:51 pm    Post subject: Reply with quote

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?
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Cacti Forum Index -> Scripts and Templates All times are GMT - 5 Hours
Goto page Previous  1, 2, 3, 4, 5, 6, 7, 8  Next
Page 6 of 8

 



Powered by phpBB © 2001, 2005 phpBB Group