]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
ServiceDiscovery: Replacing deprecated 'netstat' command with 'ss'
authorOliver Kurth <okurth@vmware.com>
Fri, 12 Jun 2020 03:43:21 +0000 (20:43 -0700)
committerOliver Kurth <okurth@vmware.com>
Fri, 12 Jun 2020 03:43:21 +0000 (20:43 -0700)
Updating the Linux serviceDiscovery scripts to use "ss" in place of
the deprecated "netstat" command.

open-vm-tools/services/plugins/serviceDiscovery/get-connection-info.sh
open-vm-tools/services/plugins/serviceDiscovery/get-listening-process-info.sh
open-vm-tools/services/plugins/serviceDiscovery/get-listening-process-perf-metrics.sh
open-vm-tools/services/plugins/serviceDiscovery/get-versions.sh

index 1694514afa19c4cc60beadfdf7edb95b5a96e84e..0fc89c628ea1d746e098124b832f4ef9968ec886 100644 (file)
@@ -1,16 +1,16 @@
 #!/bin/sh
 
 # check if necesary commands exist
-command -v netstat >/dev/null 2>&1 || { echo >&2 "netstat doesn't exist"; exit 1; }
+command -v ss >/dev/null 2>&1 || { echo >&2 "ss doesn't exist"; exit 1; }
 command -v grep >/dev/null 2>&1 || { echo >&2 "grep doesn't exist"; exit 1; }
 command -v sort >/dev/null 2>&1 || { echo >&2 "sort doesn't exist"; exit 1; }
 command -v tr >/dev/null 2>&1 || { echo >&2 "tr doesn't exist"; exit 1; }
 
 # get pids of listening processes
-space_separated_pids=$(netstat -lntup | grep -Eo "[0-9]+/" | sort -u)
+space_separated_pids=$(ss -lntup | grep -Eo "pid=[0-9]+" | sort -u)
 
 # grep pattern
 pattern=$(echo $space_separated_pids | tr ' ' '|')
 
 # get matching lines
-netstat -antup | grep -E $pattern
+ss -antup | grep -E $pattern
index 173b1c044dad9d84ac5b3084968dfe13ad823f56..d7a102005c4d648807c210f70eae61a0af6ef244 100644 (file)
@@ -1,14 +1,14 @@
 #!/bin/sh
 
 # check if necesary commands exist
-command -v netstat >/dev/null 2>&1 || { echo >&2 "netstat doesn't exist"; exit 1; }
+command -v ss >/dev/null 2>&1 || { echo >&2 "ss doesn't exist"; exit 1; }
 command -v grep >/dev/null 2>&1 || { echo >&2 "grep doesn't exist"; exit 1; }
 command -v sort >/dev/null 2>&1 || { echo >&2 "sort doesn't exist"; exit 1; }
 command -v tr >/dev/null 2>&1 || { echo >&2 "tr doesn't exist"; exit 1; }
 command -v ps >/dev/null 2>&1 || { echo >&2 "ps doesn't exist"; exit 1; }
 
 # get pids of listening processes
-space_separated_pids=$(netstat -lntup | grep -Eo "[0-9]+/" | grep -Eo "[0-9]*" | sort -u)
+space_separated_pids=$(ss -lntup | grep -Eo "pid=[0-9]+" | grep -Eo "[0-9]*" | sort -u)
 
 # ps accepts comma separated pids
 comma_separated_pids=$(echo $space_separated_pids | tr ' ' ',')
index ad83762d53e50db30f5cf39989525bcf5e831da1..9a694d4c452af3d884940e79181c5a4249498fe3 100644 (file)
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 # check if necesary commands exist
-command -v netstat >/dev/null 2>&1 || { echo >&2 "netstat doesn't exist"; exit 1; }
+command -v ss >/dev/null 2>&1 || { echo >&2 "ss doesn't exist"; exit 1; }
 command -v grep >/dev/null 2>&1 || { echo >&2 "grep doesn't exist"; exit 1; }
 command -v sort >/dev/null 2>&1 || { echo >&2 "sort doesn't exist"; exit 1; }
 command -v awk >/dev/null 2>&1 || { echo >&2 "awk doesn't exist"; exit 1; }
@@ -108,6 +108,6 @@ get_performance_metrics() {
   run $pids
 }
 
-space_separated_pids=$(netstat -lntup | grep -Eo "[0-9]+/" | grep -Eo "[0-9]+" | sort -u)
+space_separated_pids=$(ss -lntup | grep -Eo "pid=[0-9]+" | grep -Eo "[0-9]+" | sort -u)
 
 get_performance_metrics $space_separated_pids
\ No newline at end of file
index b74d17153b44741eca60ef6772508cc97ebfa9df..c7a1e7cfb494a3c8821d59f63513f617949b2874 100644 (file)
@@ -1,12 +1,12 @@
 #!/bin/sh
 
 # check if necesary commands exist
-command -v netstat >/dev/null 2>&1 || { echo >&2 "netstat doesn't exist"; exit 1; }
+command -v ss >/dev/null 2>&1 || { echo >&2 "ss doesn't exist"; exit 1; }
 command -v grep >/dev/null 2>&1 || { echo >&2 "grep doesn't exist"; exit 1; }
 command -v sort >/dev/null 2>&1 || { echo >&2 "sort doesn't exist"; exit 1; }
 command -v ps >/dev/null 2>&1 || { echo >&2 "ps doesn't exist"; exit 1; }
 
-space_separated_pids=$(netstat -lntup | grep -Eo "[0-9]+/" | grep -Eo "[0-9]*" | sort -u)
+space_separated_pids=$(ss -lntup | grep -Eo "pid=[0-9]+" | grep -Eo "[0-9]*" | sort -u)
 
 get_command_line() {
   ps --pid $1 -o command