天天看點

Icinga2使用graphite顯示圖像

Icinga2使用graphite顯示圖像

下載下傳位址:

<a href="https://github.com/findmypast/icingaweb2-module-graphite" target="_blank">https://github.com/findmypast/icingaweb2-module-graphite</a>

<a href="http://dl.marmotte.net/rpms/redhat/el6/x86_64/" target="_blank">http://dl.marmotte.net/rpms/redhat/el6/x86_64/</a>

需要下載下傳安裝的軟體: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'*******'

&gt; create database graphite;

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

&gt; flush privileges;

&gt; 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

注:如果之前沒設定補上後删除/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存放路徑(長期下來量很大的):

# vi /etc/carbon/carbon.conf 

STORAGE_DIR    = /space/carbon/

LOCAL_DATA_DIR = /space/carbon/whisper/

WHITELISTS_DIR = /space/carbon/lists/

# 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 = "&amp;target=$target$&amp;source=0&amp;width=300&amp;height=120&amp;hideAxes=true&amp;lineWidth=2&amp;hideLegend=true&amp;colorList=049BAF"

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

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

 host = "127.0.0.1"  (預設為注釋掉)

 port = 2003       (預設為注釋掉)

# service httpd restart

# service icinga2 restart

此時到icinga2頁面上看圖像已經是graphite在顯示了,通路http://ip/graphite也可以通路

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

yangzhimingg