Routerconfigs plugin / how it works?
Moderators: Developers, Moderators
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?
How did you get it to press any key?
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: correct? (of course using the credentials listed in routerconfigs / auth)
Code: Select all
copy running-config tftp x.x.x.x
- Attachments
-
- functions.txt
- (28.49 KiB) Downloaded 561 times
I copied over the functions file from above again so it was fresh but I still get this:
Code: Select all
��������
User Access Verification
Username: �� ������'��admin
Password:
3750-1>exit
333
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: Select all
//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
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.
Here's that if:
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:
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.
Code: Select all
($telnetHP = new PHPTelnetHP();)
Code: Select all
$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;
}
}
Code: Select all
$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;
}
}
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 :/
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 :/
Who is online
Users browsing this forum: No registered users and 0 guests