<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugzilla.yoctoproject.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugzilla.yoctoproject.org/"
          
          maintainer="it-coreprojects-helpdesk@linuxfoundation.org"
>

    <bug>
          <bug_id>11897</bug_id>
          
          <creation_ts>2017-08-04 22:35:32 +0000</creation_ts>
          <short_desc>checkvnc script fails on Centos 7 due to netstat being deprecated</short_desc>
          <delta_ts>2017-09-13 09:09:36 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>5</classification_id>
          <classification>Infrastructure</classification>
          <product>AutoBuilder</product>
          <component>autobuilder</component>
          <version>unspecified</version>
          <rep_platform>x86</rep_platform>
          <op_sys>Multiple</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>Medium</priority>
          <bug_severity>enhancement</bug_severity>
          <target_milestone>2.4</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Tracy Graydon">tracy.graydon</reporter>
          <assigned_to name="Tracy Graydon">tracy.graydon</assigned_to>
          <cc>infras.ab.watcher</cc>
    
    <cc>Infras.watcher</cc>
    
    <cc>joshuagloe</cc>
    
    <cc>mhalstead</cc>
    
    <cc>pidge</cc>
          
          
          <cf_os>---</cf_os>
          <cf_regression_type>---</cf_regression_type>
          
          <cf_docchange>Don&apos;t know</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>75665</commentid>
    <comment_count>0</comment_count>
    <who name="Tracy Graydon">tracy.graydon</who>
    <bug_when>2017-08-04 22:35:32 +0000</bug_when>
    <thetext>When running checkvnc script on Centos 7, the script fails on missing netstat command. The netstat command is deprecated for Centos and ss is used instead.

A potential fix would be to replace the &quot;netstat -tnl | grep :5901 &gt; /dev/null&quot; line in the checkvnc script with &quot;grep &apos;:170D&apos; /proc/net/tcp &gt; /dev/null&quot;

i.e.

#!/bin/sh
#
# check if vnc server is running, and if not, cleanup and restart
#
grep &apos;:170D&apos; /proc/net/tcp &gt; /dev/null
if [ $? != 0 ]; then
    echo &quot;Xvnc not running, attempting restart&quot;
    vncserver -kill :1
    vncserver
fi</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>75686</commentid>
    <comment_count>1</comment_count>
    <who name="Joshua Lock">joshuagloe</who>
    <bug_when>2017-08-07 13:06:08 +0000</bug_when>
    <thetext>We have netstat installed on the CentOS 7 workers on the public Autobuilder clusters. 

$ yum provides /usr/bin/netstat

net-tools-2.0-0.17.20131004git.el7.x86_64 : Basic networking tools
Repo        : @base
Matched from:
Filename    : /usr/bin/netstat</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>75693</commentid>
    <comment_count>2</comment_count>
    <who name="Tracy Graydon">tracy.graydon</who>
    <bug_when>2017-08-07 16:49:22 +0000</bug_when>
    <thetext>I could certainly install the net-tools package on the meta-intel systems, but I am questioning whether or not we might want to update the script in anticipation of the general deprecation of net-tools and the rise of using ss (from iproute2) instead. i.e. We may eventually see checkvnc fail down the road on systems using OS that have dropped net-tools, as that becomes more common.

This is obviously not a big ole&apos; fire or anything, but my feeling is that it would be better to update the script to move away from the deprecated net-tools (and netstat command), since it is a simple fix and actually just requires grep. But can&apos;t say I have my heart set on the outcome. ;)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>75695</commentid>
    <comment_count>3</comment_count>
    <who name="Joshua Lock">joshuagloe</who>
    <bug_when>2017-08-07 18:45:29 +0000</bug_when>
    <thetext>Oh, sure. Apologies, I hadn&apos;t internalised that net-tools is abandoned/deprecated.

Would we better off using ss instead?

[joshuagl@centos7 ~]$ netstat -tnl | grep :5901
tcp        0      0 0.0.0.0:5901            0.0.0.0:*               LISTEN     
tcp6       0      0 :::5901                 :::*                    LISTEN   
  
[joshuagl@centos7 ~]$ ss -tnl | grep :5901
LISTEN     0      5            *:5901                     *:*                  
LISTEN     0      5           :::5901                    :::*</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>75701</commentid>
    <comment_count>4</comment_count>
    <who name="Michael Halstead">mhalstead</who>
    <bug_when>2017-08-07 20:03:44 +0000</bug_when>
    <thetext>We could choose dynamically to depend on ss or netstat depending on which is available. I recommended just removing the dependency entirely since  /proc/net/tcp should work on all Linux hosts but I don&apos;t really care.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>75705</commentid>
    <comment_count>5</comment_count>
    <who name="Tracy Graydon">tracy.graydon</who>
    <bug_when>2017-08-07 23:59:48 +0000</bug_when>
    <thetext>I concur with Michael. Going straight to grep, which will be ubiquitous, seems the cleanest. No mucking with searching for which package is installed and then conditionally executing. In either case, we would be passing that output to grep for the port. So, I&apos;d vote for cutting to the chase and just using the /proc/net/tcp grep for port and call it good.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>75714</commentid>
    <comment_count>6</comment_count>
    <who name="Joshua Lock">joshuagloe</who>
    <bug_when>2017-08-08 08:46:21 +0000</bug_when>
    <thetext>Sure, let&apos;s do it</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>75868</commentid>
    <comment_count>7</comment_count>
    <who name="Tracy Graydon">tracy.graydon</who>
    <bug_when>2017-08-15 21:58:10 +0000</bug_when>
    <thetext>Submitted patch to yocto mailing list:

[Yocto #11897]

The checkvnc script uses deprecated netstat command for finding vnc sessions.
This breaks on Centos, and will break on other OS as it is removed in the
future.

Drop the dependency on netstat and instead grep /proc/net/tcp for
active sessions on 5901 port.

Signed-off-by: Graydon, Tracy &lt;tracy.graydon@intel.com&gt;
---
bin/checkvnc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bin/checkvnc b/bin/checkvnc
index d934dfa..11e03bb 100755
--- a/bin/checkvnc
+++ b/bin/checkvnc
@@ -2,7 +2,7 @@
#
# check if vnc server is running, and if not, cleanup and restart
#
-netstat -tnl | grep :5901 &gt; /dev/null
+grep &apos;:170D&apos; /proc/net/tcp &gt; /dev/null
if [ $? != 0 ]; then
     echo &quot;Xvnc not running, attempting restart&quot;
     vncserver -kill :1
--
2.7.0

--


Also can be found on yocto-autobuilder branch contrib/tgraydon/checkvnc-11897</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>76778</commentid>
    <comment_count>8</comment_count>
    <who name="Joshua Lock">joshuagloe</who>
    <bug_when>2017-09-13 09:09:36 +0000</bug_when>
    <thetext>http://git.yoctoproject.org/clean/cgit.cgi/yocto-autobuilder/commit/?id=303742bdf5e7995e6e9e25fab29deeb260a3cb55</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>