Skip to content

Colorize zpool iostat output #14459

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

ethan-coe-renner
Copy link
Contributor

Motivation and Context

Add colored output to zpool iostat to improve readability and allow users to quickly see relative sizes of various entries. Addresses #13168 by coloring space suffixes.

Description

Uses the interface introduced in #9340 to add color to zpool iostat.

If the ZFS_COLOR env variable is set, then the output of zpool iostat is colored as follows:

  • Header rows are bold
  • 0 space is colored gray
  • Size suffixes are colored by order of magnitude
    • K is green
    • M is yellow
    • G is red
    • T is blue
    • P is magenta
    • E is cyan

Screenshots
Screen Shot 2023-02-03 at 13 16 33
Screen Shot 2023-02-03 at 13 17 14

How Has This Been Tested?

Manually tested

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Performance enhancement (non-breaking change which improves efficiency)
  • Code cleanup (non-breaking change which makes code smaller or more readable)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Library ABI change (libzfs, libzfs_core, libnvpair, libuutil and libzfsbootenv)
  • Documentation (a change to man pages or other documentation)

Checklist:

- Bold header
- Color space suffixes in iostat by order of magnitude
    - K is green
    - M is yellow
    - G is red
    - T is blue
    - P is magenta
    - E is cyan
- 0 space is colored gray

Signed-off-by: Ethan Coe-Renner <[email protected]>
@behlendorf behlendorf added the Status: Code Review Needed Ready for review and testing label Feb 14, 2023
@mcmilk
Copy link
Contributor

mcmilk commented Feb 28, 2023

When the output of zpool iostat is redirected to some file, then it will also print those ANSI key escapes ....
Maybe some check with isatty(int fd); could be done before?

Edit: libzfs_util.c has a isatty() check - so everything is fine with this. Please ignore this comment.

Copy link
Contributor

@mcmilk mcmilk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A rebase would be fine.
I see no errors within the code - but the tests should be triggered again.

Copy link
Contributor

@Low-power Low-power left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

diff --git a/include/libzutil.h b/include/libzutil.h
index fe65265..a2938c7 100644
--- a/include/libzutil.h
+++ b/include/libzutil.h
@@ -173,9 +173,8 @@ struct zfs_cmd;
 #define	ANSI_GREEN	"\033[0;32m"
 #define	ANSI_YELLOW	"\033[0;33m"
 #define	ANSI_BLUE	"\033[0;34m"
-#define	ANSI_MAGENTA	"\033[0;34m"
-#define	ANSI_CYAN	"\033[0;34m"
-
+#define	ANSI_MAGENTA	"\033[0;35m"
+#define	ANSI_CYAN	"\033[0;36m"
 #define	ANSI_GRAY	"\033[0;37m"
 #define	ANSI_RESET	"\033[0m"
 #define	ANSI_BOLD	"\033[1m"

@Low-power
Copy link
Contributor

Low-power commented Mar 10, 2023

Since this color scheme didn't use bold (bright) colors, some colors it uses may look too dark on a black background terminal; this actually reduces readability, especially for blue. Try finding the blue T in this example:

colorized zpool iostat on black background terminal

Therefore I suggest avoid using ANSI_BLUE without ANSI_BOLD.

@Low-power
Copy link
Contributor

Therefore I suggest avoid using ANSI_BLUE without ANSI_BOLD.

This also applies to commit fb11b15 -- the renamed pathes in dark blue are extremely hard to read.

mcmilk added a commit to mcmilk/zfs that referenced this pull request Mar 13, 2023
Use a bold header and colorize the space suffixes in iostat
by order of magnitude like this:
- K is green
- M is yellow
- G is red
- T is lightblue
- P is magenta
- E is cyan
- 0 space is colored gray

Signed-off-by: Ethan Coe-Renner <[email protected]>
Signed-off-by: Tino Reichardt <[email protected]>
Closes: openzfs#14459
@mcmilk mcmilk mentioned this pull request Mar 14, 2023
13 tasks
mcmilk added a commit to mcmilk/zfs that referenced this pull request Mar 14, 2023
Use a bold header and colorize the space suffixes in iostat
by order of magnitude like this:
- K is green
- M is yellow
- G is red
- T is lightblue
- P is magenta
- E is cyan
- 0 space is colored gray

Signed-off-by: Ethan Coe-Renner <[email protected]>
Signed-off-by: Tino Reichardt <[email protected]>
Closes: openzfs#14459
mcmilk added a commit to mcmilk/zfs that referenced this pull request Mar 14, 2023
Use a bold header and colorize the space suffixes in iostat
by order of magnitude like this:
- K is green
- M is yellow
- G is red
- T is lightblue
- P is magenta
- E is cyan
- 0 space is colored gray

Signed-off-by: Ethan Coe-Renner <[email protected]>
Signed-off-by: Tino Reichardt <[email protected]>
Closes: openzfs#14459
andrewc12 pushed a commit to andrewc12/openzfs that referenced this pull request Mar 26, 2023
Use a bold header and colorize the space suffixes in iostat
by order of magnitude like this:
- K is green
- M is yellow
- G is red
- T is lightblue
- P is magenta
- E is cyan
- 0 space is colored gray

Reviewed-by: WHR <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Ethan Coe-Renner <[email protected]>
Signed-off-by: Tino Reichardt <[email protected]>
Closes openzfs#14621
Closes openzfs#14459
andrewc12 pushed a commit to andrewc12/openzfs that referenced this pull request Mar 26, 2023
Use a bold header and colorize the space suffixes in iostat
by order of magnitude like this:
- K is green
- M is yellow
- G is red
- T is lightblue
- P is magenta
- E is cyan
- 0 space is colored gray

Reviewed-by: WHR <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Ethan Coe-Renner <[email protected]>
Signed-off-by: Tino Reichardt <[email protected]>
Closes openzfs#14621
Closes openzfs#14459
tonyhutter pushed a commit to tonyhutter/zfs that referenced this pull request Mar 28, 2023
Use a bold header and colorize the space suffixes in iostat
by order of magnitude like this:
- K is green
- M is yellow
- G is red
- T is lightblue
- P is magenta
- E is cyan
- 0 space is colored gray

Reviewed-by: WHR <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Ethan Coe-Renner <[email protected]>
Signed-off-by: Tino Reichardt <[email protected]>
Closes openzfs#14621
Closes openzfs#14459
tonyhutter pushed a commit to tonyhutter/zfs that referenced this pull request Apr 5, 2023
Use a bold header and colorize the space suffixes in iostat
by order of magnitude like this:
- K is green
- M is yellow
- G is red
- T is lightblue
- P is magenta
- E is cyan
- 0 space is colored gray

Reviewed-by: WHR <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Ethan Coe-Renner <[email protected]>
Signed-off-by: Tino Reichardt <[email protected]>
Closes openzfs#14621
Closes openzfs#14459
pcd1193182 pushed a commit to pcd1193182/zfs that referenced this pull request Sep 26, 2023
Use a bold header and colorize the space suffixes in iostat
by order of magnitude like this:
- K is green
- M is yellow
- G is red
- T is lightblue
- P is magenta
- E is cyan
- 0 space is colored gray

Reviewed-by: WHR <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Ethan Coe-Renner <[email protected]>
Signed-off-by: Tino Reichardt <[email protected]>
Closes openzfs#14621
Closes openzfs#14459
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Code Review Needed Ready for review and testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants