Processor data filtering

(http://docs.librenms.org/Support/FAQ/#faq20).

I need to apply a regex over the processor data (similar to what can be done with “version_regex:”). The device processor data is as shown in the logs below.

I have tried different ways to apply a regex over the output data (last try was “value_regex:”) but none has worked.

SNMPBulkGet Processor data:

‘5 Secs ( 14.9172%) 60 Secs ( 14.8959%) 300 Secs ( 15.4585%)’

the value retrieved by the code is “5”
Is there a way to get the correct values? by now I need the 60 Secs value…

YAML discovery file:

processors:
    data:
        -
            oid: agentSwitchCpuProcessTotalUtilization
            value: agentSwitchCpuProcessTotalUtilization
            num_oid: '.1.3.6.1.4.1.4413.1.1.1.1.4.9.0'
            value_regex: '/([0-9][0-9].[0-9][0-9])/'

Logs:

YAML Discovery Data:

array (
‘data’ =>
array (
0 =>
array (
‘oid’ => ‘agentSwitchCpuProcessTotalUtilization’,
‘value’ => ‘agentSwitchCpuProcessTotalUtilization’,
‘num_oid’ => ‘.1.3.6.1.4.1.4413.1.1.1.1.4.9.0’,
‘value_regex’ => ‘/([0-9][0-9].[0-9][0-9])/’,
),
),
)

Data agentSwitchCpuProcessTotalUtilization:

array (
0 =>
array (
‘agentSwitchCpuProcessTotalUtilization’ => ‘5 Secs ( 14.9172%) 60 Secs ( 14.8959%) 300 Secs ( 15.4585%)’,
),
)

Discovered LibreNMS\Device\Processor Array
(
[processor_id] =>
[entPhysicalIndex] => 0
[hrDeviceIndex] => 0
[device_id] => 25
[processor_oid] => .1.3.6.1.4.1.4413.1.1.1.1.4.9.0
[processor_index] => 0
[processor_type] => datacom-dm1200e
[processor_usage] => 5
[processor_descr] => Processor
[processor_precision] => 1
[processor_perc_warn] => 75
)

SQL[SELECT * FROM processors WHERE device_id=? AND processor_index=? AND processor_type=? [25,“0”,“datacom-dm1200e”] 0.77ms]

Not entirely sure, as there are no existing examples of {field}_regex I can find in the codebase, but the version_regex examples use named capture groups, have you tried:

value_regex: '/(?<value>[0-9][0-9].[0-9][0-9])/'

Granted that would potentially capture only the first, or all 3 numbers. You’d probably have to placehold it a bit such as:

\).+(?<value>\d\d\.\d\d).+\(

Test it out with https://regex101.com/

Thanks for replying @rhinoau.

I think the main point is that apparently there is no way to apply a regex over the processor data. The the field “value_regex” I did not see it on documentation. I have just guessed trying “value_regex” because I saw the “version_regex” option on documentation and I have also tried “processor_regex”.

Anyway, in the following the results using the regex suggested (still get the number “5”):

Load disco module processors

Caching data: os processors
SNMP[’/usr/bin/snmpbulkwalk’ ‘-v2c’ ‘-c’ ‘COMMUNITY’ ‘-OteQUsa’ ‘-Ih’ ‘-m’ ‘FASTPATH-SWITCHING-MIB’ ‘-M’ ‘/opt/librenms/mibs:/opt/librenms/mibs/datacom-dm1200e:/opt/librenms/mibs/datacom’ ‘udp:HOSTNAME:161’ ‘agentSwitchCpuProcessTotalUtilization’]

agentSwitchCpuProcessTotalUtilization.0 = " 5 Secs ( 13.9476%) 60 Secs ( 14.8021%) 300 Secs ( 15.5146%)"

mempools

YAML Discovery Data:

array (
‘data’ =>
array (
0 =>
array (
‘oid’ => ‘agentSwitchCpuProcessTotalUtilization’,
‘value’ => ‘agentSwitchCpuProcessTotalUtilization’,
‘num_oid’ => ‘.1.3.6.1.4.1.4413.1.1.1.1.4.9.0’,
‘value_regex’ => ‘/(?[0-9][0-9].[0-9][0-9])/’,
),
),
)

Data agentSwitchCpuProcessTotalUtilization:

array (
0 =>
array (
‘agentSwitchCpuProcessTotalUtilization’ => ‘5 Secs ( 13.9476%) 60 Secs ( 14.8021%) 300 Secs ( 15.5146%)’,
),
)

Discovered LibreNMS\Device\Processor Array
(
[processor_id] =>
[entPhysicalIndex] => 0
[hrDeviceIndex] => 0
[device_id] => 25
[processor_oid] => .1.3.6.1.4.1.4413.1.1.1.1.4.9.0
[processor_index] => 0
[processor_type] => datacom-dm1200e
[processor_usage] => 5
[processor_descr] => Processor
[processor_precision] => 1
[processor_perc_warn] => 75
)

SQL[SELECT * FROM processors WHERE device_id=? AND processor_index=? AND processor_type=? [25,“0”,“datacom-dm1200e”] 0.71ms]

.
SQL[SELECT * FROM processors WHERE device_id=? AND processor_index=? AND processor_type=? [25,“0”,“datacom-dm1200e”] 0.36ms]

.
SQL[SELECT * FROM processors WHERE device_id=? AND processor_id NOT IN (?,?) [25,42,42] 0.4ms]

SQL[DELETE T FROM processors T LEFT JOIN devices ON devices.device_id = T.device_id WHERE devices.device_id IS NULL [] 0.31ms]

Right you are - I didn’t see the Feature Request category originally :confused:

There is code for this as it states for the OS discovery, but yes - all the other modules are different, guessing it needs to be handled around here:

The OS discovery ones look like this: