Include used space in disk reports for osTicket
* Used space info is not included if the drive failed the test(s)
This commit is contained in:
parent
25d3413986
commit
0d35d81b97
1 changed files with 57 additions and 32 deletions
|
|
@ -8,7 +8,7 @@ import mysql.connector as mariadb
|
||||||
import requests
|
import requests
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from functions.common import *
|
from functions.data import *
|
||||||
from numpy import *
|
from numpy import *
|
||||||
|
|
||||||
# Database connection
|
# Database connection
|
||||||
|
|
@ -345,12 +345,15 @@ def menu_diags(*args):
|
||||||
if diag_modes[int(selection)-1]['Name'] != 'Quick drive test':
|
if diag_modes[int(selection)-1]['Name'] != 'Quick drive test':
|
||||||
clear_screen()
|
clear_screen()
|
||||||
print_standard(' ')
|
print_standard(' ')
|
||||||
try_and_print(
|
result = try_and_print(
|
||||||
message='Connecting to osTicket database...',
|
message='Connecting to osTicket database...',
|
||||||
function=connect_to_db,
|
function=connect_to_db,
|
||||||
width=40)
|
width=40)
|
||||||
|
if not result['CS']:
|
||||||
|
print_warning('osTicket integration disabled for this run.')
|
||||||
|
pause()
|
||||||
# Save log for non-quick tests
|
# Save log for non-quick tests
|
||||||
ticket_number = get_osticket_number()
|
global_vars['Date-Time'] = time.strftime("%Y-%m-%d_%H%M_%z")
|
||||||
global_vars['LogDir'] = '{}/Logs/{}_{}'.format(
|
global_vars['LogDir'] = '{}/Logs/{}_{}'.format(
|
||||||
global_vars['Env']['HOME'],
|
global_vars['Env']['HOME'],
|
||||||
ticket_number,
|
ticket_number,
|
||||||
|
|
@ -358,6 +361,7 @@ def menu_diags(*args):
|
||||||
os.makedirs(global_vars['LogDir'], exist_ok=True)
|
os.makedirs(global_vars['LogDir'], exist_ok=True)
|
||||||
global_vars['LogFile'] = '{}/Hardware Diagnostics.log'.format(
|
global_vars['LogFile'] = '{}/Hardware Diagnostics.log'.format(
|
||||||
global_vars['LogDir'])
|
global_vars['LogDir'])
|
||||||
|
ticket_number = get_osticket_number()
|
||||||
run_tests(diag_modes[int(selection)-1]['Tests'], ticket_number)
|
run_tests(diag_modes[int(selection)-1]['Tests'], ticket_number)
|
||||||
elif selection == 'A':
|
elif selection == 'A':
|
||||||
run_program(['hw-diags-audio'], check=False, pipe=False)
|
run_program(['hw-diags-audio'], check=False, pipe=False)
|
||||||
|
|
@ -634,6 +638,25 @@ def post_drive_results(ticket_number):
|
||||||
# Oh well
|
# Oh well
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
# Used space
|
||||||
|
report.append('')
|
||||||
|
report.append('Volumes:')
|
||||||
|
if dev_failed:
|
||||||
|
report.append('Skipped due to error(s) above.')
|
||||||
|
else:
|
||||||
|
volume_report = mount_volumes(
|
||||||
|
all_devices=False,
|
||||||
|
device_path='/dev/{}'.format(name))
|
||||||
|
for vol_path, vol_data in sorted(volume_report.items()):
|
||||||
|
line = vol_path
|
||||||
|
if vol_data.get('label', False):
|
||||||
|
line += ' "{}"'.format(vol_data['label'])
|
||||||
|
line += ' Used: {}, Free: {}'.format(
|
||||||
|
vol_data.get('size_used', 'UNKNOWN'),
|
||||||
|
vol_data.get('size_avail', 'UNKNOWN'),
|
||||||
|
)
|
||||||
|
report.append(line)
|
||||||
|
|
||||||
# Post reply for drive
|
# Post reply for drive
|
||||||
osticket_post_reply(
|
osticket_post_reply(
|
||||||
ticket_id=ticket_number,
|
ticket_id=ticket_number,
|
||||||
|
|
@ -979,35 +1002,36 @@ def run_mprime(ticket_number):
|
||||||
update_progress()
|
update_progress()
|
||||||
|
|
||||||
# Build osTicket report
|
# Build osTicket report
|
||||||
report = ['Prime95 ({}):'.format(TESTS['Prime95']['Status'])]
|
if ticket_number:
|
||||||
log_path = '{}/prime.log'.format(global_vars['LogDir'])
|
report = ['Prime95 ({}):'.format(TESTS['Prime95']['Status'])]
|
||||||
try:
|
log_path = '{}/prime.log'.format(global_vars['LogDir'])
|
||||||
with open(log_path, 'r') as f:
|
try:
|
||||||
for line in f.readlines():
|
with open(log_path, 'r') as f:
|
||||||
line = line.strip()
|
for line in f.readlines():
|
||||||
r = re.search('(completed \d+ tests.*)', line, re.IGNORECASE)
|
line = line.strip()
|
||||||
if r:
|
r = re.search('(completed \d+ tests.*)', line, re.IGNORECASE)
|
||||||
report.append(r.group(1))
|
if r:
|
||||||
except:
|
report.append(r.group(1))
|
||||||
report.append('ERROR: Failed to read log.')
|
except:
|
||||||
report.append('')
|
report.append('ERROR: Failed to read log.')
|
||||||
report.append('Final temps:')
|
report.append('')
|
||||||
log_path = '{}/Final Temps.log'.format(global_vars['LogDir'])
|
report.append('Final temps:')
|
||||||
try:
|
log_path = '{}/Final Temps.log'.format(global_vars['LogDir'])
|
||||||
with open(log_path, 'r') as f:
|
try:
|
||||||
for line in f.readlines():
|
with open(log_path, 'r') as f:
|
||||||
line = line.strip()
|
for line in f.readlines():
|
||||||
if not line:
|
line = line.strip()
|
||||||
# Stop after CPU temp(s)
|
if not line:
|
||||||
break
|
# Stop after CPU temp(s)
|
||||||
report.append(line)
|
break
|
||||||
except:
|
report.append(line)
|
||||||
report.append('ERROR: Failed to read log.')
|
except:
|
||||||
|
report.append('ERROR: Failed to read log.')
|
||||||
|
|
||||||
# Upload osTicket report
|
# Upload osTicket report
|
||||||
osticket_post_reply(
|
osticket_post_reply(
|
||||||
ticket_id=ticket_number,
|
ticket_id=ticket_number,
|
||||||
response='\n'.join(report))
|
response='\n'.join(report))
|
||||||
|
|
||||||
# Done
|
# Done
|
||||||
run_program('tmux kill-pane -a'.split())
|
run_program('tmux kill-pane -a'.split())
|
||||||
|
|
@ -1140,7 +1164,8 @@ def run_tests(tests, ticket_number=None):
|
||||||
run_iobenchmark(ticket_number)
|
run_iobenchmark(ticket_number)
|
||||||
|
|
||||||
# Show results
|
# Show results
|
||||||
post_drive_results(ticket_number)
|
if ticket_number:
|
||||||
|
post_drive_results(ticket_number)
|
||||||
show_results()
|
show_results()
|
||||||
|
|
||||||
# Open log
|
# Open log
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue