Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[system-health] Remove booting stage in system health service #2022

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
234 changes: 111 additions & 123 deletions show/system_health.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def summary():
HealthCheckerManager = MockerManager
Chassis = MockerChassis
except Exception:
# Normal run... #
# Normal run... #
if os.geteuid():
click.echo("Root privileges are required for this operation")
return
Expand All @@ -38,44 +38,40 @@ def summary():
click.echo("System health configuration file not found, exit...")
return
chassis = Chassis()
state, stat = manager.check(chassis)
if state == HealthCheckerManager.STATE_BOOTING:
click.echo("System is currently booting...")
return
if state == HealthCheckerManager.STATE_RUNNING:
chassis.initizalize_system_led()
led = chassis.get_status_led()
click.echo("System status summary\n\n System status LED " + led)
services_list = []
fs_list = []
device_list =[]
for category, elements in stat.items():
for element in elements:
if elements[element]['status'] != "OK":
if 'Running' in elements[element]['message']:
services_list.append(element)
elif 'Accessible' in elements[element]['message']:
fs_list.append(element)
else:
device_list.append(elements[element]['message'])
if len(services_list) or len(fs_list):
click.echo(" Services:\n Status: Not OK")
else:
click.echo(" Services:\n Status: OK")
if len(services_list):
services_list_string = str(services_list)
click.echo(" Not Running: " + services_list_string.replace("[", "").replace(']', ""))
if len(fs_list):
fs_list_string = str(fs_list)
click.echo(" Not Accessible: " + fs_list_string.replace("[", "").replace(']', ""))
if len(device_list):
click.echo(" Hardware:\n Status: Not OK")
click.echo(" Reasons: " + device_list.pop())
while len(device_list):
click.echo("\t " + device_list.pop())
else:
click.echo(" Hardware:\n Status: OK")

stat = manager.check(chassis)
chassis.initizalize_system_led()
led = chassis.get_status_led()
click.echo("System status summary\n\n System status LED " + led)
services_list = []
fs_list = []
device_list =[]
for category, elements in stat.items():
for element in elements:
if elements[element]['status'] != "OK":
if 'Running' in elements[element]['message']:
services_list.append(element)
elif 'Accessible' in elements[element]['message']:
fs_list.append(element)
else:
device_list.append(elements[element]['message'])
if len(services_list) or len(fs_list):
click.echo(" Services:\n Status: Not OK")
else:
click.echo(" Services:\n Status: OK")
if len(services_list):
services_list_string = str(services_list)
click.echo(" Not Running: " + services_list_string.replace("[", "").replace(']', ""))
if len(fs_list):
fs_list_string = str(fs_list)
click.echo(" Not Accessible: " + fs_list_string.replace("[", "").replace(']', ""))
if len(device_list):
click.echo(" Hardware:\n Status: Not OK")
click.echo(" Reasons: " + device_list.pop())
while len(device_list):
click.echo("\t " + device_list.pop())
else:
click.echo(" Hardware:\n Status: OK")

@system_health.command()
def detail():
"""Show system-health detail information"""
Expand All @@ -89,7 +85,7 @@ def detail():
HealthCheckerManager = MockerManager
Chassis = MockerChassis
except Exception:
# Normal run... #
# Normal run... #
if os.geteuid():
click.echo("Root privileges are required for this operation")
return
Expand All @@ -101,73 +97,69 @@ def detail():
click.echo("System health configuration file not found, exit...")
return
chassis = Chassis()
state, stat = manager.check(chassis)
if state == HealthCheckerManager.STATE_BOOTING:
click.echo("System is currently booting...")
return
if state == HealthCheckerManager.STATE_RUNNING:
#summary output
chassis.initizalize_system_led()
led = chassis.get_status_led()
click.echo("System status summary\n\n System status LED " + led)
services_list = []
fs_list = []
device_list =[]
for category, elements in stat.items():
for element in elements:
if elements[element]['status'] != "OK":
if 'Running' in elements[element]['message']:
services_list.append(element)
elif 'Accessible' in elements[element]['message']:
fs_list.append(element)
else:
device_list.append(elements[element]['message'])
if len(services_list) or len(fs_list):
click.echo(" Services:\n Status: Not OK")
else:
click.echo(" Services:\n Status: OK")
if len(services_list):
services_list_string = str(services_list)
click.echo(" Not Running: " + services_list_string.replace("[", "").replace(']', ""))
if len(fs_list):
fs_list_string = str(fs_list)
click.echo(" Not Accessible: " + fs_list_string.replace("[", "").replace(']', ""))
if len(device_list):
click.echo(" Hardware:\n Status: Not OK")
click.echo(" Reasons: " + device_list.pop())
while len(device_list):
click.echo("\t " + device_list.pop())
else:
click.echo(" Hardware:\n Status: OK")
stat = manager.check(chassis)
#summary output
chassis.initizalize_system_led()
led = chassis.get_status_led()
click.echo("System status summary\n\n System status LED " + led)
services_list = []
fs_list = []
device_list =[]
for category, elements in stat.items():
for element in elements:
if elements[element]['status'] != "OK":
if 'Running' in elements[element]['message']:
services_list.append(element)
elif 'Accessible' in elements[element]['message']:
fs_list.append(element)
else:
device_list.append(elements[element]['message'])
if len(services_list) or len(fs_list):
click.echo(" Services:\n Status: Not OK")
else:
click.echo(" Services:\n Status: OK")
if len(services_list):
services_list_string = str(services_list)
click.echo(" Not Running: " + services_list_string.replace("[", "").replace(']', ""))
if len(fs_list):
fs_list_string = str(fs_list)
click.echo(" Not Accessible: " + fs_list_string.replace("[", "").replace(']', ""))
if len(device_list):
click.echo(" Hardware:\n Status: Not OK")
click.echo(" Reasons: " + device_list.pop())
while len(device_list):
click.echo("\t " + device_list.pop())
else:
click.echo(" Hardware:\n Status: OK")

click.echo('\nSystem services and devices monitor list\n')
header = ['Name', 'Status', 'Type']
table = []
for category, elements in stat.items():
for element in sorted(elements.items(), key=lambda x: x[1]['status']):
entry = []
entry.append(element[0])
entry.append(element[1]['status'])
entry.append(element[1]['type'])
table.append(entry)
click.echo(tabulate(table, header))
click.echo('\nSystem services and devices ignore list\n')
table = []
if manager.config.ignore_services:
for element in manager.config.ignore_services:
entry = []
entry.append(element)
entry.append("Ignored")
entry.append("Service")
table.append(entry)
if manager.config.ignore_devices:
for element in manager.config.ignore_devices:
entry = []
entry.append(element)
entry.append("Ignored")
entry.append("Device")
table.append(entry)
click.echo(tabulate(table, header))
click.echo('\nSystem services and devices monitor list\n')
header = ['Name', 'Status', 'Type']
table = []
for category, elements in stat.items():
for element in sorted(elements.items(), key=lambda x: x[1]['status']):
entry = []
entry.append(element[0])
entry.append(element[1]['status'])
entry.append(element[1]['type'])
table.append(entry)
click.echo(tabulate(table, header))
click.echo('\nSystem services and devices ignore list\n')
table = []
if manager.config.ignore_services:
for element in manager.config.ignore_services:
entry = []
entry.append(element)
entry.append("Ignored")
entry.append("Service")
table.append(entry)
if manager.config.ignore_devices:
for element in manager.config.ignore_devices:
entry = []
entry.append(element)
entry.append("Ignored")
entry.append("Device")
table.append(entry)
click.echo(tabulate(table, header))

@system_health.command()
def monitor_list():
Expand All @@ -182,7 +174,7 @@ def monitor_list():
HealthCheckerManager = MockerManager
Chassis = MockerChassis
except Exception:
# Normal run... #
# Normal run... #
if os.geteuid():
click.echo("Root privileges are required for this operation")
return
Expand All @@ -194,19 +186,15 @@ def monitor_list():
click.echo("System health configuration file not found, exit...")
return
chassis = Chassis()
state, stat = manager.check(chassis)
if state == HealthCheckerManager.STATE_BOOTING:
click.echo("System is currently booting...")
return
if state == HealthCheckerManager.STATE_RUNNING:
click.echo('\nSystem services and devices monitor list\n')
header = ['Name', 'Status', 'Type']
table = []
for category, elements in stat.items():
for element in sorted(elements.items(), key=lambda x: x[1]['status']):
entry = []
entry.append(element[0])
entry.append(element[1]['status'])
entry.append(element[1]['type'])
table.append(entry)
click.echo(tabulate(table, header))
stat = manager.check(chassis)
click.echo('\nSystem services and devices monitor list\n')
header = ['Name', 'Status', 'Type']
table = []
for category, elements in stat.items():
for element in sorted(elements.items(), key=lambda x: x[1]['status']):
entry = []
entry.append(element[0])
entry.append(element[1]['status'])
entry.append(element[1]['type'])
table.append(entry)
click.echo(tabulate(table, header))
Loading