Skip to content

Commit

Permalink
Merge branch 'master' of github.com:marineam/nagcat
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Cooper committed Aug 17, 2011
2 parents f2ae8fe + 120da2d commit cb4a98b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
6 changes: 6 additions & 0 deletions python/nagcat/notify.py
Expand Up @@ -246,6 +246,12 @@ def __init__(self, type_, macros, config):
(self.macros['HOSTNAME'],
self.macros['SERVICEDESC'], ex))

def metadata(self, key, default=None):
macro = key.upper()
return self.macros.get('_CONTACT%s' % macro,
self.macros.get('_SERVICE%s' % macro,
self.macros.get('_HOST%s' % macro, default)))

def subject(self):
return self._format(self.config[self.type]['subject'])

Expand Down
26 changes: 18 additions & 8 deletions python/nagcat/plugins/notify_smtp.py
Expand Up @@ -100,14 +100,21 @@ def headers(self):

def body(self):
text = super(EmailNotification, self).body()
if self.format == "long":
urls = self.urls()
if urls:
text += "\n"
if 'nagios' in urls:
text += "Nagios: %s\n" % urls['nagios']
if 'graphs' in urls:
text += "Graphs: %s\n" % urls['graphs']
text += self.footer()
return text

def footer(self):
urls = self.urls()

if urls:
text = "\n"
if 'nagios' in urls:
text += "Nagios: %s\n" % urls['nagios']
if 'graphs' in urls:
text += "Graphs: %s\n" % urls['graphs']
else:
text = ""

return text

def send(self):
Expand Down Expand Up @@ -169,6 +176,9 @@ def headers(self):
headers['To'] = self.macros['CONTACTPAGER']
return headers

def footer(self):
return ""

def graph(self):
return None

Expand Down

0 comments on commit cb4a98b

Please sign in to comment.