Filippo Giunchedi has submitted this change and it was merged. Change subject: statsite: new module ......................................................................
statsite: new module statsite provides a txstatsd replacement, the module allows for multiple instances to be provisioned with statsite::instance and controlled using the '*ctl pattern'. Bug: T90111 Change-Id: I265f5307f73f69c242832d148e14595bfccfdba9 --- A modules/statsite/files/init/init.conf A modules/statsite/files/init/instance.conf A modules/statsite/files/statsitectl A modules/statsite/manifests/init.pp A modules/statsite/manifests/instance.pp A modules/statsite/templates/statsite.ini.erb 6 files changed, 179 insertions(+), 0 deletions(-) Approvals: Filippo Giunchedi: Verified; Looks good to me, approved jenkins-bot: Verified diff --git a/modules/statsite/files/init/init.conf b/modules/statsite/files/init/init.conf new file mode 100644 index 0000000..2e15fd0 --- /dev/null +++ b/modules/statsite/files/init/init.conf @@ -0,0 +1,15 @@ +description "Start statsite instances" +author "Filippo Giunchedi <fili...@wikimedia.org>" + +start on runlevel [2345] or statsite.start + +task + +script + for config in /etc/statsite/*.ini; do + [ -e "$config" ] || break + name="$(basename $config .ini)" + start statsite/instance NAME="$name" CONFIG="$config" || + status statsite/instance NAME="$name" + done +end script diff --git a/modules/statsite/files/init/instance.conf b/modules/statsite/files/init/instance.conf new file mode 100644 index 0000000..06186a1 --- /dev/null +++ b/modules/statsite/files/init/instance.conf @@ -0,0 +1,13 @@ +description "C statsd daemon" + +setuid statsite + +instance $NAME + +start on runlevel [2345] +stop on runlevel [!2345] + +respawn +respawn limit 10 5 + +exec /usr/bin/statsite -f "$CONFIG" diff --git a/modules/statsite/files/statsitectl b/modules/statsite/files/statsitectl new file mode 100755 index 0000000..50e6fe4 --- /dev/null +++ b/modules/statsite/files/statsitectl @@ -0,0 +1,42 @@ +#!/bin/bash +# statsitectl -- Manage statsite jobs +# Usage: statsitectl {status|check|start|stop|restart} +# +command=$1 +shift +case "$command" in + status) + status=0 + for config in /etc/statsite/*.ini; do + instance="$(basename $config .ini)" + status statsite/instance NAME="$instance" || status=$? + done + exit $status + ;; + check) + $0 status >/dev/null 2>&1 || { + echo "CRITICAL: Not all configured statsite instances are running." + exit 2 + } + echo "OK: All defined statsite jobs are runnning." + exit 0 + ;; + start) + initctl start statsite/init + ;; + stop) + for config in /etc/statsite/*.ini; do + instance="$(basename $config .ini)" + initctl stop statsite/instance NAME="$instance" + done + ;; + restart) + for config in /etc/statsite/*.ini; do + instance="$(basename $config .ini)" + initctl restart statsite/instance NAME="$instance" + done + ;; + *) + echo >&2 "Usage: ${0##*/} {status|check|start|stop|restart}" + ;; +esac diff --git a/modules/statsite/manifests/init.pp b/modules/statsite/manifests/init.pp new file mode 100644 index 0000000..266ba03 --- /dev/null +++ b/modules/statsite/manifests/init.pp @@ -0,0 +1,62 @@ +# == Class: statsite +# +# Configure statsite https://github.com/armon/statsite +# To add individual instances, use statsite::instance +# +# === Parameters +# +# [*port*] +# Port to listen for messages on over UDP. +# +# [*graphite_host*] +# Send metrics to graphite on this host +# +# [*graphite_port*] +# Send metrics to graphite on this port +# +# [*input_counter*] +# Use this metric to report self-statistics +# +# [*extended_counters*] +# Export additional metrics for counters + +class statsite { + package { 'statsite': + ensure => present, + } + + file { '/etc/statsite': + ensure => 'directory', + owner => 'root', + group => 'root', + mode => '0555', + } + + file { '/sbin/statsitectl': + source => 'puppet:///modules/statsite/statsitectl', + mode => '0755', + } + + file { '/etc/init/statsite': + source => 'puppet:///modules/statsite/init', + recurse => true, + purge => true, + force => true, + } + + # prevent the system-wide statsite from starting + file { '/etc/init/statsite.override': + content => 'manual', + before => Package['statsite'], + } + + service { 'statsite': + ensure => 'running', + provider => 'base', + restart => '/sbin/statsitectl restart', + start => '/sbin/statsitectl start', + status => '/sbin/statsitectl status', + stop => '/sbin/statsitectl stop', + require => Package['statsite'], + } +} diff --git a/modules/statsite/manifests/instance.pp b/modules/statsite/manifests/instance.pp new file mode 100644 index 0000000..709d634 --- /dev/null +++ b/modules/statsite/manifests/instance.pp @@ -0,0 +1,36 @@ +# == Define: statsite +# +# Configure an instance of statsite +# +# === Parameters +# +# [*port*] +# Port to listen for messages on over UDP. +# +# [*graphite_host*] +# Send metrics to graphite on this host +# +# [*graphite_port*] +# Send metrics to graphite on this port +# +# [*input_counter*] +# Use this metric to report self-statistics +# +# [*extended_counters*] +# Export additional metrics for counters + +define statsite::instance( + $port = 8125, + $graphite_host = 'graphite-in.eqiad.wmnet', + $graphite_port = 2003, + $input_counter = "statsd.$::{hostname}.received", + $extended_counters = 0, +) { + $stream_cmd = "python /usr/lib/statsite/sinks/graphite.py $graphite_host $graphite_port" + + file { "/etc/statsite/$port.ini": + content => template('statsite/statsite.ini.erb'), + require => Package['statsite'], + notify => Service['statsite'], + } +} diff --git a/modules/statsite/templates/statsite.ini.erb b/modules/statsite/templates/statsite.ini.erb new file mode 100644 index 0000000..86f956e --- /dev/null +++ b/modules/statsite/templates/statsite.ini.erb @@ -0,0 +1,11 @@ +[statsite] +port = <%= @port %> +udp_port = <%= @port %> +log_level = INFO +input_counter = <%= @input_counter %> +flush_interval = 60 +timer_eps = 0.01 +set_eps = 0.02 +stream_cmd = <%= @stream_cmd %> +use_type_prefix = 0 +extended_counters = <%= @extended_counters %> -- To view, visit https://gerrit.wikimedia.org/r/199599 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I265f5307f73f69c242832d148e14595bfccfdba9 Gerrit-PatchSet: 5 Gerrit-Project: operations/puppet Gerrit-Branch: production Gerrit-Owner: Filippo Giunchedi <fgiunch...@wikimedia.org> Gerrit-Reviewer: Filippo Giunchedi <fgiunch...@wikimedia.org> Gerrit-Reviewer: Giuseppe Lavagetto <glavage...@wikimedia.org> Gerrit-Reviewer: Ori.livneh <o...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits