创建脚本 flink-monitor.sh
#!/bin/bash
case $1 in
"start") {
echo '----- 启动 prometheus -----'
nohup /opt/module/prometheus-2.29.1/prometheus --web.enable-admin-api --config.file=/opt/module/prometheus-2.29.1/prometheus.yml >/opt/module/prometheus-2.29.1/prometheus.log 2>&1 &
echo '----- 启动 pushgateway -----'
nohup /opt/module/pushgateway-1.4.1/pushgateway --web.listen-address :9091 >/opt/module/pushgateway-1.4.1/pushgateway.log 2>&1 &
echo '----- 启动 grafana -----'
nohup /opt/module/grafana-8.1.2/bin/grafana-server --homepath /opt/module/grafana-8.1.2 web >/opt/module/grafana-8.1.2/grafana.log 2>&1 &
} ;;
"stop") {
echo '----- 停止 grafana -----'
pgrep -f grafana | xargs kill
echo '----- 停止 pushgateway -----'
pgrep -f pushgateway | xargs kill
echo '----- 停止 prometheus -----'
pgrep -f prometheus | xargs kill
} ;;
esac
脚本添加执行权限
[root@hadoop102 bin]$ chmod +x flink-monitor.sh