New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: PoE graphs #8705

Merged
merged 10 commits into from May 15, 2018

Conversation

Projects
None yet
5 participants
@PipoCanaja
Contributor

PipoCanaja commented May 12, 2018

Hello,

I did some tests and enhancements in the POE polling code (Cisco, Huawei), and also added graphing code in the port page.

Then code has been tested onto Cisco 2960X, and Huawei 5720 access switches.

PipoCanaja

DO NOT DELETE THIS TEXT

Please note

Please read this information carefully. You can run ./scripts/pre-commit.php to check your code before submitting.

Testers

If you would like to test this pull request then please run: ./scripts/github-apply <pr_id>, i.e ./scripts/github-apply 5926

@theherodied

This comment has been minimized.

Contributor

theherodied commented May 12, 2018

@PipoCanaja what should we look for when testing? I'm not familiar with what was graphed previously with POE ports.

@PipoCanaja

This comment has been minimized.

Contributor

PipoCanaja commented May 13, 2018

Hello

On a Poe Switch, either Cisco or Huawei, you should be able to have a new graph in the "port" page (URL like http://myserver.mydomain/device/device=1/tab=port/port=50/ ), after the Interface Traffic, Packets and Errors.

To check if the polling works, you can go in the RRD directory of the device you would like to ckeck (usually /opt/librenms/rrd/), and do a "ls poe" to see how it goes.

PoeGraph example for a Wireless Antenna (Cisco 2702) on a Huawei switch (5720):
capturegraphpoe

Extract of the Port Page for this same port :
captureportscreen

Bye

@laf

@PipoCanaja You've altered a lot of the indentation here, can you revert all of that please.

Will take a look at the code after that.

@PipoCanaja

This comment has been minimized.

Contributor

PipoCanaja commented May 13, 2018

Hello @laf

Done. Except 2 or 3 \n, the changes are now only linked to PoE code.

Bye

@laf

Some in line comments.

Also, can you generate some test data for the devices you have which support this please.

@@ -174,6 +174,20 @@
'dot3StatsDuplexStatus',
];
$vrp_poe_oids = array(

This comment has been minimized.

@laf

laf May 13, 2018

Member

Where is this used?

@@ -274,8 +288,41 @@
}//end if
if ($config['enable_ports_poe']) {
$port_stats = snmpwalk_cache_oid($device, 'pethPsePortEntry', $port_stats, 'POWER-ETHERNET-MIB');

This comment has been minimized.

@laf

laf May 13, 2018

Member

With your new code you've now stopped this working for any none ios, procurve or vrp devices, how come?

This comment has been minimized.

@PipoCanaja

PipoCanaja May 14, 2018

Contributor

The existing code was most probably not used for any other device than Cisco (POWER-ETHERNET-MIB is polled but never used in the code, and CISCO-POWER-ETHERNET-EXT-MIB is CISCO specific) but in case it was used by somebody, I restored the original code in the final 'else' statement now.

if ($device['os'] == 'ios') {
$port_stats_poe = snmpwalk_cache_oid($device, 'pethPsePortEntry', array(), 'POWER-ETHERNET-MIB');
$port_stats_poe = snmpwalk_cache_oid($device, 'cpeExtPsePortEntry', $port_stats_poe, 'CISCO-POWER-ETHERNET-EXT-MIB');
$port_ent_to_if = snmpwalk_cache_oid($device, 'portIfIndex', array(), 'CISCO-STACK-MIB');

This comment has been minimized.

@laf

laf May 13, 2018

Member

This + the extra walks below is going to slow polling down and could do so considerably. What's the reason for performing these?

This comment has been minimized.

@PipoCanaja

PipoCanaja May 14, 2018

Contributor

'pethPsePortEntry' is now removed as it is not necessary for Cisco polling. cpeExtPsePortEntry and portIfIndex are mandatory :
cpeExtPsePortEntry contains the actual value, but indexed by entIndex, and portIfIndex contains the mapping to change entIndex into ifIndex.
Then we have a foreach loop to do the actual mapping and get the usable values.

if (isset($this_port['hwPoePortEnable'])) {
$rrd_name = getPortRrdName($port_id, 'poe');
$rrd_def = RrdDefinition::make()
->addDataset('PortPwrAllocated', 'GAUGE', 0)

This comment has been minimized.

@laf

laf May 13, 2018

Member

You're duplicating this block + data_update() 3 times, would be better to move these outside of the if blocks.

data_update($device, 'poe', $tags, $fields);
echo 'PoE(vrp) ';
}
} elseif (($device['os'] == 'ios')||($device['os'] == 'ciscosb')) {

This comment has been minimized.

@laf

laf May 13, 2018

Member

You can do if (str_contains($device['os'], ['ios', 'ciscosb'])) { instead.

This comment has been minimized.

@PipoCanaja

PipoCanaja May 14, 2018

Contributor

removed ciscosb for now as I cannot test it. ciscosb will fall in default value until somebody has a test bench for it.

}
} elseif (($device['os'] == 'ios')||($device['os'] == 'ciscosb')) {
// Code for Cisco IOS, tested on 2960X
if (isset($this_port['cpeExtPsePortPwrAllocated'])) {

This comment has been minimized.

@laf

laf May 13, 2018

Member

Where is $this_port['cpeExtPsePortPwrAllocated'] coming from as it's not in the code anywhere before this?

This comment has been minimized.

@PipoCanaja

PipoCanaja May 14, 2018

Contributor

$this_port is defined in line 491 of includes/polling/ports.inc.php as &port_stats[$ifIndex].

if (($device['os'] == 'vrp')) {
//Tested against Huawei 5720 access switches
if (isset($this_port['hwPoePortEnable'])) {
$rrd_name = getPortRrdName($port_id, 'poe');

This comment has been minimized.

@laf

laf May 13, 2018

Member

This is also being duplicated

This comment has been minimized.

@PipoCanaja

PipoCanaja May 14, 2018

Contributor

done

$port_stats_poe = snmpwalk_cache_oid($device, 'cpeExtPsePortEntry', $port_stats_poe, 'CISCO-POWER-ETHERNET-EXT-MIB');
$port_ent_to_if = snmpwalk_cache_oid($device, 'portIfIndex', array(), 'CISCO-STACK-MIB');
foreach ($port_ent_to_if as $p_index => $p_stats) {
if ($p_stats[portIfIndex] > 0) {

This comment has been minimized.

@laf

laf May 13, 2018

Member

Can you update to use 'portifIndex' + any other indexes in arrays which don't contain ''

This comment has been minimized.

@PipoCanaja

PipoCanaja May 14, 2018

Contributor

On the way.

@@ -0,0 +1,720 @@

This comment has been minimized.

@laf

laf May 13, 2018

Member

Can you rename this to drop the .mib please.

This comment has been minimized.

@PipoCanaja

PipoCanaja May 14, 2018

Contributor

OK

PipoCanaja added some commits May 14, 2018

Cleaning of code not used for Cisco IOS, removal of untested Procurve…
… code, and restore of legacy generic code (tested with Cisco+huawei)
//Any other device, generic polling
$port_stats = snmpwalk_cache_oid($device, 'pethPsePortEntry', $port_stats, 'POWER-ETHERNET-MIB');
$port_stats = snmpwalk_cache_oid($device, 'cpeExtPsePortEntry', $port_stats, 'CISCO-POWER-ETHERNET-EXT-MIB');
}

This comment has been minimized.

@PipoCanaja

PipoCanaja May 14, 2018

Contributor

Legacy polling in the 'else' statement.

@PipoCanaja

This comment has been minimized.

Contributor

PipoCanaja commented May 14, 2018

Looking at the test data, will come back with this later.

@laf

Once you have test data in place I'm happy with this. Might impact polling now that we collect data for devices we didn't before but those with this enabled should expect it anyway.

@PipoCanaja

This comment has been minimized.

Contributor

PipoCanaja commented May 14, 2018

Test data for huawei device with PoE antenna plugged in. You already have a bunch of Cisco devices but not 2960X so I'll try to capture the data and clean it to submit it as well.

@PipoCanaja

This comment has been minimized.

Contributor

PipoCanaja commented May 14, 2018

And done with Cisco 2960X

@laf

laf approved these changes May 15, 2018

LGTM

Thanks for contributing :)

@laf laf merged commit a1a13de into librenms:master May 15, 2018

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
license/cla Contributor License Agreement is signed.
Details

@PipoCanaja PipoCanaja deleted the PipoCanaja:PoE_poll_code branch May 15, 2018

TheMysteriousX added a commit to TheMysteriousX/librenms that referenced this pull request May 20, 2018

feature: Added PoE graphs and improved PoE polling code (librenms#8705)
* Poe Polling Code, Poe Graphs, and Huawei MIB

* Reverting the reindent done after pre-commit script

* Cleaning of code not used for Cisco IOS, removal of untested Procurve code, and restore of legacy generic code (tested with Cisco+huawei)

* Rename MIB file

* Rearranged duplicated code

* Cleaning of variable not used

* Cleaning of commented code after night validation in test environnement

* Cleaning after pre-commit.php comments

* test data with PoE oids for huawei 5720

* test data with PoE oids for cisco 2960X

@laf laf added Feature WebUI labels May 30, 2018

@boudreau

This comment has been minimized.

Contributor

boudreau commented Jun 1, 2018

Hi, not graphing on the Cat3850 from Cisco.

image

Doing a debug on the poller.php I see it get the SNMP for the POE, but it does not update the RRD file:


<...>
SNMP[^[[0;36m/usr/bin/snmpbulkwalk -Cr10  -v2c -c 'L0tsSwtH' -OQUs -m CISCO-POWER-ETHERNET-EXT-MIB -M /var/www/librenms/mibs:/var/www/librenms/mibs/cisco -t 2 -r 2 udp:peel3704-009-sw1.test.com:161 cpeExtPsePortEntry^[[0m]
cpeExtPsePortEnable.1.1 = auto
cpeExtPsePortEnable.1.2 = auto
cpeExtPsePortEnable.1.3 = auto
cpeExtPsePortEnable.1.4 = auto
cpeExtPsePortEnable.1.5 = auto
cpeExtPsePortEnable.1.6 = auto
cpeExtPsePortEnable.1.7 = auto
cpeExtPsePortEnable.1.8 = auto
<....>
cpeExtPsePortPwrMax.1.44 = 30000
cpeExtPsePortPwrMax.1.45 = 30000
cpeExtPsePortPwrMax.1.46 = 30000
cpeExtPsePortPwrMax.1.47 = 30000
cpeExtPsePortPwrMax.1.48 = 30000
cpeExtPsePortPwrAllocated.1.1 = 23010
cpeExtPsePortPwrAllocated.1.2 = 23010
cpeExtPsePortPwrAllocated.1.3 = 23010
cpeExtPsePortPwrAllocated.1.4 = 23010
cpeExtPsePortPwrAllocated.1.5 = 23010
<...>
RRDtool Output: PoE(generic) SQL[^[[0;33mUPDATE `ports` set `poll_time` ='1527857116',`poll_prev` ='1527856893',`poll_period` ='223',`ifLastChange` ='2536780829',`ifInOctets` ='217393945176',`ifInOctets_prev` ='217393809829',`ifInOctets_rate` ='606.93721973094',`ifInOctets_delta` ='135347',`ifOutOctets` ='1840905090615',`ifOutOctets_prev` ='1840905029394',`ifOutOctets_rate` ='274.533632287',`ifOutOctets_delta` ='61221',`ifInErrors` ='0',`ifInErrors_prev` ='0',`ifInErrors_rate` ='0',`ifInErrors_delta` ='0',`ifOutErrors` ='0',`ifOutErrors_prev` ='0',`ifOutErrors_rate` ='0',`ifOutErrors_delta` ='0',`ifInUcastPkts` ='567726615',`ifInUcastPkts_prev` ='567726205',`ifInUcastPkts_rate` ='1.8385650224215',`ifInUcastPkts_delta` ='410',`ifOutUcastPkts` ='1380419881',`ifOutUcastPkts_prev` ='1380419536',`ifOutUcastPkts_rate` ='1.5470852017937',`ifOutUcastPkts_delta` ='345' WHERE `port_id` = '84572'^[[0m]
SQL[^[[0;33mUPDATE `ports_statistics` set `ifInNUcastPkts` ='0',`ifInNUcastPkts_prev` ='0',`ifInNUcastPkts_rate` ='0',`ifInNUcastPkts_delta` ='0',`ifOutNUcastPkts` ='0',`ifOutNUcastPkts_prev` ='0',`ifOutNUcastPkts_rate` ='0',`ifOutNUcastPkts_delta` ='0',`ifInDiscards` ='0',`ifInDiscards_prev` ='0',`ifInDiscards_rate` ='0',`ifInDiscards_delta` ='0',`ifOutDiscards` ='0',`ifOutDiscards_prev` ='0',`ifOutDiscards_rate` ='0',`ifOutDiscards_delta` ='0',`ifInUnknownProtos` ='0',`ifInUnknownProtos_prev` ='0',`ifInUnknownProtos_rate` ='0',`ifInUnknownProtos_delta` ='0',`ifInBroadcastPkts` ='31391',`ifInBroadcastPkts_prev` ='31391',`ifInBroadcastPkts_rate` ='0',`ifInBroadcastPkts_delta` ='0',`ifOutBroadcastPkts` ='1289260',`ifOutBroadcastPkts_prev` ='1289253',`ifOutBroadcastPkts_rate` ='0.031390134529148',`ifOutBroadcastPkts_delta` ='7',`ifInMulticastPkts` ='914828',`ifInMulticastPkts_prev` ='914820',`ifInMulticastPkts_rate` ='0.035874439461883',`ifInMulticastPkts_delta` ='8',`ifOutMulticastPkts` ='14961631',`ifOutMulticastPkts_prev` ='14961509',`ifOutMulticastPkts_rate` ='0.54708520179372',`ifOutMulticastPkts_delta` ='122' WHERE `port_id` = '84572'^[[0m]


that port uses 23 watts:

sh power inline g1/0/1
Interface Admin  Oper       Power   Device              Class Max
                            (Watts)
--------- ------ ---------- ------- ------------------- ----- ----
Gi1/0/1   auto   on         23.0    Ieee PD             4     30.0

I don't see the 23W (23010) being updated to the RRD files ?

Thanks

@csalcedo1024

This comment has been minimized.

csalcedo1024 commented Jun 18, 2018

Yup, not working for me either on a cisco 3560..

@librenms librenms locked and limited conversation to collaborators Jun 19, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.