Bug 212906

Summary: PATCH: awk + grep vs. sed in /usr/share/cluster/ip.sh
Product: [Retired] Red Hat Cluster Suite Reporter: Satoru SATOH <ssato>
Component: rgmanagerAssignee: Marek Grac <mgrac>
Status: CLOSED WONTFIX QA Contact: Cluster QE <mspqa-list>
Severity: low Docs Contact:
Priority: low    
Version: 4CC: cluster-maint
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2006-11-28 17:31:55 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
grep+awk -> sed patch none

Description Satoru SATOH 2006-10-30 02:42:27 UTC
Description of problem:

It is quite trivial issue, but, there are a few lines, awk+grep combination is
used, found in /usr/share/cluster/ip.sh. I think it may be substituted with sed
(requires less resource and perhaps a little bit faster) such like the following.

## The former is the way found in ip.sh and the later is alternative.
[root@gescom ~]# /sbin/ethtool eth0 | grep "Link detected:" | awk '{print $3;}'
yes
[root@gescom ~]# ethtool eth0 | sed -ne 's/.*Link detected: \(.*\)/\1/p'
yes

## Size of these commands:
[root@foo ~]# cat /etc/redhat-release 
Red Hat Desktop release 4 (Nahant Update 4)
[root@foo ~]# ls -lh /bin/*awk /bin/sed /bin/*grep
lrwxrwxrwx  1 root root    4  6月 29 12:57 /bin/awk -> gawk
lrwxrwxrwx  1 root root    4  8月 14 17:36 /bin/egrep -> grep
lrwxrwxrwx  1 root root    4  8月 14 17:36 /bin/fgrep -> grep
-rwxr-xr-x  1 root root 247K 11月  5  2004 /bin/gawk
-rwxr-xr-x  1 root root  76K  2月 20  2006 /bin/grep
-rwxr-xr-x  1 root root 3.1K 11月  5  2004 /bin/igawk
-rwxr-xr-x  1 root root 248K 11月  5  2004 /bin/pgawk
-rwxr-xr-x  1 root root  46K  4月 14  2006 /bin/sed
[root@foo ~]#

I attached a sample patch, rgmanager-1.9.54_ip.sh_lr.patch.


Version-Release number of selected component (if applicable): rgmanager-1.9.54

How reproducible: always


Steps to Reproduce:
1.
2.
3.
  
Actual results:


Expected results:


Additional info:

Comment 1 Satoru SATOH 2006-10-30 02:42:27 UTC
Created attachment 139691 [details]
grep+awk -> sed patch

Comment 2 Lon Hohberger 2006-11-10 15:55:16 UTC
I say 'to-MAY-toes', you say 'to-MAH-toes'.

I'd like to know a clear benefit before I change currently-working code in a
stable release.

It spawns one less process.  However, if it's performance we cared about, we
could use bash shell text parsing to accomplish the same things...

Does it fix a bug?

Comment 3 Lon Hohberger 2006-11-10 15:57:24 UTC
Note: I'm cool with putting this in RHCS5 for GA, and backporting to RHCS4 later.

Comment 5 Satoru SATOH 2006-11-28 02:15:24 UTC
Excuse me not to give any response for a while.

I'm not sure there are any clear benefits actually. My patch is just another way
to do that and I just thought that less program size and less dependency is
better for HA softwares.

Comment 6 Kiersten (Kerri) Anderson 2006-11-28 17:02:07 UTC
devel NAK for rhel4.

Comment 7 RHEL Program Management 2006-11-28 17:31:55 UTC
Development Management has reviewed and declined this request.  You may appeal
this decision by reopening this request. 

Comment 8 Marek Grac 2006-11-29 20:37:44 UTC
I'm also against changing working code because there are no real benefits. 

resources)
Yes, grep + awk is surely slower than sed (2 vs 1 process) but for input as
small as we have from ethtool/ifconfig/ip/... it doesn't matter at all. 

dependencies)
You have to have installed awk anyway

clean code)
Such simple awk commands are easily read by non-awk users but you are right that
this combination should not be used in new RA.