[packages/diamond: 1/2] Initial version 4.0.195.
matkor
matkor at pld-linux.org
Wed Dec 2 17:35:55 CET 2015
commit 30fc16b95cbfdc820670bf10d5cfbaf1da7dc07c
Author: Mateusz Korniak <matkor at pld-linux.org>
Date: Wed Dec 2 17:13:03 2015 +0100
Initial version 4.0.195.
PostgresqlCollector.conf | 17 ++++
diamond.conf | 259 +++++++++++++++++++++++++++++++++++++++++++++++
diamond.init | 115 +++++++++++++++++++++
diamond.spec | 166 ++++++++++++++++++++++++++++++
4 files changed, 557 insertions(+)
---
diff --git a/diamond.spec b/diamond.spec
new file mode 100644
index 0000000..98d35bd
--- /dev/null
+++ b/diamond.spec
@@ -0,0 +1,166 @@
+# Conditional build:
+# %bcond_with doc # don't build doc
+# %bcond_with tests # do not perform "make test"
+%bcond_without python2 # CPython 2.x module
+# %bcond_with python3 # CPython 3.x module
+
+%define module diamond
+Summary: Python daemon that collects system metrics and publishes them to Graphite (and others).
+Summary(pl.UTF-8): Demon napisany w Pythonie, zbierający statystyki i publikujący je do Graphite (i innych)
+# Name must match the python module/package name (as in 'import' statement)
+Name: diamond
+Version: 4.0.195
+Release: 0.5
+License: MIT
+Group: Libraries/Python
+# https://github.com/python-diamond/Diamond/archive/v4.0.tar.gz
+# https://pypi.python.org/packages/source/d/diamond/diamond-4.0.195.tar.gz#md5=b49da676079eafab3e784cccedc6bfa1
+Source0: https://pypi.python.org/packages/source/d/diamond/%{name}-%{version}.tar.gz
+# Source0-md5: b49da676079eafab3e784cccedc6bfa1
+#URL: https://pypi.python.org/pypi/MODULE
+Source1: %{name}.conf
+Source3: %{name}.init
+Source10: PostgresqlCollector.conf
+
+URL: https://github.com/python-diamond/Diamond
+BuildRequires: rpm-pythonprov
+# for the py_build, py_install macros
+BuildRequires: rpmbuild(macros) >= 1.710
+%if %{with python2}
+BuildRequires: python-modules
+#BuildRequires: python-setuptools
+%endif
+# %if %{with python3}
+# #BuildRequires: python3-setuptools
+# BuildRequires: python3-modules
+# %endif
+# when using /usr/bin/env or other in-place substitutions
+#BuildRequires: sed >= 4.0
+# replace with other requires if defined in setup.py
+Requires: python-configobj >= 5.0.6
+Requires: python-modules
+Suggests: python-setproctitle
+Provides: group(diamond)
+Provides: user(diamond)
+
+BuildArch: noarch
+BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
+
+%description
+
+%description -l pl.UTF-8
+
+
+%package -n %{module}-collector-postgresql
+Summary: Data collector for PostgreSQL database
+Summary(pl.UTF-8): Zbieracz statystyk dla bazdy danych Postgresql
+Group: Libraries/Python
+Requires: %{name}
+Requires: python-psycopg2
+
+%description -n %{module}-collector-postgresql
+Data collector for PostgreSQL database
+
+%description -n %{module}-collector-postgresql -l pl.UTF-8
+Zbieracz statystyk dla bazdy danych Postgresql
+
+%prep
+%setup -q -n %{module}-%{version}
+
+# fix #!%{_bindir}/env python -> #!%{_bindir}/python:
+#%{__sed} -i -e '1s,^#!.*python,#!%{__python},' %{name}.py
+
+%build
+%if %{with python2}
+%py_build %{?with_tests:test}
+%endif
+
+# %if %{with python3}
+# %%py3_build %{?with_tests:test}
+# %endif
+
+# %if %{with doc}
+# cd docs
+# %{__make} -j1 html
+# rm -rf _build/html/_sources
+# %endif
+
+%install
+rm -rf $RPM_BUILD_ROOT
+
+%if %{with python2}
+%py_install
+%py_postclean
+%endif
+# %if %{with python3}
+# %%py3_install
+# %endif
+install -d $RPM_BUILD_ROOT%{_sysconfdir}/%{module}
+install -d $RPM_BUILD_ROOT%{_sysconfdir}/%{module}/collectors
+install -d $RPM_BUILD_ROOT%{_sysconfdir}/%{module}/handlers
+## install -d $RPM_BUILD_ROOT%{_sysconfdir}/%{module}/configs
+install -p %{SOURCE1} $RPM_BUILD_ROOT/%{_sysconfdir}/%{module}/diamond.conf
+
+install -d $RPM_BUILD_ROOT%{_localstatedir}/log/%{module}
+# install -d $RPM_BUILD_ROOT%{_localstatedir}/run/carbon
+# install -d $RPM_BUILD_ROOT%{_sharedstatedir}/carbon
+
+install -d $RPM_BUILD_ROOT/etc/rc.d/init.d
+install -p %{SOURCE3} $RPM_BUILD_ROOT/etc/rc.d/init.d/diamond
+
+install -p %{SOURCE10} $RPM_BUILD_ROOT%{_sysconfdir}/%{module}/collectors
+
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+%pre
+%groupadd -g 327 diamond
+%useradd -u 327 -d /var/log/diamond -g diamond -c "Diamond daemon user" diamond
+
+%postun
+if [ "$1" = "0" ]; then
+ %userremove diamond
+ %groupremove diamond
+fi
+
+%if %{with python2}
+%files
+%defattr(644,root,root,755)
+%doc README.md LICENSE
+%dir %attr(750,root,diamond) %{_sysconfdir}/%{module}
+%dir %attr(640,root,diamond) %{_sysconfdir}/%{module}/diamond.conf
+%dir %attr(750,root,diamond) %{_sysconfdir}/%{module}/collectors
+%dir %attr(750,root,diamond) %{_sysconfdir}/%{module}/handlers
+%attr(755,root,root) %{_bindir}/diamond
+%attr(755,root,root) %{_bindir}/diamond-setup
+%{py_sitescriptdir}/%{module}
+# %{py_sitescriptdir}/%{module}/collectors
+%{_datadir}/diamond/
+%attr(750,diamond,diamond) /var/log/diamond
+%attr(754,root,root) /etc/rc.d/init.d/diamond
+
+
+%if "%{py_ver}" > "2.4"
+%{py_sitescriptdir}/%{module}-%{version}-py*.egg-info
+%endif
+%endif
+
+# %if %{with python3}
+# %files -n python3-%{module}
+# %defattr(644,root,root,755)
+# %doc AUTHORS CHANGES LICENSE
+# %{py3_sitescriptdir}/%{module}
+# %{py3_sitescriptdir}/%{module}-%{version}-py*.egg-info
+# %{_examplesdir}/python3-%{module}-%{version}
+# %endif
+#
+# %if %{with doc}
+# %files apidocs
+# %defattr(644,root,root,755)
+# %doc docs/_build/html/*
+# %endif
+
+%files -n %{module}-collector-postgresql
+%defattr(644,root,root,755)
+%{_sysconfdir}/%{module}/collectors/PostgresqlCollector.conf
diff --git a/PostgresqlCollector.conf b/PostgresqlCollector.conf
new file mode 100644
index 0000000..312f408
--- /dev/null
+++ b/PostgresqlCollector.conf
@@ -0,0 +1,17 @@
+# https://github.com/BrightcoveOS/Diamond/wiki/collectors-PostgresqlCollector
+[collectors]
+[[PostgresqlCollector]]
+enabled = True
+
+host=localhost
+dbname=postgres
+pg_version=9.3
+
+# By default try use diamond user/pass
+# CREATE ROLE diamond WITH LOGIN PASSWORD 'diamond' CONNECTION LIMIT 3 NOSUPERUSER NOCREATEDB NOCREATEROLE NOINHERIT NOREPLICATION;
+user=diamond
+password=diamond
+
+# has_admin=True
+# extended=True
+
diff --git a/diamond.conf b/diamond.conf
new file mode 100644
index 0000000..8df5c24
--- /dev/null
+++ b/diamond.conf
@@ -0,0 +1,259 @@
+################################################################################
+# Diamond Configuration File
+################################################################################
+
+################################################################################
+### Options for the server
+[server]
+
+# Handlers for published metrics.
+handlers = diamond.handler.graphite.GraphiteHandler, diamond.handler.archive.ArchiveHandler
+
+# User diamond will run as
+# Leave empty to use the current user
+user = diamond
+
+# Group diamond will run as
+# Leave empty to use the current group
+group = diamond
+
+# Pid file
+pid_file = /var/run/diamond.pid
+
+# Directory to load collector modules from
+collectors_path = /usr/share/diamond/collectors/
+
+# Directory to load collector configs from
+collectors_config_path = /etc/diamond/collectors/
+
+# Directory to load handler configs from
+handlers_config_path = /etc/diamond/handlers/
+
+# Directory to load handler modules from
+handlers_path = /usr/share/diamond/handlers/
+
+################################################################################
+### Options for handlers
+[handlers]
+
+# daemon logging handler(s)
+keys = rotated_file
+
+### Defaults options for all Handlers
+[[default]]
+
+[[ArchiveHandler]]
+
+# File to write archive log files
+log_file = /var/log/diamond/archive.log
+
+# Number of days to keep archive log files
+days = 7
+
+[[GraphiteHandler]]
+### Options for GraphiteHandler
+
+# Graphite server host
+host = 127.0.0.1
+
+
+# Port to send metrics to
+port = 2003
+
+# Socket timeout (seconds)
+timeout = 15
+
+# Batch size for metrics
+batch = 1
+
+[[GraphitePickleHandler]]
+### Options for GraphitePickleHandler
+
+# Graphite server host
+host = 127.0.0.1
+
+# Port to send metrics to
+port = 2004
+
+# Socket timeout (seconds)
+timeout = 15
+
+# Batch size for pickled metrics
+batch = 256
+
+[[MySQLHandler]]
+### Options for MySQLHandler
+
+# MySQL Connection Info
+hostname = 127.0.0.1
+port = 3306
+username = root
+password =
+database = diamond
+table = metrics
+# INT UNSIGNED NOT NULL
+col_time = timestamp
+# VARCHAR(255) NOT NULL
+col_metric = metric
+# VARCHAR(255) NOT NULL
+col_value = value
+
+[[StatsdHandler]]
+host = 127.0.0.1
+port = 8125
+
+[[TSDBHandler]]
+host = 127.0.0.1
+port = 4242
+timeout = 15
+
+[[LibratoHandler]]
+user = user at example.com
+apikey = abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz01
+
+[[HostedGraphiteHandler]]
+apikey = abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz01
+timeout = 15
+batch = 1
+
+[[SignalfxHandler]]
+auth_token = abcdefghijklmnopqrstuvwxyz
+
+# And any other config settings from GraphiteHandler are valid here
+
+[[HttpPostHandler]]
+
+### Urp to post the metrics
+url = http://localhost:8888/
+### Metrics batch size
+batch = 100
+
+
+################################################################################
+### Options for collectors
+[collectors]
+
+[[default]]
+### Defaults options for all Collectors
+
+# Uncomment and set to hardcode a hostname for the collector path
+# Keep in mind, periods are seperators in graphite
+# hostname = my_custom_hostname
+
+# If you prefer to just use a different way of calculating the hostname
+# Uncomment and set this to one of these values:
+
+# smart = Default. Tries fqdn_short. If that's localhost, uses hostname_short
+
+# fqdn_short = Default. Similar to hostname -s
+# fqdn = hostname output
+# fqdn_rev = hostname in reverse (com.example.www)
+
+# uname_short = Similar to uname -n, but only the first part
+# uname_rev = uname -r in reverse (com.example.www)
+
+# hostname_short = `hostname -s`
+# hostname = `hostname`
+# hostname_rev = `hostname` in reverse (com.example.www)
+
+# shell = Run the string set in hostname as a shell command and use its
+# output(with spaces trimmed off from both ends) as the hostname.
+
+# hostname_method = smart
+
+# Path Prefix and Suffix
+# you can use one or both to craft the path where you want to put metrics
+# such as: %(path_prefix)s.$(hostname)s.$(path_suffix)s.$(metric)s
+# path_prefix = servers
+# path_suffix =
+
+# Path Prefix for Virtual Machines
+# If the host supports virtual machines, collectors may report per
+# VM metrics. Following OpenStack nomenclature, the prefix for
+# reporting per VM metrics is "instances", and metric foo for VM
+# bar will be reported as: instances.bar.foo...
+# instance_prefix = instances
+
+# Default Poll Interval (seconds)
+# interval = 300
+
+################################################################################
+# Default enabled collectors
+################################################################################
+
+[[CPUCollector]]
+enabled = True
+interval=60
+
+[[DiskSpaceCollector]]
+enabled = True
+interval=300
+
+[[DiskUsageCollector]]
+enabled = True
+interval=60
+# Devices to collect data from
+devices=md[0-9]+$|sd[a-z]+[0-9]*$|x?vd[a-z]+[0-9]*$|disk[0-9]+$|dm\\-[0-9]+$|bcache[0-9]+$
+
+[[LoadAverageCollector]]
+enabled = True
+interval=60
+
+[[MemoryCollector]]
+enabled = True
+interval=60
+
+[[VMStatCollector]]
+enabled = True
+interval=60
+
+################################################################################
+### Options for logging
+# for more information on file format syntax:
+# http://docs.python.org/library/logging.config.html#configuration-file-format
+
+[loggers]
+
+keys = root
+
+# handlers are higher in this config file, in:
+# [handlers]
+# keys = ...
+
+[formatters]
+
+keys = default
+
+[logger_root]
+
+# to increase verbosity, set DEBUG
+level = INFO
+handlers = rotated_file
+propagate = 1
+
+[handler_rotated_file]
+
+class = handlers.TimedRotatingFileHandler
+level = DEBUG
+formatter = default
+# rotate at midnight, each day and keep 7 days
+args = ('/var/log/diamond/diamond.log', 'midnight', 1, 7)
+
+[formatter_default]
+
+format = [%(asctime)s] [%(threadName)s] %(message)s
+datefmt =
+
+################################################################################
+### Options for config merging
+[configs]
+path = "/etc/diamond/collectors/"
+extension = ".conf"
+#-------------------------------------------------------------------------------
+# Example:
+# /etc/diamond/configs/net.conf
+# [collectors]
+#
+# [[NetworkCollector]]
+# enabled = True
+
diff --git a/diamond.init b/diamond.init
new file mode 100755
index 0000000..fcb189c
--- /dev/null
+++ b/diamond.init
@@ -0,0 +1,115 @@
+#!/bin/sh
+#
+# diamond Start the diamond statistics collector
+#
+# chkconfig: 345 85 15
+# description: Diamond is a daemon and toolset for gathering system statistics \
+# and publishing them to Graphite.
+# processname: python
+# config: /etc/diamond/diamond.conf
+# pidfile: /var/run/diamond.pid
+
+# Source function library
+. /etc/rc.d/init.d/functions
+
+# Get network config
+. /etc/sysconfig/network
+
+# Get service config
+[ -f /etc/sysconfig/diamond ] && . /etc/sysconfig/diamond
+
+
+SVC_NAME="Diamond stats gathering daemon"
+
+
+
+start() {
+ # Check if the service is already running?
+ if [ -f /var/lock/subsys/diamond ]; then
+ msg_already_running "$SVC_NAME"
+ return
+ fi
+
+ ## [ "$1" -eq 0 ] || checkconfig
+ msg_starting "$SVC_NAME"
+ # diamond switches to diamond:diamond on his own, let's not use --user diamond here
+ daemon /usr/bin/diamond --pidfile /var/run/diamond.pid
+ RETVAL=$?
+ [ $RETVAL -eq 0 ] && touch /var/lock/subsys/diamond
+}
+
+stop() {
+ # Stop daemon.
+ if [ ! -f /var/lock/subsys/diamond ]; then
+ msg_not_running "$SVC_NAME"
+ return
+ fi
+
+ msg_stopping "$SVC_NAME"
+ killproc --pidfile /var/run/diamond.pid # httpd
+ rm -f /var/lock/subsys/diamond /var/run/diamond.pid >/dev/null 2>&1
+}
+
+
+reload() {
+ if [ ! -f /var/lock/subsys/diamond ]; then
+ msg_not_running "$SVC_NAME"
+ RETVAL=7
+ return
+ fi
+
+ ## checkconfig
+ ## msg_reloading "$SVC_NAME"
+ ## busy
+ ## /usr/sbin/httpd $CFG $HTTPD_OPTS -k graceful
+ ## RETVAL=$?
+ ## [ $RETVAL -eq 0 ] && ok || fail
+}
+
+condrestart() {
+ if [ ! -f /var/lock/subsys/diamond ]; then
+ msg_not_running "$SVC_NAME"
+ RETVAL=$1
+ return
+ fi
+
+ ## checkconfig
+ stop
+ start
+}
+
+RETVAL=0
+# See how we were called.
+case "$1" in
+ start)
+ start
+ ;;
+ stop)
+ stop
+ ;;
+ restart)
+ ## checkconfig
+ stop
+ start 0
+ ;;
+ try-restart)
+ condrestart 0
+ ;;
+ ## reload|force-reload|graceful|flush-logs)
+ ## reload
+ ## ;;
+ ## checkconfig|configtest)
+ ## checkconfig 1
+ ## ;;
+ status)
+ status diamond
+ RETVAL=$?
+ ;;
+ *)
+ ## msg_usage "$0 {start|stop|restart|try-restart|reload|force-reload|graceful|configtest|status}"
+ msg_usage "$0 {start|stop|restart|try-restart}"
+ exit 3
+ ;;
+esac
+
+exit $RETVAL
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/packages/diamond.git/commitdiff/8fceffddf4ee9e387072e82845d1dc37cee57c14
More information about the pld-cvs-commit
mailing list