Mail alerts SMTP

Hello, I configured librenms some weeks ago. Now I realize that my email alerts don’t work. My transport works (I can send the test mail from the webui), my rules work (I do get the alerts on the webui), I can reach my smtp server with telnet,…

When I use the script ./scrips/test-alerting.php, I don’t get errors.

./scripts/test-alert.php -r 5 -h 14 -d
SQL[SELECT alerts.id, alerts.alerted, alerts.device_id, alerts.rule_id, alerts.state, alerts.note, alerts.info FROM alerts WHERE alerts.device_id = 14 && alerts.rule_id = 5 0.34ms]

SQL[SELECT alert_log.id,alert_log.rule_id,alert_log.device_id,alert_log.state,alert_log.details,alert_log.time_logged,alert_rules.rule,alert_rules.severity,alert_rules.extra,alert_rules.name,alert_rules.query,alert_rules.builder,alert_rules.proc FROM alert_log,alert_rules WHERE alert_log.rule_id = alert_rules.id && alert_log.device_id = ? && alert_log.rule_id = ? && alert_rules.disabled = 0 ORDER BY alert_log.id DESC LIMIT 1 [14,5] 2.11ms]

SQL[SELECT DISTINCT a.* FROM alert_rules a
LEFT JOIN alert_device_map d ON a.id=d.rule_id AND (a.invert_map = 0 OR a.invert_map = 1 AND d.device_id = ?)
LEFT JOIN alert_group_map g ON a.id=g.rule_id AND (a.invert_map = 0 OR a.invert_map = 1 AND g.group_id IN (SELECT DISTINCT device_group_id FROM device_group_device WHERE device_id = ?))
LEFT JOIN alert_location_map l ON a.id=l.rule_id AND (a.invert_map = 0 OR a.invert_map = 1 AND l.location_id IN (SELECT DISTINCT location_id FROM devices WHERE device_id = ?))
LEFT JOIN devices ld ON l.location_id=ld.location_id AND ld.device_id = ?
LEFT JOIN device_group_device dg ON g.group_id=dg.device_group_id AND dg.device_id = ?
WHERE a.disabled = 0 AND (
(d.device_id IS NULL AND g.group_id IS NULL AND l.location_id IS NULL)
OR (a.invert_map = 0 AND (d.device_id=? OR dg.device_id=? OR ld.device_id=?))
OR (a.invert_map = 1 AND (d.device_id != ? OR d.device_id IS NULL) AND (dg.device_id != ? OR dg.device_id IS NULL) AND (ld.device_id != ? OR ld.device_id IS NULL))
) [14,14,14,14,14,14,14,14,14,14,14] 1.02ms]

SQL[select * from devices where device_id = ? limit 1 [14] 0.29ms]

SQL[select * from locations where locations.id = ? limit 1 [3] 0.19ms]

SQL[select * from devices_attribs where devices_attribs.device_id = ? and devices_attribs.device_id is not null [14] 0.22ms]

RRD[lastupdate /opt/librenms/rrd/DEVICE/icmp-perf.rrd ]
SQL[select * from alert_templates where exists (select * from alert_template_map where alert_templates.id = alert_template_map.alert_templates_id and alert_rule_id = ?) limit 1 [5] 0.47ms]

SQL[select * from alert_templates where name = ? limit 1 [“Default Alert Template”] 0.19ms]

SQL[SELECT alert_log.id,alert_log.time_logged,alert_log.details FROM alert_log WHERE alert_log.state != ? && alert_log.state != ? && alert_log.rule_id = ? && alert_log.device_id = ? && alert_log.id < ? ORDER BY id DESC LIMIT 1 [2,0,5,14,67536] 0.32ms]

SQL[UPDATE alert_log set details=? WHERE id = ? 0.19ms]

Reporting disabled by user setting
Issuing Alert-UID #67536/0:
SQL[SELECT rule_id FROM alerts WHERE id=? [161] 0.17ms]

SQL[SELECT b.transport_id, b.transport_type, b.transport_name FROM alert_transport_map AS a LEFT JOIN alert_transports AS b ON b.transport_id=a.transport_or_group_id WHERE a.target_type=‘single’ AND a.rule_id=? UNION DISTINCT SELECT d.transport_id, d.transport_type, d.transport_name FROM alert_transport_map AS a LEFT JOIN alert_transport_groups AS b ON a.transport_or_group_id=b.transport_group_id LEFT JOIN transport_group_transport AS c ON b.transport_group_id=c.transport_group_id LEFT JOIN alert_transports AS d ON c.transport_id=d.transport_id WHERE a.target_type=‘group’ AND a.rule_id=? [5,5] 0.33ms]

:: Transport mail => SQL[select * from alert_transports where alert_transports.transport_id = ? limit 1 [2] 0.18ms]

Attempting to email Device DEVICE recovered from Ping Latency to: [email protected]
OKSQL[insert into eventlog (reference, type, datetime, severity, message, username, device_id) values (?, ?, ?, ?, ?, ?, ?) [null,“alert”,“2024-08-26 14:39:38”,1,“Issued recovery for rule ‘Ping Latency’ to transport ‘mail’”,“”,14] 0.32ms]

:: Transport mail => SQL[select * from alert_transports where alert_transports.transport_id = ? limit 1 [3] 0.24ms]

Attempting to email Device DEVICE recovered from Ping Latency to: [email protected]
OKSQL[insert into eventlog (reference, type, datetime, severity, message, username, device_id) values (?, ?, ?, ?, ?, ?, ?) [null,“alert”,“2024-08-26 14:39:38”,1,“Issued recovery for rule ‘Ping Latency’ to transport ‘mail’”,“”,14] 0.18ms]

:: Transport mail => SQL[select * from alert_transports where alert_transports.transport_id = ? limit 1 [4] 0.18ms]

Attempting to email Device DEVICE recovered from Ping Latency to: [email protected]
OKSQL[insert into eventlog (reference, type, datetime, severity, message, username, device_id) values (?, ?, ?, ?, ?, ?, ?) [null,“alert”,“2024-08-26 14:39:38”,1,“Issued recovery for rule ‘Ping Latency’ to transport ‘mail’”,“”,14] 0.16ms]

When I use this test script, my tcpdump command (tcpdump -i any port 25 or port 465 or port 587 -vvv) finds nothing. The only special thing that I see myself is the following line: Reporting disabled by user setting. Could this be related to the problem?

Anyone an idea what the problem could be? I think it might be related to the rule triggering the transport, but in the test-alerting.php it seems like it does the trigger. Or does anyone have an idea where I can find the right logs?

What’s your mail transport config?

Hey laf, thanks for the answer.

This is the config of one of my three transports:

Thanks, and what about the mail config: /settings/alerting/email in the WebUI.

Do you mean these settings?

Of course the real IP address of our SMTP server is not 1.1.1.1, I just changed it to put it online.

And these are my other alert configs:

if the config is working …no error, and when “test email” send email is suceess/receive.
have u check “spam” or “junk” in email setting ?

Hey sham, thanks for joining the conversation!

I did a check, but my junk mailbox is empty. By the way, I’ve already done a tcpdump while I run the test-alerting.php script, and I couldn’t see the email leave my librenms server. When I try to test my transport individualy without the alert, I could see the email leaving, so I think my transport isn’t triggered correctly.

Hey laf

Excuse me for replying again, I’m a little bit desperate in finding a solution after searching around for almost a month now… :slight_smile:

Solution: no alert template used.

I thought there was already a default alert template, but I had to add it myself, en assign all my rules to it.

The default template (id 0) is used if no templates have been associated with the rules so unless you’ve deleted that from the database then it sounds like the issue is elsewhere and assigning a new template is just a work around.

Possible… I can’t see a default alert template in the overview with id 0, my overview starts with the new one I created today with id 1.

I can’t remember deleting the template, or even doing something with it, but my initial setup is already 8 months ago, so it is possible I did something wrong back then.

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