def _io_ps(path, prev, curr, attr): path = only_one_path(path) if all_not_none(prev, curr): prev_counter = prev.by_path(path) curr_counter = curr.by_path(path) else: prev_counter = None curr_counter = None if all_not_none(prev_counter, curr_counter): delta = getattr(curr_counter, attr) - getattr(prev_counter, attr) ret = delta / curr.diff_seconds(prev) else: ret = IdValues() return ret
def sp_delta_ps(path, prev, curr): path = only_one_path(path) if all_not_none(prev, curr): prev_counter = prev.by_path(path) curr_counter = curr.by_path(path) else: prev_counter = None curr_counter = None if all_not_none(prev_counter, curr_counter): delta = curr_counter.sp_values - prev_counter.sp_values ret = delta / curr.diff_seconds(prev) else: ret = IdValues() return ret
def div(op1, op2): ret = NaN if all_not_none(op1, op2): if op1 == 0: ret = 0.0 elif op2 != 0: ret = op1 / op2 return ret
def _get_calculated_stats(cli, config, obj): prev = cli.prev_counter curr = cli.curr_counter if all_not_none(prev, curr): ret = config.calculator(prev, curr, obj, config.counters) else: ret = NaN return ret
def wrapper(prev, curr, obj, counters): prev_rsc = prev.get_rsc(obj) curr_rsc = curr.get_rsc(obj) if all_not_none(prev_rsc, curr_rsc): ret = func(prev_rsc, curr_rsc, counters) if per_second: dt = round_60(curr.delta_seconds(prev)) ret = div(ret, dt) else: ret = NaN return ret
def _sp_pct(path, curr, prev): part1, part2 = path if all_not_none(prev, curr): prev_part1 = prev.by_path(part1) prev_part2 = prev.by_path(part2) curr_part1 = curr.by_path(part1) curr_part2 = curr.by_path(part2) delta_part1 = curr_part1.sp_values - prev_part1.sp_values delta_part2 = curr_part2.sp_values - prev_part2.sp_values ret = delta_part1 * 100 / (delta_part2 + delta_part1) else: ret = IdValues() return ret
def _byte_rate(path, prev, curr, err_msg, attr): if len(path) != 2: raise ValueError(err_msg) part1, part2 = path if all_not_none(prev, curr): delta = getattr(curr.by_path(part1), attr)(curr.by_path(part2)) - getattr( prev.by_path(part1), attr)(prev.by_path(part2)) ret = delta / curr.diff_seconds(prev) else: ret = IdValues() return ret
def busy_idle_util(path, prev, curr): if len(path) != 2: raise ValueError('takes in "busy" and "idle" counter.') busy_path, idle_path = path if all_not_none(prev, curr): prev_busy = prev.by_path(busy_path) prev_idle = prev.by_path(idle_path) curr_busy = curr.by_path(busy_path) curr_idle = curr.by_path(idle_path) delta_busy = curr_busy.sum_sp() - prev_busy.sum_sp() delta_idle = curr_idle.sum_sp() - prev_idle.sum_sp() ret = delta_busy * 100 / (delta_idle + delta_busy) else: ret = IdValues() return ret
def disk_response_time(path, prev, curr): if len(path) != 5: raise ValueError( 'takes in "busyTicks", "sumArrivalQueueLength", "reads", ' '"writes" and "coreCount" counter.') busy_tick_path, sum_arr_ql_path, read_path, write_path, core_count_path = \ path if all_not_none(prev, curr): prev_busy_tick = prev.by_path(busy_tick_path) prev_sum_arr_ql = prev.by_path(sum_arr_ql_path) prev_read = prev.by_path(read_path) prev_write = prev.by_path(write_path) prev_core_count = prev.by_path(core_count_path) curr_busy_tick = curr.by_path(busy_tick_path) curr_sum_arr_ql = curr.by_path(sum_arr_ql_path) curr_read = curr.by_path(read_path) curr_write = curr.by_path(write_path) curr_core_count = curr.by_path(core_count_path) delta_busy_tick = curr_busy_tick.sum_sp() - prev_busy_tick.sum_sp() delta_sum_arr_ql = curr_sum_arr_ql.sum_sp() - prev_sum_arr_ql.sum_sp() delta_read = curr_read.sum_sp() - prev_read.sum_sp() delta_write = curr_write.sum_sp() - prev_write.sum_sp() delta_read_core_count = curr_read.combine_numeric_values( curr_core_count) - prev_read.combine_numeric_values( prev_core_count) delta_write_core_count = curr_write.combine_numeric_values( curr_core_count) - prev_write.combine_numeric_values( prev_core_count) ret = delta_busy_tick * delta_sum_arr_ql / ( (delta_read + delta_write) * (delta_read_core_count + delta_write_core_count)) else: ret = IdValues() return ret
def _queue_length(path, prev, curr, err_msg, func): if len(path) != 3: raise ValueError(err_msg) part1, part2, part3 = path if all_not_none(prev, curr): prev_part1 = prev.by_path(part1) prev_part2 = prev.by_path(part2) prev_part3 = prev.by_path(part3) curr_part1 = curr.by_path(part1) curr_part2 = curr.by_path(part2) curr_part3 = curr.by_path(part3) delta_part1 = curr_part1.sum_sp() - prev_part1.sum_sp() delta_part2 = curr_part2.sum_sp() - prev_part2.sum_sp() delta_part3 = curr_part3.sum_sp() - prev_part3.sum_sp() ret = func(delta_part1, delta_part2, delta_part3) else: ret = IdValues() return ret
def mul(op1, op2): if all_not_none(op1, op2): ret = op1 * op2 else: ret = NaN return ret
def minus(op1, op2): if all_not_none(op1, op2): ret = op1 - op2 else: ret = NaN return ret