#!/bin/bash
echo "安装prometheus-server(服务端),grafana按任意键继续"
read -n1
mkdir -p /data/software
cd /data/software
echo "安装grafana"
curl -O http://down.yadeaiot.net:8000/grafana-enterprise-8.5.4-1.x86_64.rpm
yum -y install urw-fonts
rpm -ivh /data/software/grafana-enterprise-8.5.4-1.x86_64.rpm
sudo /bin/systemctl daemon-reload
sudo /bin/systemctl enable grafana-server.service
sudo /bin/systemctl start grafana-server.service

echo "安装prometheus-server(服务端)"
cd /data/software
wget http://down.yadeaiot.net:8000/prometheus-2.36.0.linux-amd64.tar.gz
tar -zxvf /data/software/prometheus-2.36.0.linux-amd64.tar.gz -C /usr/local/
mv /usr/local/prometheus-2.36.0.linux-amd64/ /usr/local/prometheus
cd /usr/local/prometheus/
cd /usr/lib/systemd/system
echo '
[Unit]
  Description=https://prometheus.io
[Service]
  Restart=on-failure
  ExecStart=/usr/local/prometheus/prometheus --config.file=/usr/local/prometheus/prometheus.yml --web.listen-address=:9090
[Install]
  WantedBy=multi-user.target'>>/usr/lib/systemd/system/prometheus.service
systemctl daemon-reload
systemctl start prometheus
systemctl enable prometheus

echo
echo
echo "grafana 端口3000，用户名密码admin"
echo "grafana模板: https://grafana.com/grafana/dashboards"
echo "prometheus-端口9090添加客户端位置/usr/local/prometheus/prometheus.yml在最后添加"
echo "prometheus添加客户端后需要重启，systemctl restart prometheus"
