python_graph-ite

 
 
####################################
# BASIC REQUIREMENTS
# http://graphite.wikidot.com/installation
# http://geek.michaelgrace.org/2011/09/how-to-install-graphite-on-ubuntu/
# Last tested & updated 10/13/2011
####################################
 
cd
sudo apt-get update
sudo apt-get upgrade
 
wget https://launchpad.net/graphite/0.9/0.9.10/+download/graphite-web-0.9.10.tar.gz
wget https://launchpad.net/graphite/0.9/0.9.10/+download/carbon-0.9.10.tar.gz
wget https://launchpad.net/graphite/0.9/0.9.10/+download/whisper-0.9.10.tar.gz
tar -zxvf graphite-web-0.9.10.tar.gz
tar -zxvf carbon-0.9.10.tar.gz
tar -zxvf whisper-0.9.10.tar.gz
mv graphite-web-0.9.10 graphite
mv carbon-0.9.10 carbon
mv whisper-0.9.10 whisper
rm graphite-web-0.9.10.tar.gz
rm carbon-0.9.10.tar.gz
rm whisper-0.9.10.tar.gz
sudo apt-get install --assume-yes apache2 apache2-mpm-worker apache2-utils apache2.2-bin apache2.2-common libapr1 libaprutil1 libaprutil1-dbd-sqlite3 build-essential python3.2 python-dev libpython3.2 python3-minimal libapache2-mod-wsgi libaprutil1-ldap memcached python-cairo-dev python-django python-ldap python-memcache python-pysqlite2 sqlite3 erlang-os-mon erlang-snmp rabbitmq-server bzr expect ssh libapache2-mod-python python-setuptools
sudo easy_install django-tagging
 
sudo easy_install zope.interface
 
sudo easy_install twisted
 
sudo easy_install txamqp
 
####################################
# INSTALL WHISPER
####################################
 
cd ~/whisper
sudo python setup.py install
 
####################################
# INSTALL CARBON
####################################
 
cd ~/carbon
sudo python setup.py install
 
cd /opt/graphite/conf
sudo cp carbon.conf.example carbon.conf
sudo cp storage-schemas.conf.example storage-schemas.conf
sudo gedit storage-schemas.conf
### Replace contents of storage-schemas.conf to be the following
[stats ]
priority = 110
pattern = .*
retentions = 10:2160,60:10080,600:262974
###
 
 
####################################
# CONFIGURE GRAPHITE (webapp)
####################################
 
cd ~/graphite
sudo python check-dependencies.py
sudo python setup.py install
 
# CONFIGURE APACHE
###################
cd ~/graphite/examples
sudo cp example-graphite-vhost.conf /etc/apache2/sites-available/default
sudo cp /opt/graphite/conf/graphite.wsgi.example /opt/graphite/conf/graphite.wsgi
sudo mkdir /etc/httpd
sudo mkdir /etc/httpd/wsgi
 
sudo gedit /etc/apache2/sites-available/default
#####
# Change the line: WSGISocketPrefix run/wsgi
# To: WSGISocketPrefix /etc/httpd/wsgi
#####
 
sudo /etc/init.d/apache2 reload
 
 
####################################
# INITIAL DATABASE CREATION
####################################
cd /opt/graphite/webapp/graphite/
sudo python manage.py syncdb
# follow prompts to setup django admin user
sudo chown -R www-data:www-data /opt/graphite/storage/
sudo /etc/init.d/apache2 restart
cd /opt/graphite/webapp/graphite
sudo cp local_settings.py.example local_settings.py
 
####################################
# START CARBON
####################################
cd /opt/graphite/
sudo ./bin/carbon-cache.py start

Gentoo x86

Graphite 0.9.9

Python 2.7.2

Apache 2.2.22

一. 关于Graphite

1. Graphite,相当年轻的企业级开源监控工具,可以用于采集、统计多个服务器的实时状态,包括用户请求、memcached缓存命中、rabbitMQ消息服务器状态,以及基本的系统负载等。

2. 采用Python编写,Django框架,sqlite数据库存储,自有简单文本协议通讯,绘图功能强大。

3. 事实上,严格地说,Graphite只是一个根据数据绘图的工具,数据收集通常由第三方工具或插件完成,自带的是carbon,可根据其协议选用别的数据源供其绘图。

二. 安装流程

1. 更改Gentoo的python版本到2.7

# eselect python list

Available Python interpreters:

[1] python2.7

[2] python3.2 *

# eselect python set 1

2. 安装软件包,包括依赖包和graphite本身

# emerge apache apache-wsgi pip pysqlite

# pip install django django-tagging twisted cairo whisper carbon graphite-web

3. 初始化配置文件

# cd /opt/graphite/conf

# cp carbon.conf.example carbon.conf

# cp storage-schemas.conf.example storage-schemas.conf

# cp graphite.wsgi.example graphite.wsgi

# cd /opt/graphite/webapp/graphite

# cp local_settings.py.example local_settings.py

4. 修改httpd.config添加wsgi模块

在LoadModule的部分添加一行:

LoadModule wsgi_module modules/mod_wsgi.so

5. 修改默认的虚拟主机配置文件

# cd /etc/apache2/vhosts.d

# mv 00_default_vhost.conf 00_default_vhost.conf.bak

# mkdir -p /etc/apache2/wsgi

# vim 00_default_vhost.conf

Listen 80

WSGISocketPrefix /etc/apache2/wsgi/

<VirtualHost *:80>

ServerName graphite

DocumentRoot “/opt/graphite/webapp”

ErrorLog /opt/graphite/storage/log/webapp/error.log

CustomLog /opt/graphite/storage/log/webapp/access.log common

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}

WSGIScriptAlias / /opt/graphite/conf/graphite.wsgi

Alias /content/ /opt/graphite/webapp/content/

<Location “/content/”>

SetHandler None

Order Deny,Allow

</Location>

Alias /media/ “/usr/lib/python2.7/site-packages/django/contrib/admin/media/”

<Location “/media/”>

SetHandler None

Order Deny,allow

</Location>

<Directory /opt/graphite/conf/>

Order deny,allow

Allow from all

</Directory>

</VirtualHost>

上面的配置文件内容修改自graphite源码包内的默认配置文件,修改部分已经标出

6. 生成数据库并更改数据库目录权限

# cd /opt/graphite/webapp/graphite

# python manage.py syncdb

# chown -R apache:apache /opt/graphite/storage

7. 启动相关程序

carbon:

/opt/graphite/bin/carbon-cache.py start

apache2:

/etc/init.d/apache2 start

至此Graphite安装完毕。浏览器中的效果如图所示,可以对数据源、图表的风格等分别自定义,也可以实现自动刷新、对图表进行聚合等等,功能丰富完备。

30512999

三. 备注

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值