status checks were broken if sshd was not present, fixes #444

This commit is contained in:
Joshua Tauberer 2015-06-18 11:01:11 +00:00
parent ab36cc8968
commit 6258a7f311
2 changed files with 14 additions and 2 deletions

View file

@ -19,6 +19,7 @@ DNS:
Control panel:
* Resetting a user's password now forces them to log in again everywhere.
* Status checks were not working if an ssh server was not installed.
System:
* The munin system monitoring tool is now installed and accessible at /admin/munin.

View file

@ -42,16 +42,22 @@ def run_checks(rounded_values, env, output, pool):
def get_ssh_port():
# Returns ssh port
try:
output = shell('check_output', ['sshd', '-T'])
returnNext = False
except FileNotFoundError:
# sshd is not installed. That's ok.
return None
returnNext = False
for e in output.split():
if returnNext:
return int(e)
if e == "port":
returnNext = True
# Did not find port!
return None
def run_services_checks(env, output, pool):
# Check that system services are running.
@ -82,6 +88,7 @@ def run_services_checks(env, output, pool):
fatal = False
ret = pool.starmap(check_service, ((i, service, env) for i, service in enumerate(services)), chunksize=1)
for i, running, fatal2, output2 in sorted(ret):
if output2 is None: continue # skip check (e.g. no port was set, e.g. no sshd)
all_running = all_running and running
fatal = fatal or fatal2
output2.playback(output)
@ -92,6 +99,10 @@ def run_services_checks(env, output, pool):
return not fatal
def check_service(i, service, env):
if not service["port"]:
# Skip check (no port, e.g. no sshd).
return (i, None, None, None)
import socket
output = BufferedOutput()
running = False