1. 安裝依賴包
apt-get install -y adduser libfontconfig1 curl wget vim unzip net-tools
2. 下載安裝包
https://dl.grafana.com/oss/release/grafana_7.3.6_amd64.deb
https://dl.influxdata.com/telegraf/releases/telegraf_1.17.0-1_amd64.deb
https://dl.influxdata.com/influxdb/releases/influxdb_1.8.3_amd64.deb
3. 安裝軟件包
dpkg -i grafana_7.3.6_amd64.deb influxdb_1.8.3_amd64.deb telegraf_1.17.0-1_amd64.deb
4. 安裝grafana插件,用於顯示餅圖
wget -nv https://grafana.com/api/plugins/grafana-piechart-panel/versions/latest/download -O /tmp/grafana-piechart-panel.zip
cd /tmp
unzip grafana-piechart-panel.zip
mv grafana-piechart-panel /var/lib/grafana/plugins/
5. 修改influxdb配置文件
/etc/influxdb/influxdb.conf
將下面三行取消註釋並修改監聽的IP地址,出於安全考慮只監聽在127.0.0.1的地址
[http]
enabled = true
bind-address = "127.0.0.1:8086"
6. 啓動influxdb
systemctl start influxdb
7. 修改telegraf配置文件
/etc/telegraf/telegraf.conf
將下面三行取消註釋,數據記錄到influxdb中,出於安全考慮只監聽在127.0.0.1的地址
[[outputs.influxdb]]
urls = ["http://127.0.0.1:8086"]
database = "telegraf"
添加vCenter的連接地址和認證信息
[[inputs.vsphere]]
vcenters = [ "https://192.168.1.250/sdk" ]
username = "[email protected]"
password = "your_password"
將需要監控的項目取消註釋
vm_include = [ "/*/vm/**"]
host_include = [ "/*/host/**"]
cluster_include = [ "/*/host/**"]
datastore_include = [ "/*/datastore/**"]
datacenter_include = [ "/*/host/**"]
separator = "_"
提升輪詢速度
collect_concurrency = 5
discover_concurrency = 5
忽略自簽名證書
insecure_skip_verify = true
測試telegraf配置
telegraf -config /etc/telegraf/telegraf.conf -test
8. 啓動telegraf
systemctl start telegraf
9. 配置grafana
1. 啓動grafana
systemctl start grafana-server
2. 登錄Web-UI,修改初始密碼
默認賬號 admin 密碼 admin
強制修改默認密碼
3. 添加數據源
4. 通過鏈接導入模板
https://grafana.com/api/dashboards/8162/revisions/7/download
https://grafana.com/api/dashboards/8168/revisions/11/download
https://grafana.com/api/dashboards/8159/revisions/32/download
https://grafana.com/api/dashboards/8165/revisions/14/download