graphite 监控---安装

1.graphite简介:

Graphite 是一个数据绘图工具,安装完成之后需要喂它数据,就可以根据你的需要将数据生成制定的格式(绘图、json、xml等),还可以和Nagios结合完成报警功能。具体的数据采集工具是由第三方工具完成。


2.graphite 安装:

2.1 通过yum安装所需要的开发包:


yum install -y gcc zlib-devel curl curl-devel openssl rpm-build gcc-c++ rpm-build python python-ldap python-memcached python-sqlite2 pycairo python-twisted Django django-tagging bitmap bitmap-fonts python-devel glibc-devel gcc-c++ openssl-devel python-zope-interface httpd memcached mod_wsgi
2.2 下载graphite、carbon并进行安装:


cd
mkdir rpmbuild
mkdir rpmbuild/SOURCES
cd ~/rpmbuild/SOURCES
wget http://launchpad.net/graphite/0.9/0.9.9/+download/whisper-0.9.9.tar.gz
wget http://launchpad.net/graphite/0.9/0.9.9/+download/carbon-0.9.9.tar.gz
wget http://launchpad.net/graphite/0.9/0.9.9/+download/graphite-web-0.9.9.tar.gz
cp carbon-0.9.9.tar.gz carbon-0.9.9.tar.gz.orig
cp graphite-web-0.9.9.tar.gz graphite-web-0.9.9.tar.gz.orig
cp whisper-0.9.9.tar.gz whisper-0.9.9.tar.gz.orig
cd ~/rpmbuild/SOURCES/
tar -zxvf whisper-0.9.9.tar.gz
cd whisper-0.9.9
python setup.py bdist_rpm
rpm -ivh dist/whisper-0.9.9-1.src.rpm
cd ..
cp whisper-0.9.9.tar.gz.orig whisper-0.9.9.tar.gz
cd ../SPECS/
rpmbuild -ba whisper.spec
sudo yum --nogpgcheck localinstall -y ../RPMS/noarch/whisper-0.9.9-1.noarch.rpm
cd ~/rpmbuild/SOURCES/
tar -zxvf graphite-web-0.9.9.tar.gz
cd graphite-web-0.9.9
python setup.py bdist_rpm
rpm -ivh dist/graphite-web-0.9.9-1.src.rpm
cd ../
cp graphite-web-0.9.9.tar.gz.orig graphite-web-0.9.9.tar.gz
cd ../SPECS/
rpmbuild -ba graphite-web.spec
sudo yum --nogpgcheck localinstall -y ../RPMS/noarch/graphite-web-0.9.9-1.noarch.rpm
cd ~/rpmbuild/SOURCES/
tar -zxvf carbon-0.9.9.tar.gz
cd carbon-0.9.9
python setup.py bdist_rpm
rpm -ivh dist/carbon-0.9.9-1.src.rpm
cd ..
cp carbon-0.9.9.tar.gz.orig carbon-0.9.9.tar.gz
cd ../SPECS/
rpmbuild -ba carbon.spec
sudo yum --nogpgcheck localinstall -y ../RPMS/noarch/carbon-0.9.9-1.noarch.rpm

2.3 配置graphite:

cd /opt/graphite/conf/
sudo cp graphite.wsgi.example graphite.wsgi
sudo cp storage-schemas.conf.example storage-schemas.conf
sudo cp carbon.conf.example carbon.conf
cd ../webapp/graphite
sudo cp local_settings.py.example local_settings.py
sudo vim local_settings.py
IME_ZONE = 'Asia/Shanghai'
MEMCACHE_HOSTS = ['127.0.0.1:11211']  #memcached 服务器
sudo python /opt/graphite/webapp/graphite/manage.py syncdb  #初始化数据库


3.配置Apache并设置权限

3.1 配置Apache 并设置权限:

chown -R apache:apache /opt/graphite/storage/
vim /etc/httpd/conf.d/wsgi.conf  #配置虚拟主机
LoadModule wsgi_module modules/mod_wsgi.so
WSGISocketPrefix /var/run/wsgi
NameVirtualHost *:80
<VirtualHost *:80>
        ServerName localhost
        DocumentRoot "/opt/graphite/webapp"
        ErrorLog /opt/graphite/storage/log/webapp/error.log
        CustomLog /opt/graphite/storage/log/webapp/access.log common
        # I've found that an equal number of processes & threads tends
        # to show the best performance for Graphite (ymmv).
        WSGIDaemonProcess graphite processes=5 threads=5 display-name='%{GROUP}' inactivity-timeout=120
        WSGIProcessGroup graphite
        WSGIApplicationGroup %{GLOBAL}
        WSGIImportScript /opt/graphite/conf/graphite.wsgi process-group=graphite application-group=%{GLOBAL}
        # XXX You will need to create this file! There is a graphite.wsgi.example
        # file in this directory that you can safely use, just copy it to graphite.wgsi
        WSGIScriptAlias / /opt/graphite/conf/graphite.wsgi
        Alias /content/ /opt/graphite/webapp/content/
        <Location "/content/">
                SetHandler None
        </Location>
        # XXX In order for the django admin site media to work you
        # must change @DJANGO_ROOT@ to be the path to your django
        # installation, which is probably something like:
        # /usr/lib/python2.6/site-packages/django
        Alias /media/ "@DJANGO_ROOT@/contrib/admin/media/"
        <Location "/media/">
                SetHandler None
        </Location>
        # The graphite.wsgi file has to be accessible by apache. It won't
        # be visible to clients because of the DocumentRoot though.
        <Directory /opt/graphite/conf/>
                Order deny,allow
                Allow from all
        </Directory>
</VirtualHost>
                                                          

4. 启动服务

service memcached start
/opt/graphite/bin/carbon-cache.py start
service httpd start


5.测试效果:

173707844.png


你可能感兴趣的:(python,监控,数据采集,第三方,绘图工具)