Skip to content

Commit

Permalink
Merge pull request #25 from Freaky/add-timestamp
Browse files Browse the repository at this point in the history
Add a -T timestamp flag with u and d options
  • Loading branch information
jimsalterjrs authored Jan 26, 2022
2 parents c4c83f5 + d993317 commit 58cb14a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ For the most part, `ioztat` behaves the same way that the system standard `iosta

````
usage: ioztat [-b] [-c COUNT] [-h] [-i INTERVAL] [-n] [-o] [-P | -p] [-s {name,rps,wps,rMBps,wMBps}]
[-y] [-V] [-z]
[-T {u,d}] [-y] [-V] [-z]
[dataset [dataset ...]]
iostat for ZFS datasets
Expand All @@ -46,6 +46,7 @@ optional arguments:
-p display dataset names as an abbreviated tree
-s {name,rps,wps,rMBps,wMBps}
sort by the specified field
-T {u,d} prefix each report with a Unix timestamp or formatted date
-y skip the initial "summary" report
-V, --version show program's version number and exit
-z suppress datasets with zero activity
Expand Down
6 changes: 6 additions & 0 deletions ioztat
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ group = parser.add_mutually_exclusive_group()
group.add_argument('-P', dest='fullname', default=None, action='store_true', help='display dataset names on a single line')
group.add_argument('-p', dest='fullname', default=None, action='store_false', help='display dataset names as an abbreviated tree')
parser.add_argument('-s', dest='sort', default='name', choices=sorts.keys(), help='sort by the specified field')
parser.add_argument('-T', dest='timestamp', default=False, choices=['u', 'd'], help='prefix each report with a Unix timestamp or formatted date')
parser.add_argument('-y', dest='skipsummary', default=False, action='store_true', help='skip the initial "summary" report')
parser.add_argument('-V', '--version', action='version', version='%(prog)s ' + PROGRAM_VERSION)
parser.add_argument('-z', dest='nonzero', default=False, action='store_true', help='suppress datasets with zero activity')
Expand Down Expand Up @@ -240,6 +241,11 @@ try:
# Clear the screen and move the cursor to the upper-left
print("\033[2J\033[1;1H", end = '')

if args.timestamp == 'u':
print(int(time.time()))
elif args.timestamp == 'd':
print(time.strftime('%c'))

print('{:40s} {:>10s} {:>10s} {:>10s} {:>10s} {:>10s} {:>10s}'
.format('dataset', 'w/s', 'wMB/s', 'r/s', 'rMB/s', 'wareq-sz', 'rareq-sz'))

Expand Down

0 comments on commit 58cb14a

Please sign in to comment.