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 time
|
||||
|
||||
from functions.common import *
|
||||
from functions.data import *
|
||||
from numpy import *
|
||||
|
||||
# Database connection
|
||||
|
|
@ -345,12 +345,15 @@ def menu_diags(*args):
|
|||
if diag_modes[int(selection)-1]['Name'] != 'Quick drive test':
|
||||
clear_screen()
|
||||
print_standard(' ')
|
||||
try_and_print(
|
||||
result = try_and_print(
|
||||
message='Connecting to osTicket database...',
|
||||
function=connect_to_db,
|
||||
width=40)
|
||||
if not result['CS']:
|
||||
print_warning('osTicket integration disabled for this run.')
|
||||
pause()
|
||||
# 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['Env']['HOME'],
|
||||
ticket_number,
|
||||
|
|
@ -358,6 +361,7 @@ def menu_diags(*args):
|
|||
os.makedirs(global_vars['LogDir'], exist_ok=True)
|
||||
global_vars['LogFile'] = '{}/Hardware Diagnostics.log'.format(
|
||||
global_vars['LogDir'])
|
||||
ticket_number = get_osticket_number()
|
||||
run_tests(diag_modes[int(selection)-1]['Tests'], ticket_number)
|
||||
elif selection == 'A':
|
||||
run_program(['hw-diags-audio'], check=False, pipe=False)
|
||||
|
|
@ -634,6 +638,25 @@ def post_drive_results(ticket_number):
|
|||
# Oh well
|
||||
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
|
||||
osticket_post_reply(
|
||||
ticket_id=ticket_number,
|
||||
|
|
@ -979,35 +1002,36 @@ def run_mprime(ticket_number):
|
|||
update_progress()
|
||||
|
||||
# Build osTicket report
|
||||
report = ['Prime95 ({}):'.format(TESTS['Prime95']['Status'])]
|
||||
log_path = '{}/prime.log'.format(global_vars['LogDir'])
|
||||
try:
|
||||
with open(log_path, 'r') as f:
|
||||
for line in f.readlines():
|
||||
line = line.strip()
|
||||
r = re.search('(completed \d+ tests.*)', line, re.IGNORECASE)
|
||||
if r:
|
||||
report.append(r.group(1))
|
||||
except:
|
||||
report.append('ERROR: Failed to read log.')
|
||||
report.append('')
|
||||
report.append('Final temps:')
|
||||
log_path = '{}/Final Temps.log'.format(global_vars['LogDir'])
|
||||
try:
|
||||
with open(log_path, 'r') as f:
|
||||
for line in f.readlines():
|
||||
line = line.strip()
|
||||
if not line:
|
||||
# Stop after CPU temp(s)
|
||||
break
|
||||
report.append(line)
|
||||
except:
|
||||
report.append('ERROR: Failed to read log.')
|
||||
if ticket_number:
|
||||
report = ['Prime95 ({}):'.format(TESTS['Prime95']['Status'])]
|
||||
log_path = '{}/prime.log'.format(global_vars['LogDir'])
|
||||
try:
|
||||
with open(log_path, 'r') as f:
|
||||
for line in f.readlines():
|
||||
line = line.strip()
|
||||
r = re.search('(completed \d+ tests.*)', line, re.IGNORECASE)
|
||||
if r:
|
||||
report.append(r.group(1))
|
||||
except:
|
||||
report.append('ERROR: Failed to read log.')
|
||||
report.append('')
|
||||
report.append('Final temps:')
|
||||
log_path = '{}/Final Temps.log'.format(global_vars['LogDir'])
|
||||
try:
|
||||
with open(log_path, 'r') as f:
|
||||
for line in f.readlines():
|
||||
line = line.strip()
|
||||
if not line:
|
||||
# Stop after CPU temp(s)
|
||||
break
|
||||
report.append(line)
|
||||
except:
|
||||
report.append('ERROR: Failed to read log.')
|
||||
|
||||
# Upload osTicket report
|
||||
osticket_post_reply(
|
||||
ticket_id=ticket_number,
|
||||
response='\n'.join(report))
|
||||
# Upload osTicket report
|
||||
osticket_post_reply(
|
||||
ticket_id=ticket_number,
|
||||
response='\n'.join(report))
|
||||
|
||||
# Done
|
||||
run_program('tmux kill-pane -a'.split())
|
||||
|
|
@ -1140,7 +1164,8 @@ def run_tests(tests, ticket_number=None):
|
|||
run_iobenchmark(ticket_number)
|
||||
|
||||
# Show results
|
||||
post_drive_results(ticket_number)
|
||||
if ticket_number:
|
||||
post_drive_results(ticket_number)
|
||||
show_results()
|
||||
|
||||
# Open log
|
||||
|
|
|
|||
Loading…
Reference in a new issue