Skip to content
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

Add more Procera interfaces #7422

Merged
merged 13 commits into from Oct 19, 2017
2 changes: 2 additions & 0 deletions includes/definitions/procera.yaml
Expand Up @@ -11,3 +11,5 @@ processor_stacked: 1
discovery:
- sysObjectId:
- .1.3.6.1.4.1.15397.2
mib_dir:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MIB dirs matching the OS name are added by default.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well that's convenient. I'll remove it, thanks Murrant.

- procera
4 changes: 4 additions & 0 deletions includes/polling/ports.inc.php
Expand Up @@ -230,6 +230,10 @@
$port_stats = snmpwalk_cache_oid($device, 'dot3StatsDuplexStatus', $port_stats, 'EtherLike-MIB');
}

if ($device['os'] == 'procera') {
require_once 'ports/procera.inc.php';
}

if ($config['enable_ports_adsl']) {
$device['adsl_count'] = dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE `device_id` = ? AND `ifType` = 'adsl'", array($device['device_id']));
}
Expand Down
64 changes: 64 additions & 0 deletions includes/polling/ports/procera.inc.php
@@ -0,0 +1,64 @@
<?php
/**
* procera.inc.php
*
* LibreNMS Procera Ports include
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2017 Paul Heinrichs
* @author Paul Heinrichs <pdheinrichs@gmail.com>
*/

$packetlogic_stats = snmpwalk_cache_oid($device, 'netDeviceTable', array(), 'PACKETLOGIC-CHANNEL-MIB');
$packetlogic_info = snmpwalk_cache_oid($device, 'channelInfoTable', array(), 'PACKETLOGIC-CHANNEL-MIB');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you put both these in the same array it will make things easier for you below. Just send the array from the first walk to the second walk instead of array().

snmpwalk_group() is a newer function, but either is fine here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'd like to see the use of snmpwalk_group() if possible.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I attempted the snmpwalk_group(), I don't know if the oddly decimal labeled indexes are causing issues but here's what happened, also created some odd loop that created 6 more interfaces 😕

https://pastebin.com/eADLHYij

Did I use it wrong?

Copy link
Member

@murrant murrant Oct 4, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is odd @pheinrichs can you do that same thing with debug set so I can see the raw snmpwalk output?

Also, don't mix them:

$packetlogic_stats = snmpwalk_group($device, 'netDeviceTable', 'PACKETLOGIC-CHANNEL-MIB');
$packetlogic_stats = snmpwalk_group($device, 'channelInfoTable', 'PACKETLOGIC-CHANNEL-MIB', 1, $packetlogic_stats);

You can also try changing the depth value to see if the grouping is wrong. Try 0 and 2 (on both walks). Depth determines the cut off point for what parts to group together.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding the depth at 2 seems to be kind of working but still giving the array a sub array with an index of [.0]

https://pastebin.com/0gSBzhwq

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, the snmp engine isn't returning it right.

It is returning channelInternalTxAborted[11].0 when it should be channelInternalTxAborted[11][0]

Maybe I can update the code to handle this as it might be common when walking tables of single values.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#7427 should fix this


$channelTypes = array(
array(
'type' => 'channelExternal',
'name' => 'External'
),
array(
'type' => 'channelInternal',
'name' => 'Internal'
)
);

$required = array(
'ifInOctets' => 'RxBytes',
'ifOutOctets' => 'TxBytes',
'ifInUcastPkts' => 'RxPackets',
'ifOutUcastPkts' => 'TxPackets',
'ifInErrors' => 'RxErrors',
'ifOutErrors' => 'TxErrors',
);

foreach ($packetlogic_stats as $index => $port) {
$procera_port = array();
foreach ($channelTypes as $cType) {
foreach ($required as $ifEntry => $IfxStat) {
$procera_port[$ifEntry] = $packetlogic_stats[$index][$cType['type'].$IfxStat];
}
$procera_port['ifName'] = $packetlogic_info[$index]['channelName']. ' '.$cType['name'];
$procera_port['ifDescr'] = $packetlogic_info[$index]['channelName']. ' '.$cType['name'];
$procera_port['ifConnectorPresent'] = ($packetlogic_info[$index]['NegotiatedMedia'] != 'linkdown' ? "true" : "false");
$procera_port['ifOperStatus'] = ($packetlogic_info[$index]['channelActive'] === 'active' ? "up" : "down");
$procera_port['ifType'] = 'ethernetCsmacd';
array_push($port_stats, $procera_port);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will add it to the existing array, are these ports in addition to? If so, do we need anything like speed and things to be registered?

Copy link
Member

@murrant murrant Oct 5, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

channelInternalNegotiatedMedia should allow ifSpeed/ifDuplex to be filled in.

But yes, please try to fill in as many fields from ifTable as possible.

}
}

unset($packetlogic_info, $channelTypes, $packetlogic_stats, $procera_port);