因为公司云平台需要对各个用户的代理流量进行监控。
所以搞了这套监控流量的平台。可以创建子用户给用户查看
现在开始
1:安装grafana
wget https://dl.grafana.com/oss/release/grafana-6.4.4-1.x86_64.rpm
yum localinstall grafana-6.4.4-1.x86_64.rpm
systemctl start grafana-server
2:安装Influxdb
将InfluxDB加入yum源
cat <<EOF | sudo tee /etc/yum.repos.d/influxdb.repo
[influxdb]
name = InfluxDB Repository - RHEL \$releasever
baseurl = https://repos.influxdata.com/rhel/\$releasever/\$basearch/stable
enabled = 1
gpgcheck = 1
gpgkey = https://repos.influxdata.com/influxdb.key
EOF
yum install -y influxdb
systemctl enable influxdb
3:配置influxdb
创建用户
CREATE USER influx WITH PASSWORD 'influx' WITH ALL PRIVILEGES
创建库
CREATE DATABASE telegraf
4:安装telegraf
wget https://dl.influxdata.com/telegraf/releases/telegraf-1.12.5-1.x86_64.rpm
yum localinstall telegraf-1.12.5-1.x86_64.rpm
5:修改telegraf配置
echo "[[inputs.net]]" >> /etc/telegraf/telegraf.conf
echo " interfaces = [\"em1.*\"]" >> /etc/telegraf/telegraf.conf
echo " fieldpass = [\"bytes_recv\", \"bytes_sent\"]" >>
/etc/telegraf/telegraf.conf
echo "[[outputs.influxdb]]" >> /etc/telegraf/telegraf.conf
echo " urls = [\"http://*******:8086\"]" >> /etc/telegraf/telegraf.conf
echo " database = \"telegraf\"" >> /etc/telegraf/telegraf.conf
echo " username = \"influx\"" >> /etc/telegraf/telegraf.conf
echo " password = \"influx\"" >> /etc/telegraf/telegraf.conf
这面就是我们要监控的网卡流量,我们只监控em1.vlan标识的,只要创建em1.vlan网卡就会自动把数据存入influx里。
6:配置grafana
image.png7:成果
image.png完美结束。这个在host装好telegraf后,以后只要创建vroute,就会自动监控数据,基本就是全自动了。
网友评论