Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #1157 from peterbe/bug854903-crontabber-nagios-err…

…ors-all-on-one-line

bug 854903 - [crontabber] nagios errors all on one line
  • Loading branch information...
commit cae8aafb44a43ef43e97da9c5bf00130aff3ed37 2 parents 7811a11 + d5dd4b8
@lonnen lonnen authored
View
10 socorro/cron/crontabber.py
@@ -573,14 +573,12 @@ def nagios(self, stream=sys.stdout):
if criticals:
stream.write('CRITICAL - ')
- for each in criticals:
- stream.write(each)
- stream.write('\n')
+ stream.write('; '.join(criticals))
+ stream.write('\n')
elif warnings:
stream.write('WARNING - ')
- for each in warnings:
- stream.write(each)
- stream.write('\n')
+ stream.write('; '.join(warnings))
+ stream.write('\n')
if criticals:
return 2
View
25 socorro/unittest/cron/test_crontabber.py
@@ -1479,6 +1479,27 @@ def test_nagios_critical(self):
self.assertTrue('NameError' in output)
self.assertTrue('Trouble!!' in output)
+ def test_nagios_multiple_messages(self):
+ config_manager, json_file = self._setup_config_manager(
+ 'socorro.unittest.cron.test_crontabber.TroubleJob|1d\n'
+ 'socorro.unittest.cron.test_crontabber.MoreTroubleJob|1d'
+ )
+ with config_manager.context() as config:
+ tab = crontabber.CronTabber(config)
+ tab.run_all()
+ stream = StringIO()
+ exit_code = tab.nagios(stream=stream)
+ self.assertEqual(exit_code, 2)
+ output = stream.getvalue()
+ self.assertEqual(len(output.strip().splitlines()), 1)
+ self.assertEqual(output.count('CRITICAL'), 1)
+ self.assertTrue('trouble' in output)
+ self.assertTrue('more-trouble' in output)
+ self.assertTrue('TroubleJob' in output)
+ self.assertTrue('MoreTroubleJob' in output)
+ self.assertTrue('NameError' in output)
+ self.assertTrue('Trouble!!' in output)
+
def test_reorder_dag_on_joblist(self):
config_manager, json_file = self._setup_config_manager(
'socorro.unittest.cron.test_crontabber.FooBarJob|1d\n'
@@ -1913,6 +1934,10 @@ def run(self):
raise NameError("Trouble!!")
+class MoreTroubleJob(TroubleJob):
+ app_name = 'more-trouble'
+
+
class SadJob(_Job):
app_name = 'sad'
depends_on = 'trouble', # <-- note: a tuple
Please sign in to comment.
Something went wrong with that request. Please try again.