Commit 5c25b2d1 authored by Sigmund Augdal's avatar Sigmund Augdal

Added a switch to allow listing only enabled or disabled hosts

parent d191ce22
......@@ -114,8 +114,11 @@ def get_unreachable():
print(url, host['name'], host['error'])
def get_hosts():
for host in invoke('host.get'):
def get_hosts(args):
params = {}
if args.status is not None:
params['filter'] = {'status': args.status}
for host in invoke('host.get', **params):
url = 'https://zabbix.uninett.no/zabbix/hosts.php?form=update&hostid={hostid}'.format(hostid=host['hostid'])
print(url, host['name'])
......@@ -225,6 +228,8 @@ def parse_args():
parser_get_unreachable = subparsers.add_parser('get-unreachable', help='Get unreachable hosts')
parser_get_hosts = subparsers.add_parser('get-hosts', help='Get hosts')
parser_get_hosts.add_argument('--status', type=int, choices=[0, 1],
help="Find hosts with the given status")
noicy = subparsers.add_parser('noicy-nodes', help="Find hosts with most events")
noicy.add_argument('--days', default=7, type=int,
......@@ -253,7 +258,7 @@ def main():
elif args.command == 'get-unreachable':
return get_unreachable()
elif args.command == 'get-hosts':
return get_hosts()
return get_hosts(args)
elif args.command == 'noicy-nodes':
return noicy_nodes(args)
elif args.command == 'check-kind':
......
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