Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jalons/d5239d97694c53ed40e6 to your computer and use it in GitHub Desktop.
Save jalons/d5239d97694c53ed40e6 to your computer and use it in GitHub Desktop.
reactor:
- 'salt/minion/*/start':
- /srv/reactor/sync_all.sls
- /srv/reactor/graphite_event.sls
graph_evt:
cmd.graphite.post_event:
- tgt: 'tags:master'
- expr_form: grain
- arg:
- {{ tag }}
- {{ data }}
# Interface with a graphite server
# for now just sending events
#
# To use, put the following in your reactor config:
#
# TODO
import json
import httplib
def __virtual__():
'''
'''
return 'graphite'
def post_event(tag, data):
'''Post an event to the graphite servers rest interface'''
fun = data.get('fun', 'FUN NOT SET')
# don't post_event if we're already post_event'ing or uninteresting events2
if fun in ['graphite.post_event', 'post_event',
'saltutil.find_job', 'saltutil.running',
'test.ping']:
return True
payload = {
'what': 'SALT EVENT (R)',
'tags': '{} {}'.format(fun, tag),
'data': data,
}
headers = {}
conn = httplib.HTTPConnection(__salt__['mine.get']('roles:mon', 'network.get_hostname', 'grain').keys()[0])
conn.request('POST', '/events/', json.dumps(payload), headers)
return True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment