Custom Interface parsing is not updating the ports table

Hello,

For a while I’ve had an issue with interface parsing. I’ve written a custom interface parser and tested it successfully:

<?php

$str_teste = '\<CORE> descriptive/string/0/0 [10G] (NOTES GO HERE) {CIRCUIT GOES HERE}';

list(,$type, $descr)    = preg_split('/[\<\>\[]/', $str_teste);
list(,$circuit) = preg_split('/[\{\}]/', $str_teste);
list(,$notes)   = preg_split('/[\(\)]/', $str_teste);
list(,$speed)   = preg_split('/[\[\]]/', $str_teste);
$descr          = trim($descr);

echo "type: " . $type . "\</br>";
echo "descr: " . $descr . "\</br>";
echo "circuit: " . $circuit . "\</br>";
echo "speed: " . $speed . "\</br>";
echo "notes: " . $notes . "\</br>";

d_echo($port_ifAlias);

?>

This correctly outputs:

type: CORE</br>
descr: descriptive/string/0/0</br>
circuit: CIRCUIT GOES HERE</br>
speed: 10G</br>
notes: NOTES GO HERE</br>

My config.php contains the following line:

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

The file’s content is:

<?php


list(,$type, $descr)    = preg_split('/[\<\>\[]/', $str_teste);
list(,$circuit) = preg_split('/[\{\}]/', $str_teste);
list(,$notes)   = preg_split('/[\(\)]/', $str_teste);
list(,$speed)   = preg_split('/[\[\]]/', $str_teste);
$descr          = trim($descr);
echo "type: " . $type . "\</br>";
echo "descr: " . $descr . "\</br>";
echo "circuit: " . $circuit . "\</br>";
echo "speed: " . $speed . "\</br>";
echo "notes: " . $notes . "\</br>";
d_echo($port_ifAlias);

However for device 1, I can see that no parsing is being done, f I run the following query:

SELECT hostname, ifDescr, ifName, ifAlias, port_descr_type AS 'Type', port_descr_descr AS 'Description', port_descr_circuit AS 'Circuit', port_descr_speed AS 'Speed', port_descr_notes AS 'Notes' FROM ports, devices WHERE ports.device_id = devices.device_id AND devices.hostname LIKE '%erm-mse2%';

The snipped output is:

| devices.hostname | TenGigE0/0/0/3 | TenGigE0/0/0/3 | <CORE> text:Te2/1/0 [10G] (more text) | NULL | NULL | NULL | NULL | NULL |

Can anyone point me in the right direction for debugging this please?

Thank you

Hi,

First, i’ve edited your post for correct formatting. Instead of <code> tags use triple ```

In your parser, you are using $str_teste and that doesnt exists. Also, there are missing code that need to be there.

Take a look to the original parser and “copy&paste” just changing the type parser to be <> instead :

So, it will looks like this:

<?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']);
list(,$circuit)    = preg_split('/[\{\}]/', $this_port['ifAlias']);
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);

Thanks for the formatting corrections.

I guess I’m blind for not seeing that my parser was not actually doing anything.

I’ve corrected the parser file as you suggested, however, the interfaces descriptions are still not being parsed, and I can’t see anything being displayed on ports\customer or ports.

Do I need to take any aditional steps?

try running discovery/poller on that host, if nothing happens, do it with debug flag:
./poller.php -d -h host -m ports

I ran the command you suggested but still no luck.

I checked the output with the debug flag and only fields ‘ifDescr’, ‘ifName’, ‘ifAlias’, ‘ifType’ and ‘ifIndex’ are being updated.

Is there something else I can try?

Port descr parse is done in poller.

And it should log an event in your librenms when it changes.

Nevermind, solved it, I had misconfigured the parser! Thanks for the help.