Feature Request: PoE Control via SNMP

Help us decide what to build next.
User avatar
totalhighspeed
Member
 
Posts: 6
Joined: Fri Oct 23, 2015 11:30 am
Location: Nixa, MO
Has thanked: 2 times
Been thanked: 3 times

Feature Request: PoE Control via SNMP

Thu Apr 06, 2017 10:45 am

We would simply like to have the ability to enable/disable PoE via SNMP. The object is already in the MIB, but it's read-only. Not sure how hard it would be to make it write-able as well, but it would be nice to be able to turn power on/off via simple SNMP set command. Maybe make it an option to make it read-only/read-write selectable via the GUI for those that don't want it.

User avatar
Eric Stern
Employee
Employee
 
Posts: 524
Joined: Wed Apr 09, 2014 9:41 pm
Location: Toronto, Ontario
Has thanked: 0 time
Been thanked: 128 times

Re: Feature Request: PoE Control via SNMP

Thu Apr 06, 2017 1:01 pm

This is very unlikely to happen. Our entire SNMP subsystem is read only, it is only designed to providing monitoring.

User avatar
totalhighspeed
Member
 
Posts: 6
Joined: Fri Oct 23, 2015 11:30 am
Location: Nixa, MO
Has thanked: 2 times
Been thanked: 3 times

Re: Feature Request: PoE Control via SNMP

Thu Apr 06, 2017 2:05 pm

I'm trying to setup a system to automatically upgrade and configure radios before they get to our installers, a shop config that only requires minor changes so that they don't have to remember every setting, especially those that don't change from one tower to the next. Since every radio has the same IP address by default you can't just plug them all in and walk away. So the easiest way that I can think to this is to power one on, do what you need to do, then power it off and move to the next one. So we're really needing a way to power cycle ports through PHP or Python scripts. Or if you know a better way of doing this, I'm all ears.

This is the only missing piece right now. I have been using PacketFlux SyncInjectors but that gets complicated as the ports are not sequential across Injectors and your SNMP OIDs have to jump by like 13 digits for the next Injector which is less than ideal and they only have 4 ports per Injector unless I drop $800 on the new rack mount version which is currently pre-order only. I have all of the other systems in place for uploading firmware and configs to the radios, I just need a way to power them on and off. Any help is appreciated.

User avatar
Eric Stern
Employee
Employee
 
Posts: 524
Joined: Wed Apr 09, 2014 9:41 pm
Location: Toronto, Ontario
Has thanked: 0 time
Been thanked: 128 times

Re: Feature Request: PoE Control via SNMP

Thu Apr 06, 2017 4:07 pm

Should be trivial to script an SSH connection to the switch in either PHP or Python and issue appropriate CLI commands to turn the PoE on and off.

ie
conf
interface port 2
poe 24V
exit
exit
<ENTER> (to confirm the configuration change)

User avatar
jakematic
Experienced Member
 
Posts: 145
Joined: Thu Jul 14, 2016 8:15 am
Location: NC USA
Has thanked: 237 times
Been thanked: 75 times

Re: Feature Request: PoE Control via SNMP

Thu Apr 06, 2017 6:04 pm

Eric Stern wrote:Should be trivial to script an SSH connection to the switch in either PHP or Python and issue appropriate CLI commands to turn the PoE on and off.


Can't we just have a command like option e.g. to turn port 5 on with 24V:
Code: Select all
 POEcontrol 5 24V


Pretty please? I'll buy you beer :cheers:


Trying to automate with passwordless ssh is a bear and has caused much swearing because it drops you to ash instead of sh.
Python/PHP/JSON are things not all of us want to spend a boatload of time learning. :headb:

User avatar
totalhighspeed
Member
 
Posts: 6
Joined: Fri Oct 23, 2015 11:30 am
Location: Nixa, MO
Has thanked: 2 times
Been thanked: 3 times

Re: Feature Request: PoE Control via SNMP

Fri Apr 07, 2017 11:45 am

Okay, here is what I quickly coded up and tried using PHP and it doesn't work for some reason. It runs without any errors, but doesn't output anything and doesn't turn PoE on for the specified port. Any suggestions on how to get this to work?

Code: Select all
 #!/bin/php
<?php

$host = 'x.x.x.x'; // Hostname or IP address
$username = 'admin'; // Admin username
$password = 'xxxxxxxx'; // Admin password
$port = '4'; // Port number on the Netonix
$poe = '24V'; // off,24V,48V, etc


// Setup the SSH connection
$connection = ssh2_connect($host);
ssh2_auth_password($connection, $username, $password);

// Run the SSH command(s)
$stream = ssh2_exec($connection, "conf;interface port ".$port.";poe ".$poe.";exit;exit;\n");

// Turn on blocking so it doesn't disconnect between multiple commands
stream_set_blocking($stream, true);

// Display any output
echo 'Output: '.stream_get_contents($stream)."\r\n";

// Close the connection
fclose($stream);

?>

User avatar
Eric Stern
Employee
Employee
 
Posts: 524
Joined: Wed Apr 09, 2014 9:41 pm
Location: Toronto, Ontario
Has thanked: 0 time
Been thanked: 128 times

Re: Feature Request: PoE Control via SNMP

Fri Apr 07, 2017 1:36 pm

The SSH connection gives you a shell, not the CLI. You need to start the CLI first.

Code: Select all
#!/bin/php
<?php

$host = '192.168.2.104'; // Hostname or IP address
$username = 'admin'; // Admin username
$password = 'admin'; // Admin password
$port = '4'; // Port number on the Netonix
$poe = '24V'; // off,24V,48V, etc

// Setup the SSH connection
$connection = ssh2_connect($host);
ssh2_auth_password($connection, $username, $password);

$shell=ssh2_shell($connection, 'switch');
fwrite( $shell, 'conf'.PHP_EOL);
fwrite( $shell, 'interface port '.$port.PHP_EOL);
fwrite( $shell, 'poe '.$poe.PHP_EOL);
fwrite( $shell, 'exit'.PHP_EOL);
fwrite( $shell, 'exit'.PHP_EOL);
sleep(1); // wait for the confirm prompt
fwrite( $shell, PHP_EOL); // send ENTER to confirm
fwrite( $shell, 'exit'.PHP_EOL); // exit the CLI which will terminate the SSH session

// Turn on blocking so it doesn't disconnect between multiple commands
stream_set_blocking($shell, true);

// Display any output
echo 'Output: '.stream_get_contents($shell)."\r\n";

// Close the connection
fclose($shell);

?>

User avatar
totalhighspeed
Member
 
Posts: 6
Joined: Fri Oct 23, 2015 11:30 am
Location: Nixa, MO
Has thanked: 2 times
Been thanked: 3 times

Re: Feature Request: PoE Control via SNMP

Fri Apr 07, 2017 3:20 pm

That works perfectly. Thanks for the assistance.
This will make programming this thing about a million times easier now.

For anyone interested here is the "finished" code with command line arguments so that your user/pass isn't stored in plain text in the PHP file...

Code: Select all
#!/bin/php
<?php
function help() {
 print "\r\n** Syntax error - You must supply all of the following options:\r\n\r\n";
 print " h <host> The hostname or IP address for the Netonix\r\n";
 print " n <portnumber> The port number that you wish to alter\r\n";
 print " v <value> The value for the PoE, off, 24V, 24VH, 48V, 48VH\r\n";
 print " u <username> The username to use for logging in\r\n";
 print " p <password> The Password used to log into the switch\r\n";
 print "\r\n";
 exit(1);
}

$options = getopt("h:u:p:n:v:");
if((!isset($options['h'])) || (!isset($options['u'])) || (!isset($options['p'])) || (!isset($options['n'])) || (!isset($options['v']))) {
 help();
}else{
 $host = ($options['h']);
 $username = ($options['u']);
 $password = ($options['p']);
 $port = ($options['n']);
 $poe = ($options['v']);
}
print "Setting PoE to $poe on port $port of $host\r\n";

// Setup the SSH connection
$connection = ssh2_connect($host);
ssh2_auth_password($connection, $username, $password);

$shell=ssh2_shell($connection, 'switch');
fwrite( $shell, 'conf'.PHP_EOL);
fwrite( $shell, 'interface port '.$port.PHP_EOL);
fwrite( $shell, 'poe '.$poe.PHP_EOL);
fwrite( $shell, 'exit'.PHP_EOL);
fwrite( $shell, 'exit'.PHP_EOL);
sleep(1); // wait for the confirm prompt
fwrite( $shell, PHP_EOL); // send ENTER to confirm
fwrite( $shell, 'exit'.PHP_EOL); // exit the CLI which will terminate the SSH session

// Turn on blocking so it doesn't disconnect between multiple commands
stream_set_blocking($shell, true);

// Display any output
echo 'Output: '.stream_get_contents($shell)."\r\n";

// Close the connection
fclose($shell);

?>

calliowarebow
Member
 
Posts: 4
Joined: Tue Sep 11, 2018 11:21 am
Location: Czech
Has thanked: 0 time
Been thanked: 0 time

Feature Request PoE Control via SNMP

Mon Sep 24, 2018 11:35 am

I have understood you like to dothis via webinterface but Im pretty sure Sanchos GUI implements this feature yet.
[url="http://hd-wallpapersfd.info/category/art/"]HD Wallpapers[/url]

Return to What should we build next

Who is online

Users browsing this forum: No registered users and 3 guests