#!/usr/bin/env bash set -e cat << 'LOGO' ---------------------------------- LOGO base_dir=$( cd "$(dirname "$0")" pwd ) cd $base_dir pid=$(ps -auxc | grep prometheus | grep -vE "grep|-Xmx700m" | awk '{print $2}') if [[ $pid == "" ]]; then echo "prometheus未在运行" else running_time=$(ps -o etime= -p "$pid") ports=$(netstat -tnlp | grep prome. | head -n +1 | awk '{print $4}') echo "prometheus当前PID: $pid" echo "当前运行时间: $running_time" | tr -s " " echo "当前运行端口:" for i in "$ports"; do echo "$i" done fi echo -e "\n" pid=$(ps -auxc | grep alertm | grep -vE "grep|-Xmx700m" | awk '{print $2}') if [[ $pid == "" ]]; then echo "alertmanager未在运行" else running_time=$(ps -o etime= -p "$pid") ports=$(netstat -tnlp | grep alertm. | head -n +1 | awk '{print $4}') echo "alertmanager当前PID: $pid" echo "当前运行时间: $running_time" | tr -s " " echo "当前运行端口:" for i in "$ports"; do echo "$i" done fi #echo -e "\n" # #pid=$(ps -auxc | grep dingtalk | grep -vE "grep|-Xmx700m" | awk '{print $2}') #if [[ $pid == "" ]]; then # echo "dingtalk未在运行" #else # running_time=$(ps -o etime= -p "$pid") # ports=$(netstat -tnlp | grep dingta | head -n +1 | awk '{print $4}') # # echo "dingtalk当前PID: $pid" # echo "当前运行时间: $running_time" | tr -s " " # echo "当前运行端口:" # for i in "$ports"; do # echo "$i" # done #fi