diff options
author | Lars Wirzenius <liw@liw.fi> | 2013-09-06 19:52:57 +0100 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2013-09-06 19:52:57 +0100 |
commit | 2a3a1e574f5be7161f147f65912d428768e4739f (patch) | |
tree | 64de58af2398c9ed45d216e50b13b0e865c0d620 | |
parent | 5f96a5b3b113caed9c5f76160799ff5ea794be45 (diff) | |
download | obnam-2a3a1e574f5be7161f147f65912d428768e4739f.tar.gz |
Improve nagios plugin error reporting for Nagios
Patch by Martijn Grendelman.
-rw-r--r-- | NEWS | 3 | ||||
-rw-r--r-- | obnamlib/plugins/show_plugin.py | 9 |
2 files changed, 10 insertions, 2 deletions
@@ -18,6 +18,9 @@ Version 1.6, released UNRELEASED * Backup progress reporting now reports scanned file data, not just backed up file data. This will hopefully be less confusing to people. +* The nagios plugin to report errors in a way Nagios expects. + Patch by Martijn Grendelman. + Bug fixes: * Fix "obnam list-toplevels" so it doesn't give an error when it's diff --git a/obnamlib/plugins/show_plugin.py b/obnamlib/plugins/show_plugin.py index 75d95ae9..8e9bffb1 100644 --- a/obnamlib/plugins/show_plugin.py +++ b/obnamlib/plugins/show_plugin.py @@ -98,7 +98,12 @@ class ShowPlugin(obnamlib.ObnamPlugin): def nagios_last_backup_age(self, args): '''Check if the most recent generation is recent enough.''' - self.open_repository() + try: + self.open_repository() + except obnamlib.Error, e: + self.app.output.write('CRITICAL: %s\n' % e) + sys.exit(2) + most_recent = None warn_age = self._convert_time(self.app.settings['warn-age']) @@ -119,7 +124,7 @@ class ShowPlugin(obnamlib.ObnamPlugin): self.app.output.write( 'WARNING: backup is old. last backup was %s.\n' % self.format_time(most_recent)) - sys.exit(2) + sys.exit(1) self.app.output.write( 'OK: backup is recent. last backup was %s.\n' % self.format_time(most_recent)) |