Mostly cosmetic changes
A few things I noticed while porting this code to the JSON script. The only real change here is fixing the bulk history output to print UTC time instead of local time.
This commit is contained in:
parent
258a33d62d
commit
e10c9dbb7f
3 changed files with 12 additions and 12 deletions
|
@ -74,8 +74,8 @@ def create_arg_parser(output_description, bulk_history=True):
|
||||||
metavar="N")
|
metavar="N")
|
||||||
if bulk_history:
|
if bulk_history:
|
||||||
sample_help = ("Number of data samples to parse; normally applies to first loop "
|
sample_help = ("Number of data samples to parse; normally applies to first loop "
|
||||||
"iteration only, default: -1 in bulk mode, loop interval if loop interval "
|
"iteration only, default: all in bulk mode, loop interval if loop "
|
||||||
"set, else " + str(SAMPLES_DEFAULT))
|
"interval set, else " + str(SAMPLES_DEFAULT))
|
||||||
no_counter_help = ("Don't track sample counter across loop iterations in non-bulk "
|
no_counter_help = ("Don't track sample counter across loop iterations in non-bulk "
|
||||||
"modes; keep using samples option value instead")
|
"modes; keep using samples option value instead")
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -65,7 +65,7 @@ def parse_args():
|
||||||
|
|
||||||
opts = dish_common.run_arg_parser(parser, no_stdout_errors=True)
|
opts = dish_common.run_arg_parser(parser, no_stdout_errors=True)
|
||||||
|
|
||||||
if len(opts.mode) > 1 and "bulk_history" in opts.mode:
|
if (opts.history_stats_mode or opts.satus_mode) and opts.bulk_mode:
|
||||||
parser.error("bulk_history cannot be combined with other modes for CSV output")
|
parser.error("bulk_history cannot be combined with other modes for CSV output")
|
||||||
|
|
||||||
return opts
|
return opts
|
||||||
|
@ -148,8 +148,8 @@ def loop_body(opts, gstate):
|
||||||
def cb_add_bulk(bulk, count, timestamp, counter):
|
def cb_add_bulk(bulk, count, timestamp, counter):
|
||||||
if opts.verbose:
|
if opts.verbose:
|
||||||
print("Time range (UTC): {0} -> {1}".format(
|
print("Time range (UTC): {0} -> {1}".format(
|
||||||
datetime.fromtimestamp(timestamp).isoformat(),
|
datetime.utcfromtimestamp(timestamp).isoformat(),
|
||||||
datetime.fromtimestamp(timestamp + count).isoformat()))
|
datetime.utcfromtimestamp(timestamp + count).isoformat()))
|
||||||
for key, val in bulk.items():
|
for key, val in bulk.items():
|
||||||
print("{0:22} {1}".format(key + ":", ", ".join(str(subval) for subval in val)))
|
print("{0:22} {1}".format(key + ":", ", ".join(str(subval) for subval in val)))
|
||||||
if opts.loop_interval > 0.0:
|
if opts.loop_interval > 0.0:
|
||||||
|
@ -157,7 +157,7 @@ def loop_body(opts, gstate):
|
||||||
else:
|
else:
|
||||||
for i in range(count):
|
for i in range(count):
|
||||||
timestamp += 1
|
timestamp += 1
|
||||||
fields = [datetime.fromtimestamp(timestamp).isoformat()]
|
fields = [datetime.utcfromtimestamp(timestamp).isoformat()]
|
||||||
fields.extend(["" if val[i] is None else str(val[i]) for val in bulk.values()])
|
fields.extend(["" if val[i] is None else str(val[i]) for val in bulk.values()])
|
||||||
print(",".join(fields))
|
print(",".join(fields))
|
||||||
|
|
||||||
|
|
|
@ -883,7 +883,7 @@ def history_ping_stats(parse_samples, verbose=False, context=None):
|
||||||
|
|
||||||
|
|
||||||
def history_stats(parse_samples, start=None, verbose=False, context=None, history=None):
|
def history_stats(parse_samples, start=None, verbose=False, context=None, history=None):
|
||||||
"""Fetch, parse, and compute the packet loss stats.
|
"""Fetch, parse, and compute ping and usage stats.
|
||||||
|
|
||||||
Note:
|
Note:
|
||||||
See module level docs regarding brackets in field names.
|
See module level docs regarding brackets in field names.
|
||||||
|
@ -918,10 +918,10 @@ def history_stats(parse_samples, start=None, verbose=False, context=None, histor
|
||||||
except grpc.RpcError as e:
|
except grpc.RpcError as e:
|
||||||
raise GrpcError(e)
|
raise GrpcError(e)
|
||||||
|
|
||||||
sample_range, parse_samples, current = _compute_sample_range(history,
|
sample_range, parsed_samples, current = _compute_sample_range(history,
|
||||||
parse_samples,
|
parse_samples,
|
||||||
start=start,
|
start=start,
|
||||||
verbose=verbose)
|
verbose=verbose)
|
||||||
|
|
||||||
tot = 0.0
|
tot = 0.0
|
||||||
count_full_drop = 0
|
count_full_drop = 0
|
||||||
|
@ -1051,7 +1051,7 @@ def history_stats(parse_samples, start=None, verbose=False, context=None, histor
|
||||||
deciles_full = [None] * 11
|
deciles_full = [None] * 11
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"samples": parse_samples,
|
"samples": parsed_samples,
|
||||||
"end_counter": current,
|
"end_counter": current,
|
||||||
}, {
|
}, {
|
||||||
"total_ping_drop": tot,
|
"total_ping_drop": tot,
|
||||||
|
|
Loading…
Reference in a new issue