librenms-librenms/misc/macros.json
Neil Lathwood 03076c4025 feature: Added new alert rule builder UI and rule mapping UI (#8293)
* feature: Added new alert rule builder UI

* Updated to export sql queries

* More updates

* more changes

* removed debug

* fix scrut

* Updated to include import options + various other fixes

* fix rule

* Populate name from collection rules.

* Fix default rule import
Allow new and old style rules in the collection.
Don't add new yet as I'm not sure GenSQL() is working.

* Fix GenSQL call

* Extract filter building to class so it is nicely contained in one place

* moved schema

* some fixes and tweaks

* travis fixes

* Some more features / updates

* Fix up my mistakes when adding default rules

* Use a modal for new alert (Incomplete)
Larger dialog!!
Remove page loading stuff.

Working:
Loading rules, resetting dialog, importing from collection.

Not working yet:
select width
device limited rule access? don't know what this is...

Lots of unused stuff to delete...

* reload "table" after save

* fixed editing rule

* Auto select2 width

* Reload window on save

* Restore per-device alert. Remove debug.

* Small cleanups. Rule Name first.

* Restore button to button type. Rename schema.

* Fixes: wrong command to reload window, remove extra attributes, rule is never passed

* Fixed old rule editing

* some small updates for old imports

* travis update to use trusty

* maybe travis fix

* Ability to set alert rule mappings on the rule edit screen

* pip installs one line, no quiet for deploy

* update schema def

* Fix style and some copyright headers

* fix docs missing file

* Allow new versions of snmpsim and libraries

* Parser WIP

* Fix default rules insert

* reorganize

* Legacy import first draft done

* Implement saving
Skip translation to sql for now

* Working on glues

* small rule collection fix

* Working on glues

* Working on glues

* Docs updates + small UI changes

* Parser WIP

* reorganize

* Legacy import first draft done

* Implement saving
Skip translation to sql for now

* Working on glues

* Working on glues

* Working on glues

* Add table mapping, should move to it's own class

* WIP

* Glue working!!

* Extract Schema class

* Some final touches.
revert alerts_rules.json for now.

* Finish up initial implementation
Needs more tests

* Fix a few places

* small doc updates

* Fix finding tables in grouped rules.

* remove unused code

* code format fixes

* Some quick tests for Schema
Simplified output for findRelationshipPath. Always includes start and target in the result.
This simplifies a lot of code in QueryBuilderParser.php
This also always loads the target table data now (which we want)

* Make bill_id the PRIMARY index for the bills table

* Load macros from a json file in misc instead of the database.

* Fix whitespace and wrong key for collection.

* Handle IN properly when generating SQL

* Fix glue (devices.device_id = ports.port_id) is incorrect :D
Show ALL tables we can resolve relationships for in the query builder filter.

* Remove all macros from the database
Remove insert statements, leave updates to update user's existing rules.
2018-03-14 20:25:19 +00:00

36 lines
3.0 KiB
JSON

{
"now": "NOW()",
"past_5m": "DATE_SUB(NOW(),INTERVAL 5 MINUTE)",
"past_10m": "DATE_SUB(NOW(),INTERVAL 10 MINUTE)",
"past_15m": "DATE_SUB(NOW(),INTERVAL 15 MINUTE)",
"past_30m": "DATE_SUB(NOW(),INTERVAL 30 MINUTE)",
"device": "(%devices.disabled = 0 && %devices.ignore = 0)",
"device_up": "(%devices.status = 1 && %macros.device)",
"device_down": "(%devices.status = 0 && %macros.device)",
"port": "(%ports.deleted = 0 && %ports.ignore = 0 && %ports.disabled = 0)",
"port_up": "(%ports.ifOperStatus = \"up\" && %ports.ifAdminStatus = \"up\" && %macros.port)",
"past_60m": "DATE_SUB(NOW(),INTERVAL 60 MINUTE)",
"port_usage_perc": "((%ports.ifInOctets_rate*8) \/ %ports.ifSpeed)*100",
"port_down": "(%ports.ifOperStatus = \"down\" && %ports.ifAdminStatus != \"down\" && %macros.port)",
"sensor": "(%sensors.sensor_alert = 1)",
"packet_loss_15m": "(%macros.past_15m && %device_perf.loss)",
"packet_loss_5m": "(%macros.past_5m && %device_perf.loss)",
"component": "(%component.disabled = 0 && %component.ignore = 0)",
"component_warning": "(%component.status = 1 && %macros.component)",
"component_normal": "(%component.status = 0 && %macros.component)",
"port_in_usage_perc": "((%ports.ifInOctets_rate*8) \/ %ports.ifSpeed)*100",
"port_out_usage_perc": "((%ports.ifOutOctets_rate*8) \/ %ports.ifSpeed)*100",
"port_now_down": "%ports.ifOperStatus != %ports.ifOperStatus_prev && %ports.ifOperStatus_prev = \"up\" && %ports.ifAdminStatus = \"up\"",
"device_component_down_junos": "%sensors.sensor_class = \"state\" && %sensors.sensor_current != \"6\" && %sensors.sensor_type = \"jnxFruState\" && %sensors.sensor_current != \"2\" && %sensors.sensor_alert = \"1\"",
"device_component_down_cisco": "%sensors.sensor_current != \"1\" && %sensors.sensor_current != \"5\" && %sensors.sensor_type ~ \"^cisco.*State$\" && %sensors.sensor_alert = \"1\"",
"pdu_over_amperage_apc": "%sensors.sensor_class = \"current\" && %sensors.sensor_descr = \"Bank Total\" && %sensors.sensor_current > %sensors.sensor_limit && %devices.os = \"apc\"",
"component_critical": "(%component.status = 2 && %macros.component)",
"bill_quota_over_quota": "((%bills.total_data \/ %bills.bill_quota)*100) && %bills.bill_type = \"quota\"",
"bill_cdr_over_quota": "((%bills.rate_95th \/ %bills.bill_cdr)*100) && %bills.bill_type = \"cdr\"",
"sensor_port_link": "(%sensors.entPhysicalIndex_measured = 'ports' && %sensors.entPhysicalIndex = %ports.ifIndex && %macros.port_up)",
"state_sensor_ok": "%sensors.sensor_current = %state_translations.state_value && %state_translations.state_generic_value = 0",
"state_sensor_warning": "%sensors.sensor_current = %state_translations.state_value && %state_translations.state_generic_value = 1",
"state_sensor_critical": "%sensors.sensor_current = %state_translations.state_value && %state_translations.state_generic_value = 2",
"state_sensor_unknown": "%sensors.sensor_current = %state_translations.state_value && %state_translations.state_generic_value = 3"
}