status.sh 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. echo -e "\n"
  12. # node_exporter
  13. node_exporter_pid=$(ps -auxc | grep node_exporter | grep -vE "grep|-Xmx700m" | awk '{print $2}')
  14. if [[ $node_exporter_pid == "" ]]; then
  15. echo "node_exporter未在运行"
  16. else
  17. running_time=$(ps -o etime= -p "$node_exporter_pid")
  18. ports=$(netstat -tnlp | grep node_e. | head -n +1 | awk '{print $4}')
  19. echo "node_exporter当前PID: $node_exporter_pid"
  20. echo "当前运行时间: $running_time" | tr -s " "
  21. echo "当前运行端口:"
  22. for i in "$ports"; do
  23. echo "$i"
  24. done
  25. fi
  26. # blackbox_exporter
  27. echo -e "\n"
  28. blackbox_exporter_pid=$(ps -auxc | grep blackbox_export | grep -vE "grep|-Xmx700m" | awk '{print $2}')
  29. if [[ $blackbox_exporter_pid == "" ]]; then
  30. echo "blackbox_exporter未在运行"
  31. else
  32. running_time=$(ps -o etime= -p "$blackbox_exporter_pid")
  33. ports=$(netstat -tnlp | grep redis_e. | head -n +1 | awk '{print $4}')
  34. echo "blackbox_exporter当前PID: $blackbox_exporter_pid"
  35. echo "当前运行时间: $running_time" | tr -s " "
  36. echo "当前运行端口:"
  37. for i in "$ports"; do
  38. echo "$i"
  39. done
  40. fi