Super Cacti script - Does everything!
Moderators: Developers, Moderators
Super Cacti script - Does everything!
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
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 370 times
-
- Cacti User
- Posts: 379
- Joined: Fri Feb 16, 2007 11:37 am
- Location: Emeryville, CA
- Contact:
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
right below
Try that and see if you get any farther.
app
Code: Select all
include_once($cacti_base_dir."/include/global.php");
Code: Select all
include_once($cacti_base_dir."/include/config.php");
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]
[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]
-
- Cacti User
- Posts: 379
- Joined: Fri Feb 16, 2007 11:37 am
- Location: Emeryville, CA
- Contact:
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
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]
[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]
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
[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
-
- Cacti User
- Posts: 379
- Joined: Fri Feb 16, 2007 11:37 am
- Location: Emeryville, CA
- Contact:
And this is where i get off the train!!!
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
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
why not using the scripts from cli/ ? have a look at http://forums.cacti.net/viewtopic.php?t=7683
Didnt see all the features as my original..
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
Are you telling me that you can do all that from the CLI scripts?
Is each one a separate script?
Steve
Re: Didnt see all the features as my original..
Most likely. Take a read http://docs.cacti.net/node/529stgarner wrote:Are you telling me that you can do all that from the CLI scripts?Is each one a separate script?
If you implemented a feature that the current scripts do not, feel free to submit it http://www.cacti.net/bugs.php
| Scripts: Monitor processes | RFC1213 MIB | DOCSIS Stats | Dell PowerEdge | Speedfan | APC UPS | DOCSIS CMTS | 3ware | Motorola Canopy |
| Guides: Windows Install | [HOWTO] Debug Windows NTFS permission problems |
| Tools: Windows All-in-one Installer |
- rony
- Developer/Forum Admin
- Posts: 6022
- Joined: Mon Nov 17, 2003 6:35 pm
- Location: Michigan, USA
- Contact:
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]
[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]
script to add multiple devices at the same time
is there a script that bulk inserts devices to cacti - that works for version. 0.8.7?
Thanks,
mike
Thanks,
mike
Who is online
Users browsing this forum: No registered users and 0 guests