status.sh 665 B

123456789101112131415161718192021222324
  1. #!/usr/bin/env bash
  2. set -e
  3. cat << 'LOGO'
  4. ----------------------------------
  5. LOGO
  6. base_dir=$(
  7. cd "$(dirname "$0")"
  8. pwd
  9. )
  10. cd $base_dir
  11. prometheus_alert_pid=$(ps -auxc | grep PrometheusAlert | grep -vE "grep|-Xmx700m" | awk '{print $2}')
  12. if [[ $prometheus_alert_pid == "" ]]; then
  13. echo "PrometheusAlert未在运行"
  14. else
  15. running_time=$(ps -o etime= -p "$prometheus_alert_pid")
  16. ports=$(netstat -tnlp | grep Prome | head -n +1 | awk '{print $4}')
  17. echo "PrometheusAlert当前PID: $prometheus_alert_pid"
  18. echo "当前运行时间: $running_time" | tr -s " "
  19. echo "当前运行端口:"
  20. for i in "$ports"; do
  21. echo "$i"
  22. done
  23. fi