Super Cacti script - Does everything!

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

Moderators: Developers, Moderators

stgarner
Posts: 7
Joined: Fri Dec 21, 2007 11:34 am

Super Cacti script - Does everything!

Post by stgarner »

Hello everyone,

I have a script that my company used to add devices to Cacti. I have no idea who made it. It did everything from adding the devices, adding them to the tree, and creating the graphs. It was super easy to add devices from a text file where the IP was listed first and then the hostname separated by a space.

The script doesnt work in the new version and I am not a PHP programmer or a Cacti expert. I believe anyone with good Cacti knowledge and PHP skills should be able to correct/fix them.

I think it has value, you tell me. Sure made things easy!

There are 3 files attached:
super_cacti_config.php (the configuration file)
super_cacti.php (the script that does all the work)
myloadfile.txt (an example load file)

The steps I used to add devices were as follows:
1) Create the import file (text file) with the IP and the hostname separated by a space, tab, or comma. One device per line, IP address must be first.

2) Run the command:
php super_cacti.php

This gave the listing of the trees and tree number association. You need the tree number to append it to the command when you import. See the example below where the end of the command has a number. This is the tree number.

3) Run the command:
php super_cacti.php myloadfile.txt 2

Sit back and wait. It runs pretty fast.

4) Verify the graphs were created and populated.

So I have about 1200 devices that need to be added to my new 0.8.7a server. The old server corrupted. I believe the old server was running 0.8.6.

Any help would be appreciated. Maybe the script can be used by others or brought into the product itself.

Steve
Attachments
super_cacti_config.php.txt
Configuration file - Remove the .txt from the file.
(801 Bytes) Downloaded 336 times
super_cacti.php.txt
Main script - Remove the .txt from the file.
(15.43 KiB) Downloaded 383 times
myloadfile.txt
Example load file.
(28 Bytes) Downloaded 369 times
apperrault
Cacti User
Posts: 379
Joined: Fri Feb 16, 2007 11:37 am
Location: Emeryville, CA
Contact:

Post by apperrault »

I am no expert, but after have a brief look at super_cacti_config.php, there do not appear to be any references to global.php. the first thing i would do to try and fix this would be to add the following line

Code: Select all

include_once($cacti_base_dir."/include/global.php");
right below

Code: Select all

include_once($cacti_base_dir."/include/config.php");
Try that and see if you get any farther.

app
[b]Cacti Version[/b] - 0.8.7b
[b]Plugin Architecture[/b] - 2.2 Beta
[b]Poller Type[/b] - CMD.php
[b]Server Info[/b] - Linux 2.6.9-78.0.1.ELsmp
[b]Web Server[/b] - Apache/2.0.52 (Red Hat)
[b]PHP[/b] - 4.3.9
[b]MySQL[/b] - 4.1.22
[b]RRDTool[/b] - 1.2.23
[b]SNMP[/b] - 5.1.2
[b]Plugins[/b][list]Global Plugin Settings (settings - v0.5)
SuperLinks (superlinks - v0.72)
Host Info (hostinfo - v0.2)
Report Creator (reports - v0.3)
Update Checker (update - v0.4)
Realtime for Cacti (realtime - v0.35)
Cacti Log View (clog - v1.1)
RRD File Cleaner (rrdclean - v0.36)
Network Discovery (discovery - v0.9)
Uptime (uptime - v0.4)[/list]
stgarner
Posts: 7
Joined: Fri Dec 21, 2007 11:34 am

Post by stgarner »

Doesnt the config script reference this?

Database authentication info gathered from cacti config:
/usr/share/cacti/include/config.php

Forgive my ignorance. Like I said, Im not a developer.

Steve
apperrault
Cacti User
Posts: 379
Joined: Fri Feb 16, 2007 11:37 am
Location: Emeryville, CA
Contact:

Post by apperrault »

It is my understanding that config.php only has the database connection information, but global.php includes the bulk of the other cacti reference information. I have had some scripts that used to work, and didn't after the upgrade, but changing the scripts to include global.php corrected the problems.

app
[b]Cacti Version[/b] - 0.8.7b
[b]Plugin Architecture[/b] - 2.2 Beta
[b]Poller Type[/b] - CMD.php
[b]Server Info[/b] - Linux 2.6.9-78.0.1.ELsmp
[b]Web Server[/b] - Apache/2.0.52 (Red Hat)
[b]PHP[/b] - 4.3.9
[b]MySQL[/b] - 4.1.22
[b]RRDTool[/b] - 1.2.23
[b]SNMP[/b] - 5.1.2
[b]Plugins[/b][list]Global Plugin Settings (settings - v0.5)
SuperLinks (superlinks - v0.72)
Host Info (hostinfo - v0.2)
Report Creator (reports - v0.3)
Update Checker (update - v0.4)
Realtime for Cacti (realtime - v0.35)
Cacti Log View (clog - v1.1)
RRD File Cleaner (rrdclean - v0.36)
Network Discovery (discovery - v0.9)
Uptime (uptime - v0.4)[/list]
stgarner
Posts: 7
Joined: Fri Dec 21, 2007 11:34 am

Post by stgarner »

Ok. So I added that line. This is the output from trying to add a device.. x's in place of some information. It adds a blank item to the tree. There is no name associated with it.

[root@xxxxxxxxxxx Bulk_Load_Tool]# php super_cacti.php xxxxxxxxxx.txt 2
host (xxx.xxx.xxx.xxx) is visible and new to cacti, proceeding with discovery
Adding xxxxxx.xxxxxx.COM (xxx.xxx.xxx.xxx) as "Windows" using SNMP v1 with community "xxxxxxx" to Org ID: 2
PHP Notice: Undefined variable: availability_method in /root/Bulk_Load_Tool/super_cacti.php on line 141

Notice: Undefined variable: availability_method in /root/Bulk_Load_Tool/super_cacti.php on line 141
PHP Notice: Undefined variable: ping_method in /root/Bulk_Load_Tool/super_cacti.php on line 141

Notice: Undefined variable: ping_method in /root/Bulk_Load_Tool/super_cacti.php on line 141
PHP Notice: Undefined variable: ping_port in /root/Bulk_Load_Tool/super_cacti.php on line 141

Notice: Undefined variable: ping_port in /root/Bulk_Load_Tool/super_cacti.php on line 141
PHP Notice: Undefined variable: ping_timeout in /root/Bulk_Load_Tool/super_cacti.php on line 141

Notice: Undefined variable: ping_timeout in /root/Bulk_Load_Tool/super_cacti.php on line 141
PHP Notice: Undefined variable: ping_retries in /root/Bulk_Load_Tool/super_cacti.php on line 141

Notice: Undefined variable: ping_retries in /root/Bulk_Load_Tool/super_cacti.php on line 141
PHP Notice: Undefined variable: notes in /root/Bulk_Load_Tool/super_cacti.php on line 142

Notice: Undefined variable: notes in /root/Bulk_Load_Tool/super_cacti.php on line 142
PHP Notice: Undefined variable: snmp_auth_protocol in /root/Bulk_Load_Tool/super_cacti.php on line 142

Notice: Undefined variable: snmp_auth_protocol in /root/Bulk_Load_Tool/super_cacti.php on line 142
PHP Notice: Undefined variable: snmp_priv_passphrase in /root/Bulk_Load_Tool/super_cacti.php on line 142

Notice: Undefined variable: snmp_priv_passphrase in /root/Bulk_Load_Tool/super_cacti.php on line 142
PHP Notice: Undefined variable: snmp_priv_protocol in /root/Bulk_Load_Tool/super_cacti.php on line 142

Notice: Undefined variable: snmp_priv_protocol in /root/Bulk_Load_Tool/super_cacti.php on line 142
PHP Notice: Undefined variable: snmp_context in /root/Bulk_Load_Tool/super_cacti.php on line 142

Notice: Undefined variable: snmp_context in /root/Bulk_Load_Tool/super_cacti.php on line 142
PHP Notice: Undefined variable: max_oids in /root/Bulk_Load_Tool/super_cacti.php on line 142

Notice: Undefined variable: max_oids in /root/Bulk_Load_Tool/super_cacti.php on line 142
Host ID: 0
PHP Notice: Undefined variable: index in /root/Bulk_Load_Tool/super_cacti.php on line 163

Notice: Undefined variable: index in /root/Bulk_Load_Tool/super_cacti.php on line 163
Non-Cisco Device, please configure other counters via the cacti web interface
PHP Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /root/Bulk_Load_Tool/super_cacti.php on line 243

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /root/Bulk_Load_Tool/super_cacti.php on line 243
PHP Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /root/Bulk_Load_Tool/super_cacti.php on line 244

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /root/Bulk_Load_Tool/super_cacti.php on line 244
apperrault
Cacti User
Posts: 379
Joined: Fri Feb 16, 2007 11:37 am
Location: Emeryville, CA
Contact:

Post by apperrault »

And this is where i get off the train!!! :lol:

I had a feeling that something like this was going to happen. More than likely, the files that your script points to have moved, or their names have changed. I am not a big programmer, so i am going to step out of the way and see if someone that knows more about this stuff that I take over. I will probably keep looking into it to see if i can figure it out, but i can't be sure much will come of it.

app
stgarner
Posts: 7
Joined: Fri Dec 21, 2007 11:34 am

Post by stgarner »

Cool. Lets see if the community or developers can help resolve this. I hav faith!
User avatar
timi
Cacti User
Posts: 240
Joined: Wed Nov 09, 2005 8:35 am
Location: Timisoara, Romania
Contact:

Post by timi »

why not using the scripts from cli/ ? have a look at http://forums.cacti.net/viewtopic.php?t=7683
stgarner
Posts: 7
Joined: Fri Dec 21, 2007 11:34 am

Didnt see all the features as my original..

Post by stgarner »

I did see those but I didnt see one that added the graphs. I see one to add the devices but the one I used to use added the devices, created the graphs and added them to the proper tree.

Are you telling me that you can do all that from the CLI scripts?
Is each one a separate script?

Steve
User avatar
BSOD2600
Cacti Moderator
Posts: 12171
Joined: Sat May 08, 2004 12:44 pm
Location: USA

Re: Didnt see all the features as my original..

Post by BSOD2600 »

stgarner wrote:Are you telling me that you can do all that from the CLI scripts?Is each one a separate script?
Most likely. Take a read http://docs.cacti.net/node/529

If you implemented a feature that the current scripts do not, feel free to submit it http://www.cacti.net/bugs.php
kuma3
Posts: 25
Joined: Tue Oct 02, 2007 1:17 pm

Post by kuma3 »

Maybe you can take a look at "Super Add" at my signature. It tries to solve the same problem except it uses cacti UI to do the work. But it doesn't automatically add data query graph and only works with 0.87+
Super Add Plugin - http://forums.cacti.net/viewtopic.php?t=25475
User avatar
rony
Developer/Forum Admin
Posts: 6022
Joined: Mon Nov 17, 2003 6:35 pm
Location: Michigan, USA
Contact:

Post by rony »

This script is not compliant with 0.8.7x, I suggest you don't use it.
[size=117][i][b]Tony Roman[/b][/i][/size]
[size=84][i]Experience is what causes a person to make new mistakes instead of old ones.[/i][/size]
[size=84][i]There are only 3 way to complete a project: Good, Fast or Cheap, pick two.[/i][/size]
[size=84][i]With age comes wisdom, what you choose to do with it determines whether or not you are wise.[/i][/size]
gsaray101
Cacti User
Posts: 233
Joined: Thu May 17, 2007 9:18 am

script to add multiple devices at the same time

Post by gsaray101 »

is there a script that bulk inserts devices to cacti - that works for version. 0.8.7?

Thanks,

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

Post by gandalf »

Sure. See cli/add_devices.php
Early versions were very slow on a decent installation. Use latest code from SVN branch 0.8.7, then
Reinhard
hurgh
Posts: 13
Joined: Wed Oct 11, 2006 2:40 am
Contact:

Post by hurgh »

I dont seem to have a "cli" directory in my cacti Install.

Does it come with it standard??

Thanks

-Hurgh-
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest