-
Notifications
You must be signed in to change notification settings - Fork 0
/
mon.sh
executable file
·111 lines (102 loc) · 2.74 KB
/
mon.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#!/bin/bash
NEXP_VER=${1:-'0.18.1'}
sudo yum -q -y install epel-release
sudo yum -q -y install yum-utils
sudo yum -q -y groupinstall development
sudo yum -q -y install python python-pip python-dev
sudo yum -q -y install https://centos7.iuscommunity.org/ius-release.rpm
sudo yum -q -y install python3
sudo yum -q -y install python3-pip
sudo yum -q -y install python3-devel
sudo yum -q -y install ca-certificates
sudo yum -q -y install sshpass
sudo yum -q -y install bind-utils
sudo yum -q -y install wget curl stress stress-ng vim git tree jq
# install weave network
sudo curl -L git.io/weave -o /usr/local/bin/weave
sudo chmod a+x /usr/local/bin/weave
# install node_exporter
sudo useradd --no-create-home --shell /bin/false prometheus
export NODE_EXPORTER_VERSION=${NEXP_VER}
wget -q https://github.com/prometheus/node_exporter/releases/download/v${NODE_EXPORTER_VERSION}/node_exporter-${NODE_EXPORTER_VERSION}.linux-amd64.tar.gz
tar -xzf node_exporter-${NODE_EXPORTER_VERSION}.linux-amd64.tar.gz
sudo mv node_exporter-${NODE_EXPORTER_VERSION}.linux-amd64/node_exporter /usr/local/bin/
sudo cat << EOT > /etc/systemd/system/node_exporter.service
[Unit]
Description=Node Exporter
After=network.target
[Service]
User=prometheus
Group=prometheus
Type=simple
ExecStart=/usr/local/bin/node_exporter
[Install]
WantedBy=multi-user.target
EOT
sudo systemctl daemon-reload
sudo systemctl start node_exporter
sudo systemctl enable node_exporter
# install telegraf
sudo cat << EOT > /etc/yum.repos.d/influxdb.repo
[influxdb]
name = InfluxDB Repository - RHEL 7
baseurl = https://repos.influxdata.com/rhel/7/x86_64/stable
enabled = 1
gpgcheck = 1
gpgkey = https://repos.influxdata.com/influxdb.key
EOT
sudo yum -y install telegraf
sudo telegraf --input-filter cpu:disk:diskio:kernel:mem:processes:net:swap:system:docker:kernel_vmstat:netstat --output-filter prometheus_client config > /etc/telegraf/telegraf.conf
sudo systemctl start telegraf
sudo systemctl enable telegraf
usermod -aG docker telegraf
mkdir projects
cd projects
git clone https://github.com/bcochofel/prometheus-configuration.git
cd prometheus-configuration
sudo cat << EOT > ./prometheus/node_exporter-targets.json
[
{
"labels": {
"environment": "tst",
"host": "mon-1"
},
"targets": [
"mon-1:9100"
]
},
{
"labels": {
"environment": "dev",
"host": "mon-2"
},
"targets": [
"mon-2:9100"
]
}
]
EOT
sudo cat << EOT > ./prometheus/telegraf-targets.json
[
{
"labels": {
"environment": "tst",
"host": "mon-1"
},
"targets": [
"mon-1:9273"
]
},
{
"labels": {
"environment": "dev",
"host": "mon-2"
},
"targets": [
"mon-2:9273"
]
}
]
EOT
sudo chown vagrant.vagrant /home/vagrant/projects -R
exit 0