Quick and dirty script to add devices to cacti

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

Moderators: Developers, Moderators

Post Reply
neteng30
Posts: 12
Joined: Thu Nov 13, 2008 12:43 pm

what script?

Post by neteng30 »

gandalf wrote:Please use the cli scripts provided by cacti since 087
Reinhard
i am using the latest version... what is the name of the script?
TheBigOne
Posts: 45
Joined: Mon Sep 29, 2008 8:57 am
Location: Basel

Post by TheBigOne »

I think you should use the cli scripts /var/www/html/cacti/cli/
You will find a howto in the cacti documentation and a help if you run the script with -h
neteng30
Posts: 12
Joined: Thu Nov 13, 2008 12:43 pm

dont see that folder

Post by neteng30 »

TheBigOne wrote:I think you should use the cli scripts /var/www/html/cacti/cli/
You will find a howto in the cacti documentation and a help if you run the script with -h

I don't have a folder named /cli under the cacti directory. I am running the latest cacti version.

[xxxxxx@localhost cacti]$ ls -la
total 1620
drwxr-xr-x 11 root root 4096 2008-11-18 23:13 .
drwxr-xr-x 271 root root 12288 2008-11-20 14:36 ..
-rw-r--r-- 1 root root 6387 2008-02-14 09:39 about.php
-rw-r--r-- 1 root root 4703 2008-11-13 15:35 auth_changepassword.php
-rw-r--r-- 1 root root 531 2008-11-13 16:03 auth_changepassword.php.rej
-rw-r--r-- 1 root root 11868 2008-11-13 15:35 auth_login.php
-rw-r--r-- 1 root root 1762 2008-11-13 16:03 auth_login.php.rej
-rw-r--r-- 1 root root 85470 2008-11-13 16:03 cacti-plugin-0.8.7b-PA-v2.1.diff
drwxr-xr-x 3 root root 4096 2008-11-13 15:34 cacti-plugin-arch
-rw-r--r-- 1 root root 173327 2008-03-22 23:47 cacti-plugin-arch.tar.gz
drwxr-xr-x 6 root root 4096 2008-11-13 13:16 cacti-spine-0.8.7a
-rw-r--r-- 1 root root 364746 2007-11-25 22:40 cacti-spine-0.8.7a.tar.gz
-rw-r--r-- 1 root root 124294 2008-11-07 15:31 cacti.sql
-rw-r--r-- 1 root root 12960 2008-02-14 09:39 cdef.php
-rwxr-xr-x 1 root root 18369 2008-02-14 09:39 cmd.php
-rw-r--r-- 1 root root 5765 2008-02-14 09:39 color.php
drwxr-xr-x 2 777 root 4096 2008-11-13 16:45 conifg_backups
-rw-r--r-- 1 root root 23279 2008-02-14 09:39 data_input.php
-rw-r--r-- 1 root root 33923 2008-02-14 09:39 data_queries.php
-rw-r--r-- 1 root root 49345 2008-11-13 15:35 data_sources.php
-rw-r--r-- 1 root root 1120 2008-11-13 16:03 data_sources.php.rej
-rw-r--r-- 1 root root 31304 2008-02-14 09:39 data_templates.php
-rw-r--r-- 1 root root 5958 2008-02-14 09:39 gprint_presets.php
-rw-r--r-- 1 root root 3446 2008-11-13 15:35 graph_image.php
-rw-r--r-- 1 root root 312 2008-11-13 16:03 graph_image.php.rej
-rw-r--r-- 1 root root 12106 2008-11-13 15:35 graph.php
-rw-r--r-- 1 root root 5602 2008-11-13 16:03 graph.php.rej
-rw-r--r-- 1 root root 7716 2008-02-14 09:39 graph_settings.php
-rw-r--r-- 1 root root 13828 2008-02-14 09:39 graphs_items.php
-rw-r--r-- 1 root root 37183 2008-11-13 15:35 graphs_new.php
-rw-r--r-- 1 root root 928 2008-11-13 16:03 graphs_new.php.rej
-rw-r--r-- 1 root root 50907 2008-11-13 15:35 graphs.php
-rw-r--r-- 1 root root 1489 2008-11-13 16:03 graphs.php.rej
-rw-r--r-- 1 root root 9945 2008-02-14 09:39 graph_templates_inputs.php
-rw-r--r-- 1 root root 18482 2008-02-14 09:39 graph_templates_items.php
-rw-r--r-- 1 root root 25042 2008-02-14 09:39 graph_templates.php
-rw-r--r-- 1 root root 29052 2008-02-14 09:39 graph_view.php
-rw-r--r-- 1 root root 5758 2008-02-14 09:39 graph_xport.php
-rw-r--r-- 1 root root 50696 2008-11-13 15:35 host.php
-rw-r--r-- 1 root root 2284 2008-11-13 16:03 host.php.rej
-rw-r--r-- 1 root root 18045 2008-02-14 09:39 host_templates.php
drwxr-xr-x 2 root root 4096 2008-11-07 14:56 images
drwxr-xr-x 5 root root 4096 2008-11-18 16:12 include
-rw-r--r-- 1 root root 2313 2008-11-13 15:36 index.php
-rw-r--r-- 1 root root 551 2008-11-13 16:03 index.php.rej
drwxr-xr-x 2 root root 4096 2008-11-07 14:56 install
drwxr-xr-x 3 root root 4096 2008-11-13 16:03 lib
lrwxrwxrwx 1 root root 15 2008-11-07 14:56 log -> /var/log/cacti/
-rw-r--r-- 1 root root 2451 2008-02-14 09:39 logout.php
drwxrwxrwx 15 777 root 4096 2008-11-14 14:17 plugins
-rw-r--r-- 1 root root 14967 2008-11-13 15:36 plugins.php
-rw-r--r-- 1 root root 15813 2008-11-13 16:03 plugins.php.rej
-rw-r--r-- 1 root root 4306 2008-02-14 09:39 poller_commands.php
-rw-r--r-- 1 root root 2243 2008-02-14 09:39 poller_export.php
-rwxr-xr-x 1 root root 15178 2008-11-13 15:36 poller.php
-rw-r--r-- 1 root root 2322 2008-11-13 16:03 poller.php.rej
drwxr-xr-x 5 root root 4096 2008-11-07 14:56 resource
lrwxrwxrwx 1 root root 18 2008-11-07 14:56 rra -> /var/lib/cacti/rra
-rw-r--r-- 1 root root 7084 2008-02-14 09:39 rra.php
lrwxrwxrwx 1 root root 22 2008-11-07 14:56 scripts -> /var/lib/cacti/scripts
-rw-r--r-- 1 root root 7304 2008-02-14 09:39 script_server.php
-rw-r--r-- 1 root root 4996 2008-02-14 09:39 settings.php
-rw-r--r-- 1 root root 6667 2008-02-14 09:39 templates_export.php
-rw-r--r-- 1 root root 6524 2008-02-14 09:39 templates_import.php
-rw-r--r-- 1 root root 17835 2008-02-14 09:39 tree.php
-rw-r--r-- 1 root root 42240 2008-11-13 15:36 user_admin.php
-rw-r--r-- 1 root root 3830 2008-11-13 16:03 user_admin.php.rej
-rw-r--r-- 1 root root 48973 2008-11-13 15:36 utilities.php
-rw-r--r-- 1 root root 733 2008-11-13 16:03 utilities.php.rej
User avatar
timi
Cacti User
Posts: 240
Joined: Wed Nov 09, 2005 8:35 am
Location: Timisoara, Romania
Contact:

Post by timi »

in cacti 0.8.7b still some rows are not indexed :( so it can take up to 25 minutes to add a host from cli whithout indexing :( anyway here is a script that I use to add cisco devices to cacti, just copy the script to cli/ dir, modify it to suit your needs and run it like this cisco.pl device_name device_ip
Attachments
cisco.pl
(15.65 KiB) Downloaded 527 times
neteng30
Posts: 12
Joined: Thu Nov 13, 2008 12:43 pm

...

Post by neteng30 »

ok i will give it a shot. But why don't I have a cli/ folder if I am running the latest version?
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

timi wrote:in cacti 0.8.7b still some rows are not indexed :( so it can take up to 25 minutes to add a host from cli whithout indexing :( anyway here is a script that I use to add cisco devices to cacti, just copy the script to cli/ dir, modify it to suit your needs and run it like this cisco.pl device_name device_ip
Any hints on indexes required?
Reinhard
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Re: ...

Post by gandalf »

neteng30 wrote:ok i will give it a shot. But why don't I have a cli/ folder if I am running the latest version?
Cacti has a cli folder since 087a
Reinhard
User avatar
timi
Cacti User
Posts: 240
Joined: Wed Nov 09, 2005 8:35 am
Location: Timisoara, Romania
Contact:

Post by timi »

gandalf wrote:
timi wrote:in cacti 0.8.7b still some rows are not indexed :( so it can take up to 25 minutes to add a host from cli whithout indexing :( anyway here is a script that I use to add cisco devices to cacti, just copy the script to cli/ dir, modify it to suit your needs and run it like this cisco.pl device_name device_ip
Any hints on indexes required?
Reinhard
based on the selects found on the scripts I modified :

table data_input_fields

Code: Select all

...
  PRIMARY KEY (`id`),
  KEY `data_input_id` (`data_input_id`),
  KEY `input_output` (`input_output`),
  KEY `type_code` (`type_code`),
  KEY `name` (`name`),
  KEY `data_name` (`data_name`)
...
table data_input_data

Code: Select all

...
  PRIMARY KEY (`data_input_field_id`,`data_template_data_id`),
  KEY `t_value` (`t_value`)
...
table snmp_query_graph_rrd

Code: Select all

...
  PRIMARY KEY (`snmp_query_graph_id`,`data_template_id`,`data_template_rrd_id`),
  KEY `snmp_query_graph_id` (`snmp_query_graph_id`),
  KEY `snmp_field_name` (`snmp_field_name`)
...
table graph_templates_item

Code: Select all

...
  PRIMARY KEY (`id`),
  KEY `graph_template_id` (`graph_template_id`),
  KEY `local_graph_id` (`local_graph_id`),
  KEY `task_item_id` (`task_item_id`)
...
table data_template_data

Code: Select all

...
  PRIMARY KEY (`id`),
  KEY `local_data_id` (`local_data_id`),
  KEY `data_template_id` (`data_template_id`),
  KEY `name` (`name`),
  KEY `data_source_path` (`data_source_path`)
...
don't know if all the keys were necessary, but the time to add a device was reduced from more then 25minute to nearly 5 minutes...
TheBigOne
Posts: 45
Joined: Mon Sep 29, 2008 8:57 am
Location: Basel

Post by TheBigOne »

I have the same problems adding devices.

It is hard to debug but i found a bit.
http://forums.cacti.net/viewtopic.php?t ... highlight=

BUT i still dont know how to fix it.
Barichon
Posts: 6
Joined: Fri Oct 02, 2009 1:40 am

Post by Barichon »

Hello guys,

Well firstable I had to say that this post is very interesting and high skill also.
I'm not a fan on scripting and Stuff like that, so congrats for this work !

I would likle to know if someone of you guys could make a brief sumup on the requirements and what to do to sucessfully implement devices, graphs tree etc... Because having ridden this post its pretty difficult to have a Quick "how to" overview.

I have a 0.8.7b version.

Thx by advance for your help and sorry for mistakes... My written English is not so perfect!
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

Please see 1st link of my sig for a general introduction to templates. That should be enough to understand this one
Reinhard
sangayya.alagundimath
Posts: 20
Joined: Thu Aug 20, 2009 7:41 am

Post by sangayya.alagundimath »

Hi All,

can some body tell me whether any variable need to be set beause am using latest cacti . is there any change in config files?

[root@localhost cacti]# php add_device.php
PHP Notice: Undefined variable: config in /var/www/htdocs/cacti/add_device.php on line 13
PHP Warning: include_once(/lib/utility.php): failed to open stream: No such file or directory in /var/www/htdocs/cacti/add_device.php on line 13
PHP Warning: include_once(): Failed opening '/lib/utility.php' for inclusion (include_path='.:/usr/share/pear:/usr/share/php') in /var/www/htdocs/cacti/add_device.php on line 13
PHP Notice: Undefined variable: config in /var/www/htdocs/cacti/add_device.php on line 14
PHP Warning: include_once(/lib/api_data_source.php): failed to open stream: No such file or directory in /var/www/htdocs/cacti/add_device.php on line 14
PHP Warning: include_once(): Failed opening '/lib/api_data_source.php' for inclusion (include_path='.:/usr/share/pear:/usr/share/php') in /var/www/htdocs/cacti/add_device.php on line 14
PHP Notice: Undefined variable: config in /var/www/htdocs/cacti/add_device.php on line 15
PHP Warning: include_once(/lib/api_graph.php): failed to open stream: No such file or directory in /var/www/htdocs/cacti/add_device.php on line 15
PHP Warning: include_once(): Failed opening '/lib/api_graph.php' for inclusion (include_path='.:/usr/share/pear:/usr/share/php') in /var/www/htdocs/cacti/add_device.php on line 15
PHP Notice: Undefined variable: config in /var/www/htdocs/cacti/add_device.php on line 16
PHP Warning: include_once(/lib/snmp.php): failed to open stream: No such file or directory in /var/www/htdocs/cacti/add_device.php on line 16
PHP Warning: include_once(): Failed opening '/lib/snmp.php' for inclusion (include_path='.:/usr/share/pear:/usr/share/php') in /var/www/htdocs/cacti/add_device.php on line 16
PHP Notice: Undefined variable: config in /var/www/htdocs/cacti/add_device.php on line 17
PHP Warning: include_once(/lib/data_query.php): failed to open stream: No such file or directory in /var/www/htdocs/cacti/add_device.php on line 17
PHP Warning: include_once(): Failed opening '/lib/data_query.php' for inclusion (include_path='.:/usr/share/pear:/usr/share/php') in /var/www/htdocs/cacti/add_device.php on line 17
PHP Notice: Undefined variable: config in /var/www/htdocs/cacti/add_device.php on line 18
PHP Warning: include_once(/lib/api_device.php): failed to open stream: No such file or directory in /var/www/htdocs/cacti/add_device.php on line 18
PHP Warning: include_once(): Failed opening '/lib/api_device.php' for inclusion (include_path='.:/usr/share/pear:/usr/share/php') in /var/www/htdocs/cacti/add_device.php on line 18
Usage:
add_device.php templateid description IP snmp_community snmp_version disable

Where:
- templateid is a number (read below to get a list of templates)
- description: the name that will be displayed by Cacti in the graphs
- IP: self explanatory (can also be a FQDN)
- snmp_community: community string
- snmp_version: 1/2
- disable: 1 to add this host but to disable checks and 0 to enable it
--SanG
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

Were did you get that cacti installation from? Distro repository? Cacti web site?
R.
sangayya.alagundimath
Posts: 20
Joined: Thu Aug 20, 2009 7:41 am

Post by sangayya.alagundimath »

i got it from cacti site, its Version 0.8.7e
--SanG
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

The web pages are working fine?
R.
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests