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 »

Also, just to be clear, the HP devices back up fine. Its just Cisco devices it no longer manages to back up.
dieselboy
Cacti User
Posts: 135
Joined: Wed May 27, 2009 5:10 pm

Post by dieselboy »

I tried updating the php version and broke everything on that server.
The PHP version is 5.1.6.

Anyway,
If I enter these lines before if ($enablepw != '') { then it enables and logs in but doesnt run any copy commands.. can you help me remove the IF commands so that it proceeds onwards? I've tried commenting them out but I get all sorts of PHP errors relating to something called nesting
Thanks!!

Code: Select all

@fputs($this->fp, "en\r");
@fputs($this->fp, "$pass\r");
grady
Cacti User
Posts: 60
Joined: Wed Feb 20, 2008 5:02 pm

Post by grady »

Sorry for the delayed response here. Things have been hectic @ the office lately and I haven't had a moment to spare. So at this point you've upgraded php and things are working other than cisco device backups? Heres my php ver:

Code: Select all

PHP 5.1.6 (cli) (built: Jan 13 2010 17:13:05) 
Copyright (c) 1997-2006 The PHP Group
Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies
Also, do you use the same account (within router configs) to back up both ciscos and HP's?
dieselboy
Cacti User
Posts: 135
Joined: Wed May 27, 2009 5:10 pm

Post by dieselboy »

Hi,
I couldnt upgrade to 5.2 so I'm back using 5.1 (the same as you) which is okay as we have the same PHP ver.

I'm using different credentials, and have actually managed to try this on a different group of devices at a different location, without success.
If you see the post above, I can get the plugin to login to Cisco devices is I tell it not to check for the > prompt, so something is wrong with the checking the " > " feature.

I was going to try and replace the phptelnet class but I think I wont be able to, as I don't know enough to complete that task
grady
Cacti User
Posts: 60
Joined: Wed Feb 20, 2008 5:02 pm

Post by grady »

OK, was just wondering about the different accounts as I'm using different accounts here. If you want to skip checking for > you'd want to comment out the following lines: (lines 469 - 501 in my functions file)

Code: Select all

                               if ($enablepw != '') {

                                        # Get > to show we are at the command prompt and ready to input the en command
                                        $res = '';
                                        $x = 0;
                                        while ($x < 10) {
                                                sleep(3);
                                                $this->GetResponse($r);
                                                echo $r;
                                                $res .= $r;
                                                if (strpos($r, '>') !== FALSE) {
                                                        break;
                                                }
                                                $x++;
                                        }
                                        @fputs($this->fp, "en\r");

                                        # Get the password prompt again to input the enable password
                                        $res = '';
                                        $x = 0;
                                        while ($x < 10) {
                                                sleep(3);
                                                $this->GetResponse($r);
                                                echo $r;
                                                $res .= $r;
                                                if (strpos($res, $devicetype['password']) !== FALSE) {
                                                        break;
                                                }
                                                $x++;
                                        }
                                        $r=explode("\n", $r);
                                        @fputs($this->fp, "$enablepw\r");
                                }
...strange that were having issues getting it going there. It's working fine here for cisco, HP and Foundry ServerIrons.
dieselboy
Cacti User
Posts: 135
Joined: Wed May 27, 2009 5:10 pm

Post by dieselboy »

Sweet as. That now logs in to HP and Cisco.
There is an issue somewhere as the HP reports "protocol error" when it tries to back up, and the Cisco ASA reports "%Error opening system:150.20.1.140 (No such file or directory)" but, I can fix this when I have more time I'm quite certain.

Many thanks for your help for the past 6 pages. Each time I came to a dead end you have assisted. Cheers!

Once I test / fix my issues I will re-upload the functions.php
grady
Cacti User
Posts: 60
Joined: Wed Feb 20, 2008 5:02 pm

Post by grady »

Sounds good.
dertoaster
Posts: 6
Joined: Wed Nov 11, 2009 12:13 pm
Location: Germany

Post by dertoaster »

Hello,

i have installed the lates routerconfigs from www.cacti.net.
I am using cacti 0.8.7e and PIA 2.6. My php version is

Code: Select all

PHP 5.3.1 (cli) (built: Feb 15 2010 17:27:14) 
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2009 Zend Technologies
if i run from cli as cacti user

Code: Select all

php /srv/www/htdocs/cacti/plugins/routerconfigs/router-download.php
the configs of my devices are stored in the DB. I can compare config and so on.

My problem is, that the download doesn't run automaticly. What triggers the automatic download? How can i debug this? What information do you need to help to solve this issue?

Thanks
Heiko
Last edited by dertoaster on Thu May 06, 2010 9:56 am, edited 1 time in total.
dieselboy
Cacti User
Posts: 135
Joined: Wed May 27, 2009 5:10 pm

Post by dieselboy »

Are you using windows or linux?

Does your Cacti plot any graphs at all?
dertoaster
Posts: 6
Joined: Wed Nov 11, 2009 12:13 pm
Location: Germany

Post by dertoaster »

Thanks for reply!

I have graphs of ca. 350 devices. My OS is OpenSuse 11.2.
dieselboy
Cacti User
Posts: 135
Joined: Wed May 27, 2009 5:10 pm

Post by dieselboy »

have you looked in the logs? I asked whether the graphs were being plotted as if they were not it may have pointed to a cron issue.
dertoaster
Posts: 6
Joined: Wed Nov 11, 2009 12:13 pm
Location: Germany

Post by dertoaster »

I have looked in the logs. I can't see any issu that's indicate to the routerconfigs.

That's my crontab for the cacti user:

Code: Select all

php -q /srv/www/htdocs/cacti/poller.php >> /srv/www/htdocs/cacti/log/poller.log  2>&1
Can you give me a short explanation how routerconfigs work?
dieselboy
Cacti User
Posts: 135
Joined: Wed May 27, 2009 5:10 pm

Post by dieselboy »

I personally don't know. But, I summise that, when the crontab runs, it also runs the routerconfigs plugin. The plugin checks the length of time since it last run, and if its larger than the time you specified (one day, etc) then it continues to run the routerconfigs plugin.

You may wish to start a thread on your exact issue, as this thread was to enable HP and ALL Cisco devices to be backed up by the routerconfigs plugin.

If I were you (If you can do this) look at the SQL database for the times of when the last routerconfigs run. And also look under each device in cacti how long you have specified to back up devices i.e. every day, every week etc.
dieselboy
Cacti User
Posts: 135
Joined: Wed May 27, 2009 5:10 pm

Post by dieselboy »

grady wrote:Sounds good.
Okay so I have been working on the routerconfigs / cacti server. It backs up both HP and Cisco but when it does HP it doesnt realise it has saved the config so it reports as failed. However if I go to the TFTP directory then the config is there. Any ideas? Here is the output when run from the CLI

Code: Select all

2610-01# copy start tftp 192.168.250.39 172.23.3.250
2610-01# Saving Debug
05/09/2010 03:23:51 PM - RouterConfigs: Poller[0] -1273436576 seconds
0 devices backed up successfully.
1 devices failed to backup.

These devices failed to backup
--------------------------------
172.23.3.250  -
[root@localhost ~]#
dieselboy
Cacti User
Posts: 135
Joined: Wed May 27, 2009 5:10 pm

Post by dieselboy »

Any ideas on the above issue? The config is saved simply as the filename. It seems to miss the script where it gets renamed to something logical, and has no database entry either.
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests