diff options
author | azul <azul@riseup.net> | 2014-04-18 14:34:32 +0200 |
---|---|---|
committer | azul <azul@riseup.net> | 2014-04-18 14:34:32 +0200 |
commit | 8078cf0f853310cfb0d0681db45effb96850efc9 (patch) | |
tree | 86fb496091a772cefd0e07d1558f6b7fe0636963 /test/nagios/support/nagios_report.py | |
parent | 3513ad74f950b113af1ba1e3d06bc6a55c48fde5 (diff) | |
parent | d639e0a48599b30777b80c2809ded1efb3a6d926 (diff) |
Merge pull request #147 from azul/test/nagios-test-signup0.5.1-rc
Test/nagios test signup
Diffstat (limited to 'test/nagios/support/nagios_report.py')
-rw-r--r-- | test/nagios/support/nagios_report.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/test/nagios/support/nagios_report.py b/test/nagios/support/nagios_report.py new file mode 100644 index 0000000..13cd551 --- /dev/null +++ b/test/nagios/support/nagios_report.py @@ -0,0 +1,24 @@ +def functions_for_system(under_test): + """ + returns a set of functions to use for nagios reporting: + >>> ok, warn, critical, unknown = functions_for_system("tested system") + + each of them will print a nagios line with its argument and + return the exit code: + >>> warn("that looks strange") + 1 tested system - WARNING - that looks strange + 1 + """ + def report_function(code): + return lambda message : report(under_test, code, message) + return map(report_function, [0,1,2,3]) + +def report(system, code, message): + codes = {0: 'OK', 1: 'WARNING', 2: 'CRITICAL', 3: 'UNKNOWN'} + print "%d %s - %s - %s" % \ + (code, system, codes[code], message) + return code + +if __name__ == "__main__": + import doctest + doctest.testmod() |