Macros are shorthands to either portion of rules or pure SQL enhanced with placeholders.
You can define your own macros in your
Example macro-implementation of Debian-Devices
$config['alert']['macros']['rule']['is_debian'] = 'devices.features ~ "@[email protected]"';
And in the Rule:
... macros.is_debian = 1 ...
This Example-macro is a Boolean-macro, it applies a form of filter to the set of results defined by the rule.
All macros that are not unary should return Boolean.
Description: Only select devices that aren't deleted, ignored or disabled.
(devices.disabled = 0 AND devices.ignore = 0)
Device is up (Boolean)
Description: Only select devices that are up.
(devices.status = 1 AND macros.device)
Device is down (Boolean)
Description: Only select devices that are down.
(devices.status = 0 AND macros.device)
Description: Only select ports that aren't deleted, ignored or disabled.
(ports.deleted = 0 AND ports.ignore = 0 AND ports.disabled = 0)
Port is up (Boolean)
Description: Only select ports that are up and also should be up.
(ports.ifOperStatus = up AND ports.ifAdminStatus = up AND macros.port)
Port is down (Boolean)
Description: Only select ports that are down.
(ports.ifOperStatus = "down" AND ports.ifAdminStatus != "down" AND macros.port)
Port-Usage in Percent (Decimal)
Description: Return port-usage in percent.
((ports.ifInOctets_rate*8) / ports.ifSpeed)*100
Description: Alias of MySQL's NOW()
Past N Minutes (Datetime)
Description: Returns a MySQL Timestamp dated
$ Minutes in the past.
$ can only be a supported Resolution.
macros.past_5m is Last 5 Minutes.
DATE_SUB(NOW(),INTERVAL $ MINUTE)
Description: Only select sensors that aren't ignored.
(sensors.sensor_alert = 1)
macros.sensor_port_link = 1
Description: Only selects sensors that have a port linked to them, the port is up and the device is up.
(sensors.entity_link_type = "port" AND sensors.entity_link_index = ports.ifIndex AND macros.port_up AND macros.device_up))
State Sensors (Boolean)
Description: Select state sensors by their generic status ok (0), warning (1), critical (2), unknown (3)
(sensors.sensor_current = state_translations.state_value AND state_translations.state_generic_value = 2)
Description: Packet loss % value for the device within the last 5 minutes.
macros.packet_loss_5m > 50
Description: Packet loss % value for the device within the last 15 minutes.
macros.packet_loss_15m > 50
Ports in usage perc (Int)
Description: Port in used more than 50%
Example: `macros.port_in_usage_perc > 50
Ports out usage perc (Int)
Description: Port out used more than 50%
Example: `macros.port_out_usage_perc > 50
Ports now down (Boolean)
ports.ifOperStatus != ports.ifOperStatus_prev AND ports.ifOperStatus_prev = "up" AND ports.ifAdminStatus = "up"
Description: Ports that were previously up and have now gone down.
macros.port_now_down = 1
Device component down [JunOS]
sensors.sensor_class = "state" AND sensors.sensor_current != "6" AND sensors.sensor_type = "jnxFruState" AND sensors.sensor_current != "2"
Description: Device component is down such as Fan, PSU, etc for JunOS devices.
macros.device_component_down_junos = 1
Device component down [Cisco]
sensors.sensor_current != 1 AND sensors.sensor_current != 5 AND sensors.sensor_type ~ "^cisco.*State$"
Description: Device component is down such as Fan, PSU, etc for Cisco devices.
macros.device_component_down_cisco = 1
PDU over amperage [APC]
sensors.sensor_class = "current" AND sensors.sensor_descr = "Bank Total" AND sensors.sensor_current > sensors.sensor_limit AND devices.os = "apc"
Description: APC PDU over amperage
macros.pdu_over_amperage_apc = 1