12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- #!/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
- # blackbox_exporter
- echo -e "\n"
- blackbox_exporter_pid=$(ps -auxc | grep blackbox_export | grep -vE "grep|-Xmx700m" | awk '{print $2}')
- if [[ $blackbox_exporter_pid == "" ]]; then
- echo "blackbox_exporter未在运行"
- else
- running_time=$(ps -o etime= -p "$blackbox_exporter_pid")
- ports=$(netstat -tnlp | grep redis_e. | head -n +1 | awk '{print $4}')
- echo "blackbox_exporter当前PID: $blackbox_exporter_pid"
- echo "当前运行时间: $running_time" | tr -s " "
- echo "当前运行端口:"
- for i in "$ports"; do
- echo "$i"
- done
- fi
|