Skip to content

Commit

Permalink
add agent metrics sending
Browse files Browse the repository at this point in the history
  • Loading branch information
assafgi committed Oct 27, 2019
1 parent b7be255 commit 5af8a43
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
3 changes: 2 additions & 1 deletion talker_agent/config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ port = 6379
logpath = /var/log/talker.log

[metrics]
enabled = False
enabled = True
host = graphite
7 changes: 6 additions & 1 deletion talker_agent/talker.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
from configparser import ConfigParser
except: # python 2.7
from ConfigParser import ConfigParser

import graphyte

PY3 = sys.version_info[0] == 3

Expand Down Expand Up @@ -709,6 +709,9 @@ def finalize_previous_session(self):
def start_job(self, job_data_raw):
job_data = json.loads(job_data_raw)
cmd = job_data['cmd']
if config.parser.getboolean('metrics', 'enabled'):
logger.debug('sending command metrics')
graphyte.send('commands_received', 1)
if isinstance(cmd, list):
if SIMULATE_DROPS_RATE and cmd != ['true'] and random.random() > SIMULATE_DROPS_RATE:
logger.warning("dropping job: %(id)s", job_data)
Expand Down Expand Up @@ -932,6 +935,8 @@ def main(*args):

config = Config()
set_logging_to_file(config.parser.get('logging', 'logpath'))
if config.parser.getboolean('metrics', 'enabled'):
graphyte.init(config.parser.get('metrics', 'host'))

# to help with WEKAPP-74054
os.system("df")
Expand Down
10 changes: 10 additions & 0 deletions tests/integration/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@ version: '3'
services:
redis:
image: "redis:4.0.14-alpine"
graphite:
image: "graphiteapp/graphite-statsd"
container_name: graphite
ports:
- 80:80
- 2003-2004:2003-2004
- 2023-2024:2023-2024
- 8125:8125/udp
- 8126:8126
talker:
build:
context: ../../talker_agent/.
Expand All @@ -10,3 +19,4 @@ services:
- TALKER_HOST_ID=$TALKER_HOST_ID
links:
- redis
- graphite

0 comments on commit 5af8a43

Please sign in to comment.