How to display or pass the $alert->faults values

I am trying to utilize the information from snmptrap ‘message’ field to display and pass the values.
But other than Alert Template standard processing method, these values are not getting substituted even for Alert Template’s, Alert title or Recovery.

image
image
900×758 20.8 KB
If these values can be display or passed, then how can we send them through API.

/opt/librenms $ ./validate.php

Component Version
LibreNMS 25.7.0 (2025-07-24T15:04:52+00:00)
DB Schema 2025_07_29_025425_hr_device_table_add_type_default (351)
PHP 8.3.23
Python 3.12.11
Database MariaDB 10.11.14-MariaDB-ubu2204
RRDTool 1.9.0
SNMP 5.9.4
===========================================
[OK] Installed from the official Docker image; no Composer required
[OK] Database Connected
[OK] Database Schema is current
[OK] SQL Server meets minimum requirements
[OK] lower_case_table_names is enabled
[OK] MySQL engine is optimal
[OK] Database and column collations are correct
[OK] Database schema correct
[OK] MySQL and PHP time match
[OK] Distributed Polling setting is enabled globally
[OK] Connected to rrdcached
[OK] Active pollers found
[OK] Dispatcher Service is enabled
[OK] Locks are functional
[OK] No python wrapper pollers found
[OK] Redis is functional
[OK] rrdtool version ok
[OK] Connected to rrdcached
[WARN] Updates are managed through the official Docker image

When asking for help and support, please provide as much information as possible. This should include:

  • Steps to reproduce an issue.
  • The output of ./validate.php

If it’s an issue with the WebUI then please consider including a screenshot and the browser version you are using.

If you are having troubles with discovery/polling include the pastebin output of:

./discovery.php -h HOSTNAME -d | curl --data-binary @- https://paste.rs/
./poller.php -h HOSTNAME -r -f -d | curl --data-binary @- https://paste.rs/

If you need to post any text longer than a few lines, please use a “pastebin” service, we recommend using https://paste.rs/ or https://paste.sh/

Not sure where you got those values from but they aren’t what you need to use. Basically the syslog table should be available to you:

image

You can use those.

As for the subject, it’s hard to use items from $alert→faults array as you would have to technically loop through the array like you do in the template, that gets messy. You can however access say the first item in the array like $alert→fault[0]

Hi Iaf,

Thanks for you inputs.

Above values we are getting using the sql from Alert Rules

SELECT
t.device_id,
MAX(t.datetime) AS datetime,
t.node_name,
t.alarm_type,
t.source_type,
t.severity,
t.probable_cause
FROM (
SELECT
el.device_id,
el.datetime,
REGEXP_REPLACE(
el.message,
‘(?s).ASMAX-NETSPAN-MIB::asxNmsAlarm2NodeName":“([^”])“.',
‘\1’
) AS node_name,
REGEXP_REPLACE(
el.message,
'(?s).ASMAX-NETSPAN-MIB::asxNmsAlarm2Type":“([^”]
)”.’,
‘\1’
) AS alarm_type,
REGEXP_REPLACE(
el.message,
‘(?s).ASMAX-NETSPAN-MIB::asxNmsAlarm2SourceType":“([^”])“.',
‘\1’
) AS source_type,
REGEXP_REPLACE(
el.message,
'(?s).ASMAX-NETSPAN-MIB::asxNmsAlarm2Severity":“([^”]
)”.’,
‘\1’
) AS severity,
REGEXP_REPLACE(
el.message,
‘(?s).ASMAX-NETSPAN-MIB::asxNmsAlarm2ProbableCause":“([^”])“.*’,
‘\1’
) AS probable_cause
FROM
librenms.eventlog AS el
WHERE
el.device_id = ?
AND el.type = “trap”
AND el.datetime >= DATE_SUB(NOW(), INTERVAL 1 HOUR)
AND el.message REGEXP ‘ASMAX-NETSPAN-MIB::asxNmsAlarm7Trap’
AND el.message REGEXP ‘ASMAX-NETSPAN-MIB::asxNmsAlarm2Severity”:“major”,’
ORDER BY
el.datetime DESC
) As t
GROUP BY
t.node_name
ORDER BY
datetime DESC;

Basically, what we are trying to achieve here is the EMS system which sends traps for our different sites the hostname always comes as the EMS hostname and the site name is incorporated in the ‘message’ body so, we are trying to extract that site name and pass is to alert/ticketing system in that way we can at least display the correct site name.

Probably best of doing:

@php
var_dump($alert->faults);
@endphp

In your template and run the cli command ./scripts/test-template.php

See what’s actually in the array

This is output for the var_dump

array(1) { [1]=> array(8) { [“device_id”]=> int(4) [“datetime”]=> string(19) “2025-11-20 20:15:38” [“node_name”]=> string(11) “test4-node4” [“alarm_type”]=> string(31) “RU Antenna Tilt Permanent Shift” [“source_type”]=> string(5) “gnbRu” [“severity”]=> string(5) “major” [“probable_cause”]=> string(12) “Test Trigger” [“string”]=> NULL } }

It looks like you do have what you need in that then. The only way for me to debug this is if you provide an example syslog entry from the DB and your template in text format.

Hi IaF,

Template code:-

@foreach ($alert->faults as $key => $value)

HostName: {{ $value[‘node_name’] }}
AlarmType: {{ $value[‘alarm_type’] }}
SourceType: {{ $value[‘source_type’] }}
Severity: {{ $value[‘severity’] }}
ProbableCause: {{ $value[‘probable_cause’] }}

@endforeach

But syslog table is showing 0 data.

MariaDB [librenms]> SELECT count(*) from syslog;
±---------+
| count(
) |
±---------+
| 0 |
±---------+
1 row in set (0.000 sec)

As I am testing with SNMPTRAP, I can provide the sample trap but this require Airspan MIB’s

snmptrap -v 2c -c public ‘’ ASMAX-NETSPAN-MIB::asxNmsAlarm7Trap ASMAX-NETSPAN-MIB::asxNmsAlarm2Type s “RU Antenna Tilt Permanent Shift” ASMAX-NETSPAN-MIB::asxNmsAlarm2Severity i 4 ASMAX-NETSPAN-MIB::asxNmsAlarm2NodeName s “test4-node4” ASMAX-NETSPAN-MIB::asxNmsAlarm2SourceId s “test-source” ASMAX-NETSPAN-MIB::asxNmsAlarm2ProbableCause s “Test Trigger” ASMAX-NETSPAN-MIB::asxNmsAlarm2SourceType i “gnbRu”

Please provide one of the entries from the syslog table.

Hi Iaf,

I don’t see a single entry in both our Lab and Prod libre for syslog table.

Not sure about the exact reason. Any input.

I am pasting some entry from eventlog table as snmptrap data is getting reported.

Aveek

[Timestamp](javascript:void(0):wink: [Type](javascript:void(0):wink: [Hostname](javascript:void(0):wink: [Message](javascript:void(0):wink: [User](javascript:void(0):wink:
2025-11-20 13:15:38 trap eobrmfcopod03.baengr.gogoair.com ASMAX-NETSPAN-MIB::asxNmsAlarm7Trap {“DISMAN-EVENT-MIB::sysUpTimeInstance”:“84:16:56:23.60”,“ASMAX-NETSPAN-MIB::asxNmsAlarm2Type”:“RU Antenna Tilt Permanent Shift”,“ASMAX-NETSPAN-MIB::asxNmsAlarm2Severity”:“major”,“ASMAX-NETSPAN-MIB::asxNmsAlarm2NodeName”:“test4-node4”,“ASMAX-NETSPAN-MIB::asxNmsAlarm2SourceId”:“test-source”,“ASMAX-NETSPAN-MIB::asxNmsAlarm2ProbableCause”:“Test Trigger”,“ASMAX-NETSPAN-MIB::asxNmsAlarm2SourceType”:“gnbRu”} System
2025-11-20 12:02:39 trap eobrmfcopod03.baengr.gogoair.com ASMAX-NETSPAN-MIB::asxNmsAlarm7Trap {“DISMAN-EVENT-MIB::sysUpTimeInstance”:“84:15:43:24.23”,“ASMAX-NETSPAN-MIB::asxNmsAlarm2Type”:“RU Antenna Tilt Permanent Shift”,“ASMAX-NETSPAN-MIB::asxNmsAlarm2Severity”:“major”,“ASMAX-NETSPAN-MIB::asxNmsAlarm2NodeName”:“test4-node3”,“ASMAX-NETSPAN-MIB::asxNmsAlarm2SourceId”:“test-source”,“ASMAX-NETSPAN-MIB::asxNmsAlarm2ProbableCause”:“Test Trigger”,“ASMAX-NETSPAN-MIB::asxNmsAlarm2SourceType”:“gnbRu”} System
2025-11-20 12:02:29 trap eobrmfcopod03.baengr.gogoair.com ASMAX-NETSPAN-MIB::asxNmsAlarm7Trap {“DISMAN-EVENT-MIB::sysUpTimeInstance”:“84:15:43:14.27”,“ASMAX-NETSPAN-MIB::asxNmsAlarm2Type”:“RU Antenna Tilt Permanent Shift”,“ASMAX-NETSPAN-MIB::asxNmsAlarm2Severity”:“major”,“ASMAX-NETSPAN-MIB::asxNmsAlarm2NodeName”:“test4-node2”,“ASMAX-NETSPAN-MIB::asxNmsAlarm2SourceId”:“test-source”,“ASMAX-NETSPAN-MIB::asxNmsAlarm2ProbableCause”:“Test Trigger”,“ASMAX-NETSPAN-MIB::asxNmsAlarm2SourceType”:“gnbRu”} System
2025-11-20 12:02:20 trap eobrmfcopod03.baengr.gogoair.com ASMAX-NETSPAN-MIB::asxNmsAlarm7Trap {“DISMAN-EVENT-MIB::sysUpTimeInstance”:“84:15:43:05.18”,“ASMAX-NETSPAN-MIB::asxNmsAlarm2Type”:“RU Antenna Tilt Permanent Shift”,“ASMAX-NETSPAN-MIB::asxNmsAlarm2Severity”:“major”,“ASMAX-NETSPAN-MIB::asxNmsAlarm2NodeName”:“test4-node1”,“ASMAX-NETSPAN-MIB::asxNmsAlarm2SourceId”:“test-source”,“ASMAX-NETSPAN-MIB::asxNmsAlarm2ProbableCause”:“Test Trigger”,“ASMAX-NETSPAN-MIB::asxNmsAlarm2SourceType”:“gnbRu”} System
2025-11-19 14:38:21 trap eobrmfcopod03.baengr.gogoair.com ASMAX-NETSPAN-MIB::asxNmsAlarm7Trap {“DISMAN-EVENT-MIB::sysUpTimeInstance”:“83:18:19:06.05”,“ASMAX-NETSPAN-MIB::asxNmsAlarm2Type”:“RU Antenna Tilt Permanent Shift”,“ASMAX-NETSPAN-MIB::asxNmsAlarm2Severity”:“major”,“ASMAX-NETSPAN-MIB::asxNmsAlarm2NodeName”:“test3-node9”,“ASMAX-NETSPAN-MIB::asxNmsAlarm2SourceId”:“test-source”,“ASMAX-NETSPAN-MIB::asxNmsAlarm2ProbableCause”:“Test Trigger”,“ASMAX-NETSPAN-MIB::asxNmsAlarm2SourceType”:“gnbRu”} System
2025-11-19 14:33:22 trap eobrmfcopod03.baengr.gogoair.com ASMAX-NETSPAN-MIB::asxNmsAlarm7Trap {“DISMAN-EVENT-MIB::sysUpTimeInstance”:“83:18:14:06.99”,“ASMAX-NETSPAN-MIB::asxNmsAlarm2Type”:“RU Antenna Tilt Permanent Shift”,“ASMAX-NETSPAN-MIB::asxNmsAlarm2Severity”:“major”,“ASMAX-NETSPAN-MIB::asxNmsAlarm2NodeName”:“test3-node8”,“ASMAX-NETSPAN-MIB::asxNmsAlarm2SourceId”:“test-source”,“ASMAX-NETSPAN-MIB::asxNmsAlarm2ProbableCause”:“Test Trigger”,“ASMAX-NETSPAN-MIB::asxNmsAlarm2SourceType”:“gnbRu”} System
2025-11-19 14:02:02 trap eobrmfcopod03.baengr.gogoair.com ASMAX-NETSPAN-MIB::asxNmsAlarm7Trap {“DISMAN-EVENT-MIB::sysUpTimeInstance”:“83:17:42:47.62”,“ASMAX-NETSPAN-MIB::asxNmsAlarm2Type”:“RU Antenna Tilt Permanent Shift”,“ASMAX-NETSPAN-MIB::asxNmsAlarm2Severity”:“major”,“ASMAX-NETSPAN-MIB::asxNmsAlarm2NodeName”:“test3-node7”,“ASMAX-NETSPAN-MIB::asxNmsAlarm2SourceId”:“test-source”,“ASMAX-NETSPAN-MIB::asxNmsAlarm2ProbableCause”:“Test Trigger”,“ASMAX-NETSPAN-MIB::asxNmsAlarm2SourceType”:“gnbRu”} System
2025-11-18 14:21:31 trap eobrmfcopod03.baengr.gogoair.com ASMAX-NETSPAN-MIB::asxNmsAlarm7Trap {“DISMAN-EVENT-MIB::sysUpTimeInstance”:“82:18:02:16.62”,“ASMAX-NETSPAN-MIB::asxNmsAlarm2Type”:“RU Antenna Tilt Permanent Shift”,“ASMAX-NETSPAN-MIB::asxNmsAlarm2Severity”:“major”,“ASMAX-NETSPAN-MIB::asxNmsAlarm2NodeName”:“test3-node6”,“ASMAX-NETSPAN-MIB::asxNmsAlarm2SourceId”:“test-source”,“ASMAX-NETSPAN-MIB::asxNmsAlarm2ProbableCause”:“Test Trigger”,“ASMAX-NETSPAN-MIB::asxNmsAlarm2SourceType”:“gnbRu”} System
2025-11-18 14:18:59 trap eobrmfcopod03.baengr.gogoair.com ASMAX-NETSPAN-MIB::asxNmsAlarm7Trap {“DISMAN-EVENT-MIB::sysUpTimeInstance”:“82:17:59:44.18”,“ASMAX-NETSPAN-MIB::asxNmsAlarm2Type”:“RU Antenna Tilt Permanent Shift”,“ASMAX-NETSPAN-MIB::asxNmsAlarm2Severity”:“major”,“ASMAX-NETSPAN-MIB::asxNmsAlarm2NodeName”:“test3-node5”,“ASMAX-NETSPAN-MIB::asxNmsAlarm2SourceId”:“test-source”,“ASMAX-NETSPAN-MIB::asxNmsAlarm2ProbableCause”:“Test Trigger”,“ASMAX-NETSPAN-MIB::asxNmsAlarm2SourceType”:“gnbRu”} System
2025-11-18 14:10:44 trap eobrmfcopod03.baengr.gogoair.com ASMAX-NETSPAN-MIB::asxNmsAlarm7Trap {“DISMAN-EVENT-MIB::sysUpTimeInstance”:“82:17:51:29.66”,“ASMAX-NETSPAN-MIB::asxNmsAlarm2Type”:“RU Antenna Tilt Permanent Shift”,“ASMAX-NETSPAN-MIB::asxNmsAlarm2Severity”:“major”,“ASMAX-NETSPAN-MIB::asxNmsAlarm2NodeName”:“test3-node4”,“ASMAX-NETSPAN-MIB::asxNmsAlarm2SourceId”:“test-source”,“ASMAX-NETSPAN-MIB::asxNmsAlarm2ProbableCause”:“Test Trigger”,“ASMAX-NETSPAN-MIB::asxNmsAlarm2SourceType”:“gnbRu”} System
2025-11-18 13:29:07 trap eobrmfcopod03.baengr.gogoair.com ASMAX-NETSPAN-MIB::asxNmsAlarm7Trap {“DISMAN-EVENT-MIB::sysUpTimeInstance”:“82:17:09:52.30”,“ASMAX-NETSPAN-MIB::asxNmsAlarm2Type”:“RU Antenna Tilt Permanent Shift”,“ASMAX-NETSPAN-MIB::asxNmsAlarm2Severity”:“major”,“ASMAX-NETSPAN-MIB::asxNmsAlarm2NodeName”:“test3-node3”,“ASMAX-NETSPAN-MIB::asxNmsAlarm2SourceId”:“test-source”,“ASMAX-NETSPAN-MIB::asxNmsAlarm2ProbableCause”:“Test Trigger”,“ASMAX-NETSPAN-MIB::asxNmsAlarm2SourceType”:“gnbRu”} System

Any input will be appreciated.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.