diff --git a/check_xbps.py b/check_xbps.py index c3d3679..5b7d93d 100755 --- a/check_xbps.py +++ b/check_xbps.py @@ -88,7 +88,7 @@ def run_command(cmdline): stderr = subprocess.PIPE ) except OSError: - plugin.back2nagios(3, 'Could not execute command line: %s' % subprocess.list2cmdline(cmdline)) + plugin.back2nagios(plugin.RETURNCODE['UNKNOWN'], 'Could not execute command line: %s' % subprocess.list2cmdline(cmdline)) (sout,serr) = cmd.communicate() plugin.verbose(2, 'Runtime %.3fs' % (time.time() - tstart, ) ) @@ -112,7 +112,7 @@ if plugin.options.sync_repo_index: serr and plugin.verbose(3, serr, prefix='stderr: ') plugin.verbose(2, 'Return code: %d' % rc) if rc != 0 and plugin.options.fail_on_sync_failure: - plugin.back2nagios(2, 'Syncing of repository index files failed') + plugin.back2nagios(plugin.RETURNCODE['CRITICAL'], 'Syncing of repository index files failed') ############################################################################## @@ -122,6 +122,14 @@ sout and plugin.verbose(3, sout, prefix='stdout: ') serr and plugin.verbose(3, serr, prefix='stderr: ') plugin.verbose(2, 'Return code: %d' % rc) +if rc == 8: + # RC 8: Transaction aborted due to unresolved shlibs. + plugin.back2nagios(plugin.RETURNCODE['WARNING'], serr[-1], serr[:-1]) +elif rc not in [0, 6]: + # RC 0: Packages to update + # RC 6: Package(s) already installed + plugin.back2nagios(plugin.RETURNCODE['WARNING'], 'Unknown returncode "%s", please contact the author of plugin or open an issue!' % rc) + action = {'remove':[], 'update':[], 'install':[],} arch = {} repo = {} @@ -182,7 +190,7 @@ else: stats += '%s from %s, ' % (v, k) multiline.append(stats[:-2]) - plugin.remember_check('Updates', plugin.RETURNCODE['WARNING'], out, multilineoutput=multiline) + plugin.remember_check('Updates', plugin.RETURNCODE['CRITICAL'], out, multilineoutput=multiline) # Exit plugin.brain2output()