Skip to content

Commit

Permalink
Merge pull request #62 from sanga/nginx_cleanup
Browse files Browse the repository at this point in the history
nginx: small cleanup - don't define the same thing twice
  • Loading branch information
mattrobenolt committed Jan 14, 2015
2 parents e6c6fc8 + a46fc26 commit 7a772d7
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/collectors/nginx/nginx.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,16 @@ def get_default_config(self):
return default_config

def collect(self):
url = 'http://%s:%i%s' % (self.config['req_host'],
int(self.config['req_port']),
self.config['req_path'])
activeConnectionsRE = re.compile(r'Active connections: (?P<conn>\d+)')
totalConnectionsRE = re.compile('^\s+(?P<conn>\d+)\s+'
+ '(?P<acc>\d+)\s+(?P<req>\d+)')
connectionStatusRE = re.compile('Reading: (?P<reading>\d+) '
+ 'Writing: (?P<writing>\d+) '
+ 'Waiting: (?P<waiting>\d+)')
req = urllib2.Request('http://%s:%i%s' % (self.config['req_host'],
int(self.config['req_port']),
self.config['req_path']))
req = urllib2.Request(url)
try:
handle = urllib2.urlopen(req)
for l in handle.readlines():
Expand All @@ -82,9 +83,6 @@ def collect(self):
self.publish_gauge('act_writes', int(m.group('writing')))
self.publish_gauge('act_waits', int(m.group('waiting')))
except IOError, e:
self.log.error("Unable to open http://%s:%i%s",
self.config['req_host'],
int(self.config['req_port']),
self.config['req_path'])
self.log.error("Unable to open %s" % url)
except Exception, e:
self.log.error("Unknown error opening url: %s", e)

0 comments on commit 7a772d7

Please sign in to comment.