Alert problem

In librenms.log i have some error like this:

[2018-08-22 09:14:02] production.ERROR: Symfony\Component\Debug\Exception\FatalThrowableError: Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in /home/librenms/includes/alerts.inc.php(401) : eval()'d code:3
Stack trace:
#0 /home/librenms/LibreNMS/Alert/Template.php(174): RunJail('$ret .= "RECOVE...', Array)
#1 /home/librenms/LibreNMS/Alert/Template.php(65): LibreNMS\Alert\Template->legacyBody(Array)
#2 /home/librenms/includes/alerts.inc.php(856): LibreNMS\Alert\Template->getBody(Array)
#3 /home/librenms/includes/alerts.inc.php(605): ExtTransports(Array)
#4 /home/librenms/includes/alerts.inc.php(797): IssueAlert(Array)
#5 /home/librenms/alerts.php(48): RunAlerts()
#6 {main}  

It is a problem because some alert doesn’t send. When I test with scripts/test-alert.php and scripts/test-template.php I don’t have any problem. I convert all my template.

My validate.php is good:

root@mon3:/home/librenms# ./validate.php

Component Version
LibreNMS 1.42.01-63-ge448190a6
DB Schema 260
PHP 7.0.30-0+deb9u1
MySQL 10.1.26-MariaDB-0+deb9u1
RRDTool 1.6.0
SNMP NET-SNMP 5.7.3

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

[OK] Composer Version: 1.7.2
[OK] Dependencies up-to-date.
[OK] Database connection successful
[OK] Database schema correct
root@mon3:/home/librenms#

Somebody can help me ?

My template:

  • default template

{{ $alert->title }}
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: {{ $value[‘string’] }}
@foreach ($alert->faults as $key => $value) #{{ $key }}:
@endforeach @endif Alert sent to: @foreach ($alert->contacts as $key => $value){{ $value }} <{{ $key }}>
@endforeach

  • Service template

{{ $alert->title }}

Device Name: {{ $alert->hostname }}
Severity: {{ $alert->severity }}
Uptime: {{ $alert->uptime_short }}

Server: {{ $alert->sysName }}
Services: @if ($alert->faults)
@foreach ($alert->faults as $key => $value){{ $value[‘service_desc’] }} - {{ $value[‘service_type’] }}
{{ $value[‘service_message’] }}
@endforeach
@endif

  • sensor value template

{{ $alert->title }}

Device Name: {{ $alert->hostname }}
Severity: {{ $alert->severity }}
Timestamp: {{ $alert->timestamp }}
Uptime: {{ $alert->uptime_short }}
@if ($alert->state == 0) Time elapsed: {{ $alert->elapsed }} @endif
Location: {{ $alert->location }}
Description: {{ $alert->description }}
Features: {{ $alert->features }}
Purpose: {{ $alert->purpose }}
Notes: {{ $alert->notes }}

Rule: @if ($alert->name) {{ $alert->name }} @else {{ $alert->rule }} @endif
@if ($alert->faults) Faults:
@foreach ($alert->faults as $key => $value)
#{{ $key }}: Sensor {{ $value[‘sensor_current’] }}
** @php echo ($value[‘sensor_current’]-$value[‘sensor_limit’]); @endphp over limit
Previous Measurement: {{ $value[‘sensor_prev’] }}
Limit: {{ $value[‘sensor_limit’] }}
@endforeach
@endif

  • Storage template

{{ $alert->title }}


@foreach ($alert->faults as $key => $value)Mount Point: $value[‘storage_descr’] Percent Utilized: $value[‘storage_perc’]@endforeach


@if ($alert->state == 0) Time elapsed: {{ $alert->elapsed }} @endif
Timestamp: {{ $alert->timestamp }}
Unique-ID: {{ $alert->uid }}

  • BGP session>

{{ $alert->title }}\r\n
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’] }}
Peer: {{ $value[‘astext’] }}
Peer IP: {{ $value[‘bgpPeerIdentifier’] }}
Peer AS: {{ $value[‘bgpPeerRemoteAs’] }}
Peer EstTime: {{ $value[‘bgpPeerFsmEstablishedTime’] }}
Peer State: {{ $value[‘bgpPeerState’] }}
@endforeach
@endif

I would change the sensor value template as a test.

Try make it simple at first and take a backup of the template,

I think it might be related to this line @php echo ($value['sensor_current']-$value['sensor_limit']); @endphp
Delete that whole line and try change it to just {{ $value['sensor_current'] }} and
{{ $value['sensor_limit'] }}

There may be a small formatting error somewhere causing this error. If it continues, un-map your templates 1 by 1 to debug.

When i run alert.php -d I have :

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

SQL[SELECT count(*) from device_relationships WHERE child_device_id = ? [1] 0.61ms]

SQL[SELECT attrib_value FROM devices_attribs WHERE attrib_type = “disable_notify” && device_id = ? [1] 0.59ms]

SQL[SELECT hostname, sysName, sysDescr, sysContact, os, type, ip, hardware, version, location, purpose, notes, uptime FROM devices WHERE device_id = ? [1] 0.61ms]

SQL[SELECT * FROM devices_attribs WHERE device_id = ? [1] 0.61ms]

SQL[SELECT timestamp, loss, min, max, avg FROM device_perf WHERE device_id = ? ORDER BY timestamp LIMIT 1 [1] 7.84ms]

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 [16] 0.94ms]

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

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

Issuing Alert-UID #5443/0: SQL[SELECT rule_id FROM alerts WHERE id=? [165] 0.53ms]

SQL[SELECT b.transport_id, b.transport_type 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 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=? [16,16] 1.04ms]

Symfony\Component\Debug\Exception\FatalThrowableError: Parse error: syntax error, unexpected ‘’ (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in /home/librenms/includes/alerts.inc.php(403) : eval()‘d code:3
Stack trace:
#0 /home/librenms/LibreNMS/Alert/Template.php(174): RunJail(’$ret .= "RECOVE…', Array)
#1 /home/librenms/LibreNMS/Alert/Template.php(65): LibreNMS\Alert\Template->legacyBody(Array)
#2 /home/librenms/includes/alerts.inc.php(862): LibreNMS\Alert\Template->getBody(Array)
#3 /home/librenms/includes/alerts.inc.php(609): ExtTransports(Array)
#4 /home/librenms/includes/alerts.inc.php(803): IssueAlert(Array)
#5 /home/librenms/alerts.php(48): RunAlerts()
#6 {main}

In alerts.inc.php(403) : eval()'d code line 3:

Parse error: syntax error, unexpected ‘’ (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING)

@Cormoran please hope you good. Please I need your help? ASAP.