collectd监控性能联合influxdb grafana打造metric收集系统

这篇文章就简单的写下,如果利用 collectd influxdb grafana构建一个轻型的性能指标收集系统。 

发现最近这个组合还是比较火辣的,相比 graphite  ,influxdb有更好的易用性和分布式扩展性。。   其次grafana的界面也比较cool和专业。 

原文链接是在 http://xiaorui.cc


collectd是什么? 一款性能监控程序,C语言开发(高效)、无需系统cron支持(独立)、简单易用。Collectd是插件式架构,主要分为输入、输出类型插件,具体可以参考collectd官方网站。
Collectd的官方网站 http://collectd.org/  那么我们首先安装colletd这个监控客户端…. … 

sudo yum install collectd

编辑 /etc/collectd/collectd.conf     这里是用了network插件做数据的输出,数据会push到127.0.0.1的8096

# Uncomment this:
LoadPlugin network

# Uncomment/update this:
<Plugin network>
  Server "127.0.0.1" "8096"
</Plugin>

然后我们再来解决 influxdb的安装…  记得当时前几版的时候,需要自己编译,现在官方都给rpm了,很是方便…. 

wget http://s3.amazonaws.com/influxdb/influxdb-latest-1.x86_64.rpm 
sudo rpm -ivh influxdb-latest-1.x86_64.rpm

collectd和influxdb的联合问题,这个时候就需要influxdb-collectd-proxy 

git clone https://github.com/hoonmin/influxdb-collectd-proxy.git
cd influxdb-collectd-proxy
make

既然安装完毕,那么我们启动这两个组件 collectd and InfluxDB:

/etc/init.d/collectd start
/etc/init.d/influxdb start

创建一个collectd服务使用的数据库。

$ curl “http://localhost:8086/db?u=root&p=root” -d “{\”name\”: \”collectd\”}”

启动influxdb proxy进程,typesdb是指定collectd的数据文件。

$ bin/proxy –influxdb=”localhost:8086″ –typesdb=”/usr/share/collectd/types.db” –database=”collectd” –username=”root” –password=”root”

$ bin/proxy –help
Usage of bin/proxy:
  -database=””: database for influxdb
  -influxdb=”localhost:8086″: host:port for influxdb
  -logfile=”proxy.log”: path to log file
  -normalize=true: true if you need to normalize data for COUNTER types (over time)
  -storerates=true: true if you need to derive rates from DERIVE types
  -password=”root”: password for influxdb
  -proxyhost=”0.0.0.0″: host for proxy
  -proxyport=”8096″: port for proxy
  -typesdb=”types.db”: path to Collectd’s types.db
  -username=”root”: username for influxdb
  -verbose=false: true if you need to trace the requests

我们测试下..
curl -G ‘http://localhost:8086/db/collectd/series?u=root&p=root&q=list+series&pretty=true’

wget http://grafanarel.s3.amazonaws.com/grafana-1.8.1.tar.gz
tar xzvf grafana-1.8.1.tar.gz
mv grafana-1.8.1 grafana
cd grafana
mv config.sample.js config.js

我们在配置文件里面加入一个datasources的配置对,collectd

    datasources: {
      collectd: {
        type: 'influxdb',
        url: "http://yourdomain.com:8086/db/collectd",
        username: 'root',
        password: 'root'
      },
    },

文章写得超简单,请见谅,操作的文档参照了. http://vincent.composieux.fr/article/grafana-monitor-metrics-collected-by-collectd-into-influxdb  



大家觉得文章对你有些作用! 如果想赏钱,可以用微信扫描下面的二维码,感谢!
另外再次标注博客原地址  xiaorui.cc

1 Response

  1. Michael Hu 2016年11月15日 / 下午1:39

    InfluxDB 现在自带一个 collectd 插件来获取 collectd 客户端发来的数据,以前可没这么方便哦,0.8.4 版本以前只能通过 influxdb-collectd-proxy 这样的第三方程序来连接 collectd 和 InfluxDB. InfluxDB 自带的 collectd 插件默认是关闭的,需要手动配置打开 enabled = true,并填上 database = “collectd” 这一行,这里的 “collectd” 就是我们上面创建的那个数据库,更改配置后记得重启 InfluxDB:

Michael Hu进行回复 取消回复

邮箱地址不会被公开。 必填项已用*标注