Skip to content

Instantly share code, notes, and snippets.

@tesseslol
Last active February 20, 2017 10:32
Show Gist options
  • Save tesseslol/3aec7e77c6e61cc82b939b6737b03a84 to your computer and use it in GitHub Desktop.
Save tesseslol/3aec7e77c6e61cc82b939b6737b03a84 to your computer and use it in GitHub Desktop.
Install graphite
Install Python 2.7:
Scaricate il tar e poi digitate questi comandi:
cd Downloads
tar -xvzf Python*
cd Python*
./configure
make
Install Python library:
curl "https://bootstrap.pypa.io/get-pip.py" -o "get-pip.py"
sudo python get-pip.py
sudo pip install django
sudo pip install django-tagging
sudo pip install cairocffi
sudo pip install pytz
sudo pip install scandir
sudo pip install simplejson
Installare graphite
sudo apt-get install python-dev libcairo2-dev libffi-dev
export PYTHONPATH="/opt/graphite/lib/:/opt/graphite/webapp/"
pip install graphite-web carbon whisper uwsgi
Installare Grafana
wget https://grafanarel.s3.amazonaws.com/builds/grafana_4.1.2-1486989747_amd64.deb
sudo apt-get install -y adduser libfontconfig
sudo dpkg -i grafana_4.1.2-1486989747_amd64.deb
sudo nano /etc/apt/sources.list
Installare apache
sudo apt install apache2
sudo apt install apache2-dev
Configurazione file configurazione:
sudo mv /opt/graphite/conf/storage-schemas.conf.example storage-schemas.conf
sudo mv /opt/graphite/conf/carbon.conf.example carbon.conf
sudo mv graphite.wsgi.example graphite.wsgi
Per far partire il demone digitiamo:
sudo python carbon-cache.py start
Aggiungere la seguente riga:
deb https://packagecloud.io/grafana/stable/debian/ jessie main
curl https://packagecloud.io/gpg.key | sudo apt-key add -
sudo apt-get update
sudo apt-get install grafana
sudo apt-get install apt-transport-https
Per far partire il server nella porta 8085:
editare il file wsgi.py con il file sotto linkato nel gist
sudo /usr/local/bin/uwsgi --http localhost:8085 --master --processes 4 --home /opt/graphite --pythonpath /opt/graphite/webapp/graphite --wsgi-file=/opt/graphite/webapp/graphite/wsgi.py
perl -e '$ts = time(); for (1..1000) { printf "foo.bar %d %d\n", int(rand(10000)), $ts - 90 * $_ }' \
| nc -c localhost 2003
firefox http://localhost:8085/render/?width=800&height=600&target=foo.bar
Esegiure grafana:
sudo service grafana-server start
Graphana ora è in ascolto nella porta 3000 in localhost con le credenziali admin e admin
Eseguire grafana all'avvio:
sudo update-rc.d grafana-server defaults
import os
import sys
sys.path.append('/usr/local/lib/python2.7/dist-packages/')
sys.path.append('/opt/graphite/webapp')
try:
from importlib import import_module
except ImportError:
from django.utils.importlib import import_module
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'graphite.settings') # noqa
from django.conf import settings
from django.core.wsgi import get_wsgi_application
from graphite.logger import log
application = get_wsgi_application()
try:
import whitenoise
except ImportError:
whitenoise = False
else:
# WhiteNoise < 2.0.1 does not support Python 2.6
if sys.version_info[:2] < (2, 7):
whitenoise_version = tuple(map(
int, getattr(whitenoise, '__version__', '0').split('.')))
if whitenoise_version < (2, 0, 1):
whitenoise = False
if whitenoise:
from whitenoise.django import DjangoWhiteNoise
application = DjangoWhiteNoise(application)
prefix = "/".join((settings.URL_PREFIX.strip('/'), 'static'))
for directory in settings.STATICFILES_DIRS:
application.add_files(directory, prefix=prefix)
for app_path in settings.INSTALLED_APPS:
module = import_module(app_path)
directory = os.path.join(os.path.dirname(module.__file__), 'static')
if os.path.isdir(directory):
application.add_files(directory, prefix=prefix)
# Initializing the search index can be very expensive. The import below
# ensures the index is preloaded before any requests are handed to the
# process.
log.info("graphite.wsgi - pid %d - reloading search index" % os.getpid())
import graphite.metrics.search # noqa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment