Cacti (home)ForumsDocumentation
Cacti: offical forums and support
It is currently Mon May 21, 2018 12:16 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: Thu Apr 08, 2010 3:40 am 
Offline
Cacti User

Joined: Wed May 27, 2009 5:10 pm
Posts: 135
When I run that from the command line, it doesnt seem to be pressing "any key" when it connects to the HP switch. Because of this it trys to log in and fails - because entering the username only takes it to the username prompt, and then it appears as if it puts the password into the username prompt and then times out.

How did you get it to press any key?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 08, 2010 8:07 am 
Offline
Cacti User

Joined: Wed Feb 20, 2008 5:02 pm
Posts: 60
Anyway you can attach your current functions file?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 08, 2010 8:10 am 
Offline
Cacti User

Joined: Wed May 27, 2009 5:10 pm
Posts: 135
Sure,
Here you go


Attachments:
functions_208.txt [29.61 KiB]
Downloaded 120 times
Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 08, 2010 8:34 am 
Offline
Cacti User

Joined: Wed Feb 20, 2008 5:02 pm
Posts: 60
Your functions file looks right. I'd removed a couple of lines of redundant code to clean mine up and have attached what I'm using at present. When you telnet to this HP it asks for a username and password when logging in right? Post login the command you're using to backup to tftp is:
Code:
copy running-config tftp x.x.x.x
correct? (of course using the credentials listed in routerconfigs / auth)


Attachments:
functions.txt [28.49 KiB]
Downloaded 188 times
Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 09, 2010 11:20 am 
Offline
Cacti User

Joined: Wed May 27, 2009 5:10 pm
Posts: 135
Thanks that now backs up HP kit!

The only problem I now have is that when I replace my config for enabling onto switches it doesn't enable. I noticed you have some enable config on there, how does this work?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 09, 2010 11:22 am 
Offline
Cacti User

Joined: Wed Feb 20, 2008 5:02 pm
Posts: 60
Can you clarify a bit? Mine is working on both platforms for enabled and no enable mode


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 09, 2010 11:23 am 
Offline
Cacti User

Joined: Wed May 27, 2009 5:10 pm
Posts: 135
Ok I'll retry,
When I look at the debug and through CLI it doesnt seem to enable at all.
Where does it get the "enablepassword" from in the $info field?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 09, 2010 11:27 am 
Offline
Cacti User

Joined: Wed May 27, 2009 5:10 pm
Posts: 135
I copied over the functions file from above again so it was fresh but I still get this:
Code:
��������

User Access Verification

Username: �� ������'��admin
Password:

3750-1>exit
333


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 09, 2010 11:36 am 
Offline
Cacti User

Joined: Wed Feb 20, 2008 5:02 pm
Posts: 60
Yeah, I removed some of that debug crap for clarity. Does it just hang when run from cli against devs requiring enable mode or does it error out eventually or what? (when run from cli eventually it should echo back something along the lines of "the following failed to be backed up" or whatever)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 09, 2010 11:43 am 
Offline
Cacti User

Joined: Wed May 27, 2009 5:10 pm
Posts: 135
It logs in but when it gets to the enable prompt it doesnt do anything. after a while it says "login failed333"
Then it moves on to the next device - this is in the CLI.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 09, 2010 11:44 am 
Offline
Cacti User

Joined: Wed May 27, 2009 5:10 pm
Posts: 135
Does the script wait for the > before trying any further commands?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 09, 2010 11:51 am 
Offline
Cacti User

Joined: Wed Feb 20, 2008 5:02 pm
Posts: 60
Yeah, so what should happen based on the below code is this. $devicetypeHP is a mysql select NAME from the plugin_routerconfigs_devicetypes table where blah isn't null. That returns a variable of type array, so we use php's foreach to evaluate what's returned and assign that string to $value. If $value is equal to HP then we use the telnetHP class to initiate a connection. (telnetHP can be found at the very bottom of the functions file. Its essentially the same as the phptelnet class, but passes extra stuff for username and copy commands) If $value is not HP and $result = 0 (result = 0 means successful connection to device) we continue down through unaltered functions (original) and use the original phptelnet class. I'm not really sure why it wouldnt work on devices that require enable. Can you try disabling that device in the routerconfigus gui and attempt to back up a device that does not require enable (cisco) to see if that works or not?


Code:
//If HP use PHPTelnetHP class vs standard
        $devicetypeHP = db_fetch_row("SELECT name FROM plugin_routerconfigs_devicetypes WHERE id = " . $device['devicetype']);
                 foreach ($devicetypeHP as $value)
                 {
                        if ($value == "HP"){
                        $result1 = $telnetHP->Connect($device['ipaddress'],  $info['username'], $info['password'], $devicetype);
                        $debug = $telnetHP->debug;
                        $result=$result1;
                        $telnetHP->DoCommandHP($devicetype['copytftp'], $result);
                        echo $result;
                        $telnetHP->DoCommandHP2($filename, $result);
                        echo $result;
                        }
                }
//end class use
                if ($result == 0) {
// If HP skip re-connecting to the device and causing a false positive
                        if ($value !="HP") {
                        $result = $telnet->Connect($device['ipaddress'], $info['username'], $info['password'], $info['enablepw'], $devicetype);
                        $debug = $telnet->debug;
                        $telnet->DoCommand($devicetype['copytftp'], $result);
                        $debug .= $result;
                        echo $result;
                        $telnet->DoCommand($tftpserver, $result);
                        $debug .= $result;
                        echo $result;
                        $telnet->DoCommand($filename, $result);
                        $debug .= $result;
                        echo $result;

                                if (strpos($result, 'confirm') !== FALSE || strpos($result, 'to tftp:') !== FALSE || $devicetype['forceconfirm']) {
                                $telnet->DoCommand('y', $result);
                                $debug .= $result;
                                echo $result;
                                }

                        }
//end false positive skip


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 13, 2010 5:09 am 
Offline
Cacti User

Joined: Wed May 27, 2009 5:10 pm
Posts: 135
Without an enable prompt it works. It logs in and backs up the config. What does this mean?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 13, 2010 8:11 am 
Offline
Cacti User

Joined: Wed Feb 20, 2008 5:02 pm
Posts: 60
That's very strange. It ought to work with enable as well. When the device type is pulled from that table there's an if statement that says if name = HP use telnetHP. -- If you page down near the bottom of the functions file you'll see both of those classes defined. Note that the telnethp class does not have the check for enable mode prompt stuff that the telnet class does.
Code:
($telnetHP = new PHPTelnetHP();)


Here's that if:
Code:
        $devicetypeHP = db_fetch_row("SELECT name FROM plugin_routerconfigs_devicetypes WHERE id = " . $device['devicetype']);
                 foreach ($devicetypeHP as $value)
                 {
                        if ($value == "HP"){
                        $result1 = $telnetHP->Connect($device['ipaddress'],  $info['username'], $info['password'], $devicetype);
                        $debug = $telnetHP->debug;
                        $result=$result1;
                        $telnetHP->DoCommandHP($devicetype['copytftp'], $result);
                        echo $result;
                        $telnetHP->DoCommandHP2($filename, $result);
                        echo $result;
                        }
                }


As a test try this, go into router configs and disable all non cisco, non enable mode devices. Then add an echo to the above code like this:

Code:
   $devicetypeHP = db_fetch_row("SELECT name FROM plugin_routerconfigs_devicetypes WHERE id = " . $device['devicetype']);
                 foreach ($devicetypeHP as $value)
                 {
                        if ($value == "HP"){
                                                echo "Are we ending up here?";
                        $result1 = $telnetHP->Connect($device['ipaddress'],  $info['username'], $info['password'], $devicetype);
                        $debug = $telnetHP->debug;
                        $result=$result1;
                        $telnetHP->DoCommandHP($devicetype['copytftp'], $result);
                        echo $result;
                        $telnetHP->DoCommandHP2($filename, $result);
                        echo $result;
                        }
                }


Then run php /var/www/html/cacti/plugins/routerconfigs/router-download.php (assuming thats the path to your plugins directory) and see if you see that echo during execution. If so all that's happening is that for some reason you're hitting that code block when you shouldn't be and we'll need to figure out why.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 14, 2010 10:06 am 
Offline
Cacti User

Joined: Wed May 27, 2009 5:10 pm
Posts: 135
It doesn't echo that line back so I guess it's not matching that.

I've selected both cisco IOS and auto detect and neither of them work. What determines what rule set the functions.php follows?
When I had enable working on my setup I had to leave it as autodetect so that functions.php followed the ifresult=empty path. I then put the enable command and password part in there. I see you have put these in the log in path above this. I tried moving this but it still didn't have any effect :/


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 2 guests


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