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 /obnamlib/plugins/show_plugin.py | |
parent | 5f96a5b3b113caed9c5f76160799ff5ea794be45 (diff) | |
download | obnam-2a3a1e574f5be7161f147f65912d428768e4739f.tar.gz |
Improve nagios plugin error reporting for Nagios
Patch by Martijn Grendelman.
Diffstat (limited to 'obnamlib/plugins/show_plugin.py')
-rw-r--r-- | obnamlib/plugins/show_plugin.py | 9 |
1 files changed, 7 insertions, 2 deletions
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)) |