From ab0fc39a4051a0cd3ebb2a72a4a2771b660100d7 Mon Sep 17 00:00:00 2001 From: Ad Schellevis Date: Sun, 20 Oct 2024 17:24:34 +0200 Subject: [PATCH] interfaces - parse part of sfp module information in legacy_interfaces_details(), adds 'module temperature' and 'lane X' information as well. `ifconfig` passes the information from `sfp.c` [1], which is has a fixed structure we can parse on our end. [1] https://github.com/opnsense/src/blob/6fbe7e4dd14df84674352c0cc77e8e74a0296563/sbin/ifconfig/sfp.c#L75-L76 --- src/etc/inc/interfaces.lib.inc | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/etc/inc/interfaces.lib.inc b/src/etc/inc/interfaces.lib.inc index 3832c7be6..93b90997f 100644 --- a/src/etc/inc/interfaces.lib.inc +++ b/src/etc/inc/interfaces.lib.inc @@ -409,6 +409,18 @@ function legacy_interfaces_details($intf = null) $result[$current_interface]['sfp']['part_number'] = $matches[2]; $result[$current_interface]['sfp']['serial_number'] = $matches[3]; $result[$current_interface]['sfp']['manufacturing_date'] = $matches[4]; + } elseif ( + isset($result[$current_interface]['sfp']) && + preg_match("/module temperature:\s+(.*)\s+voltage:\s+(.*)Volts/", $line, $matches) + ) { + $result[$current_interface]['sfp']['temperature'] = $matches[1]; + $result[$current_interface]['sfp']['voltage'] = $matches[2]; + } elseif ( + isset($result[$current_interface]['sfp']) && + preg_match("/lane\s+(.*):\s+RX power:\s+(.*)\s+TX bias:\s+(.*)/", $line, $matches) + ) { + $result[$current_interface]['sfp'][sprintf('lane_%s_rx_power', $matches[1])] = $matches[2]; + $result[$current_interface]['sfp'][sprintf('lane_%s_tx_bias', $matches[1])] = $matches[3]; } elseif (preg_match("/status: (.*)$/", $line, $matches)) { $result[$current_interface]['status'] = $matches[1]; } elseif (preg_match("/channel (\S*)/", $line, $matches)) {