Commit 2ada156c authored by Julius Goryavsky's avatar Julius Goryavsky

test...

parent 61670570
...@@ -1233,6 +1233,7 @@ check_sockets_utils() ...@@ -1233,6 +1233,7 @@ check_sockets_utils()
# sockstat in FreeBSD is different from other systems, # sockstat in FreeBSD is different from other systems,
# let's denote it with a different value: # let's denote it with a different value:
sockstat_available=2 sockstat_available=2
sockstat_opts='-46lq -P tcp -p'
fi fi
else else
socket_utility="$(commandex lsof)" socket_utility="$(commandex lsof)"
...@@ -1284,10 +1285,9 @@ check_port() ...@@ -1284,10 +1285,9 @@ check_port()
grep -q -E "[[:space:]]users:[[:space:]]?\\(.*\\(\"($utils)[^[:space:]]*\"[^)]*,pid=$pid(,[^)]*)?\\)" && rc=0 grep -q -E "[[:space:]]users:[[:space:]]?\\(.*\\(\"($utils)[^[:space:]]*\"[^)]*,pid=$pid(,[^)]*)?\\)" && rc=0
elif [ $sockstat_available -ne 0 ]; then elif [ $sockstat_available -ne 0 ]; then
if [ $sockstat_available -gt 1 ]; then if [ $sockstat_available -gt 1 ]; then
# sockstat on FreeBSD does not return the connection # The sockstat command on FreeBSD does not return
# state without special option that cancel filtering # the connection state without special option, but
# by the port, so we ignore the connection state for # it supports filtering by connection state:
# this system:
$socket_utility $sockstat_opts "$port" 2>/dev/null | \ $socket_utility $sockstat_opts "$port" 2>/dev/null | \
grep -q -E "^[^[:space:]]+[[:space:]]+($utils)[^[:space:]]*[[:space:]]+$pid([[:space:]]|\$)" && rc=0 grep -q -E "^[^[:space:]]+[[:space:]]+($utils)[^[:space:]]*[[:space:]]+$pid([[:space:]]|\$)" && rc=0
else else
...@@ -1569,7 +1569,7 @@ get_proc() ...@@ -1569,7 +1569,7 @@ get_proc()
if [ "$OS" = 'Linux' ]; then if [ "$OS" = 'Linux' ]; then
nproc=$(grep -cw -E '^processor' /proc/cpuinfo 2>/dev/null || :) nproc=$(grep -cw -E '^processor' /proc/cpuinfo 2>/dev/null || :)
elif [ "$OS" = 'Darwin' -o "$OS" = 'FreeBSD' ]; then elif [ "$OS" = 'Darwin' -o "$OS" = 'FreeBSD' ]; then
nproc=$(sysctl -n hw.ncpu) nproc=$(sysctl -n hw.ncpu || :)
fi fi
set -e set -e
if [ -z "$nproc" ] || [ $nproc -eq 0 ]; then if [ -z "$nproc" ] || [ $nproc -eq 0 ]; then
......
...@@ -105,6 +105,7 @@ check_pid_and_port() ...@@ -105,6 +105,7 @@ check_pid_and_port()
local final local final
if ! check_port $pid "$port" "$utils"; then if ! check_port $pid "$port" "$utils"; then
if [ $ss_available -ne 0 -o $sockstat_available -ne 0 ]; then if [ $ss_available -ne 0 -o $sockstat_available -ne 0 ]; then
if [ $ss_available -ne 0 ]; then if [ $ss_available -ne 0 ]; then
port_info=$($socket_utility $ss_opts -t "( sport = :$port )" 2>/dev/null | \ port_info=$($socket_utility $ss_opts -t "( sport = :$port )" 2>/dev/null | \
...@@ -112,11 +113,11 @@ check_pid_and_port() ...@@ -112,11 +113,11 @@ check_pid_and_port()
grep -o -E "([^[:space:]]+[[:space:]]+){4}[^[:space:]]+" || :) grep -o -E "([^[:space:]]+[[:space:]]+){4}[^[:space:]]+" || :)
else else
if [ $sockstat_available -gt 1 ]; then if [ $sockstat_available -gt 1 ]; then
# sockstat on FreeBSD does not return the connection # The sockstat command on FreeBSD does not return
# state without special option that cancel filtering # the connection state without special option, but
# by the port, so we ignore the connection state for # it supports filtering by connection state.
# this system, also on the FreeBSD sockstat utility # Additionally, the sockstat utility on FreeBSD
# produces an additional column: # produces an one extra column:
port_info=$($socket_utility $sockstat_opts "$port" 2>/dev/null | \ port_info=$($socket_utility $sockstat_opts "$port" 2>/dev/null | \
grep -o -E "([^[:space:]]+[[:space:]]+){5}[^[:space:]]+" || :) grep -o -E "([^[:space:]]+[[:space:]]+){5}[^[:space:]]+" || :)
else else
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment