status.sh 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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 prometheus | grep -vE "grep|-Xmx700m" | awk '{print $2}')
  12. if [[ $pid == "" ]]; then
  13. echo "prometheus未在运行"
  14. else
  15. running_time=$(ps -o etime= -p "$pid")
  16. ports=$(netstat -tnlp | grep prome. | head -n +1 | awk '{print $4}')
  17. echo "prometheus当前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"
  25. pid=$(ps -auxc | grep alertm | grep -vE "grep|-Xmx700m" | awk '{print $2}')
  26. if [[ $pid == "" ]]; then
  27. echo "alertmanager未在运行"
  28. else
  29. running_time=$(ps -o etime= -p "$pid")
  30. ports=$(netstat -tnlp | grep alertm. | head -n +1 | awk '{print $4}')
  31. echo "alertmanager当前PID: $pid"
  32. echo "当前运行时间: $running_time" | tr -s " "
  33. echo "当前运行端口:"
  34. for i in "$ports"; do
  35. echo "$i"
  36. done
  37. fi
  38. #echo -e "\n"
  39. #
  40. #pid=$(ps -auxc | grep dingtalk | grep -vE "grep|-Xmx700m" | awk '{print $2}')
  41. #if [[ $pid == "" ]]; then
  42. # echo "dingtalk未在运行"
  43. #else
  44. # running_time=$(ps -o etime= -p "$pid")
  45. # ports=$(netstat -tnlp | grep dingta | head -n +1 | awk '{print $4}')
  46. #
  47. # echo "dingtalk当前PID: $pid"
  48. # echo "当前运行时间: $running_time" | tr -s " "
  49. # echo "当前运行端口:"
  50. # for i in "$ports"; do
  51. # echo "$i"
  52. # done
  53. #fi