def nagios(self, stream=sys.stdout):
warnings = []<EOL>criticals = []<EOL>for class_name, job_class in self.config.crontabber.jobs.class_list:<EOL><INDENT>if job_class.app_name in self.job_state_database:<EOL><INDENT>info = self.job_state_database.get(job_class.app_name)<EOL>if not info.get('<STR_LIT>', <NUM_LIT:0>):<EOL><INDENT>continue<EOL><DEDENT>error_count = info['<STR_LIT>']<EOL>serialized = (<EOL>'<STR_LIT>' %<EOL>(job_class.app_name,<EOL>class_name,<EOL>info['<STR_LIT>']['<STR_LIT:type>'],<EOL>info['<STR_LIT>']['<STR_LIT:value>'])<EOL>)<EOL>if (<EOL>error_count == <NUM_LIT:1> and<EOL>hasattr(job_class, "<STR_LIT>")<EOL>):<EOL><INDENT>warnings.append(serialized)<EOL><DEDENT>else:<EOL><INDENT>criticals.append(serialized)<EOL><DEDENT><DEDENT><DEDENT>if criticals:<EOL><INDENT>stream.write('<STR_LIT>')<EOL>stream.write('<STR_LIT>'.join(criticals))<EOL>stream.write('<STR_LIT:\n>')<EOL>return <NUM_LIT:2><EOL><DEDENT>elif warnings:<EOL><INDENT>stream.write('<STR_LIT>')<EOL>stream.write('<STR_LIT>'.join(warnings))<EOL>stream.write('<STR_LIT:\n>')<EOL>return <NUM_LIT:1><EOL><DEDENT>stream.write('<STR_LIT>')<EOL>stream.write('<STR_LIT:\n>')<EOL>return <NUM_LIT:0><EOL>
return 0 (OK) if there are no errors in the state.
return 1 (WARNING) if a backfill app only has 1 error.
return 2 (CRITICAL) if a backfill app has > 1 error.
return 2 (CRITICAL) if a non-backfill app has 1 error.