Cacti (home)ForumsDocumentation
Cacti: offical forums and support
It is currently Sat Jul 21, 2018 2:43 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 100 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6, 7  Next
Author Message
 Post subject:
PostPosted: Fri Mar 26, 2010 9:13 am 
Offline
Cacti User

Joined: Wed May 27, 2009 5:10 pm
Posts: 135
Doesnt this part of routerconfigs work for you any more? When I disable the checking of the configs, I still have the diff functionality. The only thing I disabled was to delete the config if it doesnt meet the criteria. Everything else seems to work fine.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 26, 2010 9:34 am 
Offline
Cacti User

Joined: Wed Feb 20, 2008 5:02 pm
Posts: 60
Nope, I seem to have busted it totally. It works for all other devices but not the HP stuff. The script thinks that it errors out, thus it isnt aware that its actually written a file to tftp. lol


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 26, 2010 9:43 am 
Offline
Cacti User

Joined: Wed May 27, 2009 5:10 pm
Posts: 135
Oh, so the config file count still remains at zero even though there are files there?
Does it make a difference if you specify a new folder? As the functions file will check and create a new folder with propper permissions if there isnt - not sure if this will have any different outcome


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 26, 2010 3:44 pm 
Offline
Cacti User

Joined: Wed Feb 20, 2008 5:02 pm
Posts: 60
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.
Code:
#password manager <username>


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.
Code:
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', '', '');


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.


Attachments:
functions.txt [30.68 KiB]
Downloaded 330 times
Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 29, 2010 3:41 am 
Offline
Cacti User

Joined: Wed May 27, 2009 5:10 pm
Posts: 135
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?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 29, 2010 10:22 am 
Offline
Cacti User

Joined: Wed Feb 20, 2008 5:02 pm
Posts: 60
Very strange. It's failing now for me as well. I'm looking into root cause.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 01, 2010 2:44 pm 
Offline
Cacti User

Joined: Wed Feb 20, 2008 5:02 pm
Posts: 60
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:
Code:
                        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']);
                                }
                        }


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.


Attachments:
functions.txt [29.61 KiB]
Downloaded 150 times
Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 06, 2010 4:12 am 
Offline
Cacti User

Joined: Wed May 27, 2009 5:10 pm
Posts: 135
Nice work, I will give it a try now. Thanks for the update


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 06, 2010 4:46 am 
Offline
Cacti User

Joined: Wed May 27, 2009 5:10 pm
Posts: 135
I can't seem to get that working either. I setup a packet capture and cacti only initiates a telnet session. The session closes and about a minute later the cacti screen refreshes with php errors. The HP device never tries to upload a config
I'm not sure what the problem is :/


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 06, 2010 8:55 am 
Offline
Cacti User

Joined: Wed Feb 20, 2008 5:02 pm
Posts: 60
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.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 07, 2010 4:58 am 
Offline
Cacti User

Joined: Wed May 27, 2009 5:10 pm
Posts: 135
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:
Code:

[[email protected] ~]#  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
[[email protected] ~]#


I used your complete functions.php as I wanted to ensure that was working before I played with the config.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 07, 2010 9:15 am 
Offline
Cacti User

Joined: Wed Feb 20, 2008 5:02 pm
Posts: 60
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;


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 07, 2010 9:57 am 
Offline
Cacti User

Joined: Wed May 27, 2009 5:10 pm
Posts: 135
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:
Code:
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)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 07, 2010 10:01 am 
Offline
Cacti User

Joined: Wed Feb 20, 2008 5:02 pm
Posts: 60
Strange, line 713 in my functions file is 713 $r=explode("\n", $r);


whats line 713 in yours?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 07, 2010 10:12 am 
Offline
Cacti User

Joined: Wed May 27, 2009 5:10 pm
Posts: 135
My line 713 is
if (strpos($res, $devicetype['password']) == FALSE) {


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 100 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6, 7  Next

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

Protected by Anti-Spam ACP Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group