Skip to content

Commit

Permalink
fixed some references to old global config values
Browse files Browse the repository at this point in the history
  • Loading branch information
ocket8888 committed Jul 23, 2018
1 parent 7be87d2 commit 52b0407
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 18 deletions.
26 changes: 9 additions & 17 deletions connvitals/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,37 +39,29 @@ def main() -> int:
prematurely with a fatal error.
"""

from . import utils
from . import config
from . import collector

config.init()

# No hosts could be parsed
if not config.HOSTS:
if not config.CONFIG or not config.CONFIG.HOSTS:
from . import utils
utils.error("No hosts could be parsed! Exiting...", True)

collectors = [collector.Collector(host,i+1) for i,host in enumerate(config.HOSTS)]
from . import collector

collectors = [collector.Collector(host,i+1) for i,host in enumerate(config.CONFIG.HOSTS)]

# Start all the collectors
for collect in collectors:
collect.start()

# Wait for every collector to finish
# Print JSON if requested
if config.JSON:
for collect in collectors:
_ = collect.join()
collect.result = collect.recv()
print(repr(collect))

# ... else print plaintext
else:
for collect in collectors:
_ = collect.join()
collect.result = collect.recv()
print(collect)

for collect in collectors:
_ = collect.join()
collect.result = collect.recv()
print(repr(collect) if collect.conf.JSON else collect)

# Errors will be indicated on stdout; because we query multiple hosts, as
# long as the main routine doesn't crash, we have exited successfully.
Expand Down
2 changes: 1 addition & 1 deletion connvitals/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def init():
# Parse the list of hosts and try to find valid addresses for each
CONFIG.HOSTS = {}

for host in hosts:
for host in args.hosts:
info = utils.getaddr(host)
if not info:
utils.error("Unable to resolve host ( %s )" % host)
Expand Down

0 comments on commit 52b0407

Please sign in to comment.