diff --git a/.bin/Scripts/functions/hw_diags.py b/.bin/Scripts/functions/hw_diags.py index 467d3563..018d54c8 100644 --- a/.bin/Scripts/functions/hw_diags.py +++ b/.bin/Scripts/functions/hw_diags.py @@ -43,8 +43,8 @@ IO_VARS = { 'Minimum Test Size': 10*1024**3, 'Alt Test Size Factor': 0.01, 'Progress Refresh Rate': 5, - 'Scale 16': [2**(0.6*x)+(16*x) for x in range(1,17)], - 'Scale 32': [2**(0.6*x/2)+(16*x/2) for x in range(1,33)], + 'Scale 16': [2**(0.56*x)+(16*x) for x in range(1,17)], + 'Scale 32': [2**(0.56*x/2)+(16*x/2) for x in range(1,33)], 'Threshold Fail': 65*1024**2, 'Threshold Warn': 135*1024**2, 'Threshold Great': 750*1024**2, @@ -95,7 +95,7 @@ TESTS = { def connect_to_db(): """Connect to osTicket database via SSH tunnel.""" cmd = [ - 'ssh', '-N', '-p', '2222', '-L3306:127.0.0.1:3306', + 'ssh', '-N', '-p', SSH_PORT, '-L3306:127.0.0.1:3306', '{user}@{host}'.format(user=SSH_USER, host=DB_HOST), ] @@ -128,10 +128,12 @@ def disconnect_from_db(): def generate_horizontal_graph(rates): """Generate two-line horizontal graph from rates, returns str.""" - line_top = '' - line_bottom = '' + line_1 = '' + line_2 = '' + line_3 = '' + line_4 = '' for r in rates: - step = get_graph_step(r, scale=16) + step = get_graph_step(r, scale=32) # Set color r_color = COLORS['CLEAR'] @@ -143,15 +145,32 @@ def generate_horizontal_graph(rates): r_color = COLORS['GREEN'] # Build graph - if step < 8: - line_top += ' ' - line_bottom += '{}{}'.format(r_color, IO_VARS['Graph Horizontal'][step]) + full_block = '{}{}'.format(r_color, IO_VARS['Graph Horizontal'][-1]) + if step >= 24: + line_1 += '{}{}'.format(r_color, IO_VARS['Graph Horizontal'][step-24]) + line_2 += full_block + line_3 += full_block + line_4 += full_block + elif step >= 16: + line_1 += ' ' + line_2 += '{}{}'.format(r_color, IO_VARS['Graph Horizontal'][step-16]) + line_3 += full_block + line_4 += full_block + elif step >= 8: + line_1 += ' ' + line_2 += ' ' + line_3 += '{}{}'.format(r_color, IO_VARS['Graph Horizontal'][step-8]) + line_4 += full_block else: - line_top += '{}{}'.format(r_color, IO_VARS['Graph Horizontal'][step-8]) - line_bottom += '{}{}'.format(r_color, IO_VARS['Graph Horizontal'][-1]) - line_top += COLORS['CLEAR'] - line_bottom += COLORS['CLEAR'] - return '{}\n{}'.format(line_top, line_bottom) + line_1 += ' ' + line_2 += ' ' + line_3 += ' ' + line_4 += '{}{}'.format(r_color, IO_VARS['Graph Horizontal'][step]) + line_1 += COLORS['CLEAR'] + line_2 += COLORS['CLEAR'] + line_3 += COLORS['CLEAR'] + line_4 += COLORS['CLEAR'] + return '\n'.join([line_1, line_2, line_3, line_4]) def get_graph_step(rate, scale=16): """Get graph step based on rate and scale, returns int.""" @@ -763,7 +782,7 @@ def run_iobenchmark(ticket_number): h_graph_rates.append(sum(read_rates[pos:pos+width])/width) pos += width report = generate_horizontal_graph(h_graph_rates) - report += '\nRead speed: {:3.1f} MB/s (Min: {:3.1f}, Max: {:3.1f})'.format( + report += '\nAverage read speed: {:3.1f} MB/s (Min: {:3.1f}, Max: {:3.1f})'.format( sum(read_rates)/len(read_rates)/(1024**2), min(read_rates)/(1024**2), max(read_rates)/(1024**2)) diff --git a/.bin/Scripts/settings/main.py b/.bin/Scripts/settings/main.py index 0d5944a2..349723d1 100644 --- a/.bin/Scripts/settings/main.py +++ b/.bin/Scripts/settings/main.py @@ -16,6 +16,7 @@ DB_HOST='127.0.0.1' DB_NAME='osticket' DB_USER='wizardkit' DB_PASS='Abracadabra' +SSH_PORT='22' SSH_USER='sql_tunnel' # Live Linux MPRIME_LIMIT='7' # of minutes to run Prime95 during hw-diags