Routerconfigs plugin / how it works?
Moderators: Developers, Moderators
Attached is the updated functions file. RouterConfigs is now working for both Cisco & HP devices. (I've tested using a few of each) In order for this to work your HP devices need a username and a password. To configure them in that manner do the following and it'll prompt you for a password.
You'll also need to update the plugin_routerconfigs_devicetypes table. Make sure that you replace x.x.x.x in the below insert with the IP address of your tftp server.
I'm sure that there are better / cleaner approaches to take here. But, this works and all functionality in the RouterConfig UI has been maintained.
Let me know if you run into problems.
Code: Select all
#password manager <username>
Code: Select all
mysql> insert into plugin_routerconfigs_devicetypes (id, name, username, password, copytftp, version, confirm, forceconfirm) values ('', 'HP', 'sername', 'assword', 'copy running-config tftp x.x.x.x', 'sh ver', '', '');
Let me know if you run into problems.
- Attachments
-
- functions.txt
- (30.68 KiB) Downloaded 496 times
Thanks for posting this, I ran the SQL database command and I also copied your functions.php over. The problem I have is whenever I try to back up the HP device the page displays a load of php errors and no device is backed up.
Not quite sure of what is wrong. The debug just shows the initial telnet screen of the HP device "press any key to continue"
Any ideas?
Not quite sure of what is wrong. The debug just shows the initial telnet screen of the HP device "press any key to continue"
Any ideas?
What a wonky issue this turned out to be. On initial run it should have worked, and did for me last Friday. However, on 2nd run it would connect, upload the config to tftp and error out. The problem was caused by the following code:
When HP devices were thrown through the above if statements the substr function tripped on itself and triggered a false positive. It'd look at $hostname and compare that to $filename. $filename is defined above and is $hostname in quotes. ($filename vs "$hostname") Thus it evaluated it to false, and appended the device name in the plugin_routerconfigs_devices table using db_execute. Since it'd modify the table it'd then break on each subsequent run b/c "hostname" will never equal hostname. I've fixed this as well as cleaned up the functions file. (added some comments and removed redundant code that I'd added)
I've been able to successfully complete backups for a mixed bag of devices. (IOS, IOS without needing enable, HP)
Give it a go using the attached functions.php and let me know how it goes. -Naturally make sure to back your original working one up prior.
Code: Select all
if (substr($d, 0, 9) == 'hostname ') {
$filename = trim(substr($d, 9));
if ($device['hostname'] != $filename) {
db_execute("UPDATE plugin_routerconfigs_devices SET hostname = '$filename' WHERE id = " . $device['id']);
}
}
if (substr($d, 0, 17) == 'set system name ') {
$filename = trim(substr($d, 17));
if ($device['hostname'] != $filename) {
db_execute("UPDATE plugin_routerconfigs_devices SET hostname = '$filename' WHERE id = " . $device['id']);
}
}
I've been able to successfully complete backups for a mixed bag of devices. (IOS, IOS without needing enable, HP)
Give it a go using the attached functions.php and let me know how it goes. -Naturally make sure to back your original working one up prior.
- Attachments
-
- functions.txt
- (29.61 KiB) Downloaded 332 times
The stuff that's echoed out and saved as debug likely is worthless in figuring out what the problem is. Can you do a select * from plugin_routerconfigs_devicetypes; and post that output here? Also, on your HP switch you've configured it such that it requires a username and password? Did you replace your existing functions file with the one I posted or did you add stuff from mine to yours? Finally, from a command line run php /path/to/cacti/plugins/routerconfigs/router-download.php and watch the output there. That'll give you a better idea of why it isn't working.
I'm not sure how to do a select from plugin command?
Here is the output when I run the routerconfigs php from the command line as you describe:
I used your complete functions.php as I wanted to ensure that was working before I played with the config.
Here is the output when I run the routerconfigs php from the command line as you describe:
Code: Select all
[root@localhost ~]# php /var/www/html/plugins/routerconfigs/router-download.php
Processing 172.23.3.250
PHP Notice: Undefined index: enablepw in /var/www/html/plugins/routerconfigs/functions.php on line 340
Notice: Undefined index: enablepw in /var/www/html/plugins/routerconfigs/functions.php on line 340
PHP Warning: Missing argument 5 for PHPTelnetHP::Connect(), called in /var/www/html/plugins/routerconfigs/functions.php on line 131 and define2
Warning: Missing argument 5 for PHPTelnetHP::Connect(), called in /var/www/html/plugins/routerconfigs/functions.php on line 131 and defined in 2
PHP Notice: Undefined variable: devicetype in /var/www/html/plugins/routerconfigs/functions.php on line 678
Notice: Undefined variable: devicetype in /var/www/html/plugins/routerconfigs/functions.php on line 678
ÿýÿû
ProCurve J9087A Switch 2610-24-PWR
Software revision R.11.30
Copyright (C) 1991-2009 Hewlett-Packard Co. All Rights Reserved.
RESTRICTED RIGHTS LEGEND
Use, duplication, or disclosure by the Government is subject to restrictions
as set forth in subdivision (b) (3) (ii) of the Rights in Technical Data and
Computer Software clause at 52.227-7013.
HEWLETT-PACKARD COMPANY, 3000 Hanover St., Palo Alto, CA 94303
We'd like to keep you up to date about:
* Software feature updates
* New product announcements
* Special events
Please register your products now at: www.ProCurve.com
Press any key to continue PHP Notice: Undefined variable: devicetype in /var/www/html/plugins/routerconfigs/functions.php on line 695
Notice: Undefined variable: devicetype in /var/www/html/plugins/routerconfigs/functions.php on line 695
Username: admin
Password: PHP Notice: Undefined variable: devicetype in /var/www/html/plugins/routerconfigs/functions.php on line 713
Notice: Undefined variable: devicetype in /var/www/html/plugins/routerconfigs/functions.php on line 713
Invalid password
Username: Login failedPHP Warning: fputs(): 96 is not a valid stream resource in /var/www/html/plugins/routerconfigs/functions.php on line 770
Warning: fputs(): 96 is not a valid stream resource in /var/www/html/plugins/routerconfigs/functions.php on line 770
PHP Warning: stream_set_timeout(): 96 is not a valid stream resource in /var/www/html/plugins/routerconfigs/functions.php on line 792
Warning: stream_set_timeout(): 96 is not a valid stream resource in /var/www/html/plugins/routerconfigs/functions.php on line 792
PHP Warning: fread(): 96 is not a valid stream resource in /var/www/html/plugins/routerconfigs/functions.php on line 794
Warning: fread(): 96 is not a valid stream resource in /var/www/html/plugins/routerconfigs/functions.php on line 794
PHP Warning: socket_get_status(): 96 is not a valid stream resource in /var/www/html/plugins/routerconfigs/functions.php on line 796
Warning: socket_get_status(): 96 is not a valid stream resource in /var/www/html/plugins/routerconfigs/functions.php on line 796
PHP Warning: fputs(): 96 is not a valid stream resource in /var/www/html/plugins/routerconfigs/functions.php on line 780
Warning: fputs(): 96 is not a valid stream resource in /var/www/html/plugins/routerconfigs/functions.php on line 780
PHP Warning: stream_set_timeout(): 96 is not a valid stream resource in /var/www/html/plugins/routerconfigs/functions.php on line 792
Warning: stream_set_timeout(): 96 is not a valid stream resource in /var/www/html/plugins/routerconfigs/functions.php on line 792
PHP Warning: fread(): 96 is not a valid stream resource in /var/www/html/plugins/routerconfigs/functions.php on line 794
Warning: fread(): 96 is not a valid stream resource in /var/www/html/plugins/routerconfigs/functions.php on line 794
PHP Warning: socket_get_status(): 96 is not a valid stream resource in /var/www/html/plugins/routerconfigs/functions.php on line 796
Warning: socket_get_status(): 96 is not a valid stream resource in /var/www/html/plugins/routerconfigs/functions.php on line 796
PHP Warning: fputs(): 96 is not a valid stream resource in /var/www/html/plugins/routerconfigs/functions.php on line 759
Warning: fputs(): 96 is not a valid stream resource in /var/www/html/plugins/routerconfigs/functions.php on line 759
PHP Warning: stream_set_timeout(): 96 is not a valid stream resource in /var/www/html/plugins/routerconfigs/functions.php on line 792
Warning: stream_set_timeout(): 96 is not a valid stream resource in /var/www/html/plugins/routerconfigs/functions.php on line 792
PHP Warning: fread(): 96 is not a valid stream resource in /var/www/html/plugins/routerconfigs/functions.php on line 794
Warning: fread(): 96 is not a valid stream resource in /var/www/html/plugins/routerconfigs/functions.php on line 794
PHP Warning: socket_get_status(): 96 is not a valid stream resource in /var/www/html/plugins/routerconfigs/functions.php on line 796
Warning: socket_get_status(): 96 is not a valid stream resource in /var/www/html/plugins/routerconfigs/functions.php on line 796
PHP Warning: fputs(): 96 is not a valid stream resource in /var/www/html/plugins/routerconfigs/functions.php on line 759
Warning: fputs(): 96 is not a valid stream resource in /var/www/html/plugins/routerconfigs/functions.php on line 759
PHP Warning: stream_set_timeout(): 96 is not a valid stream resource in /var/www/html/plugins/routerconfigs/functions.php on line 792
Warning: stream_set_timeout(): 96 is not a valid stream resource in /var/www/html/plugins/routerconfigs/functions.php on line 792
PHP Warning: fread(): 96 is not a valid stream resource in /var/www/html/plugins/routerconfigs/functions.php on line 794
Warning: fread(): 96 is not a valid stream resource in /var/www/html/plugins/routerconfigs/functions.php on line 794
PHP Warning: socket_get_status(): 96 is not a valid stream resource in /var/www/html/plugins/routerconfigs/functions.php on line 796
Warning: socket_get_status(): 96 is not a valid stream resource in /var/www/html/plugins/routerconfigs/functions.php on line 796
PHP Warning: fclose(): 96 is not a valid stream resource in /var/www/html/plugins/routerconfigs/functions.php on line 753
Warning: fclose(): 96 is not a valid stream resource in /var/www/html/plugins/routerconfigs/functions.php on line 753
Saving Debug
04/07/2010 09:56:09 AM - RouterConfigs: Poller[0] -1270634077 seconds
0 devices backed up successfully.
1 devices failed to backup.
These devices failed to backup
--------------------------------
172.23.3.250 - Login failed
[root@localhost ~]#
It almost looks like an error with the plugin_routerconfigs_devicetypes table. All you need to do to get that output (assuming your mysql instance for cacti is on the same host, and when you installed you used cactiuser / cactiuser for mysql login)
1. mysql -u cactiuser -p
2. use cacti;
3. select * from plugin_routerconfigs_devicetypes;
1. mysql -u cactiuser -p
2. use cacti;
3. select * from plugin_routerconfigs_devicetypes;
Thanks for explaining that! I have never really used mysql from the command line. I installed phpmyadmin to use the mysql database.
Here is the output:
Here is the output:
Code: Select all
mysql> select * from plugin_routerconfigs_devicetypes;
+----+-----------+----------+----------+--------------------------------+--------------+---------+--------------+
| id | name | username | password | copytftp | version | confirm | forceconfirm |
+----+-----------+----------+----------+--------------------------------+--------------+---------+--------------+
| 1 | Cisco IOS | sername: | assword: | copy start tftp: | show version | y | 0 |
| 2 | CatOS | sername: | assword: | copy start tftp | | y | 1 |
| 3 | HP | sername | assword | copy start tftp 192.168.250.39 | sh ver | | |
+----+-----------+----------+----------+--------------------------------+--------------+---------+--------------+
3 rows in set (0.00 sec)
Who is online
Users browsing this forum: No registered users and 0 guests