Missing get_real_interface() function in interfaces.inc after upgrade to 24.1

Started by db9, February 01, 2024, 01:49:30 PM

Previous topic - Next topic
I am using the Grafana OPNsense dashboard from bsmithio that stopped working after upgrading to 24.1

One of the custom (Telegraf) scripts (telegraf_pfifgw.php) does not work because it cannot find the function get_interfaces_info() in the php file functions.inc

Is this function (and others?) removed in version 24.1 and wich function in interfaces.inc does replace this functionality 1 to 1?

Thanks in advance

It really depends what sort of information that script wanted to extract. get_interfaces_info() was ancient cruft mashing together multiple sourced of (readily available) information, such as:

# pluginctl -D

or

# pluginctl -I


Cheers,
Franco

I fixed the script temporary fixed by copying the get_interfaces_info() ifunction from interfaces.inc (OPNsense 23.7.12_5-amd64) to the custom script. Up to the script owner to change it to work with the new 24.1 functions.

--------------

<?php
require_once("config.inc");
require_once("interfaces.inc");
require_once("plugins.inc.d/dpinger.inc");
require_once("util.inc");

# Added function get_interface_info. Function was removed from interfaces.in in OPNsense version 24.1
function get_interfaces_info($include_unlinked = false)
{
    global $config;
    ....
 

> I fixed the script temporary fixed by copying the get_real_interface() function from interfaces.inc

Sorry I don't quite understand.

get_real_interface() is still there and works.

get_interfaces_info() is not.


Cheers,
Franco

Sory Franco, my fault.

I mean get_interfaces_info() and I have corrected my previous reaction.

Thank for all the good (OPNsense) work. Great product.


Sorry for hijacking this thread but I ran into the same situation.
I tried the solution from Github but I still get this error message in OPNsense https://github.com/bsmithio/OPNsense-Dashboard/issues/57
Quote#0 {main}
  thrown in /usr/local/bin/telegraf_pfifgw.php on line 13
[17-Mar-2024 10:34:40 Europe/Berlin] PHP Fatal error:  Uncaught Error: Call to undefined function get_interfaces_info() in /usr/local/bin/telegraf_pfifgw.php:13

This is the beginning of the code
#!/usr/local/bin/php-cgi -f
<?phprequire_once("config.inc");require_once("interfaces.inc");require_once("plugins.inc.d/dpinger.inc");require_once("util.inc");# Added function get_interface_info. Function was removed from interface.in in OPNsense version 24.1function get_interfaces_info($include_unlinked = false){    global $config;    $all_intf_details = legacy_interfaces_details();    $all_intf_stats = legacy_interface_stats();    $gateways = new \OPNsense\Routing\Gateways();    $ifup = legacy_interface_listget('up');    $result = [];    $interfaces = legacy_config_get_interfaces(['virtual' => false]);    $known_interfaces = [];    foreach (array_keys($interfaces) as $ifdescr) {        $interfaces[$ifdescr]['if'] = get_real_interface($ifdescr);        if (!empty($interfaces[$ifdescr]['if'])) {            $known_interfaces[] = $interfaces[$ifdescr]['if'];        }        $interfaces[$ifdescr]['ifv6'] = get_real_interface($ifdescr, 'inet6');        if (!empty($interfaces[$ifdescr]['ifv6'])) {            $known_interfaces[] = $interfaces[$ifdescr]['ifv6'];

I don't know what I missed and why there is still an error.....

When comparing the original file and the file from Github, there are a lot more lines between the #Added function and the original compared to the solution mentions in this thread. Could some of you maybe explain?


Maintainers of external code should fix their code or users need to keep using known good version.

These are two easy ways out.

Unfortunately for us progressing the code base is a slow grind and removal of functions like this take a lot of preparation and thought and are for the better in the grand scheme of things...


Cheers,
Franco