Skip to content

Commit

Permalink
Move alert module from salt project to this project
Browse files Browse the repository at this point in the history
  • Loading branch information
Erik Nolte committed Aug 16, 2011
1 parent 9dbd65e commit 2661124
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
55 changes: 55 additions & 0 deletions salt/modules/alert.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
'''
Module for issuing alerts.
Examples:
alert.notice sys.everython 'things are going great'
alert.warning disk.hardware 'the VAX drive ${value} is wobbling'
alert.error turboencabular.wanshaft '${key} is {value:.1f} mm from failure'
'''

__opts__ = {}

def _alert(level, category, msg):
'''
Send the alert to the alert service.
'''
return [level, category, msg]

def notice(category, msg):
'''
Send a 'notice' alert.
category = arbitrary alert category string, e.g. 'disk.sata.error'.
msg = the alert message string, e.g. '/dev/sdb23 spindle is on fire'
'''
return _alert("NOTICE", category, msg)

def warning(category, msg):
'''
Send a 'warning' alert.
category = arbitrary alert category string, e.g. 'disk.sata.error'.
msg = the alert message string, e.g. '/dev/sdb23 spindle is on fire'
'''
return _alert("WARNING", category, msg)

def error(category, msg):
'''
Send an 'error' alert.
category = arbitrary alert category string, e.g. 'disk.sata.error'.
msg = the alert message string, e.g. '/dev/sdb23 spindle is on fire'
'''
return _alert("ERROR", category, msg)

def critical(category, msg):
'''
Send a 'critical' alert.
category = arbitrary alert category string, e.g. 'disk.sata.error'.
msg = the alert message string, e.g. '/dev/sdb23 spindle is on fire'
'''
return _alert("FATAL", category, msg)

def fatal(category, msg):
'''
Send a 'fatal' alert.
category = arbitrary alert category string, e.g. 'disk.sata.error'.
msg = the alert message string, e.g. '/dev/sdb23 spindle is on fire'
'''
return _alert("FATAL", category, msg)
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ def _run_test(self, path):
'salt.ext.monitor.collectors',
'salt.ext.monitor.parsers',
],
py_modules=['salt.modules.alert'],
scripts=['scripts/salt-monitor'],
data_files=[(os.path.join(etc_path, 'salt'),
['conf/monitor']),
Expand Down

0 comments on commit 2661124

Please sign in to comment.