|
|
@ -401,33 +401,36 @@ openim::util::check_process_names() {
|
|
|
|
# Arrays to collect details of processes
|
|
|
|
# Arrays to collect details of processes
|
|
|
|
local not_started=()
|
|
|
|
local not_started=()
|
|
|
|
local started=()
|
|
|
|
local started=()
|
|
|
|
|
|
|
|
|
|
|
|
# Iterate over each given process name
|
|
|
|
|
|
|
|
for process_name in "$@"; do
|
|
|
|
|
|
|
|
# Use `pgrep` to find process IDs related to the given process name
|
|
|
|
|
|
|
|
local pids=($(pgrep -f $process_name))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Check if any process IDs were found
|
|
|
|
|
|
|
|
if [[ ${#pids[@]} -eq 0 ]]; then
|
|
|
|
|
|
|
|
not_started+=("$process_name")
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
# If there are PIDs, loop through each one
|
|
|
|
|
|
|
|
for pid in "${pids[@]}"; do
|
|
|
|
|
|
|
|
local command=$(ps -p $pid -o cmd=)
|
|
|
|
|
|
|
|
local start_time=$(ps -p $pid -o lstart=)
|
|
|
|
|
|
|
|
local port=$(get_port $pid | tr -d '\n') # Remove newline characters
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Ensure port information is followed by a space for separation
|
|
|
|
|
|
|
|
if [[ -z $port ]]; then
|
|
|
|
|
|
|
|
port="N/A "
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
port="$port " # Add a trailing space for separation
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
started+=("Process $process_name - Command: $command, PID: $pid, Port: $port, Start time: $start_time")
|
|
|
|
# Iterate over each given process name
|
|
|
|
done
|
|
|
|
for process_name in "$@"; do
|
|
|
|
fi
|
|
|
|
# Use `pgrep` to find process IDs related to the given process name
|
|
|
|
done
|
|
|
|
local pids=($(pgrep -f $process_name))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Check if any process IDs were found
|
|
|
|
|
|
|
|
if [[ ${#pids[@]} -eq 0 ]]; then
|
|
|
|
|
|
|
|
not_started+=("$process_name")
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
# If there are PIDs, loop through each one
|
|
|
|
|
|
|
|
for pid in "${pids[@]}"; do
|
|
|
|
|
|
|
|
local command=$(ps -p $pid -o cmd=)
|
|
|
|
|
|
|
|
local start_time=$(ps -p $pid -o lstart=)
|
|
|
|
|
|
|
|
local port=$(get_port $pid | tr -d '\n') # Remove newline characters
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Insert a space at the desired position in the port string
|
|
|
|
|
|
|
|
if [[ ! -z $port && $port != "N/A" ]]; then
|
|
|
|
|
|
|
|
port="${port:0:4} ${port:4}" # Add a space after the fourth character
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if [[ -z $port ]]; then
|
|
|
|
|
|
|
|
port="N/A"
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
started+=("Process $process_name - Command: $command, PID: $pid, Port: $port, Start time: $start_time")
|
|
|
|
|
|
|
|
done
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Print information
|
|
|
|
# Print information
|
|
|
|