Blame SOURCES/CLI-Do-not-show-column-headers-when-not-outputting-t.patch

d2f14d
From 47ea4e06b7f042fa7d8512fa8e95d513bf82c741 Mon Sep 17 00:00:00 2001
d2f14d
From: Arnaldo Carvalho de Melo <acme@felicio.ghostprotocols.net>
d2f14d
Date: Tue, 9 Jun 2015 16:27:30 -0300
d2f14d
Subject: [PATCH 13/15] CLI: Do not show column headers when not outputting to
d2f14d
 a tty:
d2f14d
d2f14d
[root@felicio ~]# tuna -q en* -Q
d2f14d
   # users            affinity
d2f14d
  54 enp1s0f0-TxRx-0     0,1,2  ixgbe
d2f14d
  55 enp1s0f0-TxRx-1     0,1,2  ixgbe
d2f14d
  56 enp1s0f0-TxRx-2     0,1,2  ixgbe
d2f14d
  57 enp1s0f0-TxRx-3     0,1,2  ixgbe
d2f14d
  58 enp1s0f0            0,1,2  ixgbe
d2f14d
  59 enp1s0f1-TxRx-0     0,1,2  ixgbe
d2f14d
  60 enp1s0f1-TxRx-1     0,1,2  ixgbe
d2f14d
  61 enp1s0f1-TxRx-2     0,1,2  ixgbe
d2f14d
  62 enp1s0f1-TxRx-3     0,1,2  ixgbe
d2f14d
  63 enp1s0f1            0,1,2  ixgbe
d2f14d
  66 enp7s0              0,1,2  atl1c
d2f14d
[root@felicio ~]# tuna -q en* -Q | head -4
d2f14d
  54 enp1s0f0-TxRx-0     0,1,2  ixgbe
d2f14d
  55 enp1s0f0-TxRx-1     0,1,2  ixgbe
d2f14d
  56 enp1s0f0-TxRx-2     0,1,2  ixgbe
d2f14d
  57 enp1s0f0-TxRx-3     0,1,2  ixgbe
d2f14d
[root@felicio ~]#
d2f14d
d2f14d
[root@felicio ~]# tuna -t xfs-d* -P
d2f14d
                      thread       ctxt_switches
d2f14d
    pid SCHED_ rtpri affinity voluntary nonvoluntary             cmd
d2f14d
  459    OTHER     0  0,1,2,3         2            1   xfs-data/dm-1
d2f14d
  654    OTHER     0  0,1,2,3         2            0   xfs-data/sda1
d2f14d
  669    OTHER     0  0,1,2,3         2            0   xfs-data/dm-2
d2f14d
[root@felicio ~]# tuna -t xfs-d* -P | head
d2f14d
  459    OTHER     0  0,1,2,3         2            1   xfs-data/dm-1
d2f14d
  654    OTHER     0  0,1,2,3         2            0   xfs-data/sda1
d2f14d
  669    OTHER     0  0,1,2,3         2            0   xfs-data/dm-2
d2f14d
[root@felicio ~]#
d2f14d
d2f14d
Useful, for instance, when using wc to count how many IRQs or threadas match
d2f14d
some filters.
d2f14d
d2f14d
Signed-off-by: Arnaldo Carvalho de Melo <acme@felicio.ghostprotocols.net>
d2f14d
Signed-off-by: John Kacur <jkacur@redhat.com>
d2f14d
---
d2f14d
 tuna-cmd.py | 6 ++++--
d2f14d
 1 file changed, 4 insertions(+), 2 deletions(-)
d2f14d
d2f14d
diff --git a/tuna-cmd.py b/tuna-cmd.py
d2f14d
index 9edf7de6c286..ba40ec8246ba 100755
d2f14d
--- a/tuna-cmd.py
d2f14d
+++ b/tuna-cmd.py
d2f14d
@@ -305,7 +305,8 @@ def do_ps(thread_list, cpu_list, irq_list, show_uthreads,
d2f14d
 	
d2f14d
 	has_ctxt_switch_info = ps[1]["status"].has_key("voluntary_ctxt_switches")
d2f14d
 	try:
d2f14d
-		ps_show_header(has_ctxt_switch_info, cgroups)
d2f14d
+		if sys.stdout.isatty():
d2f14d
+			ps_show_header(has_ctxt_switch_info, cgroups)
d2f14d
 		ps_show(ps, affect_children, thread_list,
d2f14d
 			cpu_list, irq_list, show_uthreads, show_kthreads,
d2f14d
 			has_ctxt_switch_info, sock_inodes, sock_inode_re, cgroups)
d2f14d
@@ -334,7 +335,8 @@ def show_irqs(irq_list, cpu_list):
d2f14d
 	if not irqs:
d2f14d
 		irqs = procfs.interrupts()
d2f14d
 
d2f14d
-	print "%4s %-16s %8s" % ("#", _("users"), _("affinity"),)
d2f14d
+	if sys.stdout.isatty():
d2f14d
+		print "%4s %-16s %8s" % ("#", _("users"), _("affinity"),)
d2f14d
 	sorted_irqs = []
d2f14d
 	for k in irqs.keys():
d2f14d
 		try:
d2f14d
-- 
d2f14d
1.8.3.1
d2f14d