Routerconfigs plugin / how it works?

Discussions on developing plugins for the Cacti Plugin Architecture

Moderators: Developers, Moderators

Post Reply
dieselboy
Cacti User
Posts: 135
Joined: Wed May 27, 2009 5:10 pm

Post by dieselboy »

EDIT
This has been working ALL ALONG. Thanks Grady. HP and Cisco devices DO in fact back up correctly - Here is the catch.

When adding devices, to be quick and easy I simply used the IP address as the description AND the hostname / IP part. For some reason, this messes up the script and the routerconfigs plugin does not change the file name, and does not list it in the backups. I just had a thought what would happen if I changed the file name from it's IP address, to it's correct hostname and it now backs up perfectly.

Very pleased.
Cheers,
crazy_90
Posts: 3
Joined: Sun May 30, 2010 11:54 am

Post by crazy_90 »

Thank you so much for your understanding, and I apologies if I disturbed you :[


______________
dvd replication
contract warehousing
dieselboy
Cacti User
Posts: 135
Joined: Wed May 27, 2009 5:10 pm

Post by dieselboy »

crazy_90 wrote:Thank you so much for your understanding, and I apologies if I disturbed you :[
I've been disturbed for a long time, don't worry! :)
dieselboy
Cacti User
Posts: 135
Joined: Wed May 27, 2009 5:10 pm

New Challenge

Post by dieselboy »

Hi Grady,
When trying to backup the config of an ASA over a VPN tunnel, after the IP address we need to add the command ;int=inside

Do you have any idea how I could incorporate that into routerconfigs as an option so that it doesn't effect other cisco devices, or ASAs that do not require that additional command?
grady
Cacti User
Posts: 60
Joined: Wed Feb 20, 2008 5:02 pm

Post by grady »

Hi diesel, sorry -- ive been out for a while. Youve got a couple of options there. The easiest of course would be to allow hairpinning on the ASA, though there's likely security issues that you'd need to address if you decided to take that route.

Code: Select all

The other would be to add a device type to the plugin_routerconfigs_devicetypes table in the cacti DB. That'd be as simple as mysql> insert into plugin_routerconfigs_devicetypes (id,name,username,password,copytftp,version,confirm,forceconfirm) values ('NEXT NUMBER HERE', 'ASA', 'sername:', 'assword:', 'copy run tftp', 'int inside','n', 'n');
Next go into functions (backup working one prior of course) and in the phptelnet class define an additional docommand:

Code: Select all

       function DoCommandASAint($c, &$r) {
                if ($this->fp) {
                        fputs($this->fp, " $c\r");
                        $this->Sleep();
                        $this->GetResponse($r);
                        $r = preg_replace("/^.*?\n(.*)\n[^\n]*$/", "$1", $r);
                }
                return $this->fp ? 1 : 0;
        }
Next head up and replicate the conditional HP stuff:

Code: Select all

//If ASA and need int use extra commands
        $devicetypeASA = db_fetch_row("SELECT name FROM plugin_routerconfigs_devicetypes WHERE id = " . $device['devicetype']);
                 foreach ($devicetypeASA as $value)
                 {
                        if ($value == "ASA"){
                        $result1 = $telnet->Connect($device['ipaddress'],  $info['username'], $info['password'], $devicetype);
                        $debug = $telnet->debug;
                        $result=$result2;
                        $telnet->DoCommand($devicetype['copytftp'], $result);
                        echo $result;
                        $telnet->DoCommandASA($devicetype['version'], $result);
                        $telnet->DoCommand($filename, $result);
                        echo $result;
                        }
                }
//end
Go back into router configs and re-add the device that needs this additional command. When you do in the drop down list select device type of ASA. That way the version command you pass to it in the above if block is actually the interface stuff you need. If you take that path make sure to edit the line below the comment with false positive in it:

Code: Select all

                        if ($value !="HP" && $value !="ASA") {
grady
Cacti User
Posts: 60
Joined: Wed Feb 20, 2008 5:02 pm

Post by grady »

Alternatively a MUCH easier solution here is to use the above sql to create a row for ASA device type that looks like this:

Code: Select all

|  4 | ASA         | sername: | assword:  | write net                              | sh ver       | y       |            1 |
Then, hop out to your ASA and add the following to the config:

Code: Select all

tftp-server inside x.x.x.x <device name> 
Then routerconfigs will send the command write net vs the copy run stuff. So long as your existing firewalls are set to a device type of ASA you should be gtg.
tlambert
Posts: 1
Joined: Tue Sep 06, 2011 2:52 pm

Re: Routerconfigs plugin / how it works?

Post by tlambert »

This may be a bit too late for this topic, but do you have any plans to implement your version of routerconfigs over SSH? I know some SSH modules for PHP have been gaining a lot of momentum and it would be great to see this feature in routerconfigs. I would love to help with the project with what PHP I know, and the modification of routerconfigs to support HP devices was exactly what I was looking for, so expanding further, in my opinion, would be quite useful.
magikk
Cacti User
Posts: 57
Joined: Sun Dec 23, 2012 9:59 am

Re: Routerconfigs plugin / how it works?

Post by magikk »

Hi,

I try to backup my asa firewall with routerconfigs.
I write in phpmyadmin :

Code: Select all

INSERT INTO plugin_routerconfigs_devicetypes (id, name, username, password, copytftp, version, confirm, forceconfirm) VALUES (3, 'ASA', 'sername:', 'assword:', 'write net', 'show version', 'y', 1)
but this line needs to be written on the ASA? (because i tried to connect to via telnet , and it asked me a password...How can i have this password?

Code: Select all

tftp-server inside x.x.x.x <device name>
And x x x x is which IP?
And device name?

Thank you
mduling
Posts: 39
Joined: Tue Mar 01, 2005 1:49 pm

Re: Routerconfigs plugin / how it works?

Post by mduling »

The statement on the ASA just tftp's the running config to the cacti server (running TFTP server) when triggered to do so by the plugin. So the ASA statement needs to look like this.

Code: Select all

tftp-server Inside <ip_address_of_cacti_host> <asa_hostname>
The <asa_hostname> above should match your actual ASA hostname AND the routerconfigs device name. Don't put a path on it and it will go to the tftp root like all the rest of your config files.

Here's what you do in mysql

mysql -u root -p

Code: Select all

mysql> use cacti;
mysql> INSERT INTO plugin_routerconfigs_devicetypes (id, name, username, password, copytftp, version, confirm, forceconfirm) VALUES (3, 'ASA', 'sername:', 'assword:', 'write net', 'show version', 'y', 0)
The number '3' above assumes the ASA devicetype is the 3rd one you are adding. If it is the 4th use '4' and so on. You may check your table with this command:

mysql> select * from plugin_routerconfigs_devicetypes;

Here is the result:

Code: Select all

+----+-------------+----------+----------+------------------+--------------+---------+--------------+
| id | name        | username | password | copytftp         | version      | confirm | forceconfirm |
+----+-------------+----------+----------+------------------+--------------+---------+--------------+
|  1 | Cisco IOS   | sername: | assword: | copy run tftp    | show version | y       |            0 | 
|  2 | Cisco CatOS | sername: | assword: | copy config tftp |              | y       |            1 | 
|  3 | ASA         | sername: | assword: | write net        | show version | y       |            0 | 
+----+-------------+----------+----------+------------------+--------------+---------+--------------+
smiles
Cacti User
Posts: 79
Joined: Mon Sep 10, 2012 5:54 pm

Re: Routerconfigs plugin / how it works?

Post by smiles »

I have this plugin working for Cisco IOS devices, but having issue with IOS-XR. Anyone run into this?
msdte
Posts: 1
Joined: Mon Jun 24, 2019 6:00 am

Re: Routerconfigs plugin / how it works?

Post by msdte »

Hello all!

I'm not programmer (however have some little expirience in web-programmig), but here is my (possible poor-coded) patch for plugin routerconfigs:

The goal was made posibility backup configuration of routers made by Mikrotik and another via SFTP. The following changes were made:

1. Connection methods SFTP and SSH now allow to specify non-default port (in the form ip_address:port, e.g. 192.168.1.1:2022)
2. Connection method SFTP was been repaired and now uses followed logic: if copytftp command is specified then it will execute first, and it's output will save as backup configuration in case configfile parameter was left blank. If configfile parameter is not blank then file specified by this parameter will download via SFTP and will save as backup configuration no matter copytftp was blank or not.
3. Plugin tries to recognize prompt of Mikrotik / RouterOS CLI (but saveing configuration in cisco-way don't work yet).
4. Length of field copytftp was increased from 64 to 192 characters.
5. Line feeds "\r\n" replaces to "\n" while displaying stored config.

Mikrotiks now may be backuped with followed settings in 'Device Types' tab:

Name: 'Mikrotik' or anything else
Connection Type: 'SFTP'
Copy TFTP: '/export'
Configuration file: empty
Other thields: default values or blank.

Same settings my be used for other network equipment that support SSH and command like 'show run' in IOS.

I will be very happy if someone will review the patch, maybe improves its source code and incorporate the patch in the main code of plugin.
Attachments
routerconfigs-patch-sftp-rework.patch
(6.65 KiB) Downloaded 177 times
netniV
Cacti Guru User
Posts: 3440
Joined: Sun Aug 27, 2017 12:05 am

Re: Routerconfigs plugin / how it works?

Post by netniV »

I am not sure which version of routerconfigs you had and created this patch against. When I attempted to apply it to the current develop version it failed. Can you supply a pull request on GitHub?
Cacti Developer & Release Manager
The Cacti Group

Director
BV IT Solutions Ltd

+--------------------------------------------------------------------------+

Cacti Resources:
Cacti Website (including releases)
Cacti Issues
Cacti Development Releases
Cacti Development Documentation
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests