Hi All,
I am trying to write some macros to define product vendors. We monitor large ammounts of network devices from different manufacturers. I want to be able to write rules in the rule constructer that can be easily read and provide this information to the alert.
I have tryed many combinations of macro syntax in config.php. They appear correct and apache starts correctly. However when I try to use them in rules they don’t work when used with the macros.device_down.
I have tryed to copy the syntax from the Docs page and searched for examples in the forums.
An example of the first macro i tried;
//Juniper
$config['alert']['macros']['rule']['vendor_juniper'] = 'devices.os LIKE "%junos%" AND
(devices.sysObjectID LIKE ".1.3.6.1.4.1.2636.%" OR devices.sysObjectID LIKE
".1.3.6.1.4.1.12532.%")';
I then created the following rule
When I run the rule against a device a get a SQL Syntax error
SQL Error! SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '" AND (devices," OR devices WHERE (devices.device_id = ?) AND (devices.status = ' at line 1 (SQL: SELECT * FROM devices," AND (devices," OR devices WHERE (devices.device_id = 10) AND (devices.status = 0 && (devices.disabled = 0 && devices.ignore = 0)) = 1 AND (devices.os LIKE "%junos" AND (devices.sysObjectID LIKE ".1.3.6.1.4.1.2636." OR devices.sysObjectID LIKE ".1.3.6.1.4.1.12532.%")) = 1) (SQL: SELECT * FROM devices," AND (devices," OR devices WHERE (devices.device_id = 10) AND (devices.status = 0 && (devices.disabled = 0 && devices.ignore = 0)) = 1 AND (devices.os LIKE "%junos" AND (devices.sysObjectID LIKE ".1.3.6.1.4.1.2636." OR devices.sysObjectID LIKE ".1.3.6.1.4.1.12532.%")) = 1)
/opt/librenms/html/includes/output/query.inc.php:50
/opt/librenms/html/ajax_output.php:35
If I look at the SQL generated by the rule it has this odd section where the SQL query isn’t formatted correctly and not how I thought the rule builder logic is laid out. Specifically the ," after devices.
SELECT * FROM devices," AND (devices," OR devices WHERE
I have tryed quite a few different combinations but all result in the same issue when the 2 macros are joined together.
Can anyone help with what I am doing worng please?
Duncan