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