After searchingon docs / forum / google.
Can not find a nice template example for nagios service notification.
The use of
@foreach ($alert->faults as $key => $value) @endforeach
Does not provides nothing.
Currently I have multiple nagios services forced to be on critical state assigned to localhost device.
Created an alert rule using the Service up/down rule (included in collection) and assign telegram transport.
Notifications are being sent ok.
But … can not create a nice template.
Following template documentation can not get specific info for each critical state service.
BTW:
1_Using API can check sevice id , state ,etc , so I think it should be possible to add this info on template.
2_I can succesfully create my personal templates with regular snmp alarms.
regards,
Leandro.
Ok … just to update my status:
so far, I have following template:
ALERT: {{ $alert->name}}
Severity: {{ $alert->severity }}
Estado: {{ $alert->state}}
ID: {{ $alert->id}}
UID: {{ $alert->uid}}
rule: {{ $alert->rule }}
Timestamp: {{ $alert->timestamp }}
Time elapsed: {{ $alert->elapsed }}
According to this and %services.service_status , describe at template documentation.
I will need to create a warning and critical alert rule and warning and critical template per service.
This does not sounds good to me … I need to monitor more than 15 hosts.
Hope to find more suitable solution,
Regards,
Leandro.
I don’t know how well this would fit in your environment, but I have a single alert template to cover both warning and critical service alerts. The template below plus the two alert rules works fine for the 20+ monitored services.
HTH
Severity: {{ $alert->severity }}
Rule: @if ($alert->name)
{{ $alert->name }}
@else
{{ $alert->rule }}
@endif
@if ($alert->state == 0)
Time elapsed: {{ $alert->elapsed }}
@endif
Timestamp: {{ $alert->timestamp }}
Unique-ID: {{ $alert->uid }}
@if ($alert->faults)
Faults:
@foreach ($alert->faults as $key => $value)
#{{ $key }}: Service: {{ $value['service_ip'] }}
Description: {{ $value['service_desc'] }}
Message: {{ $value['service_message'] }}
@endforeach
@endif
1 Like
Dear Alan , your template was very helpfull.
Thankyou very much.
btw: Do you know if is it possible to print all the $alarm object ? just for debugin propose.
Regards,
Leandro.
Your best bet is to use the built-in test-template.php (see https://docs.librenms.org/Alerting/Testing/). This will dump everything including the entire contents of the faults array to the command line so you can see what is available e.g. (severely cropped for brevity):
/opt/librenms/scripts/test-template.php -t 12 -d -h localhost -r 8
[faults] => Array
(
[1] => Array
(
[device_id] => 1
[hostname] => localhost
.....
[service_id] => 17
[service_ip] => www.blah.com
[service_type] => http
[service_desc] => check_http: HTTPS request check for external connectivity.
[service_param] => -S
[service_ignore] => 0
[service_status] => 2
[service_changed] => 1570347014
[service_message] => CRITICAL - Socket timeout after 10 seconds
etc....
Alan
Dint know about this script.-
Thanks again.
Please consider writting to me if I can give you back some help.
Leandro.
1 Like