-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move alert module from salt project to this project
- Loading branch information
Erik Nolte
committed
Aug 16, 2011
1 parent
9dbd65e
commit 2661124
Showing
2 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
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
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) |
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