forked from snabbco/snabb
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
155 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
Usage: snabb config purge-alarms [OPTION]... ID STATE | ||
Adds a new operator-state in an alarm. | ||
|
||
Available options: | ||
-s, --schema SCHEMA YANG data interface to request. | ||
-r, --revision REVISION Require a specific revision of the YANG module. | ||
-f, --format Selects output format (yang or xpath). Default: yang. | ||
--print-default Forces print out of default values. | ||
-h, --help Displays this message. | ||
|
||
Filtering options: | ||
--by-severity [severity-spec/value]. | ||
Severity spec: 'is', 'below', 'above'. | ||
Value: 'indeterminate', 'minor', 'warning', 'major', 'critical'. | ||
--by-older-than [age-spec/value]. | ||
Age spec: 'seconds', 'minutes', 'hours', 'days', 'weeks'. | ||
Value: integer. | ||
--by-operator-state-filter [state/user]. | ||
State: 'none', 'ack', 'closed', 'shelved', 'un-shelved'. | ||
User: string. | ||
|
||
Given an instance identifier and an alarm state ('any', 'cleared' or 'not-cleared') | ||
remove all alarms that match the filtering options. | ||
|
||
Typical usage: | ||
|
||
$ sudo ./snabb config purge-alarms lwaftr any | ||
$ sudo ./snabb config purge-alarms --by-severity above/minor lwaftr any | ||
$ sudo ./snabb config purge-alarms --by-older-than minutes/5 lwaftr cleared | ||
|
||
See https://github.com/Igalia/snabb/blob/lwaftr/src/program/config/README.md | ||
for full documentation. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
README |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
-- Use of this source code is governed by the Apache 2.0 license; see COPYING. | ||
module(..., package.seeall) | ||
|
||
local common = require("program.config.common") | ||
local lib = require("core.lib") | ||
|
||
local function usage(exit_code) | ||
print(require('program.config.purge_alarms.README_inc')) | ||
main.exit(exit_code) | ||
end | ||
|
||
local function parse_args (args) | ||
local handlers = {} | ||
local opts = {} | ||
local function table_size (t) | ||
local count = 0 | ||
for _ in pairs(t) do count = count + 1 end | ||
return count | ||
end | ||
local function without_opts (args) | ||
local ret = {} | ||
for i=1,#args do | ||
local arg = args[i] | ||
if opts[arg] then | ||
i = i + 2 | ||
else | ||
table.insert(ret, arg) | ||
end | ||
end | ||
return ret | ||
end | ||
handlers['by-older-than'] = function (arg) | ||
opts['older_than'] = arg | ||
end | ||
handlers['by-severity'] = function (arg) | ||
opts['severity'] = arg | ||
end | ||
handlers['by-operator-state'] = function (arg) | ||
opts['operator_state_filter'] = arg | ||
end | ||
args = lib.dogetopt(args, handlers, "", { ['by-older-than']=1, | ||
['by-severity']=1, ['by-operator-state']=1 }) | ||
opts.status = table.remove(args, #args) | ||
if table_size(opts) == 0 then usage(1) end | ||
local args = without_opts(args) | ||
return opts, args | ||
end | ||
|
||
function run(args) | ||
local l_args, args = parse_args(args) | ||
local opts = { command='purge-alarms', with_path=false, is_config=false } | ||
args = common.parse_command_line(args, opts) | ||
local response = common.call_leader( | ||
args.instance_id, 'purge-alarms', | ||
{ schema = args.schema_name, alarm_status = l_args.status, | ||
older_than = l_args.older_than, severity = l_args.severity, | ||
operator_state_filter = l_args.operator_state_filter, | ||
print_default = args.print_default, format = args.format }) | ||
common.print_and_exit(response, "purged_alarms") | ||
end |