Monitor Server
sudo su
sudo apt update
sudo apt -y upgrade
Install Go
curl -O https://storage.googleapis.com/golang/go1.10.1.linux-amd64.tar.gz
tar -xvf go1.10.1.linux-amd64.tar.gz
mv go /usr/local
nano ~/.profile
export PATH=$PATH:/usr/local/go/bin
source ~/.profile
go version
go version go1.10.1 linux/amd64
Download and Install Prometheus
wget https://github.com/prometheus/prometheus/releases/download/v2.2.1/prometheus-2.2.1.linux-amd64.tar.gz
tar xvf prometheus-2.2.1.linux-amd64.tar.gz
ln -sv /opt/prometheus-2.2.1.linux-amd64 /opt/prometheus
cd /opt/prometheus
nano prometheus.yml
global:
scrape_interval: 60s
evaluation_interval: 60s
scrape_configs:
- job_name: prometheus
static_configs:
- targets: ['localhost:9090']
labels:
instance: prometheus
- job_name: Linux
static_configs:
- targets: ['192.168.66.6:9100']
labels:
instance: Linux
Run it
./prometheus --config.file=prometheus.yml &
Install Grafana
wget https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana_5.0.4_amd64.deb
apt install -y adduser libfontconfig
dpkg -i grafana_5.0.4_amd64.deb
Download prometheus-system_rev4.json
https://grafana.com/api/dashboards/159/revisions/4/download
Import prometheus-system_rev4.json
Add grafana-server.service
nano /lib/systemd/system/grafana-server.service
[Unit]
Description=Grafana instance
Documentation=http://docs.grafana.org
Wants=network-online.target
After=network-online.target
After=postgresql.service mariadb.service mysql.service
[Service]
EnvironmentFile=/etc/default/grafana-server
User=grafana
Group=grafana
Type=simple
Restart=on-failure
WorkingDirectory=/usr/share/grafana
RuntimeDirectory=grafana
RuntimeDirectoryMode=0750
ExecStart=/usr/sbin/grafana-server \
--config=${CONF_FILE} \
--pidfile=${PID_FILE_DIR}/grafana-server.pid \
cfg:default.paths.logs=${LOG_DIR} \
cfg:default.paths.data=${DATA_DIR} \
cfg:default.paths.plugins=${PLUGINS_DIR} \
cfg:default.paths.provisioning=${PROVISIONING_CFG_DIR}
LimitNOFILE=10000
TimeoutStopSec=20
UMask=0027
[Install]
WantedBy=multi-user.target
Run it
/lib/systemd/systemd-sysv-install enable grafana-server
systemctl start grafana-server
systemctl status grafana-server
Node Server
sudo su
sudo apt update
sudo apt -y upgrade
Install Go
curl -O https://storage.googleapis.com/golang/go1.10.1.linux-amd64.tar.gz
tar -xvf go1.10.1.linux-amd64.tar.gz
mv go /usr/local
nano ~/.profile
export PATH=$PATH:/usr/local/go/bin
source ~/.profile
go version
go version go1.10.1 linux/amd64
Download node_exporter
wget https://github.com/prometheus/node_exporter/releases/download/v0.15.2/node_exporter-0.15.2.linux-amd64.tar.gz
tar xvf node_exporter-0.15.2.linux-amd64.tar.gz -C /usr/local/
Add node service
nano /etc/systemd/system/prometheus.service
[Unit]
Description=node_exporter
[Service]
Type=simple
ExecStart=/usr/local/node_exporter/node_exporter
[Install]
WantedBy=multi-user.target
Run it
/usr/local/node_exporter-0.15.2.linux-amd64/node_exporter &
or
systemctl enable prometheus
systemctl start prometheus
systemctl status prometheus
沒有留言:
張貼留言