Rush has submitted this change and it was merged. Change subject: phab: basic apache status metrics to graphite ......................................................................
phab: basic apache status metrics to graphite Change-Id: I276290788e8923469d73a456509dd77887a56fcd --- A modules/phabricator/files/monitor/apache_status.py M modules/phabricator/manifests/monitoring.pp 2 files changed, 71 insertions(+), 1 deletion(-) Approvals: Rush: Looks good to me, approved jenkins-bot: Verified diff --git a/modules/phabricator/files/monitor/apache_status.py b/modules/phabricator/files/monitor/apache_status.py new file mode 100644 index 0000000..6f1b6c3 --- /dev/null +++ b/modules/phabricator/files/monitor/apache_status.py @@ -0,0 +1,67 @@ +# coding=utf-8 +import diamond.collector +import re +import urllib2 + +""" + +2015 Chase Pettet + +Requires: http://httpd.apache.org/docs/2.4/mod/mod_status.html + +$server.apache.Uptime:54227|g +$server.apache.IdleWorkers:40|g +$server.apache.Total_Accesses:929239|g +$server.apache.BytesPerReq:2910|g +$server.apache.CPULoad:7|g +$server.apache.BytesPerSec:49865|g +$server.apache.ReqPerSec:17|g +$server.apache.Total_kBytes:2.64064e+06|g +$server.apache.BusyWorkers:10|g +""" + + +class ApacheStatusSimple(diamond.collector.Collector): + + def __init__(self, *args, **kwargs): + super(ApacheStatusSimple, self).__init__(*args, **kwargs) + + self.stats = [ + 'Total\sAccesses', + 'Total\skBytes', + 'CPULoad', + 'Uptime', + 'ReqPerSec', + 'BytesPerSec', + 'BytesPerReq', + 'BusyWorkers', + 'IdleWorkers', + ] + + def get_default_config(self): + """ + Returns the default collector settings + """ + config = super(ApacheStatusSimple, self).get_default_config() + config.update({ + 'path': 'apache', + 'url': 'http://127.0.0.1/server-status?auto', + }) + return config + + def _get(self): + return urllib2.urlopen(self.config['url']).read() + + def pair_stat(self, stat, text): + return re.search('%s:(.+)' % (stat), text).group(1) + + def collect(self): + status = self._get() + + stat_values = {} + for stat in self.stats: + value = self.pair_stat(stat, status) + stat_values[stat.replace('\s', '_')] = value.strip() + + for k, v in stat_values.iteritems(): + self.publish(k, v) diff --git a/modules/phabricator/manifests/monitoring.pp b/modules/phabricator/manifests/monitoring.pp index 7b1ca0a..a8f0446 100644 --- a/modules/phabricator/manifests/monitoring.pp +++ b/modules/phabricator/manifests/monitoring.pp @@ -3,6 +3,10 @@ class phabricator::monitoring { include apache::mod::status + diamond::collector { 'ApacheStatusSimple': + source => 'puppet:///modules/phabricator/monitor/apache_status.py', + } + nrpe::monitor_service { 'check_phab_taskmaster': description => 'PHD should be supervising processes', nrpe_command => '/usr/lib/nagios/plugins/check_procs -c 3:150 -u phd', @@ -14,5 +18,4 @@ check_command => 'check_https_phabricator', contact_group => 'admins,phabricator,sms', } - } -- To view, visit https://gerrit.wikimedia.org/r/242367 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I276290788e8923469d73a456509dd77887a56fcd Gerrit-PatchSet: 3 Gerrit-Project: operations/puppet Gerrit-Branch: production Gerrit-Owner: Rush <[email protected]> Gerrit-Reviewer: Rush <[email protected]> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
