ISAM Ports - empty graphs

Hi All,
Thanks for looking. Sorry novice question below…

I have LibreNMS set up to monitor a number of Nokia ISAM nodes - (R5.3.02 NFXS-D FANT-F ALCATEL-LUCENT ISAM)

The discovery has identified all the interfaces yet my graphs for these interfaces are empty.

Trying to understand what is going on behind the scenes, I ran a debug discovery and spotted

/usr/bin/snmpbulkwalk’ ‘-v2c’ ‘-c’ ‘COMMUNITY’ ‘-OQUs’ ‘-m’ ‘IF-MIB’ ‘-M’ ‘/opt/librenms/mibs:/opt/librenms/mibs/nokia’ ‘udp:HOSTNAME:161’ ‘ifXEntry’

I ran this manually and I see this amongst the output

(67108864 is just an example index)

Line 1: ifName.67108864 = P2P Ethernet interface
Line 511: ifHCInOctets.67108864 = "00 00 4B 67 50 D8 5A 52 "
Line 551: ifHCInUcastPkts.67108864 = "00 00 00 6D 97 50 30 CD "
Line 591: ifHCInMulticastPkts.67108864 = "00 00 00 00 00 15 A4 65 "
Line 631: ifHCInBroadcastPkts.67108864 = "00 00 00 00 00 2B 36 05 "
Line 671: ifHCOutOctets.67108864 = "00 03 E0 5A 7E 35 A3 63 "
Line 711: ifHCOutUcastPkts.67108864 = "00 00 00 BD 71 4D 57 A3 "
Line 751: ifHCOutMulticastPkts.67108864 = "00 00 00 00 02 8B 4E CC "
Line 791: ifHCOutBroadcastPkts.67108864 = "00 00 00 00 01 7E 86 24 "
Line 831: ifLinkUpDownTrapEnable.67108864 = enabled
Line 1489: ifHighSpeed.67108864 = 1000
Line 1561: ifPromiscuousMode.67108864 = true
Line 1597: ifConnectorPresent.67108864 = true

Now this is where my novice hat is worn, I’ve not come across an output for ifHCInOctets / ifHCOutOctets written in HEX. Does the poller script automatically handle this and covert it into decimal? Or is there something I need to enable to perform this magic to get my graphs working?

Thanks
Mark

I think this is “possibly” what I need but I’m unsure if this is the correct way to do it.

If I add this to nokia-isam.inc.php, would this give me the output Im looking for?

foreach (array ( 'ifHCInOctets','ifHCInUcastPkts','ifHCInMulticastPkts','ifHCInBroadcastPkts','ifHCOutOctets','ifHCOutUcastPkts','ifHCOutMulticastPkts','ifHCOutBroadcastPkts') as $oid_HEX_Object) {	
	$port_stats[$index][$oid_HEX_Object] = hexdecs(preg_replace("/[^0-9A-Fa-f]/", '', $port_stats[$index][$oid_HEX_Object]))
}

// -- SOURCE https://www.php.net/manual/en/function.hexdec.php
function hexdecs($hex)
{
    // ignore non hex characters
    $hex = preg_replace('/[^0-9A-Fa-f]/', '', $hex);
   
    // converted decimal value:
    $dec = hexdec($hex);
   
    // maximum decimal value based on length of hex + 1:
    //   number of bits in hex number is 8 bits for each 2 hex -> max = 2^n
    //   use 'pow(2,n)' since '1 << n' is only for integers and therefore limited to integer size.
    $max = pow(2, 4 * (strlen($hex) + (strlen($hex) % 2)));
   
    // complement = maximum - converted hex:
    $_dec = $max - $dec;
   
    // if dec value is larger than its complement we have a negative value (first bit is set)
    return $dec > $_dec ? -$_dec : $dec;
}

I think I got this working as I now have data in my graphs.

Only thing I cant see is realtime graphs…

Can someone please check that this will not break anything?

/opt/librenms/includes/polling/ports/os/nokia-isam.inc.php

<?php
/**
* nokia-isam.inc.php
*
* 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  2019 Vitali Kari
* @author     Vitali Kari <[email protected]>
*/

// Use proprietary asamIfExtCustomerId as ifAlias for Nokia ISAM Plattform. The default IF-MIB fields are here quite meaningless
$isam_port_stats = snmpwalk_cache_oid($device, 'asamIfExtCustomerId', [], 'ITF-MIB-EXT', 'nokia-isam');

foreach ($isam_port_stats as $index => $value) {
    $port_stats[$index]['ifAlias'] = $isam_port_stats[$index]['asamIfExtCustomerId'];
	
	foreach (array ( 'ifHCInOctets','ifHCInUcastPkts','ifHCInMulticastPkts','ifHCInBroadcastPkts','ifHCOutOctets','ifHCOutUcastPkts','ifHCOutMulticastPkts','ifHCOutBroadcastPkts') as $oid_HEX_Object) {	
		$port_stats[$index][$oid_HEX_Object] = hexdecs(preg_replace("/[^0-9A-Fa-f]/", '', $port_stats[$index][$oid_HEX_Object]));
	}	
	
	
}


unset($isam_ports_stats);


// -- SOURCE https://www.php.net/manual/en/function.hexdec.php
function hexdecs($hex)
{
    // ignore non hex characters
    $hex = preg_replace('/[^0-9A-Fa-f]/', '', $hex);
   
    // converted decimal value:
    $dec = hexdec($hex);
   
    // maximum decimal value based on length of hex + 1:
    //   number of bits in hex number is 8 bits for each 2 hex -> max = 2^n
    //   use 'pow(2,n)' since '1 << n' is only for integers and therefore limited to integer size.
    $max = pow(2, 4 * (strlen($hex) + (strlen($hex) % 2)));
   
    // complement = maximum - converted hex:
    $_dec = $max - $dec;
   
    // if dec value is larger than its complement we have a negative value (first bit is set)
    return $dec > $_dec ? -$_dec : $dec;
}