一、简述

  collectd可以手机服务器的日常信息,便于随时监控服务器性能

二、collectd的下载与安装

   这里用yum进行安装

#安装epel
yum install epel-release
#安装collectd
yum install -y collectd
#安装rrdtool插件及依赖包
yum install collectd-rrdtool rrdtool rrdtool-devel

   更改collectd配置文件:vim /etc/collectd.conf  (find / -name collectd.conf 查找文件位置)

            FQDNLookup true
       Hostname "VM_0_13_centos" #直接使用ifconfig命令查看(安装collectd的地址) BaseDir "/var/lib/collectd" PIDFile "/var/run/collectd.pid" PluginDir "/usr/lib64/collectd" TypesDB "/usr/share/collectd/types.db" LoadPlugin syslog LoadPlugin rrdtool LoadPlugin disk LoadPlugin interface LoadPlugin load LoadPlugin memory LoadPlugin network LoadPlugin processes LoadPlugin users
       <Plugin interface>
          Interface "eth0" #用ifconfig查看Interface对应名称
          IgnoreSelected false
       </Plugin>
<Plugin network> Server "127.0.0.1" "25826" #这里填写的是influxDB安装的服务器ip
       </Plugin>

       <Plugin rrdtool>
            DataDir "/usr/var/lib/collectd/rrd" #如果你是使用下载安装前面应该会多出一个${prefix},未尝试是否有影响
       </Plugin>
       <Plugin cpu>

                    ReportByCpu true

                    ReportByState true

                    ValuesPercentage true   此处启用cpu的使用率,5.7.*以上才有,低版本的不支持百分百

            </Plugin>

      <Plugin load>
            ReportRelative true
      </Plugin>

      #日志部分 可选

      #打开日志,并配置日志级别和路径等属性

      LoadPlugin logfile
      <Plugin logfile>
            LogLevel info
            File "/var/log/collectd.log"
      </Plugin>

      #重启collectd,在/var/log/collectd.log中可看到日志

启动collectd

#启动
systemctl start collectd.service
#配置开机自启
systemctl enable collectd.service
#重启
systemctl restart collectd.service
 

确认配置是否成功

[root@instance-arkj4je3 ~]# cd /var/lib/collectd
[root@instance-arkj4je3 collectd]# ls
rrd

 如果/var/lib/collectd目录下生成rrd文件,说明有数据了

 

 

 

posted on 2021-05-31 18:19  拥抱天空的风  阅读(427)  评论(0编辑  收藏  举报