Expanded HW-Diags - osTicket checkbox sections
This commit is contained in:
parent
a41271e296
commit
214e2c345d
4 changed files with 110 additions and 29 deletions
|
|
@ -39,6 +39,14 @@ class CpuObj():
|
||||||
self.name = self.lscpu.get('Model name', 'Unknown CPU')
|
self.name = self.lscpu.get('Model name', 'Unknown CPU')
|
||||||
self.description = self.name
|
self.description = self.name
|
||||||
|
|
||||||
|
def all_tests_passed(self):
|
||||||
|
"""Check if all tests passed, returns bool."""
|
||||||
|
return all([results.passed for results in self.tests.values()])
|
||||||
|
|
||||||
|
def any_test_failed(self):
|
||||||
|
"""Check if any test failed, returns bool."""
|
||||||
|
return any([results.failed for results in self.tests.values()])
|
||||||
|
|
||||||
def get_details(self):
|
def get_details(self):
|
||||||
"""Get CPU details from lscpu."""
|
"""Get CPU details from lscpu."""
|
||||||
cmd = ['lscpu', '--json']
|
cmd = ['lscpu', '--json']
|
||||||
|
|
@ -117,6 +125,14 @@ class DiskObj():
|
||||||
# A dict is used to avoid duplicate notes
|
# A dict is used to avoid duplicate notes
|
||||||
self.nvme_smart_notes[note] = None
|
self.nvme_smart_notes[note] = None
|
||||||
|
|
||||||
|
def all_tests_passed(self):
|
||||||
|
"""Check if all tests passed, returns bool."""
|
||||||
|
return all([results.passed for results in self.tests.values()])
|
||||||
|
|
||||||
|
def any_test_failed(self):
|
||||||
|
"""Check if any test failed, returns bool."""
|
||||||
|
return any([results.failed for results in self.tests.values()])
|
||||||
|
|
||||||
def calc_io_dd_values(self):
|
def calc_io_dd_values(self):
|
||||||
"""Calcualte I/O benchmark dd values.
|
"""Calcualte I/O benchmark dd values.
|
||||||
|
|
||||||
|
|
@ -1227,11 +1243,9 @@ def run_hw_tests(state):
|
||||||
v['Objects'][-1].update_status('N/A')
|
v['Objects'][-1].update_status('N/A')
|
||||||
if k == TESTS_CPU[-1]:
|
if k == TESTS_CPU[-1]:
|
||||||
# Last CPU test run, post CPU results
|
# Last CPU test run, post CPU results
|
||||||
cpu_failed = False
|
color_code = 'Diags'
|
||||||
for test in state.cpu.tests.values():
|
if state.cpu.any_test_failed():
|
||||||
cpu_failed = cpu_failed or test.failed
|
color_code = 'Diags FAIL'
|
||||||
cpu_failed = cpu_failed or not test.passed
|
|
||||||
color_code = 'Diags FAIL' if cpu_failed else 'Diags'
|
|
||||||
state.ost.post_device_results(
|
state.ost.post_device_results(
|
||||||
state.cpu, state.ticket_id, state.ticket_name, color_code)
|
state.cpu, state.ticket_id, state.ticket_name, color_code)
|
||||||
# Recheck attributes
|
# Recheck attributes
|
||||||
|
|
@ -1270,33 +1284,11 @@ def run_hw_tests(state):
|
||||||
for disk in state.disks:
|
for disk in state.disks:
|
||||||
# Set color code
|
# Set color code
|
||||||
color_code = 'Diags'
|
color_code = 'Diags'
|
||||||
for test in disk.tests.values():
|
if disk.any_test_failed():
|
||||||
if test.disabled:
|
color_code = 'Diags FAIL'
|
||||||
if test.failed:
|
|
||||||
color_code = 'Diags FAIL'
|
|
||||||
continue
|
|
||||||
if test.failed or not (test.passed or 'N/A' in test.status):
|
|
||||||
color_code = 'Diags FAIL'
|
|
||||||
state.ost.post_device_results(
|
state.ost.post_device_results(
|
||||||
disk, state.ticket_id, state.ticket_name, color_code)
|
disk, state.ticket_id, state.ticket_name, color_code)
|
||||||
|
|
||||||
# Check if disk checkbox needs updating
|
|
||||||
all_disks_passed = True
|
|
||||||
disk_failures = False
|
|
||||||
for disk in state.disks:
|
|
||||||
if disk.checkbox is None:
|
|
||||||
# Aborted/Unknown/etc
|
|
||||||
all_disks_passed = False
|
|
||||||
else:
|
|
||||||
all_disks_passed = all_disks_passed and disk.checkbox
|
|
||||||
disk_failures = disk_failures or not disk.checkbox
|
|
||||||
|
|
||||||
# Update checkbox if necessary
|
|
||||||
if disk_failures:
|
|
||||||
state.ost.set_disk_failed(state.ticket_id)
|
|
||||||
elif all_disks_passed:
|
|
||||||
state.ost.set_disk_passed(state.ticket_id)
|
|
||||||
|
|
||||||
# Spacer
|
# Spacer
|
||||||
print_standard(' ')
|
print_standard(' ')
|
||||||
|
|
||||||
|
|
@ -1319,6 +1311,40 @@ def run_hw_tests(state):
|
||||||
global_vars=global_vars,
|
global_vars=global_vars,
|
||||||
reason='Review')
|
reason='Review')
|
||||||
|
|
||||||
|
# Do we need to update checkboxes?
|
||||||
|
all_disks_passed = all([disk.all_tests_passed() for disk in state.disks])
|
||||||
|
all_disk_tests_enabled = all(
|
||||||
|
[state.tests[name]['Enabled'] for name in TESTS_DISK])
|
||||||
|
any_disk_failures = any([disk.any_test_failed() for disk in state.disks])
|
||||||
|
cpu_failed = state.cpu.any_test_failed()
|
||||||
|
cpu_max_temp = get_cpu_max_temp(state.cpu.sensor_data)
|
||||||
|
cpu_max_temp = f'{cpu_max_temp:2.0f}'
|
||||||
|
cpu_passed = state.cpu.all_tests_passed()
|
||||||
|
update_checkboxes = False
|
||||||
|
if state.ticket_id:
|
||||||
|
if state.tests['Prime95']:
|
||||||
|
update_checkboxes = True
|
||||||
|
elif any_disk_failures:
|
||||||
|
update_checkboxes = True
|
||||||
|
elif all_disk_tests_enabled and all_disks_passed:
|
||||||
|
update_checkboxes = True
|
||||||
|
|
||||||
|
|
||||||
|
# Ask to update checkboxes
|
||||||
|
if update_checkboxes and ask('Update checkboxes using above results?'):
|
||||||
|
# CPU checkboxes
|
||||||
|
if cpu_failed:
|
||||||
|
state.ost.set_cpu_failed(state.ticket_id)
|
||||||
|
elif cpu_passed:
|
||||||
|
state.ost.set_cpu_passed(state.ticket_id)
|
||||||
|
state.ost.set_cpu_temp(state.ticket_id, temp=cpu_max_temp)
|
||||||
|
|
||||||
|
# Disk checkboxes
|
||||||
|
if any_disk_failures:
|
||||||
|
state.ost.set_disk_failed(state.ticket_id)
|
||||||
|
elif all_disk_tests_enabled and all_disks_passed:
|
||||||
|
state.ost.set_disk_passed(state.ticket_id)
|
||||||
|
|
||||||
# Done
|
# Done
|
||||||
sleep(1)
|
sleep(1)
|
||||||
if state.quick_mode:
|
if state.quick_mode:
|
||||||
|
|
@ -1548,6 +1574,7 @@ def run_mprime_test(state, test):
|
||||||
command=['hw-diags-prime95', global_vars['TmpDir']],
|
command=['hw-diags-prime95', global_vars['TmpDir']],
|
||||||
working_dir=global_vars['TmpDir'])
|
working_dir=global_vars['TmpDir'])
|
||||||
time_limit = MPRIME_LIMIT * 60
|
time_limit = MPRIME_LIMIT * 60
|
||||||
|
time_limit = 14
|
||||||
try:
|
try:
|
||||||
for i in range(time_limit):
|
for i in range(time_limit):
|
||||||
#clear_screen()
|
#clear_screen()
|
||||||
|
|
|
||||||
|
|
@ -544,6 +544,36 @@ class osTicket():
|
||||||
# Done
|
# Done
|
||||||
self.disconnect()
|
self.disconnect()
|
||||||
|
|
||||||
|
def set_cpu_failed(self, ticket_id):
|
||||||
|
"""Mark cpu as failed in osTicket."""
|
||||||
|
self.set_flag(
|
||||||
|
ticket_id,
|
||||||
|
OSTICKET['CPU Flag']['Name'],
|
||||||
|
OSTICKET['CPU Flag']['Fail'])
|
||||||
|
|
||||||
|
def set_cpu_passed(self, ticket_id):
|
||||||
|
"""Mark cpu as passed in osTicket."""
|
||||||
|
current_value = self.get_flag(ticket_id, OSTICKET['CPU Flag']['Name'])
|
||||||
|
|
||||||
|
# Bail early?
|
||||||
|
if current_value == OSTICKET['CPU Flag']['Fail']:
|
||||||
|
print_warning('Not replacing osTicket cpu checkbox FAILED value')
|
||||||
|
return
|
||||||
|
|
||||||
|
# Current value != FAILED, set to passed
|
||||||
|
self.set_flag(
|
||||||
|
ticket_id,
|
||||||
|
OSTICKET['CPU Flag']['Name'],
|
||||||
|
OSTICKET['CPU Flag']['Pass'])
|
||||||
|
|
||||||
|
def set_cpu_max_temp(self, ticket_id, temp):
|
||||||
|
"""Set CPU temp string in osTicket."""
|
||||||
|
self.set_flag(
|
||||||
|
ticket_id,
|
||||||
|
OSTICKET['CPU Temp']['Name'],
|
||||||
|
temp,
|
||||||
|
)
|
||||||
|
|
||||||
def set_disk_failed(self, ticket_id):
|
def set_disk_failed(self, ticket_id):
|
||||||
"""Mark disk as failed in osTicket."""
|
"""Mark disk as failed in osTicket."""
|
||||||
self.set_flag(
|
self.set_flag(
|
||||||
|
|
|
||||||
|
|
@ -101,6 +101,22 @@ def get_colored_temp_str(temp):
|
||||||
**COLORS)
|
**COLORS)
|
||||||
|
|
||||||
|
|
||||||
|
def get_cpu_max_temp(sensor_data):
|
||||||
|
"""get max temp"""
|
||||||
|
max_temp = 0.0
|
||||||
|
|
||||||
|
# Check all CPU Temps
|
||||||
|
for section, adapters in sensor_data.items():
|
||||||
|
if not section.startswith('CPU'):
|
||||||
|
continue
|
||||||
|
for sources in adapters.values():
|
||||||
|
for source_data in sources.values():
|
||||||
|
max_temp = max(max_temp, source_data.get('Max', 0))
|
||||||
|
|
||||||
|
# Done
|
||||||
|
return max_temp
|
||||||
|
|
||||||
|
|
||||||
def get_raw_sensor_data():
|
def get_raw_sensor_data():
|
||||||
"""Read sensor data and return dict."""
|
"""Read sensor data and return dict."""
|
||||||
json_data = {}
|
json_data = {}
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,14 @@ OSTICKET = {
|
||||||
'Diags': '2',
|
'Diags': '2',
|
||||||
'Diags FAIL': '3',
|
'Diags FAIL': '3',
|
||||||
},
|
},
|
||||||
|
'CPU Flag': {
|
||||||
|
'Name': 'zTemps',
|
||||||
|
'Pass': 1,
|
||||||
|
'Fail': 2,
|
||||||
|
},
|
||||||
|
'CPU Temp': {
|
||||||
|
'Name': 'zMaxTemp',
|
||||||
|
},
|
||||||
'Database': {
|
'Database': {
|
||||||
'Name': 'osticket',
|
'Name': 'osticket',
|
||||||
'User': 'wizardkit',
|
'User': 'wizardkit',
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue