Commit 1ee1fd81 authored by Olav Morken's avatar Olav Morken

get-items: Replace `--only-external` with `--type=external`.

This prepares for additional type filters.
parent 330279c2
......@@ -19,6 +19,9 @@ SEVERITIES = {
"disaster": 5,
}
ITEM_TYPE_MAP = {
'external': 10,
}
def get_auth():
try:
......@@ -62,18 +65,17 @@ def get_items(args):
item_filter = {'inherited': False}
else:
item_filter = {}
type_limit = ITEM_TYPE_MAP.get(args.type, None)
for template in invoke('template.get'):
for item in invoke('item.get', templateids=template['templateid'], **item_filter):
if args.only_external and item['type'] != '10':
# Not an external check
if type_limit is not None and int(item['type']) != type_limit:
continue
if args.only_enabled and item['status'] == '1':
continue
print('https://zabbix.uninett.no/zabbix/items.php?form=update&itemid={itemid} {key}'.format(itemid=item['itemid'], key=item['key_']))
for host in invoke('host.get'):
for item in invoke('item.get', hostids=host['hostid'], **item_filter):
if args.only_external and item['type'] != '10':
# Not an external check
if type_limit is not None and int(item['type']) != type_limit:
continue
if args.only_enabled and item['status'] == '1':
continue
......@@ -271,7 +273,7 @@ def parse_args():
parser_get_items = subparsers.add_parser('get-items', help='Get script items')
parser_get_items.add_argument('--include-inherited', action='store_true', help='Include inherited items in output')
parser_get_items.add_argument('--only-enabled', action='store_true', help='Show only enabled items')
parser_get_items.add_argument('--only-external', action='store_true', help='Show only external check items')
parser_get_items.add_argument('--type', choices=sorted(ITEM_TYPE_MAP.keys()), help='Show only items of specified type')
parser_dump_vkilo = subparsers.add_parser('dump-vkilo', help='Get verktøykasse ILO config')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment