天天看點

Icinga2+Influxdb+Grafana搭建

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$"

      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面闆下載下傳網址:

<a href="https://grafana.com/dashboards/381/revisions">https://grafana.com/dashboards/381/revisions</a>

記得icinga2中需啟用ping4監控(該面闆依據ping4抓取伺服器名)

本文轉自linux部落格51CTO部落格,原文連結http://blog.51cto.com/yangzhiming/1974678如需轉載請自行聯系原作者

yangzhimingg