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