Interface separator types

Hello - trying to use custom separators with our network interface descriptions to categorize ports.

Here’s our current interface description setup:

acc__server1__eth0
bb__another router__xe-2/0/1

I’ve messed around a bit with custom port description parsing but can’t seem to get it to work properly. Here is my config:

<?php

// Parser should populate $port_ifAlias array with type, descr, circuit, speed and notes
unset($port_ifAlias);

echo $this_port['ifAlias'];

list($type,$descr) = preg_split('/[\_\_]/', $this_port['ifAlias']);
$descr             = trim($descr);

if ($type && $descr) {
    $type                    = strtolower($type);
    $port_ifAlias['type']    = $type;
    $port_ifAlias['descr']   = $descr;

    d_echo($port_ifAlias);
}

unset($port_type, $port_descr);

And here is the conf.php for custom stuff:

$config['customers_descr'] = 'acc';
$config['transit_descr'] = 'trn';
$config['core_descr'] = 'bb';

$config['port_descr_parser'] = "includes/custom/my-port-descr-parser.inc.php";

Any help here is greatly appreciated.
Thank you!

So I got this working. It appears that the issue was with my pgrep splitting. The following works fine for us now:


// Parser should populate $port_ifAlias array with type, descr, circuit, speed and notes
unset($port_ifAlias);

echo $this_port['ifAlias'];

list($type,$descr) = preg_split('/__/', $this_port['ifAlias']);
list(,$circuit)    = preg_split('/__/', $descr);
list(,$notes)      = preg_split('/[\(\)]/', $this_port['ifAlias']);
list(,$speed)      = preg_split('/[\[\]]/', $this_port['ifAlias']);
$descr             = trim($descr);

if ($type && $descr) {
    $type                    = strtolower($type);
    $port_ifAlias['type']    = $type;
    $port_ifAlias['descr']   = $descr;
    $port_ifAlias['circuit'] = $circuit;
    $port_ifAlias['speed']   = substr($speed, 0, 32);
    $port_ifAlias['notes']   = $notes;

    d_echo($port_ifAlias);
}

unset($port_type, $port_descr, $port_circuit, $port_notes, $port_speed);