Icinga2+Influxdb+Grafana搭建


注:可不要icingaweb2(即无icinga2页面),Icinga2要求2.5版本以上


不过安装icingaweb2可方便排错,步骤略,需要php和mysql


 

icinga2下载网址:http://packages.icinga.org/epel/


influxdb下载网址:https://dl.influxdata.com/influxdb/releases/influxdb-1.3.6.x86_64.rpm


Grafana下载网址:https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana-4.5.2-1.x86_64.rpm 

 


Icinga2安装步骤:


 

需要的包:libboost_system1、libboost_thread1、libboost_regex1、boost-license1、libboost_program_options1、icinga2、icinga2-bin、icinga2-common、icingacli、nagios-plugins

 

安装httpd:

# yum install httpd


 

额外包:fping、perl-NET-SNMP、perl-Crypt-DES  (需先下载好)

 

# rpm -i libboost* boost-license (需先下载好)

# rpm -i icinga2*     (需先下载好)

# rpm -i perl-Crypt-DES perl-NET-SNMP fping perl-Digest-SHA1 perl-Digest-HMACperl-Socket6

# rpm -i nagios-plugins-1.4.16-1.el6.rf.x86_64.rpm


# chkconfig icinga2 --level 35 on





Influxdb安装步骤:


# rpm -i influxdb-1.3.6.x86_64.rpm    (端口8086)


配置文件路径:/etc/influxdb/influxdb.conf

数据存放路径:/var/lib/influxdb/data

日志路径:/var/log/influxdb/


# service influxdb start

# chkconfig influxdb --level 35 on

# influx

> create database icinga2;

> create user icinga2 with password 'xxxx';

> grant all on icinga2 to icinga2;

>quit


influxdb默认保留数据为168小时(即7天),调整为1年命令:


> show retention policies on icinga2;  (查看保留策略)

> alter retention policy "autogen" on "icinga2" duration 365d default;  (对已有策略进行修改)



# vi /etc/icinga2/features-enabled/influxdb.conf



library "perfdata"


object InfluxdbWriter "influxdb" {

  host = "127.0.0.1"

  port = 8086

  database = "icinga2"

  host_template = {

    measurement = "$host.check_command$"

    tags = {

      hostname = "$host.name$"

    }

 }

  service_template = {

    measurement = "$service.check_command$"

    tags = {

      hostname = "$host.name$"

      service = "$service.name$"

    }

  }



enable_send_thresholds = true

enable_send_metadata = true


}


:wq


# icinga2 feature enable influxdb


# service icinga2 restart



Granfana安装步骤:


# rpm -i grafana-4.5.2-1.x86_64.rpm    (端口3000)

# service grafana-server start

# chkconfig grafana-server --level 35 on



访问http://ip:3000  默认用户名、密码均为admin



Data Sources:Name:icinga2(可改) Type:InfluxDB Url:http://ip:8086 Access:proxy Database:icinga2 User:icinga2 Password:xxxxx


具体icinga2配置和grafana面板配置略


Grafana求多台服务器平均值:

面板——Graph——Metrics——Toggle Edit Mode:

SELECT mean("value") FROM "nrpe-mem" WHERE "hostname" =~ /shhu*/  and "metric" = 'Per' AND $timeFilter GROUP BY time($interval)

 


icinga influxdb面板下载网址:

https://grafana.com/dashboards/381/revisions


记得icinga2中需启用ping4监控(该面板依据ping4抓取服务器名)