Chas
5 November 2018 10:06
1
Hello
Is there a new syntax for {{ $value['msg'] }}
?
It stopped working a while back for me, i wonder if it is due to the new syntax scheme?
I used this a lot as it returns the most relevant syslog info, rather than {{ $value['string'] }}
which returns too much info.
I couldn’t find it in https://docs.librenms.org/Alerting/Templates/
Anyone know? Or does it work for you?
Thanks
laf
5 November 2018 20:04
2
That’s not changed, you need to loop through the fault array though but that’s been like that since day one/
Chas
5 November 2018 21:22
3
Great thanks i’ll double check what i’ve done
Chas
6 November 2018 10:44
4
I seem to be looping through the faults, but it only outputs the value[‘string’] and not the value[‘msg’]
Can you see anything wrong here?
Rule:
Template:
@if ($alert->state == 1)
<b>Timestamp: </b> {{ $alert->timestamp }} </br>
@else
<b> Duration: </b> {{ $alert->elapsed }} </br>
@endif
Rule: @if ($alert->name) {{ $alert->name }} @else {{ $alert->rule }} @endif </br>
@if ($alert->faults)
@foreach ($alert->faults as $key => $value)
{{ $value['string'] }} {{ $value['msg'] }}
@endforeach
@endif
Result:
Software changed on x.x.x.x
Timestamp: 2018-11-06 03:21:41
Rule: Software Update Two
sysObjectID = .1.3.6.1.4.1.9.1.1286; sysDescr = Cisco IOS Software, IOS-XE Software, Catalyst 4500 L3 Switch Software (cat4500es8-UNIVERSALK9-M), Version x.x.x RELEASE SOFTWARE (fc4)
Technical Support: http://www.cisco.com/techsupport
Copyright (c) 1986-2018 by Cisco Systems, Inc.
Compiled Thu; event_id = 28329682;
I believe the value[‘msg’] just used to pull out the eventlog line related to OS Version:
OS Version -> x.x.x RELEASE SOFTWARE
If i try to just use {{ $value['msg'] }}
it is blank.
Many Thanks
laf
6 November 2018 22:17
5
You’re using the wrong $value['msg']
. The valid values are the tables column names, I’ll leave you to figure that one out
Chas
7 November 2018 09:33
6
Thanks for the hint - I looked at the column names so i think it’s 'message'
for eventlog and 'msg'
for syslog, but i have to wait till the next software change now