Icinga2使用graphite显示图像


下载地址:

https://github.com/findmypast/icingaweb2-module-graphite

http://dl.marmotte.net/rpms/redhat/el6/x86_64/



需要下载安装的软件:Django、django-tagging、pyparsing、python-whisper、pytz、mod_wsgi、python-carbon、python-twisted-core、python-zope-interface、python-zope-filesystem、mysql-python、graphite-web



软件安装略(rpm -i)


# unzip icingaweb2-module-graphite-master.zip


# mv icingaweb2-module-graphite /usr/share/icingaweb2/modules/graphite


# icinga2 feature enable graphite


icinga2页面——Configuration——Modules——graphite——enable


# mysql -u root -p'*******'


> create database graphite;

> grant all on graphite.* to graphite@'localhost' identified by 'graphite';

> flush privileges;

> quit


# vi /etc/graphite-web/local_settings.py


SECRET_KEY = 'jksjflsjfk'     (此处乱码随便敲)


TIME_ZONE = 'Asia/Shanghai'


DATABASES= {

    'default': {

      'NAME': 'graphite',

      'ENGINE': 'django.db.backends.mysql',

      'USER': 'graphite',

      'PASSWORD':'graphite',

      'HOST': '127.0.0.1',

      'PORT': '3306'

    }

}


:wq


# /usr/lib/python2.6/site-packages/graphite/manage.py syncdb 


中间输入个账号、邮箱、密码 (后面登录用的,不登录也行)


让graphite显示5年数据(默认只显示24小时)


# vi /etc/carbon/storage-schemas.conf


[carbon]

pattern = ^carbon\.

retentions = 10s:1w,120s:5y


[default]

pattern = .*

retentions = 120s:5y

:wq


注:如果之前没设置补上后删除/var/lib/carbon/whisper/icinga2/下数据即可(会重新生成的)


# cp /usr/share/doc/python-carbon-0.9.12/storage-aggregation.conf.example /etc/carbon/storage-aggregation.conf


# service carbon-cache start


自定义carbon存放路径(长期下来量很大的):


# mkdir /space/carbon

# mkdir /space/carbon/whisper

# mkdir /space/carbon/lists

# chown carbon:carbon /space/carbon -R


# vi /etc/carbon/carbon.conf 


STORAGE_DIR    = /space/carbon/

LOCAL_DATA_DIR = /space/carbon/whisper/

WHITELISTS_DIR = /space/carbon/lists/

:wq


# service carbon-cache restart



# mkdir /etc/icingaweb2/modules/graphite


# vi /etc/icingaweb2/modules/graphite/config.ini (此处内容可从icinga2页面enable graphite处的configuration复制)


[graphite]

metric_prefix = icinga2

base_url = http://zlinux3.ming.com/render?

legacy_mode = false

;if legacy mode is false (2.4 and newer):

service_name_template = "icinga2.$host.name$.services.$service.name$.$service.check_command$.perfdata.$metric$.value"

host_name_template = "icinga2.$host.name$.host.$host.check_command$.perfdata.$metric$.value"

;if legacy mode is true (pre 2.4):

;service_name_template = "icinga.$host.name$.services.$service.name$.$service.check_command$"

;host_name_template = "icinga.$host.name$.host.$host.check_command$"

;this template is used for the small image, macro $target$ can used.

graphite_args_template = "&target=$target$&source=0&width=300&height=120&hideAxes=true&lineWidth=2&hideLegend=true&colorList=049BAF"

;this template is used for the large image, macro $target$ can used.


:wq



# vi /etc/icinga2/features-available/graphite.conf 


 host = "127.0.0.1"  (默认为注释掉)

 port = 2003       (默认为注释掉)

:wq


# service httpd restart


# service icinga2 restart



此时到icinga2页面上看图像已经是graphite在显示了,访问http://ip/graphite也可以访问