Skip to content

Commit

Permalink
Fix #946: catch exception for external host/service comment commands
Browse files Browse the repository at this point in the history
  • Loading branch information
mohierf authored and ddurieux committed Oct 19, 2017
1 parent 409bcbc commit 862c745
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions alignak/external_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -981,10 +981,16 @@ def add_svc_comment(self, service, author, comment):
comm = Comment(data)
service.add_comment(comm)
# todo: create and send a brok for service comment
brok = make_monitoring_log('info', "SERVICE COMMENT: %s;%s;%s;%s"
% (self.hosts[service.host].get_name(),
service.get_name(),
unicode(author, 'utf-8'), unicode(comment, 'utf-8')))
try:
brok = make_monitoring_log('info', "SERVICE COMMENT: %s;%s;%s;%s"
% (self.hosts[service.host].get_name(),
service.get_name(),
unicode(author, 'utf-8'), unicode(comment, 'utf-8')))
except TypeError:
brok = make_monitoring_log('info', "SERVICE COMMENT: %s;%s;%s;%s"
% (self.hosts[service.host].get_name(),
service.get_name(), author, comment))

self.send_an_element(brok)

def add_host_comment(self, host, author, comment):
Expand All @@ -1008,9 +1014,14 @@ def add_host_comment(self, host, author, comment):
comm = Comment(data)
host.add_comment(comm)
# todo: create and send a brok for host comment
brok = make_monitoring_log('info', u"HOST COMMENT: %s;%s;%s"
% (host.get_name(),
unicode(author, 'utf-8'), unicode(comment, 'utf-8')))
try:
brok = make_monitoring_log('info', u"HOST COMMENT: %s;%s;%s"
% (host.get_name(),
unicode(author, 'utf-8'), unicode(comment, 'utf-8')))
except TypeError:
brok = make_monitoring_log('info', u"HOST COMMENT: %s;%s;%s"
% (host.get_name(), author, comment))

self.send_an_element(brok)

def acknowledge_svc_problem(self, service, sticky, notify, author, comment):
Expand Down

0 comments on commit 862c745

Please sign in to comment.