diff --git a/MANIFEST.in b/MANIFEST.in index 22735e6f8..14ea4bc3e 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -3,6 +3,7 @@ include README.md include MANIFEST.in include bin/* include examples/* +include debian/* include conf/*.example exclude conf/*.conf include test/common.py diff --git a/Makefile b/Makefile new file mode 100644 index 000000000..010472265 --- /dev/null +++ b/Makefile @@ -0,0 +1,33 @@ +DESTDIR=/ +PROJECT=diamond +VERSION=0.2.0 + +all: + @echo "make source - Create source package" + @echo "make install - Install on local system" + @echo "make buildrpm - Generate a rpm package" + @echo "make builddeb - Generate a deb package" + @echo "make clean - Get rid of scratch and byte files" + +source: + python setup.py sdist --prune + +install: + python setup.py install --root $(DESTDIR) + +buildrpm: source + python setup.py bdist_rpm \ + --post-install=rpm/postinstall \ + --pre-uninstall=rpm/preuninstall + +builddeb: source + mkdir -p build + tar -C build -zxf dist/$(PROJECT)-$(VERSION).tar.gz + (cd build/$(PROJECT)-$(VERSION) && debuild -us -uc) + +clean: + python setup.py clean + rm -rf build MANIFEST + find . -name '*.pyc' -delete + +.PHONY: source install buildrpm builddeb clean diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 000000000..1a856ac5f --- /dev/null +++ b/debian/changelog @@ -0,0 +1,5 @@ +diamond (0.2.0) unstable; urgency=low + + * Initial release. + + -- Ivan Pouzyrevsky Thu, 10 Nov 2011 01:42:39 +0400 diff --git a/debian/compat b/debian/compat new file mode 100644 index 000000000..7f8f011eb --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +7 diff --git a/debian/control b/debian/control new file mode 100644 index 000000000..31b0c3eed --- /dev/null +++ b/debian/control @@ -0,0 +1,16 @@ +Source: diamond +Section: misc +Priority: extra +Maintainer: Ivan Pouzyrevsky +Homepage: https://github.com/sandello/Diamond +Vcs-Git: git://github.com/sandello/Diamond.git +Vcs-Browser: https://github.com/sandello/Diamond +Build-Depends: debhelper (>= 7), python (>= 2.4), python-support +Standards-Version: 3.9.1 + +Package: diamond +Architecture: all +Depends: ${misc:Depends}, ${python:Depends}, python (>= 2.4), python-configobj +Description: System statistics collector for Graphite. + Diamond is a daemon and toolset for gathering system statistics + and publishing them to graphite. diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 000000000..108bdc77b --- /dev/null +++ b/debian/copyright @@ -0,0 +1,22 @@ +Files: * +Copyright: (C) 2011-2012 by Ivan Pouzyrevsky. + (C) 2010-2011 by Brightcove Inc. + +License: MIT + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. diff --git a/debian/diamond.default b/debian/diamond.default new file mode 100644 index 000000000..56cf7a017 --- /dev/null +++ b/debian/diamond.default @@ -0,0 +1,10 @@ +# Defaults for diamond initscript +# sourced by /etc/init.d/diamond +# installed at /etc/default/diamond by the maintainer scripts + +# +# This is a POSIX shell fragment +# + +# Additional options that are passed to the Daemon. +DAEMON_OPTS="" diff --git a/debian/init.d b/debian/init.d new file mode 100644 index 000000000..69af1eebc --- /dev/null +++ b/debian/init.d @@ -0,0 +1,140 @@ +#!/bin/sh +### BEGIN INIT INFO +# Provides: diamond +# Required-Start: $network $local_fs $remote_fs +# Required-Stop: $network $local_fs $remote_fs +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: +# Description: +# <...> +# <...> +### END INIT INFO + +# Author: Ivan Pouzyrevsky + +# PATH should only include /usr/* if it runs after the mountnfs.sh script +PATH=/sbin:/usr/sbin:/bin:/usr/bin +DESC=diamond # Introduce a short description here +NAME=diamond # Introduce the short server's name here +DAEMON=/usr/sbin/diamond # Introduce the server's location here +DAEMON_ARGS="" # Arguments to run the daemon with +PIDFILE=/var/run/$NAME.pid +SCRIPTNAME=/etc/init.d/$NAME + +# Exit if the package is not installed +[ -x $DAEMON ] || exit 0 + +# Read configuration variable file if it is present +[ -r /etc/default/$NAME ] && . /etc/default/$NAME + +# Load the VERBOSE setting and other rcS variables +. /lib/init/vars.sh + +# Define LSB log_* functions. +# Depend on lsb-base (>= 3.0-6) to ensure that this file is present. +. /lib/lsb/init-functions + +# +# Function that starts the daemon/service +# +do_start() +{ + # Return + # 0 if daemon has been started + # 1 if daemon was already running + # 2 if daemon could not be started + start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \ + || return 1 + start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \ + $DAEMON_ARGS \ + || return 2 + # Add code here, if necessary, that waits for the process to be ready + # to handle requests from services started subsequently which depend + # on this one. As a last resort, sleep for some time. +} + +# +# Function that stops the daemon/service +# +do_stop() +{ + # Return + # 0 if daemon has been stopped + # 1 if daemon was already stopped + # 2 if daemon could not be stopped + # other if a failure occurred + start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME + RETVAL="$?" + [ "$RETVAL" = 2 ] && return 2 + # Wait for children to finish too if this is a daemon that forks + # and if the daemon is only ever run from this initscript. + # If the above conditions are not satisfied then add some other code + # that waits for the process to drop all resources that could be + # needed by services started subsequently. A last resort is to + # sleep for some time. + start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON + [ "$?" = 2 ] && return 2 + # Many daemons don't delete their pidfiles when they exit. + rm -f $PIDFILE + return "$RETVAL" +} + +# +# Function that sends a SIGHUP to the daemon/service +# +do_reload() { + # + # If the daemon can reload its configuration without + # restarting (for example, when it is sent a SIGHUP), + # then implement that here. + # + start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME + return 0 +} + +case "$1" in + start) + [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC " "$NAME" + do_start + case "$?" in + 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; + 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; + esac + ;; + stop) + [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME" + do_stop + case "$?" in + 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; + 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; + esac + ;; + status) + status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $? + ;; + restart) + log_daemon_msg "Restarting $DESC" "$NAME" + do_stop + case "$?" in + 0|1) + do_start + case "$?" in + 0) log_end_msg 0 ;; + 1) log_end_msg 1 ;; # Old process is still running + *) log_end_msg 1 ;; # Failed to start + esac + ;; + *) + # Failed to stop + log_end_msg 1 + ;; + esac + ;; + *) + echo "Usage: $SCRIPTNAME {start|stop|status|restart}" >&2 + exit 3 + ;; +esac + +: diff --git a/debian/postinst b/debian/postinst new file mode 100644 index 000000000..634f35fe8 --- /dev/null +++ b/debian/postinst @@ -0,0 +1,39 @@ +#!/bin/sh +# postinst script for diamond +# +# see: dh_installdeb(1) + +set -e + +# summary of how this script can be called: +# * `configure' +# * `abort-upgrade' +# * `abort-remove' `in-favour' +# +# * `abort-remove' +# * `abort-deconfigure' `in-favour' +# `removing' +# +# for details, see http://www.debian.org/doc/debian-policy/ or +# the debian-policy package + + +case "$1" in + configure) + ;; + + abort-upgrade|abort-remove|abort-deconfigure) + ;; + + *) + echo "postinst called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 diff --git a/debian/postrm b/debian/postrm new file mode 100644 index 000000000..d555b3dfe --- /dev/null +++ b/debian/postrm @@ -0,0 +1,41 @@ +#!/bin/sh +# postrm script for diamond +# +# see: dh_installdeb(1) + +set -e + +# summary of how this script can be called: +# * `remove' +# * `purge' +# * `upgrade' +# * `failed-upgrade' +# * `abort-install' +# * `abort-install' +# * `abort-upgrade' +# * `disappear' +# +# for details, see http://www.debian.org/doc/debian-policy/ or +# the debian-policy package + + +case "$1" in + purge) + [ -d /opt/diamond ] && rm -rf /opt/diamond + ;; + + purge|remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) + ;; + + *) + echo "postrm called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 diff --git a/debian/preinst b/debian/preinst new file mode 100644 index 000000000..9bbbd4834 --- /dev/null +++ b/debian/preinst @@ -0,0 +1,35 @@ +#!/bin/sh +# preinst script for diamond +# +# see: dh_installdeb(1) + +set -e + +# summary of how this script can be called: +# * `install' +# * `install' +# * `upgrade' +# * `abort-upgrade' +# for details, see http://www.debian.org/doc/debian-policy/ or +# the debian-policy package + + +case "$1" in + install|upgrade) + ;; + + abort-upgrade) + ;; + + *) + echo "preinst called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 diff --git a/debian/prerm b/debian/prerm new file mode 100644 index 000000000..652ef9670 --- /dev/null +++ b/debian/prerm @@ -0,0 +1,38 @@ +#!/bin/sh +# prerm script for diamond +# +# see: dh_installdeb(1) + +set -e + +# summary of how this script can be called: +# * `remove' +# * `upgrade' +# * `failed-upgrade' +# * `remove' `in-favour' +# * `deconfigure' `in-favour' +# `removing' +# +# for details, see http://www.debian.org/doc/debian-policy/ or +# the debian-policy package + + +case "$1" in + remove|upgrade|deconfigure) + ;; + + failed-upgrade) + ;; + + *) + echo "prerm called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 diff --git a/debian/pyversions b/debian/pyversions new file mode 100644 index 000000000..8b253bc3c --- /dev/null +++ b/debian/pyversions @@ -0,0 +1 @@ +2.4- diff --git a/debian/rules b/debian/rules new file mode 100755 index 000000000..2d33f6ac8 --- /dev/null +++ b/debian/rules @@ -0,0 +1,4 @@ +#!/usr/bin/make -f + +%: + dh $@ diff --git a/setup.cfg b/setup.cfg index 0f536eb64..5bb58958b 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,3 +1,4 @@ [install] prefix = /opt/diamond install-lib = %(prefix)s/lib +install-data = %(prefix)s