diff mbox series

ver_linux: use lscpu command result instead of /proc/cpuinfo

Message ID 20180815185516.32726-1-msys.mizuma@gmail.com
State Changes Requested
Delegated to: Petr Vorel
Headers show
Series ver_linux: use lscpu command result instead of /proc/cpuinfo | expand

Commit Message

Masayoshi Mizuma Aug. 15, 2018, 6:55 p.m. UTC
From: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>

lscpu command shows the cpu information clearly. So let's use
the result if the command is installed to the system.

Signed-off-by: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
---
 ver_linux | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

Comments

Cyril Hrubis Sept. 27, 2018, 12:40 p.m. UTC | #1
Hi!
> Signed-off-by: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
> ---
>  ver_linux | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/ver_linux b/ver_linux
> index dda337926..5f9260f5f 100755
> --- a/ver_linux
> +++ b/ver_linux
> @@ -96,5 +96,10 @@ echo 'free reports:'
>  free
>  
>  echo
> -echo '/proc/cpuinfo'
> -cat /proc/cpuinfo
> +echo 'cpuinfo:'
> +which lscpu > /dev/null 2>&1
> +if [ $? -eq 0 ]; then

You can just write:

if which lscpu > /dev/null 2>&1; then
...


Other than that it's fine.
Masayoshi Mizuma Sept. 27, 2018, 2:02 p.m. UTC | #2
On Thu, Sep 27, 2018 at 02:40:11PM +0200, Cyril Hrubis wrote:
> Hi!
> > Signed-off-by: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
> > ---
> >  ver_linux | 9 +++++++--
> >  1 file changed, 7 insertions(+), 2 deletions(-)
> > 
> > diff --git a/ver_linux b/ver_linux
> > index dda337926..5f9260f5f 100755
> > --- a/ver_linux
> > +++ b/ver_linux
> > @@ -96,5 +96,10 @@ echo 'free reports:'
> >  free
> >  
> >  echo
> > -echo '/proc/cpuinfo'
> > -cat /proc/cpuinfo
> > +echo 'cpuinfo:'
> > +which lscpu > /dev/null 2>&1
> > +if [ $? -eq 0 ]; then
> 
> You can just write:
> 
> if which lscpu > /dev/null 2>&1; then
> ...
> 
> 
> Other than that it's fine.

Thanks! I'll send the v2 soon.

- Masa
diff mbox series

Patch

diff --git a/ver_linux b/ver_linux
index dda337926..5f9260f5f 100755
--- a/ver_linux
+++ b/ver_linux
@@ -96,5 +96,10 @@  echo 'free reports:'
 free
 
 echo
-echo '/proc/cpuinfo'
-cat /proc/cpuinfo
+echo 'cpuinfo:'
+which lscpu > /dev/null 2>&1
+if [ $? -eq 0 ]; then
+	lscpu
+else
+	cat /proc/cpuinfo
+fi