status.sh 587 B

12345678910111213141516171819202122232425
  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. pid=$(ps -auxc | grep grafana | grep -vE "grep|-Xmx700m" | awk '{print $2}')
  12. if [[ $pid == "" ]]; then
  13. echo "grafana未在运行"
  14. else
  15. running_time=$(ps -o etime= -p "$pid")
  16. ports=$(netstat -tnlp | grep graf. | head -n +1 | awk '{print $4}')
  17. echo "grafana当前PID: $pid"
  18. echo "当前运行时间: $running_time" | tr -s " "
  19. echo "当前运行端口:"
  20. for i in "$ports"; do
  21. echo "$i"
  22. done
  23. fi
  24. echo -e "\n"