This repository has been archived by the owner. It is now read-only.
forked from starsliao/Prometheus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
### 基于推送方式的进程监控脚本 | ||
说明:监控进程所在主机无需启动后台服务方式监控,而是使用定时任务来推送监控指标到pushgateway。 | ||
1. 部署Pushgateway并增加到Prometheus | ||
``` | ||
mkdir /opt/pushgateway/ | ||
wget https://github.com/prometheus/pushgateway/releases/download/v1.3.0/pushgateway-1.3.0.linux-amd64.tar.gz -O /opt/pushgateway/pushgateway-1.3.0.linux-amd64.tar.gz | ||
cd /opt/pushgateway/ | ||
tar -zxvf pushgateway-1.3.0.linux-amd64.tar.gz | ||
cat > /etc/systemd/system/pushgateway.service <<EOF | ||
[Unit] | ||
Description=pushgateway | ||
After=syslog.target network.target | ||
[Service] | ||
Type=simple | ||
RemainAfterExit=no | ||
WorkingDirectory=/opt/pushgateway | ||
ExecStart=/opt/pushgateway/pushgateway \\ | ||
--web.listen-address=:9091 \\ | ||
--web.telemetry-path=/metrics \\ | ||
--persistence.interval=5m \\ | ||
--persistence.file=/opt/pushgateway/pers-data | ||
SyslogIdentifier=pushgateway | ||
[Install] | ||
WantedBy=multi-user.target | ||
EOF | ||
systemctl daemon-reload | ||
systemctl enable pushgateway | ||
systemctl start pushgateway | ||
``` | ||
``` | ||
vi prometheus.yml | ||
- job_name: 'pushgateway' | ||
static_configs: | ||
- targets: ['pushgateway:9091'] | ||
honor_labels: true | ||
``` | ||
2. 部署监控客户端 | ||
``` | ||
yum install python3-devel | ||
pip3 install psutil prometheus_client pyyaml | ||
mkdir /opt/monit | ||
wegt | ||
``` |