system/graphite-web: Added (Enterprise Scalable Realtime Graphing).

Signed-off-by: Willy Sudiarto Raharjo <willysr@slackbuilds.org>
This commit is contained in:
Mario Preksavec 2015-02-28 03:30:02 +07:00 committed by Willy Sudiarto Raharjo
parent 46e7f74c3c
commit e3c8c6afff
18 changed files with 485 additions and 0 deletions

View file

@ -0,0 +1,3 @@
graphite-web (Enterprise Scalable Realtime Graphing)
Django-based web application that renders graphs and dashboards.

View file

@ -0,0 +1,18 @@
config() {
NEW="$1"
OLD="$(dirname $NEW)/$(basename $NEW .new)"
# If there's no config file by that name, mv it over:
if [ ! -r $OLD ]; then
mv $NEW $OLD
elif [ "$(cat $OLD | md5sum)" = "$(cat $NEW | md5sum)" ]; then
# toss the redundant copy
rm $NEW
fi
# Otherwise, we leave the .new copy for the admin to consider...
}
config etc/httpd/extra/graphite-web.conf.new
config etc/logrotate.d/graphite-web.new
find etc/graphite -type f -name '*.new' \
| while read new ; do config $new ; done

View file

@ -0,0 +1,111 @@
#!/bin/sh
# Slackware build script for graphite-web
# Copyright 2015 Mario Preksavec, Zagreb, Croatia
# All rights reserved.
#
# Redistribution and use of this script, with or without modification, is
# permitted provided that the following conditions are met:
#
# 1. Redistributions of this script must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
PRGNAM=graphite-web
VERSION=${VERSION:-0.9.3pre1}
BUILD=${BUILD:-1}
TAG=${TAG:-_SBo}
SRCVER=0.9.13-pre1
ARCH=noarch
CWD=$(pwd)
TMP=${TMP:-/tmp/SBo}
PKG=$TMP/package-$PRGNAM
OUTPUT=${OUTPUT:-/tmp}
set -e
rm -rf $PKG
mkdir -p $TMP $PKG $OUTPUT
cd $TMP
rm -rf $PRGNAM-$SRCVER
tar xvf $CWD/$v$SRCVER.tar.gz
cd $PRGNAM-$SRCVER
chown -R root:root .
find -L . \
\( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
-o -perm 511 \) -exec chmod 755 {} \; -o \
\( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
-o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;
# We don't have a RedHat system
patch -p1 <$CWD/patches/setup.cfg.diff
# Change path to wsgi
patch -p1 <$CWD/patches/graphite.wsgi.example.diff
# Patches thanks to Debian folks!
patch -p1 <$CWD/patches/local_settings.patch
patch -p1 <$CWD/patches/settings_debian.patch
patch -p1 <$CWD/patches/remove_internal_logrotate.patch
python setup.py install --root=$PKG
# Need some dirs
mkdir -p $PKG/etc/{httpd/extra,logrotate.d} $PKG/usr/share/$PRGNAM \
$PKG/var/log/graphite
chown graphite:graphite $PKG/var/log/graphite
# Add apache config
cat $CWD/$PRGNAM.conf > $PKG/etc/httpd/extra/$PRGNAM.conf.new
# Cruft removal
rm -rf $PKG/usr/{storage,examples} $PKG/usr/bin/*
find $PKG/usr -name 'local_settings.py.example' -delete
# Scripts and crontab mostly from Debian
install -m0755 -oroot -groot -t $PKG/usr/bin $CWD/scripts/graphite-manage \
$CWD/scripts/graphite-build-search-index
install -D -m0755 -oroot -groot $CWD/$PRGNAM.cron \
$PKG/etc/cron.hourly/graphite-build-search-index
cat $CWD/$PRGNAM.logrotate > $PKG/etc/logrotate.d/$PRGNAM.new
# Move wsgi script
mv $PKG/usr/conf/graphite.wsgi.example $PKG/usr/share/$PRGNAM/graphite.wsgi
# Configuration goes into /etc/graphite
mv $PKG/usr/conf $PKG/etc/graphite
for i in $PKG/etc/graphite/*.example ; do mv $i ${i/.example/.new} ; done
cat webapp/graphite/local_settings.py.example \
> $PKG/etc/graphite/local_settings.py.new
# Move webapp dir
mv $PKG/usr/webapp $PKG/usr/share/$PRGNAM/static
# Manpages also from Debian
mkdir -p $PKG/usr/man
cp -a $CWD/man1 $PKG/usr/man
find $PKG/usr/man -type f -exec gzip -9 {} \;
mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
cp -a INSTALL LICENSE README.md $PKG/usr/doc/$PRGNAM-$VERSION
cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc
cat $CWD/doinst.sh > $PKG/install/doinst.sh
cd $PKG
/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.${PKGTYPE:-tgz}

View file

@ -0,0 +1,31 @@
# This line needs to be in your server's config.
#Include /etc/httpd/extra/mod_wsgi.conf
WSGISocketPrefix /var/run/wsgi
<VirtualHost *:80>
ServerName graphite
ServerAlias graphite.*
WSGIDaemonProcess graphite processes=5 threads=5 display-name='%{GROUP}' inactivity-timeout=120 user=graphite group=graphite
WSGIProcessGroup graphite
WSGIApplicationGroup %{GLOBAL}
WSGIImportScript /usr/share/graphite-web/graphite.wsgi process-group=graphite application-group=%{GLOBAL}
WSGIScriptAlias / /usr/share/graphite-web/graphite.wsgi
<Directory /usr/share/graphite-web/>
Order deny,allow
Allow from all
Require all granted
</Directory>
Alias /content/ /usr/share/graphite-web/static/content/
<Location /content/>
SetHandler None
</Location>
ErrorLog /var/log/httpd/graphite_error_log
CustomLog /var/log/httpd/graphite_access_log common
</VirtualHost>

View file

@ -0,0 +1,7 @@
#!/bin/sh
set -e
if [ -x /usr/bin/graphite-build-search-index ]; then
/usr/bin/graphite-build-search-index
fi

View file

@ -0,0 +1,10 @@
PRGNAM="graphite-web"
VERSION="0.9.13pre1"
HOMEPAGE="https://github.com/graphite-project/"
DOWNLOAD="https://github.com/graphite-project/graphite-web/archive/0.9.13-pre1.tar.gz"
MD5SUM="527da1f89b9a60ae2af29eed06accdf3"
DOWNLOAD_x86_64=""
MD5SUM_x86_64=""
REQUIRES="graphite-carbon"
MAINTAINER="Mario Preksavec"
EMAIL="mario at slackware dot hr"

View file

@ -0,0 +1,8 @@
/var/log/graphite/*.log {
weekly
missingok
rotate 4
compress
notifempty
create 644 graphite graphite
}

View file

@ -0,0 +1,19 @@
.\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3
.
.TH "GRAPHITE\-BUILD\-SEARCH\-INDEX" "1" "December 2012" "" ""
.
.SH "NAME"
\fBgraphite\-build\-search\-index\fR \- create search index for Graphite Webapp
.
.SH "SYNOPSIS"
graphite\-build\-search\-index
.
.SH "DESCRIPTION"
This script creates the search index of Whisper files for the Graphite Webapp\. It will run as hourly cronjob\. You don\'t need to run this command manual except you want to force generating the search index\.
.
.SH "AUTHOR"
Jonas Genannt
.
.P
This manual page was written by Jonas Genannt \fIjonas\.genannt@capi2name\.de\fR for the Debian Project\.

View file

@ -0,0 +1,35 @@
.\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3
.
.TH "GRAPHITE\-MANAGE" "1" "December 2012" "" ""
.
.SH "NAME"
\fBgraphite\-manage\fR \- manage\.py wrapper for the Graphite Webapp
.
.SH "SYNOPSIS"
graphite\-manage
.
.SH "DESCRIPTION"
graphite\-manage is an wrapper script to access Django manage\.py for the Graphite Webapp\.
.
.P
See \fBgraphite\-manage \-\-help\fR for complete help\.
.
.P
To create an new sqlite database and an superuser do:
.
.IP "\(bu" 4
graphite\-manage syncdb
.
.IP "\(bu" 4
chown graphite:graphite /var/lib/graphite/graphite\.db
.
.IP "" 0
.
.SH "AUTHOR"
Jonas Genannt
.
.P
This manual page was written by Jonas Genannt \fIjonas\.genannt@capi2name\.de\fR for the Debian Project\.
.br
Modified by Mario Preksavec \fImario@slackware\.hr\fR for Slackware

View file

@ -0,0 +1,9 @@
--- graphite-web-0.9.13-pre1/conf/graphite.wsgi.example.orig 2014-12-31 17:51:36.000000000 +0100
+++ graphite-web-0.9.13-pre1/conf/graphite.wsgi.example 2015-02-19 18:26:43.753661979 +0100
@@ -1,5 +1,5 @@
import os, sys
-sys.path.append('/opt/graphite/webapp')
+sys.path.append('/usr/share/graphite/static')
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'graphite.settings')
import django

View file

@ -0,0 +1,85 @@
Description: Other defaults for Debian
Author: Jonas Genannt <jonas.genannt@capi2name.de>
Forwarded: not-needed
diff --git a/webapp/graphite/local_settings.py.example b/webapp/graphite/local_settings.py.example
index 73a0c57..c40b1e0 100644
--- a/webapp/graphite/local_settings.py.example
+++ b/webapp/graphite/local_settings.py.example
@@ -26,9 +26,10 @@
#DOCUMENTATION_URL = "http://graphite.readthedocs.org/"
# Logging
-#LOG_RENDERING_PERFORMANCE = True
-#LOG_CACHE_PERFORMANCE = True
-#LOG_METRIC_ACCESS = True
+# True see: https://answers.launchpad.net/graphite/+question/159731
+LOG_RENDERING_PERFORMANCE = True
+LOG_CACHE_PERFORMANCE = True
+LOG_METRIC_ACCESS = True
# Enable full debug page display on exceptions (Internal Server Error pages)
#DEBUG = True
@@ -54,14 +55,14 @@
#####################################
# Change only GRAPHITE_ROOT if your install is merely shifted from /opt/graphite
# to somewhere else
-#GRAPHITE_ROOT = '/opt/graphite'
+GRAPHITE_ROOT = '/usr/share/graphite-web'
# Most installs done outside of a separate tree such as /opt/graphite will only
# need to change these three settings. Note that the default settings for each
# of these is relative to GRAPHITE_ROOT
-#CONF_DIR = '/opt/graphite/conf'
-#STORAGE_DIR = '/opt/graphite/storage'
-#CONTENT_DIR = '/opt/graphite/webapp/content'
+CONF_DIR = '/etc/graphite'
+STORAGE_DIR = '/var/lib/graphite/whisper'
+CONTENT_DIR = '/usr/share/graphite-web/static'
# To further or fully customize the paths, modify the following. Note that the
# default settings for each of these are relative to CONF_DIR and STORAGE_DIR
@@ -72,11 +73,11 @@
## Data directories
# NOTE: If any directory is unreadable in DATA_DIRS it will break metric browsing
-#WHISPER_DIR = '/opt/graphite/storage/whisper'
+WHISPER_DIR = '/var/lib/graphite/whisper'
#RRD_DIR = '/opt/graphite/storage/rrd'
#DATA_DIRS = [WHISPER_DIR, RRD_DIR] # Default: set from the above variables
-#LOG_DIR = '/opt/graphite/storage/log/webapp'
-#INDEX_FILE = '/opt/graphite/storage/index' # Search index file
+LOG_DIR = '/var/log/graphite'
+INDEX_FILE = '/var/lib/graphite/search_index' # Search index file
#####################################
@@ -147,17 +148,17 @@
# The default is 'django.db.backends.sqlite3' with file 'graphite.db'
# located in STORAGE_DIR
#
-#DATABASES = {
-# 'default': {
-# 'NAME': '/opt/graphite/storage/graphite.db',
-# 'ENGINE': 'django.db.backends.sqlite3',
-# 'USER': '',
-# 'PASSWORD': '',
-# 'HOST': '',
-# 'PORT': ''
-# }
-#}
-#
+DATABASES = {
+ 'default': {
+ 'NAME': '/var/lib/graphite/graphite.db',
+ 'ENGINE': 'django.db.backends.sqlite3',
+ 'USER': '',
+ 'PASSWORD': '',
+ 'HOST': '',
+ 'PORT': ''
+ }
+}
+
#########################

View file

@ -0,0 +1,45 @@
Description: disable internal logroate
Author: Jonas Genannt <jonas.genannt@capi2name.de>
Forwarded: not-needed
diff --git a/webapp/graphite/logger.py b/webapp/graphite/logger.py
index afa43f4..44456ac 100644
--- a/webapp/graphite/logger.py
+++ b/webapp/graphite/logger.py
@@ -13,7 +13,7 @@ See the License for the specific language governing permissions and
limitations under the License."""
import os, logging
-from logging.handlers import TimedRotatingFileHandler as Rotater
+from logging import FileHandler as LogFileHandler
from django.conf import settings
logging.addLevelName(30,"rendering")
@@ -37,22 +37,22 @@ class GraphiteLogger:
self.metricAccessLogger = logging.getLogger("metric_access")
#Setup formatter & handlers
self.formatter = logging.Formatter("%(asctime)s :: %(message)s","%a %b %d %H:%M:%S %Y")
- self.infoHandler = Rotater(self.infoLogFile,when="midnight",backupCount=1)
+ self.infoHandler = LogFileHandler(self.infoLogFile)
self.infoHandler.setFormatter(self.formatter)
self.infoLogger.addHandler(self.infoHandler)
- self.exceptionHandler = Rotater(self.exceptionLogFile,when="midnight",backupCount=1)
+ self.exceptionHandler = LogFileHandler(self.exceptionLogFile)
self.exceptionHandler.setFormatter(self.formatter)
self.exceptionLogger.addHandler(self.exceptionHandler)
if settings.LOG_CACHE_PERFORMANCE:
- self.cacheHandler = Rotater(self.cacheLogFile,when="midnight",backupCount=1)
+ self.cacheHandler = LogFileHandler(self.cacheLogFile)
self.cacheHandler.setFormatter(self.formatter)
self.cacheLogger.addHandler(self.cacheHandler)
if settings.LOG_RENDERING_PERFORMANCE:
- self.renderingHandler = Rotater(self.renderingLogFile,when="midnight",backupCount=1)
+ self.renderingHandler = LogFileHandler(self.renderingLogFile)
self.renderingHandler.setFormatter(self.formatter)
self.renderingLogger.addHandler(self.renderingHandler)
if settings.LOG_METRIC_ACCESS:
- self.metricAccessHandler = Rotater(self.metricAccessLogFile,when="midnight",backupCount=10)
+ self.metricAccessHandler = LogFileHandler(self.metricAccessLogFile)
self.metricAccessHandler.setFormatter(self.formatter)
self.metricAccessLogger.addHandler(self.metricAccessHandler)

View file

@ -0,0 +1,25 @@
Description: Add etc/graphite to sys.path to load config from /etc/graphite
Author: Jonas Genannt <jonas.genannt@capi2name.de>
Forwarded: not-needed
--- a/webapp/graphite/settings.py
+++ b/webapp/graphite/settings.py
@@ -20,6 +20,9 @@
from os.path import abspath, dirname, join
from warnings import warn
+# Debian add etc/graphite into path
+sys.path.append('/etc/graphite')
+
try:
import rrdtool
except ImportError:
@@ -128,7 +131,7 @@
## Load our local_settings
try:
- from graphite.local_settings import *
+ from local_settings import *
except ImportError:
print >> sys.stderr, "Could not import graphite.local_settings, using defaults!"

View file

@ -0,0 +1,23 @@
--- graphite-web-0.9.13-pre1/setup.cfg.orig 2014-12-31 17:51:36.000000000 +0100
+++ graphite-web-0.9.13-pre1/setup.cfg 2015-02-19 16:45:23.526959108 +0100
@@ -1,20 +0,0 @@
-[install]
-prefix = /opt/graphite
-install-lib = %(prefix)s/webapp
-
-[bdist_rpm]
-requires = Django => 1.1.4
- django-tagging
- carbon
- whisper
- mod_wsgi
- pycairo
- pycairo-devel
- python-simplejson
- python-sqlite2
- python-hashlib
-
-post-install = distro/redhat/misc/postinstall
-
-provides = graphite
-obsoletes = graphite <= 0.9.9

View file

@ -0,0 +1,13 @@
--- graphite-web-0.9.13-pre1/setup.py.orig 2014-12-31 17:51:36.000000000 +0100
+++ graphite-web-0.9.13-pre1/setup.py 2015-02-19 18:45:25.173599991 +0100
@@ -58,8 +58,7 @@
'graphite.thirdparty.pytz',
],
package_data={'graphite' :
- ['templates/*', 'local_settings.py.example']},
- scripts=glob('bin/*'),
- data_files=webapp_content.items() + storage_dirs + conf_files + examples,
+ ['templates/*']},
+ data_files=webapp_content.items() + conf_files,
**setup_kwargs
)

View file

@ -0,0 +1,21 @@
#!/bin/bash
# Jonas Genannt <jonas.genannt@capi2name.de>, 2012 for the Debian Project
# Modified by Mario Preksavec <mario@slackware.hr>, 2015 for Slackware
set -e
INDEX_FILE_TMP=$(mktemp)
INDEX_FILE="/var/lib/graphite/search_index"
WHISPER_DIR="/var/lib/graphite/whisper"
cd ${WHISPER_DIR} && find -L . -name '*.wsp' | sed \
-e 's@\.wsp$@@' \
-e 's@^\./@@' \
-e 's@/@.@g' > ${INDEX_FILE_TMP}
chmod 0644 ${INDEX_FILE_TMP}
chown graphite:graphite ${INDEX_FILE_TMP}
mv -f ${INDEX_FILE_TMP} ${INDEX_FILE}

View file

@ -0,0 +1,3 @@
#!/bin/bash
django-admin.py --settings=graphite.settings

View file

@ -0,0 +1,19 @@
# HOW TO EDIT THIS FILE:
# The "handy ruler" below makes it easier to edit a package description.
# Line up the first '|' above the ':' following the base package name, and
# the '|' on the right side marks the last column you can put a character in.
# You must make exactly 11 lines for the formatting to be correct. It's also
# customary to leave one space after the ':' except on otherwise blank lines.
|-----handy-ruler------------------------------------------------------|
graphite-web: graphite-web (Enterprise Scalable Realtime Graphing)
graphite-web:
graphite-web: Django-based web application that renders graphs and dashboards.
graphite-web:
graphite-web: https://github.com/graphite-project/
graphite-web:
graphite-web:
graphite-web:
graphite-web:
graphite-web:
graphite-web: