Compare commits

..

4 commits
1.0a1 ... main

Author SHA1 Message Date
Sven Velt 4494a40822 Add README, new branch "main" 2020-12-27 13:41:45 +01:00
Sven Velt da318db5ec check_xbps.py: Hint to use "--sudo" 2017-11-09 12:29:07 +01:00
Sven Velt 2ad98cb81d check_xbps.py: run commands with sudo only when necessary 2016-12-26 22:58:47 +01:00
Sven Velt 7d476d9109 check_xbps.py: added "configure" package state 2016-12-26 22:58:22 +01:00
2 changed files with 39 additions and 7 deletions

30
README.md Normal file
View file

@ -0,0 +1,30 @@
MyMonPlugins
This is the old master branch! New development takes place in the "main" branch!
Default branch will change in the near future.
---
(c) 2010-2011 by Sven Velt and team(ix) GmbH, Nuernberg, Germany
sv@teamix.net
(c) 2016 by Sven Velt, Germany
sven-mymonplugins@velt.biz
This file is part of "velt.biz - My Monitoring Plugins"
a fork of "team(ix) Monitoring Plugins" in 2015
URL: https://gogs.velt.biz/velt.biz/MyMonPlugins/
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
by the Free Software Foundation, either version 2 of the License,
or (at your option) any later version.
This file is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this file. If not, see <http://www.gnu.org/licenses/>.

View file

@ -2,7 +2,7 @@
# -*- encoding: utf-8 -*-
#####################################################################
# (c) 2016 by Sven Velt, Germany #
# (c) 2016-2017 by Sven Velt, Germany #
# sven-mymonplugins@velt.biz #
# #
# This file is part of "velt.biz - My Monitoring Plugins" #
@ -79,9 +79,9 @@ lxc-2.0.4_1 update x86_64 https://repo.voidlinux.eu/current 1837102 468024'''.sp
##############################################################################
def run_command(cmdline):
def run_command(cmdline, needs_sudo=False):
tstart = time.time()
if plugin.options.sudo:
if needs_sudo and plugin.options.sudo:
new = ['sudo', '-n', '--']
new.extend(cmdline)
cmdline = new
@ -112,11 +112,13 @@ def run_command(cmdline):
if plugin.options.sync_repo_index:
plugin.verbose(1, '-S/--sync_repo_index given')
cmdline = [plugin.options.xbps_install, '-S',]
(sout, serr, rc) = run_command(cmdline)
(sout, serr, rc) = run_command(cmdline, needs_sudo=True)
sout and plugin.verbose(3, sout, prefix='stdout: ')
serr and plugin.verbose(3, serr, prefix='stderr: ')
plugin.verbose(2, 'Return code: %d' % rc)
if plugin.options.fail_on_sync_failure and (rc != 0 or 'ERROR:' in ' '.join(serr)):
if 'Permission denied' in ' '.join(serr):
plugin.back2nagios(plugin.RETURNCODE['CRITICAL'], 'Syncing of repository index files failed, permission denied. Do you need "--sudo"?', multiline=serr)
plugin.back2nagios(plugin.RETURNCODE['CRITICAL'], 'Syncing of repository index files failed', multiline=serr)
##############################################################################
@ -140,7 +142,7 @@ elif rc not in [0, 6]:
# 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':[],}
action = {'remove':[], 'update':[], 'install':[], 'configure':[]}
arch = {}
repo = {}
downby = 0L
@ -176,13 +178,13 @@ if len(sout) == 0:
else:
out = []
multiline = []
for act in ['update', 'install', 'remove']:
for act in ['update', 'install', 'remove', 'configure']:
pkgs = action.pop(act)
pkgs.sort()
l = len(pkgs)
out.append('%s package%s to %s' % (l, l != 1 and 's' or '', act) )
l and multiline.append('%s(%s): %s' % (act, l, ', '.join(pkgs)) )
for act in action:
for act in action.keys():
pkgs = action.pop(act)
pkgs.sort()
l = len(pkgs)