From 031f8eefa68515719bf76ac97b8b7d8440b592fd Mon Sep 17 00:00:00 2001 From: sqshq Date: Sun, 3 Mar 2019 14:35:29 -0500 Subject: [PATCH] triggers config added --- config.yml | 7 +++---- config/component.go | 17 +++++++++++++++++ 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/config.yml b/config.yml index ff13cc6..bbca2c5 100644 --- a/config.yml +++ b/config.yml @@ -7,10 +7,9 @@ runcharts: w: 53 h: 16 scale: 3 - alerts: - - name: PROCESSING STARTED // ${prev} ${cur} ${lavel} // echo $(( 3 < 4 && 1 > 2 )) - trigger: ((${prev} == 0 && ${cur} > 0)) - repeat: false + triggers: + - title: PROCESSING STARTED # ${prev} ${cur} ${lavel} echo $(( 3 < 4 && 1 > 2 )) + condition: ((${prev} == 0 && ${cur} > 0)) action: terminal-bell: true sound: false diff --git a/config/component.go b/config/component.go index 4e23402..e7e5cfe 100644 --- a/config/component.go +++ b/config/component.go @@ -13,8 +13,22 @@ type ComponentConfig struct { Size Size `yaml:"size"` } +type TriggerConfig struct { + Title string `yaml:"title"` + Condition string `yaml:"condition"` + Action *Action `yaml:"action,omitempty"` +} + +type Action struct { + TerminalBell *bool `yaml:"terminal-bell,omitempty"` + Sound *bool `yaml:"sound,omitempty"` + Visual *bool `yaml:"visual,omitempty"` + Script *bool `yaml:"script,omitempty"` +} + type GaugeConfig struct { ComponentConfig `yaml:",inline"` + TriggerConfig `yaml:",inline"` Scale *int `yaml:"scale,omitempty"` Color *ui.Color `yaml:"color,omitempty"` Values map[string]string `yaml:"values"` @@ -23,18 +37,21 @@ type GaugeConfig struct { type BarChartConfig struct { ComponentConfig `yaml:",inline"` + TriggerConfig `yaml:",inline"` Scale *int `yaml:"scale,omitempty"` Items []data.Item `yaml:"items"` } type AsciiBoxConfig struct { ComponentConfig `yaml:",inline"` + TriggerConfig `yaml:",inline"` data.Item `yaml:",inline"` Font *asciibox.AsciiFont `yaml:"font,omitempty"` } type RunChartConfig struct { ComponentConfig `yaml:",inline"` + TriggerConfig `yaml:",inline"` Legend *LegendConfig `yaml:"legend,omitempty"` Scale *int `yaml:"scale,omitempty"` Items []data.Item `yaml:"items"`