Forked from iggy/-etc-salt-master.d-60-reactor.conf
Last active
August 29, 2015 14:20
-
-
Save jalons/d5239d97694c53ed40e6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
reactor: | |
- 'salt/minion/*/start': | |
- /srv/reactor/sync_all.sls | |
- /srv/reactor/graphite_event.sls |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
graph_evt: | |
cmd.graphite.post_event: | |
- tgt: 'tags:master' | |
- expr_form: grain | |
- arg: | |
- {{ tag }} | |
- {{ data }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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