天天看點

telegraf+influxdb+grafana采集與監控

telegraf

sudo -s
wget http://get.influxdb.org/telegraf/telegraf-0.11.1-1.x86_64.rpm
wget https://dl.influxdata.com/telegraf/releases/telegraf-1.7.3-1.x86_64.rpm
alien telegraf-0.11.1-1.x86_64.rpm
dpkg -i telegrafXXX.deb
systemctl start telegraf
           

influxdb

wget http://dl.influxdata.com/influxdb/releases/influxdb-1.0.2.x86_64.rpm 
apt-get install alien
alien influxdb-1.0.2.x86_64.rpm
dpkg -i influxdbXXX.deb
systemctl start influxd 或重新開機
systemctl restart influxd

create user "tony" with password 'hi'
建立管理者 CREATE USER "ADMIN" WITH PASSWORD 'HI' WITH ALL PRIVILEGES
show users;
create database telegraf
show databases

chmod 777 telegraf.conf
vi /etc/telegraf/telegraf.conf
           

修改内容如下:

[[outputs.influxdb]]
     urls = ["http://localhost:8086"] # required 
     database = "telegraf" # required
     retention_policy = ""
     precision = "s"
     timeout = "5s"
     username = "tony"
     password = "hi"    
systemctl restart telegraf
           

influxd: http://localhost:8083

顯示資料庫:show databases
use telegraf
顯示表:show measurements
select * from cpu
select * from mem
show users
show stats
show diagnostics
           

Generate Query URL:如下

http://127.0.0.1:8086/query?q=show+databases&db=telegraf

顯示結果:

{“results”:[{“series”:[{“name”:“databases”,“columns”:[“name”],“value”:[["_internal"],[“telegraf”],[“AA”]]}]}]}

grafana: http://localhost:3000

admin admin 登入會提醒修改密碼

wget https://dl.grafana.com/oss/release/grafana_6.3.3_amd64.deb 
sudo dpkg -i grafana_6.3.3_amd64.deb 


service grafana-server start
systemctl start grafana-server

grafana-cli plugins install grafana-piechart-panel
systemctl restart grafana-server
目錄:/var/lib/grafana/plugins/grafana-piechart-panel
systemctl status grafana-server
           

比如下面是監控溫度變化過程:

telegraf+influxdb+grafana采集與監控

influx的建庫建表:

建立一個溫度資料庫
create database temperature

建立采集溫度的表t
insert t,host=127.0.0.1,m=m1 v=35


删除資料庫
drop database "db_name"  
删除表
drop measurement "表名"  
           

繼續閱讀