Skip to content

Commit

Permalink
Add support for specifying varnish instance if multiple are running
Browse files Browse the repository at this point in the history
  • Loading branch information
butlern committed Dec 4, 2013
1 parent 6845eda commit 1c1481e
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions varnish-graphite
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ class GraphiteClient:
self.disconnect()
self.connect()

def collect_metrics():
varnish_stats = json.loads(check_output(['varnishstat', '-1', '-j']))
def collect_metrics(name):
varnish_stats = json.loads(check_output(['varnishstat', '-n', name, '-1', '-j']))
timestamp = int(time())

status = []
Expand Down Expand Up @@ -109,6 +109,10 @@ def main():
parser.add_argument('-p', '--port',
default=2003,
help='The graphite server port')
parser.add_argument('-n', '--name',
default=socket.gethostname(),
help="""Specifies the name of the varnishd instance to get logs from. If
-n is not specified, the host name is used.""")
parser.add_argument('-P', '--prefix',
default='varnish',
help='The prefix for metric names')
Expand All @@ -133,7 +137,7 @@ def main():
while True:
interval_start = time()

c.send_metrics(collect_metrics())
c.send_metrics(collect_metrics(args.name))

interval_used = time() - interval_start
if interval_used < float(args.interval):
Expand Down

0 comments on commit 1c1481e

Please sign in to comment.