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 "netstat -tnl | grep :5901 > /dev/null" line in the checkvnc script with "grep ':170D' /proc/net/tcp > /dev/null" i.e. #!/bin/sh # # check if vnc server is running, and if not, cleanup and restart # grep ':170D' /proc/net/tcp > /dev/null if [ $? != 0 ]; then echo "Xvnc not running, attempting restart" vncserver -kill :1 vncserver fi
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
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' 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't say I have my heart set on the outcome. ;)
Oh, sure. Apologies, I hadn'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 :::*
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't really care.
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'd vote for cutting to the chase and just using the /proc/net/tcp grep for port and call it good.
Sure, let's do it
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 <tracy.graydon@intel.com> --- 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 > /dev/null +grep ':170D' /proc/net/tcp > /dev/null if [ $? != 0 ]; then echo "Xvnc not running, attempting restart" vncserver -kill :1 -- 2.7.0 -- Also can be found on yocto-autobuilder branch contrib/tgraydon/checkvnc-11897
http://git.yoctoproject.org/clean/cgit.cgi/yocto-autobuilder/commit/?id=303742bdf5e7995e6e9e25fab29deeb260a3cb55