open-vm-tools/sdmp-netstat-to-ss.patch
Kirk Allan 4511903876 Accepting request 815801 from home:kallan:branches:Virtualization:VMware
- jsc#ECO-2164 for update 11.1.0 (build 16036546) (boo#1171764)
  with new 'Service Discovery' plugin (boo#1171765).
- Reenabled building sdmp in the spec file.
- Added patches (boo#1171765)
  + sdmp-get-version.patch
  + sdmp-netstat-to-ss.patch
  + sdmp-warnings.patch

OBS-URL: https://build.opensuse.org/request/show/815801
OBS-URL: https://build.opensuse.org/package/show/Virtualization:VMware/open-vm-tools?expand=0&rev=395
2020-06-18 19:45:41 +00:00

96 lines
4.8 KiB
Diff

commit 64db1c0ccf1b6f5fb705a5d32778991d2e8ea7a8
Author: Oliver Kurth <okurth@vmware.com>
Date: Thu Jun 11 20:43:21 2020 -0700
ServiceDiscovery: Replacing deprecated 'netstat' command with 'ss'
Updating the Linux serviceDiscovery scripts to use "ss" in place of
the deprecated "netstat" command.
diff --git a/open-vm-tools/services/plugins/serviceDiscovery/get-connection-info.sh b/open-vm-tools/services/plugins/serviceDiscovery/get-connection-info.sh
index 1694514a..0fc89c62 100644
--- a/open-vm-tools/services/plugins/serviceDiscovery/get-connection-info.sh
+++ b/open-vm-tools/services/plugins/serviceDiscovery/get-connection-info.sh
@@ -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
diff --git a/open-vm-tools/services/plugins/serviceDiscovery/get-listening-process-info.sh b/open-vm-tools/services/plugins/serviceDiscovery/get-listening-process-info.sh
index 173b1c04..d7a10200 100644
--- a/open-vm-tools/services/plugins/serviceDiscovery/get-listening-process-info.sh
+++ b/open-vm-tools/services/plugins/serviceDiscovery/get-listening-process-info.sh
@@ -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 ' ' ',')
diff --git a/open-vm-tools/services/plugins/serviceDiscovery/get-listening-process-perf-metrics.sh b/open-vm-tools/services/plugins/serviceDiscovery/get-listening-process-perf-metrics.sh
index ad83762d..9a694d4c 100644
--- a/open-vm-tools/services/plugins/serviceDiscovery/get-listening-process-perf-metrics.sh
+++ b/open-vm-tools/services/plugins/serviceDiscovery/get-listening-process-perf-metrics.sh
@@ -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
diff --git a/open-vm-tools/services/plugins/serviceDiscovery/get-versions.sh b/open-vm-tools/services/plugins/serviceDiscovery/get-versions.sh
index b74d1715..c7a1e7cf 100644
--- a/open-vm-tools/services/plugins/serviceDiscovery/get-versions.sh
+++ b/open-vm-tools/services/plugins/serviceDiscovery/get-versions.sh
@@ -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