Dzahn has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/382916 )
Change subject: exim4/multiple roles: remove Ganglia exim stats ...................................................................... exim4/multiple roles: remove Ganglia exim stats Bug: T177225 Change-Id: Icb434fedb9d32e742a3ac2116f328f97d7e9dfec --- D modules/exim4/files/ganglia/exim-to-gmetric D modules/exim4/manifests/ganglia.pp M modules/otrs/manifests/mail.pp M modules/profile/manifests/lists.pp M modules/role/manifests/mail/mx.pp M modules/role/manifests/phabricator_server.pp 6 files changed, 0 insertions(+), 270 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/operations/puppet refs/changes/16/382916/1 diff --git a/modules/exim4/files/ganglia/exim-to-gmetric b/modules/exim4/files/ganglia/exim-to-gmetric deleted file mode 100644 index e32276e..0000000 --- a/modules/exim4/files/ganglia/exim-to-gmetric +++ /dev/null @@ -1,246 +0,0 @@ -#! /usr/bin/perl -# -# Exim stats grabber for NET-SNMP -# -# Based on a script by Matthew Newton Copyright (c) University of Leicester, -# 2005 -# -# Slightly modified for Timico (http://timico.net) by Ian P. Christian. -# -# Signficantly modified into a gmetric collector for WMF internal use by Jeff -# Green 12/2011 -# -# This program is free software; you can redistribute it and/or modify it under -# the terms of the GNU General Public License as published by the Free Software -# Foundation; either version 2 of the License, or (at your option) any later -# version. -# -# This program is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more -# details. -# -# You should have received a copy of the GNU General Public License along with -# this program; if not, write to the Free Software Foundation, Inc., 51 -# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -use strict; -use Sys::Syslog; -use Fcntl ':flock'; - -my $conf = { - 'statefile' => '/tmp/eximstats.state', - 'mainlog' => '/var/log/exim4/mainlog', - 'mainlogold' => '/var/log/exim4/mainlog.1', - 'lockfile' => '/tmp/eximstats.lock', - 'ident' => $0, - 'interval' => 60, -}; - -my $metric = { - 'message_in' => { - 'name' => 'exim messages in', - 'type' => 'uint32', - 'units' => 'messages', - 'value' => 0, - 'gmax' => $conf->{'interval'} * 1.5, - }, - 'message_out' => { - 'name' => 'exim messages out', - 'type' => 'uint32', - 'units' => 'messages', - 'value' => 0, - 'gmax' => $conf->{'interval'} * 1.5, - }, - 'delivery_deferred' => { - 'name' => 'exim deferred delivery', - 'type' => 'uint32', - 'units' => 'messages', - 'value' => 0, - 'gmax' => $conf->{'interval'} * 1.5, - }, - 'delivery_failed' => { - 'name' => 'exim failed delivery', - 'type' => 'uint32', - 'units' => 'messages', - 'value' => 0, - 'gmax' => $conf->{'interval'} * 1.5, - }, - 'delivery_suppressed' => { - 'name' => 'exim suppressed delivery', - 'type' => 'uint32', - 'units' => 'messages', - 'value' => 0, - 'gmax' => $conf->{'interval'} * 1.5, - }, - 'queued_messages' => { - 'name' => 'exim queued messages', - 'type' => 'uint32', - 'units' => 'messages', - 'value' => 0, - 'gmax' => $conf->{'interval'} * 1.5, - }, - 'queued_messages_bounce' => { - 'name' => 'exim queued bounce messages', - 'type' => 'uint32', - 'units' => 'messages', - 'value' => 0, - 'gmax' => $conf->{'interval'} * 1.5, - }, -}; - -# lock to prevent collisions -my $error = setlockfile('set'); -failboat("one: $error") if ($error); - -# read state file and figure out where to start reading logs -my $state => { - 'seek' => 0, - 'inode' => inode_number($conf->{'mainlog'}), -}; -if (-r $conf->{'statefile'}) { - open STATE, "< $conf->{'statefile'}"; - while (<STATE>) { - if (/^(inode|seek)=(\d+)$/) { - $state->{$1} = $2; - } - } - close STATE; -} - -# read the previous mainlog if we can't seek to the appropriate spot in the current log -open LOG, "< $conf->{'mainlog'}" or failboat("cannot open exim log file $conf->{'mainlog'}: $!"); -my $cantseek = 1 unless (seek(LOG, $state->{'seek'}, 0)); -close LOG; -if ($state->{'inode'} != inode_number($conf->{'mainlog'}) or $cantseek or $state->{'inode'} == inode_number($conf->{'mainlogold'})) { - read_log($conf->{'mainlogold'}, $state->{'seek'}); - $state->{'inode'} = inode_number($conf->{'mainlog'}); - $state->{'seek'} = 0; -} - -# read the mainlog -$state->{'seek'} = read_log($conf->{'mainlog'}, $state->{'seek'}); - -# collect exim queue counts -read_queue(); - -# write state file -open STATE, "> $conf->{'statefile'}"; -for my $key (keys %{$state}) { - print STATE "$key=$state->{$key}\n"; -} -close STATE; - -# puke le outputz -for my $m (keys %{$metric}) { - my $error = `/usr/bin/gmetric -n '$metric->{$m}->{'name'}' -v $metric->{$m}->{'value'} -t $metric->{$m}->{'type'} -u $metric->{$m}->{'units'} 2>&1`; - failboat("gmetric failed: $error") if ($error); -} - -setlockfile('unset'); - -exit; - - - - -# SUBROUTINES - -sub inode_number { - return (stat(shift))[1]; -} - -sub read_log { - my ($file, $seek) = @_; - open LOG, "< $file" or failboat("cannot open exim log file $file: $!"); - unless (seek(LOG, $seek, 0)) { - close LOG; - return $seek; - } - my ($prevpos,$pos,$line,$prevline); - while ($line = <LOG>) { - if (defined $prevline) { - if ($line =~ /<=/) { - $metric->{'message_in'}->{'value'}++; - } elsif ($line =~ /[-=]>/) { - $metric->{'message_out'}->{'value'}++; - } elsif ($line =~ /==/) { - $metric->{'delivery_deferred'}->{'value'}++; - } elsif ($line =~ /\*\*/) { - $metric->{'delivery_failed'}->{'value'}++; - } elsif ($line =~ /\*>/) { - $metric->{'delivery_suppressed'}->{'value'}++; - } - } - $prevline = $line; - $prevpos = $pos; - $pos = tell LOG; - } - close LOG; - $prevpos = $state->{'seek'} unless defined $prevpos; - return $prevpos; -} - - -sub read_queue { - open Q, "/usr/sbin/exim -bp |" or return 0; - while (<Q>) { - $metric->{'queued_messages'}->{'value'}++ if /\</; - $metric->{'queued_messages_bounce'}->{'value'}++ if /\<\>/; - } - close Q; - return 1; -} - -# SET LOCKFILE -sub setlockfile { - my $action = shift; - if ($action eq 'set') { - return("$0 already running") if (running($0)); - open LOCK, "> $conf->{'lockfile'}"; - flock (LOCK, 2) or return("$0 already running?"); - print LOCK $$; - close LOCK; - } else { - unlink $conf->{'lockfile'}; - } - return; -} - -# check for lockfile -# -> if found, check for process matching PID -# -> if no matching process, whack the lockfile -sub running { - my $prog = shift; - $prog =~ s/^(.*\/)+//g; - if (-e $conf->{'lockfile'}) { - open LOCK, $conf->{'lockfile'}; - my $checkpid = <LOCK>; - close LOCK; - if ($checkpid) { - chomp $checkpid; - if (`ps -p $checkpid -o command= | grep $prog`) { - return $checkpid; - } else { - printlog("removed stale lockfile for $prog ($checkpid)",'warning'); - unlink $conf->{'lockfile'}; - } - } - } - return; -} - -sub failboat { - my $msg = shift; - printlog("died: $msg"); - exit 1; -} - -sub printlog { - my $msg = $_[0] ? $_[0] : ''; - my $severity = $_[1] ? $_[1] : 'info'; # notice warning ERR etc. - Sys::Syslog::setlogsock('unix'); - Sys::Syslog::openlog($conf->{'ident'},'ndelay,pid','user'); - Sys::Syslog::syslog($severity,$msg); - Sys::Syslog::closelog(); -} - diff --git a/modules/exim4/manifests/ganglia.pp b/modules/exim4/manifests/ganglia.pp deleted file mode 100644 index ac948d2..0000000 --- a/modules/exim4/manifests/ganglia.pp +++ /dev/null @@ -1,18 +0,0 @@ -# == Class exim4::ganglia -# This installs a Ganglia plugin for exim4, using gmetric -# -class exim4::ganglia { - file { '/usr/local/bin/exim-to-gmetric': - owner => 'root', - group => 'root', - mode => '0755', - source => 'puppet:///modules/exim4/ganglia/exim-to-gmetric', - } - - cron { 'collect_exim_stats_via_gmetric': - ensure => present, - user => 'root', - command => '/usr/local/bin/exim-to-gmetric', - require => File['/usr/local/bin/exim-to-gmetric'], - } -} diff --git a/modules/otrs/manifests/mail.pp b/modules/otrs/manifests/mail.pp index 63d4257..a441230 100644 --- a/modules/otrs/manifests/mail.pp +++ b/modules/otrs/manifests/mail.pp @@ -35,8 +35,6 @@ proxy => "webproxy.${::site}.wmnet:8080", } - include ::exim4::ganglia - class { '::exim4': variant => 'heavy', config => template('otrs/exim4.conf.otrs.erb'), diff --git a/modules/profile/manifests/lists.pp b/modules/profile/manifests/lists.pp index 1675939..3a9a233 100644 --- a/modules/profile/manifests/lists.pp +++ b/modules/profile/manifests/lists.pp @@ -3,7 +3,6 @@ include ::network::constants include ::mailman include ::privateexim::listserve - include ::exim4::ganglia mailalias { 'root': recipient => 'r...@wikimedia.org' } diff --git a/modules/role/manifests/mail/mx.pp b/modules/role/manifests/mail/mx.pp index b8fdce9..3b515ef 100644 --- a/modules/role/manifests/mail/mx.pp +++ b/modules/role/manifests/mail/mx.pp @@ -42,8 +42,6 @@ require => Class['spamassassin'], } - include exim4::ganglia - file { '/etc/exim4/defer_domains': ensure => present, owner => 'root', diff --git a/modules/role/manifests/phabricator_server.pp b/modules/role/manifests/phabricator_server.pp index a0ce220..4ef1bc8 100644 --- a/modules/role/manifests/phabricator_server.pp +++ b/modules/role/manifests/phabricator_server.pp @@ -15,5 +15,4 @@ include ::profile::phabricator::main include ::phabricator::monitoring include ::phabricator::mpm - include ::exim4::ganglia } -- To view, visit https://gerrit.wikimedia.org/r/382916 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Icb434fedb9d32e742a3ac2116f328f97d7e9dfec Gerrit-PatchSet: 1 Gerrit-Project: operations/puppet Gerrit-Branch: production Gerrit-Owner: Dzahn <dz...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits