New Alert no Email being sent

I created a new alert and it is not emailing out when triggered. I have alerts that are working properly and sending emails. I then tested with the reboot rule from the collection. The original reboot rule I had sent and email but the new reboot rule did not. Under Alerts - Notifications, it shows the alert being triggered.

When I run the test-alert script the email gets sent out. But with the debug it shows the following.

Attempting to email Device test.localhost recovered from Device rebooted to: [email protected]
OKSQL[SELECT devices.*, location, lat, lng FROM devices LEFT JOIN locations ON devices.location_id=locations.id WHERE device_id = ? [1245] 0.66ms]

SQL[SELECT * FROM devices_attribs WHERE device_id = ? [1245] 0.5ms]

SQL[SELECT * FROM vrf_lite_cisco WHERE device_id = ? [1245] 0.43ms]

SQL[INSERT IGNORE INTO eventlog (device_id,reference,type,datetime,severity,message,username) VALUES (:device_id,:reference,:type,:datetime,:severity,:message,:username) {“device_id”:1245,“reference”:null,“type”:“alert”,“datetime”:“2019-03-12 09:40:58”,“severity”:1,“message”:“Issued recovery for rule ‘Device rebooted’ to transport ‘mail’”,“username”:""} 1.6ms]

:: Transport mail => Attempting to email Device test.localhost recovered from Device rebooted to: email.email.com; 0
ERROR: Invalid address: (to): 0
SQL[INSERT IGNORE INTO eventlog (device_id,reference,type,datetime,severity,message,username) VALUES (:device_id,:reference,:type,:datetime,:severity,:message,:username) {“device_id”:1245,“reference”:null,“type”:“error”,“datetime”:“2019-03-12 09:40:58”,“severity”:5,“message”:“Could not issue recovery for rule ‘Device rebooted’ to transport ‘mail’ Error: Invalid address: (to): 0”,“username”:""} 0.76ms]

Thats why is not sending

Where is the email to correct this located? Under transport it has the correct email addresses. And for the other alerts I am getting emails using the same settings.

Seems is trying to send the email to email.email.com and to 0

default contact or syscontact maybe?

I replaced my email with email.email.com sorry. My default is working along with the test transports on the transport emails. Its weird because the old rules created a year ago work fine

Here are my settings. Test Transport works. Also seeing a Notification was triggered.

I am getting this error when I run the test-template script

Rule: test Device rebooted
Faults:

Warning: Invalid argument supplied for foreach() in /opt/librenms/storage/framework/views/18be87097a24012c62b0a755dae97684 on line 19

Warning: Use of undefined constant mail - assumed ‘mail’ (this will throw an Error in a future version of PHP) in /opt/librenms/storage/framework/views/18be87097a24012c62b0a755dae97684 on line 41
http://localhost/device/device=localhost

Can yo post your template?

{{ $alert->title }}

Device Name: {{ $alert->sysName }}

IP Address: {{ $alert->hostname }}

Severity: {{ $alert->severity }}

@if ($alert->state == 0) Time elapsed: {{ $alert->elapsed }} @endif
Timestamp: {{ $alert->timestamp }}
Unique-ID: {{ $alert->uid }}
Rule: @if ($alert->name) {{ $alert->name }} @else {{ $alert->rule }} @endif
@if ($alert->faults) Faults:
@foreach ($alert->faults as $key => $value)
#{{ $key }}: {{ $value[‘string’] }}
Port: {{ $value[‘ifName’] }}
Port Name: {{ $value[‘ifAlias’] }}
Port Status: {{ $value[‘message’] }}
Port Description: {{ $value[‘ifDescr’] }}
Port Speed: {{ $value[‘ifHighSpeed’] }}
Current Speed: {{ $value[‘ifInOctets_rate’] }}

In: @php echo ($value[‘ifInOctets_rate’]*8/1000000); @endphp Mbps
Out: @php echo ($value[‘ifOutOctets_rate’]*8/1000000); @endphp Mbps
@endforeach
@endif

@if ($alert->transport == mail) http://(ipaddress)/device/device={{ $alert->hostname }} @else {{ $alert->hostname }} @endif

Why you used {{ $value[‘message’] }} instead {{ $value[‘ifOperStatus’] }} ?

Will change. Thank You.

Still no alerts from new Alert Rules

When checking the Alert Log.
Issuing Alert-UID #206135/1:
:: Transport mail => OK
:: Transport mail => OK

In alerts.inc.php line 160:

Call to a member function isUnderMaintenance() on null

Start: Fri, 15 Mar 2019 14:53:01 -1000
ClearStaleAlerts():
RunFollowUp():
RunAlerts():

In alerts.inc.php line 160:

Call to a member function isUnderMaintenance() on null

When i test Template. Am I supposed to get an email?
./test-template.php -t 20 -h 172.31.127.34 -r 59 -p mail -d

====================================

Component Version
LibreNMS 1.49-59-g907579d
DB Schema 2019_02_10_220000_add_dates_to_fdb (132)
PHP 7.2.14
MySQL 5.5.60-MariaDB
RRDTool 1.4.8
SNMP NET-SNMP 5.7.2

====================================

I did a little more testing. I had some rules from before that were turned off and not being used. I copied the statements from the newer ones. And it started emailing out. But for some reason whenever I create a new rule it does not send out emails. Is there a limit on rules?

There is no limit for number of rules.

You need quotes around the word mail like "mail", otherwise php thinks you are trying to reference a constant.

The docs need this updated. Please can you? I don’t want to create a new clone and pull just to add quotes around mail
It’s here: https://docs.librenms.org/Alerting/Templates/#advanced-options
https://github.com/librenms/librenms/blob/master/doc//Alerting/Templates.md

1 Like

Hi you can edit the the docs by clicking on the edit button on the top and submit changes. Help like this keeps librenms going. It’s all by volunteers.

2 Likes