Compare commits
1 commit
main
...
check_coll
Author | SHA1 | Date | |
---|---|---|---|
6840d8fc91 |
30
README.md
30
README.md
|
@ -1,30 +0,0 @@
|
||||||
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/>.
|
|
||||||
|
|
|
@ -4,12 +4,9 @@
|
||||||
#####################################################################
|
#####################################################################
|
||||||
# (c) 2007-2011 by Sven Velt and team(ix) GmbH, Nuernberg, Germany #
|
# (c) 2007-2011 by Sven Velt and team(ix) GmbH, Nuernberg, Germany #
|
||||||
# sv@teamix.net #
|
# sv@teamix.net #
|
||||||
# (c) 2016 by Sven Velt, Germany #
|
|
||||||
# sven-mymonplugins@velt.biz #
|
|
||||||
# #
|
# #
|
||||||
# This file is part of "velt.biz - My Monitoring Plugins" #
|
# This file is part of "team(ix) Monitoring Plugins" #
|
||||||
# a fork of "team(ix) Monitoring Plugins" in 2015 #
|
# URL: http://oss.teamix.org/projects/monitoringplugins/ #
|
||||||
# URL: https://gogs.velt.biz/velt.biz/MyMonPlugins/ #
|
|
||||||
# #
|
# #
|
||||||
# This file is free software: you can redistribute it and/or modify #
|
# This file is free software: you can redistribute it and/or modify #
|
||||||
# it under the terms of the GNU General Public License as published #
|
# it under the terms of the GNU General Public License as published #
|
||||||
|
@ -40,10 +37,9 @@ except ImportError:
|
||||||
print 'Did you download "%s"' % os.path.basename(sys.argv[0])
|
print 'Did you download "%s"' % os.path.basename(sys.argv[0])
|
||||||
print 'without "monitoringplugin.py"?\n'
|
print 'without "monitoringplugin.py"?\n'
|
||||||
print 'Please go back to'
|
print 'Please go back to'
|
||||||
print 'https://gogs.velt.biz/velt.biz/MyMonPlugins and download it,'
|
print 'http://oss.teamix.org/projects/monitoringplugins/ and download it,'
|
||||||
print 'or even better:'
|
print 'or even better:'
|
||||||
print 'get a full archive at http://gogs.velt.biz/velt.biz/MyMonPlugins/releases'
|
print 'get a hole archive at http://oss.teamix.org/projects/monitoringplugins/files\n'
|
||||||
print 'or a master snapshot at http://gogs.velt.biz/velt.biz/MyMonPlugins/archive/master.tar.gz\n'
|
|
||||||
sys.exit(127)
|
sys.exit(127)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,11 +3,11 @@
|
||||||
|
|
||||||
#####################################################################
|
#####################################################################
|
||||||
# (c) 2016 by Sven Velt, Germany #
|
# (c) 2016 by Sven Velt, Germany #
|
||||||
# sven-mymonplugins@velt.biz #
|
# sven-mymon-plugins@velt.biz #
|
||||||
# #
|
# #
|
||||||
# This file is part of "velt.biz - My Monitoring Plugins" #
|
# This file is part of "velt.biz - My Monitoring Plugins" #
|
||||||
# a fork of "team(ix) Monitoring Plugins" in 2015 #
|
# a fork of "team(ix) Monitoring Plugins" in 2015 #
|
||||||
# URL: https://gogs.velt.biz/velt.biz/MyMonPlugins/ #
|
# URL: https://github.com/veltbiz/mymonplugins/ #
|
||||||
# #
|
# #
|
||||||
# This file is free software: you can redistribute it and/or modify #
|
# This file is free software: you can redistribute it and/or modify #
|
||||||
# it under the terms of the GNU General Public License as published #
|
# it under the terms of the GNU General Public License as published #
|
||||||
|
@ -40,10 +40,9 @@ except ImportError:
|
||||||
print 'Did you download "%s"' % os.path.basename(sys.argv[0])
|
print 'Did you download "%s"' % os.path.basename(sys.argv[0])
|
||||||
print 'without "monitoringplugin.py"?\n'
|
print 'without "monitoringplugin.py"?\n'
|
||||||
print 'Please go back to'
|
print 'Please go back to'
|
||||||
print 'https://gogs.velt.biz/velt.biz/MyMonPlugins and download it,'
|
print 'https://github.com/veltbiz/mymonplugins and download it,'
|
||||||
print 'or even better:'
|
print 'or even better:'
|
||||||
print 'get a full archive at http://gogs.velt.biz/velt.biz/MyMonPlugins/releases'
|
print 'get a full archive at http://github.com/veltbiz/mymonplugins/releases\n'
|
||||||
print 'or a master snapshot at http://gogs.velt.biz/velt.biz/MyMonPlugins/archive/master.tar.gz\n'
|
|
||||||
sys.exit(127)
|
sys.exit(127)
|
||||||
|
|
||||||
|
|
||||||
|
@ -140,3 +139,105 @@ for (key,value) in answer.iteritems():
|
||||||
plugin.brain2output()
|
plugin.brain2output()
|
||||||
plugin.exit()
|
plugin.exit()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
|
if plugin.options.proto not in ['http', 'https']:
|
||||||
|
plugin.back2nagios(3, 'Unknown protocol "' + plugin.options.proto + '"')
|
||||||
|
|
||||||
|
if not plugin.options.port:
|
||||||
|
if plugin.options.proto == 'https':
|
||||||
|
plugin.options.port = '443'
|
||||||
|
else:
|
||||||
|
plugin.options.port = '80'
|
||||||
|
|
||||||
|
url = plugin.options.proto + '://' + plugin.options.host + ':' + plugin.options.port + '/' + plugin.options.url + '?auto'
|
||||||
|
plugin.verbose(1, 'Status URL: ' + url)
|
||||||
|
|
||||||
|
if plugin.options.httpauth:
|
||||||
|
httpauth = plugin.options.httpauth.split(':')
|
||||||
|
if len(httpauth) != 2:
|
||||||
|
plugin.back2nagios(3, 'Wrong format of authentication data! Need "USERNAME:PASSWORD", got "' + plugin.options.httpauth + '"')
|
||||||
|
passman = urllib2.HTTPPasswordMgrWithDefaultRealm()
|
||||||
|
passman.add_password(None, url, httpauth[0], httpauth[1])
|
||||||
|
authhandler = urllib2.HTTPBasicAuthHandler(passman)
|
||||||
|
opener = urllib2.build_opener(authhandler)
|
||||||
|
urllib2.install_opener(opener)
|
||||||
|
|
||||||
|
try:
|
||||||
|
data = urllib2.urlopen(url).read()
|
||||||
|
except urllib2.HTTPError, e:
|
||||||
|
plugin.back2nagios(2, 'Could not read data! ' + str(e))
|
||||||
|
except urllib2.URLError, e:
|
||||||
|
plugin.back2nagios(2, 'Could not connect to server!')
|
||||||
|
|
||||||
|
plugin.verbose(2, 'Got data:\n' + data)
|
||||||
|
|
||||||
|
try:
|
||||||
|
idle = int(re.search('Idle(?:Workers|Servers): (\d+)\n', data).group(1))
|
||||||
|
busy = int(re.search('Busy(?:Workers|Servers): (\d+)\n', data).group(1))
|
||||||
|
except:
|
||||||
|
plugin.back2nagios(2, 'Could not analyze data!')
|
||||||
|
|
||||||
|
description = OrderedDict()
|
||||||
|
description['_'] = 'waiting for connection'
|
||||||
|
description['S'] = 'starting up'
|
||||||
|
description['R'] = 'reading request'
|
||||||
|
description['W'] = 'writing/sending reply'
|
||||||
|
description['K'] = 'keepalive'
|
||||||
|
description['D'] = 'looking up in DNS'
|
||||||
|
description['C'] = 'closing connection'
|
||||||
|
description['L'] = 'logging'
|
||||||
|
description['G'] = 'gracefully finishing'
|
||||||
|
description['I'] = 'idle cleanup of worker'
|
||||||
|
description['.'] = 'open slots(up to ServerLimit)'
|
||||||
|
|
||||||
|
states = {'_':0, 'S':0, 'R':0, 'W':0, 'K':0, 'D':0, 'C':0, 'L':0, 'G':0, 'I':0, '.':0,}
|
||||||
|
|
||||||
|
scoreboard = re.search('Scoreboard: (.*)\n', data)
|
||||||
|
if scoreboard:
|
||||||
|
for worker in scoreboard.group(1):
|
||||||
|
states[worker] += 1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if plugin.options.statistics:
|
||||||
|
scoreboard = re.search('Scoreboard: (.*)\n', data)
|
||||||
|
if scoreboard:
|
||||||
|
states = {'_':0, 'S':0, 'R':0, 'W':0, 'K':0, 'D':0, 'C':0, 'L':0, 'G':0, 'I':0, '.':0,}
|
||||||
|
for worker in scoreboard.group(1):
|
||||||
|
states[worker] += 1
|
||||||
|
plugin.add_multilineoutput(str(states['_']) + ' waiting for connection')
|
||||||
|
plugin.add_multilineoutput(str(states['S']) + ' starting up')
|
||||||
|
plugin.add_multilineoutput(str(states['R']) + ' reading request')
|
||||||
|
plugin.add_multilineoutput(str(states['W']) + ' writing/sending reply')
|
||||||
|
plugin.add_multilineoutput(str(states['K']) + ' keepalive')
|
||||||
|
plugin.add_multilineoutput(str(states['D']) + ' looking up in DNS')
|
||||||
|
plugin.add_multilineoutput(str(states['C']) + ' closing connection')
|
||||||
|
plugin.add_multilineoutput(str(states['L']) + ' logging')
|
||||||
|
plugin.add_multilineoutput(str(states['G']) + ' gracefully finishing')
|
||||||
|
plugin.add_multilineoutput(str(states['I']) + ' idle cleanup of worker')
|
||||||
|
plugin.add_multilineoutput(str(states['.']) + ' open slots(up to ServerLimit)')
|
||||||
|
|
||||||
|
returncode = plugin.value_wc_to_returncode(busy, plugin.options.warn, plugin.options.crit)
|
||||||
|
|
||||||
|
plugin.add_output(str(busy) + ' busy workers, ' + str(idle) + ' idle')
|
||||||
|
|
||||||
|
plugin.add_returncode(returncode)
|
||||||
|
|
||||||
|
plugin.format_add_performancedata('busy', busy, '', warn=plugin.options.warn, crit=plugin.options.crit, min=0.0)
|
||||||
|
plugin.format_add_performancedata('idle', idle, '')
|
||||||
|
|
||||||
|
plugin.exit()
|
||||||
|
|
||||||
|
|
180
check_cups.py
180
check_cups.py
|
@ -1,180 +0,0 @@
|
||||||
#!/usr/bin/env python2
|
|
||||||
# -*- encoding: utf-8 -*-
|
|
||||||
|
|
||||||
#####################################################################
|
|
||||||
# (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/>. #
|
|
||||||
#####################################################################
|
|
||||||
|
|
||||||
import os
|
|
||||||
import re
|
|
||||||
import subprocess
|
|
||||||
import sys
|
|
||||||
import time
|
|
||||||
|
|
||||||
try:
|
|
||||||
from monitoringplugin import MonitoringPlugin
|
|
||||||
except ImportError:
|
|
||||||
print '=========================='
|
|
||||||
print 'AIKS! Python import error!'
|
|
||||||
print '==========================\n'
|
|
||||||
print 'Could not find "monitoringplugin.py"!\n'
|
|
||||||
print 'Did you download "%s"' % os.path.basename(sys.argv[0])
|
|
||||||
print 'without "monitoringplugin.py"?\n'
|
|
||||||
print 'Please go back to'
|
|
||||||
print 'https://gogs.velt.biz/velt.biz/MyMonPlugins and download it,'
|
|
||||||
print 'or even better:'
|
|
||||||
print 'get a full archive at http://gogs.velt.biz/velt.biz/MyMonPlugins/releases'
|
|
||||||
print 'or a master snapshot at http://gogs.velt.biz/velt.biz/MyMonPlugins/archive/master.tar.gz\n'
|
|
||||||
sys.exit(127)
|
|
||||||
|
|
||||||
|
|
||||||
plugin = MonitoringPlugin(
|
|
||||||
pluginname='check_cups',
|
|
||||||
tagforstatusline='CUPS',
|
|
||||||
description='Check CUPS jobs and printer queues',
|
|
||||||
version='0.1',
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
plugin.add_cmdlineoption('-P', '--check-printers', 'check_printers', 'check printer queue', default=False, action='store_true' )
|
|
||||||
plugin.add_cmdlineoption('-J', '--check-jobs', 'check_jobs', 'check job queue', default=False, action='store_true')
|
|
||||||
plugin.add_cmdlineoption('-w', '', 'warn', 'warning thresold for old jobs (seconds)', default='3600')
|
|
||||||
plugin.add_cmdlineoption('-c', '', 'crit', 'warning thresold for old jobs (seconds)', default='86400')
|
|
||||||
|
|
||||||
plugin.add_cmdlineoption('', '--mymonplugins-testmode', 'mymonplugins_testmode', None, default=False, action='store_true')
|
|
||||||
|
|
||||||
plugin.parse_cmdlineoptions()
|
|
||||||
|
|
||||||
##############################################################################
|
|
||||||
##### Testmode
|
|
||||||
|
|
||||||
if plugin.options.mymonplugins_testmode:
|
|
||||||
# Because we need tzlocal from dateutil.tz
|
|
||||||
mymonplugins_testmode = {}
|
|
||||||
|
|
||||||
mymonplugins_testmode['lpstat -a'] = '''Printer_One accepting requests since Thu 16 Jun 2016 02:57:36 PM CEST
|
|
||||||
Printer_Two accepting requests since Thu 16 Jun 2016 02:57:36 PM CEST
|
|
||||||
Printer_Three accepting requests since Thu 16 Jun 2016 02:57:36 PM CEST
|
|
||||||
Printer_Rejecting not accepting requests since Thu 16 Jun 2016 02:57:36 PM CEST -
|
|
||||||
Rejecting Jobs'''.split('\n')
|
|
||||||
|
|
||||||
mymonplugins_testmode['lpstat -o'] = '''Printer_One-1234 username 12345 Thu 01 Jan 1970 01:07:19 AM CET
|
|
||||||
Printer_Two-1234 username 12345 %s''' % time.strftime('%a %d %b %Y %I:%M:%S %p %Z', time.localtime())
|
|
||||||
mymonplugins_testmode['lpstat -o'] = mymonplugins_testmode['lpstat -o'].split('\n')
|
|
||||||
|
|
||||||
##############################################################################
|
|
||||||
|
|
||||||
def check_printer_queue(output_printer_queue):
|
|
||||||
plugin.verbose(1, 'Checking printers')
|
|
||||||
lidx = 0
|
|
||||||
printers = []
|
|
||||||
printers_bad = []
|
|
||||||
|
|
||||||
while lidx < len(output_printer_queue):
|
|
||||||
printer = output_printer_queue[lidx].split(' ')[0]
|
|
||||||
plugin.verbose(2, 'Printer "%s"' % printer)
|
|
||||||
if output_printer_queue[lidx].find('not accepting') > 0:
|
|
||||||
reason = output_printer_queue[(lidx+1)].replace('\t', '').lstrip().rstrip()
|
|
||||||
printers_bad.append( (printer, reason,) )
|
|
||||||
lidx += 1
|
|
||||||
plugin.verbose(3, 'Problem: printer "%s", problem "%s"' % (printer, reason) )
|
|
||||||
|
|
||||||
printers.append( printer )
|
|
||||||
lidx += 1
|
|
||||||
|
|
||||||
plugin.remember_check('All Printers', 0, '%d printer%s found' % (len(printers), len(printers) != 1 and 's' or ''), perfdata=[ {'label':'printers', 'value':len(printers), 'unit':''}, ] )
|
|
||||||
|
|
||||||
for p in printers_bad:
|
|
||||||
plugin.remember_check('%s' % p[0], 1, p[1])
|
|
||||||
|
|
||||||
##############################################################################
|
|
||||||
|
|
||||||
def check_job_queue(output_job_queue):
|
|
||||||
plugin.verbose(1, 'Checking job queue')
|
|
||||||
m = re.compile('(\w{3} \d\d \w{3} \d{4} \d\d:\d\d:\d\d (AM|PM) \w{3,5})')
|
|
||||||
nowsecs = long( time.time() )
|
|
||||||
|
|
||||||
jobs_warn = []
|
|
||||||
jobs_crit = []
|
|
||||||
for line in output_job_queue:
|
|
||||||
plugin.verbose(3, line)
|
|
||||||
f = m.search(line)
|
|
||||||
if not f:
|
|
||||||
plugin.verbose(1, 'No timestamp found in "%s"' % line)
|
|
||||||
continue
|
|
||||||
tstamp = time.strptime(f.group(1), '%a %d %b %Y %I:%M:%S %p %Z')
|
|
||||||
|
|
||||||
tsecs = long( time.mktime(tstamp) )
|
|
||||||
age = nowsecs - tsecs
|
|
||||||
rc = plugin.value_wc_to_returncode(age, plugin.options.warn, plugin.options.crit)
|
|
||||||
if rc == 1:
|
|
||||||
jobs_warn.append(line)
|
|
||||||
elif rc == 2:
|
|
||||||
jobs_crit.append(line)
|
|
||||||
plugin.verbose(1, 'Job is %s seconds old, state/returncode: %s' % (age, rc))
|
|
||||||
|
|
||||||
jobs = len(output_job_queue)
|
|
||||||
jobs_old = len(jobs_warn) + len(jobs_crit)
|
|
||||||
perfdata = []
|
|
||||||
perfdata.append( { 'label':'jobs', 'value':'%d' % jobs, 'unit':'', } )
|
|
||||||
perfdata.append( { 'label':'jobs_old', 'value':'%d' % jobs_old, 'unit':'', } )
|
|
||||||
plugin.remember_check('Jobs', 0, '%d job%s found' % (jobs, jobs != 1 and 's' or ''), perfdata=perfdata )
|
|
||||||
|
|
||||||
for j in jobs_crit:
|
|
||||||
plugin.remember_check('Job %s' % j.split(' ')[0], 2, m.search(j).group(0) )
|
|
||||||
for j in jobs_warn:
|
|
||||||
plugin.remember_check('Job %s' % j.split(' ')[0], 1, m.search(j).group(0) )
|
|
||||||
|
|
||||||
##############################################################################
|
|
||||||
|
|
||||||
def call_cmd(cmdline):
|
|
||||||
if plugin.options.mymonplugins_testmode:
|
|
||||||
return (mymonplugins_testmode.get(' '.join(cmdline)), '', 0)
|
|
||||||
|
|
||||||
myenv = dict(os.environ)
|
|
||||||
myenv['LC_ALL'] = 'C'
|
|
||||||
|
|
||||||
try:
|
|
||||||
cmd = subprocess.Popen(cmdline, stdout=subprocess.PIPE, env=myenv)
|
|
||||||
(sout, serr) = cmd.communicate()
|
|
||||||
if sout:
|
|
||||||
sout = sout.lstrip().rstrip().split('\n')
|
|
||||||
else:
|
|
||||||
sout = []
|
|
||||||
except OSError:
|
|
||||||
plugin.back2nagios(3, 'Could not execute "%s"' % ' '.join(cmdline))
|
|
||||||
return (sout, serr, cmd.returncode)
|
|
||||||
|
|
||||||
##############################################################################
|
|
||||||
|
|
||||||
allchecks = not( plugin.options.check_printers or plugin.options.check_jobs )
|
|
||||||
|
|
||||||
if allchecks or plugin.options.check_printers:
|
|
||||||
(sout, serr, retcode) = call_cmd(['lpstat', '-a'])
|
|
||||||
check_printer_queue(sout)
|
|
||||||
if allchecks or plugin.options.check_jobs:
|
|
||||||
(sout, serr, retcode) = call_cmd(['lpstat', '-o'])
|
|
||||||
check_job_queue(sout)
|
|
||||||
|
|
||||||
# Exit
|
|
||||||
plugin.brain2output()
|
|
||||||
plugin.exit()
|
|
||||||
|
|
|
@ -1,51 +1,10 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/python
|
||||||
# -*- encoding: utf-8 -*-
|
|
||||||
|
|
||||||
#####################################################################
|
from monitoringplugin import MonitoringPlugin
|
||||||
# (c) 2006-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/>. #
|
|
||||||
#####################################################################
|
|
||||||
|
|
||||||
import fcntl
|
import fcntl
|
||||||
import socket
|
import socket
|
||||||
import struct
|
import struct
|
||||||
import sys
|
|
||||||
|
|
||||||
try:
|
|
||||||
from monitoringplugin import SNMPMonitoringPlugin
|
|
||||||
except ImportError:
|
|
||||||
print '=========================='
|
|
||||||
print 'AIKS! Python import error!'
|
|
||||||
print '==========================\n'
|
|
||||||
print 'Could not find "monitoringplugin.py"!\n'
|
|
||||||
print 'Did you download "%s"' % os.path.basename(sys.argv[0])
|
|
||||||
print 'without "monitoringplugin.py"?\n'
|
|
||||||
print 'Please go back to'
|
|
||||||
print 'https://gogs.velt.biz/velt.biz/MyMonPlugins and download it,'
|
|
||||||
print 'or even better:'
|
|
||||||
print 'get a full archive at http://gogs.velt.biz/velt.biz/MyMonPlugins/releases'
|
|
||||||
print 'or a master snapshot at http://gogs.velt.biz/velt.biz/MyMonPlugins/archive/master.tar.gz\n'
|
|
||||||
sys.exit(127)
|
|
||||||
|
|
||||||
|
|
||||||
def get_ipv4_address(iface):
|
def get_ipv4_address(iface):
|
||||||
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||||
|
|
|
@ -1,171 +0,0 @@
|
||||||
#!/usr/bin/env python
|
|
||||||
# -*- encoding: utf-8 -*-
|
|
||||||
|
|
||||||
#####################################################################
|
|
||||||
# (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/>. #
|
|
||||||
#####################################################################
|
|
||||||
|
|
||||||
import os
|
|
||||||
import re
|
|
||||||
import socket
|
|
||||||
import sys
|
|
||||||
|
|
||||||
try:
|
|
||||||
from monitoringplugin import MonitoringPlugin
|
|
||||||
except ImportError:
|
|
||||||
print '=========================='
|
|
||||||
print 'AIKS! Python import error!'
|
|
||||||
print '==========================\n'
|
|
||||||
print 'Could not find "monitoringplugin.py"!\n'
|
|
||||||
print 'Did you download "%s"' % os.path.basename(sys.argv[0])
|
|
||||||
print 'without "monitoringplugin.py"?\n'
|
|
||||||
print 'Please go back to'
|
|
||||||
print 'https://gogs.velt.biz/velt.biz/MyMonPlugins and download it,'
|
|
||||||
print 'or even better:'
|
|
||||||
print 'get a full archive at http://gogs.velt.biz/velt.biz/MyMonPlugins/releases'
|
|
||||||
print 'or a master snapshot at http://gogs.velt.biz/velt.biz/MyMonPlugins/archive/master.tar.gz\n'
|
|
||||||
sys.exit(127)
|
|
||||||
|
|
||||||
|
|
||||||
plugin = MonitoringPlugin(
|
|
||||||
pluginname='check_livestatus_latency',
|
|
||||||
tagforstatusline='LATENCY',
|
|
||||||
description='Check latency via Livestatus',
|
|
||||||
version='0.1',
|
|
||||||
)
|
|
||||||
|
|
||||||
SOCKPATHs= [
|
|
||||||
'/var/cache/naemon/live',
|
|
||||||
'/usr/local/nagios/var/rw/live',
|
|
||||||
'/var/lib/nagios3/rw/live',
|
|
||||||
'/usr/local/icinga/var/rw/live',
|
|
||||||
'/var/lib/icinga/rw/live',
|
|
||||||
]
|
|
||||||
|
|
||||||
plugin.add_cmdlineoption('-S', '--socket', 'socket', 'path to livestatus socket', default=None)
|
|
||||||
plugin.add_cmdlineoption('-w', '', 'warn', 'warning thresold', default='10')
|
|
||||||
plugin.add_cmdlineoption('-c', '', 'crit', 'warning thresold', default='20')
|
|
||||||
|
|
||||||
plugin.parse_cmdlineoptions()
|
|
||||||
|
|
||||||
|
|
||||||
# FIXME: New method: find path (file or dir) and test we can read/write from/to it
|
|
||||||
if not plugin.options.socket:
|
|
||||||
plugin.verbose(2, "Auto-detecting path to livestatus unixsock...")
|
|
||||||
for sockpath in SOCKPATHs:
|
|
||||||
if os.path.exists(sockpath):
|
|
||||||
plugin.options.socket = sockpath
|
|
||||||
plugin.verbose(2, 'Found it at "%s"' % sockpath)
|
|
||||||
break
|
|
||||||
|
|
||||||
if not plugin.options.socket:
|
|
||||||
plugin.back2nagios(3, 'Need a socket path (-S/--socket) to connecto to')
|
|
||||||
|
|
||||||
if not os.access(plugin.options.socket, os.W_OK):
|
|
||||||
plugin.back2nagios(3, 'Could not read from socket "%s"' % plugin.options.socket)
|
|
||||||
# FIXME: End
|
|
||||||
|
|
||||||
cmd_svc='''GET services
|
|
||||||
OutputFormat: csv
|
|
||||||
Stats: min latency
|
|
||||||
Stats: max latency
|
|
||||||
Stats: avg latency
|
|
||||||
Stats: min execution_time
|
|
||||||
Stats: max execution_time
|
|
||||||
Stats: avg execution_time
|
|
||||||
'''
|
|
||||||
|
|
||||||
cmd_hst='''GET hosts
|
|
||||||
OutputFormat: csv
|
|
||||||
Stats: min latency
|
|
||||||
Stats: max latency
|
|
||||||
Stats: avg latency
|
|
||||||
Stats: min execution_time
|
|
||||||
Stats: max execution_time
|
|
||||||
Stats: avg execution_time
|
|
||||||
'''
|
|
||||||
|
|
||||||
# Read service data from socket
|
|
||||||
s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
|
|
||||||
s.connect(plugin.options.socket)
|
|
||||||
plugin.verbose(3, 'Livestatus: GET services')
|
|
||||||
s.send(cmd_svc)
|
|
||||||
s.shutdown(socket.SHUT_WR)
|
|
||||||
|
|
||||||
answer = ''
|
|
||||||
try:
|
|
||||||
while True:
|
|
||||||
s.settimeout(10)
|
|
||||||
data = s.recv(32768)
|
|
||||||
if data:
|
|
||||||
answer += data
|
|
||||||
else:
|
|
||||||
break
|
|
||||||
except socket.timeout:
|
|
||||||
plugin.back2nagios(3, 'Timeout while reading from socket')
|
|
||||||
|
|
||||||
svc_answer = answer.split('\n')[0].split(';')
|
|
||||||
plugin.verbose(3, 'Socket answer: %s' % answer.rstrip())
|
|
||||||
|
|
||||||
svc_answer = [ float(fl) for fl in svc_answer ]
|
|
||||||
plugin.verbose(3, 'Answer: %s' % svc_answer)
|
|
||||||
|
|
||||||
|
|
||||||
# Read host data from socket
|
|
||||||
s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
|
|
||||||
s.connect(plugin.options.socket)
|
|
||||||
plugin.verbose(3, 'Livestatus: GET hosts')
|
|
||||||
s.send(cmd_hst)
|
|
||||||
s.shutdown(socket.SHUT_WR)
|
|
||||||
|
|
||||||
answer = ''
|
|
||||||
try:
|
|
||||||
while True:
|
|
||||||
s.settimeout(10)
|
|
||||||
data = s.recv(32768)
|
|
||||||
if data:
|
|
||||||
answer += data
|
|
||||||
else:
|
|
||||||
break
|
|
||||||
except socket.timeout:
|
|
||||||
plugin.back2nagios(3, 'Timeout while reading from socket')
|
|
||||||
|
|
||||||
hst_answer = answer.split('\n')[0].split(';')
|
|
||||||
plugin.verbose(3, 'Socket answer: %s' % answer.rstrip())
|
|
||||||
|
|
||||||
hst_answer = [ float(fl) for fl in hst_answer ]
|
|
||||||
plugin.verbose(3, 'Answer: %s' % hst_answer)
|
|
||||||
|
|
||||||
# Check values against thresholds
|
|
||||||
for (k, v) in (
|
|
||||||
('AvgServiceLatency', svc_answer[2]),
|
|
||||||
('AvgServiceExecution', svc_answer[5]),
|
|
||||||
('AvgHostLatency', hst_answer[2]),
|
|
||||||
('AvgHostExecution', hst_answer[5]),
|
|
||||||
):
|
|
||||||
rc = plugin.value_wc_to_returncode(v, plugin.options.warn, plugin.options.crit)
|
|
||||||
perfdata = { 'label':k, 'value':'%.3f' % v, 'unit':'s', 'warn':plugin.options.warn, 'crit':plugin.options.crit }
|
|
||||||
plugin.remember_check(k, rc, '%.2fs' % v, perfdata=[perfdata,])
|
|
||||||
|
|
||||||
# Exit
|
|
||||||
plugin.brain2output()
|
|
||||||
plugin.exit()
|
|
||||||
|
|
12
check_naf.py
12
check_naf.py
|
@ -4,12 +4,9 @@
|
||||||
#####################################################################
|
#####################################################################
|
||||||
# (c) 2006-2011 by Sven Velt and team(ix) GmbH, Nuernberg, Germany #
|
# (c) 2006-2011 by Sven Velt and team(ix) GmbH, Nuernberg, Germany #
|
||||||
# sv@teamix.net #
|
# sv@teamix.net #
|
||||||
# (c) 2016 by Sven Velt, Germany #
|
|
||||||
# sven-mymonplugins@velt.biz #
|
|
||||||
# #
|
# #
|
||||||
# This file is part of "velt.biz - My Monitoring Plugins" #
|
# This file is part of "team(ix) Monitoring Plugins" #
|
||||||
# a fork of "team(ix) Monitoring Plugins" in 2015 #
|
# URL: http://oss.teamix.org/projects/monitoringplugins/ #
|
||||||
# URL: https://gogs.velt.biz/velt.biz/MyMonPlugins/ #
|
|
||||||
# #
|
# #
|
||||||
# This file is free software: you can redistribute it and/or modify #
|
# This file is free software: you can redistribute it and/or modify #
|
||||||
# it under the terms of the GNU General Public License as published #
|
# it under the terms of the GNU General Public License as published #
|
||||||
|
@ -38,10 +35,9 @@ except ImportError:
|
||||||
print 'Did you download "%s"' % os.path.basename(sys.argv[0])
|
print 'Did you download "%s"' % os.path.basename(sys.argv[0])
|
||||||
print 'without "monitoringplugin.py"?\n'
|
print 'without "monitoringplugin.py"?\n'
|
||||||
print 'Please go back to'
|
print 'Please go back to'
|
||||||
print 'https://gogs.velt.biz/velt.biz/MyMonPlugins and download it,'
|
print 'http://oss.teamix.org/projects/monitoringplugins/ and download it,'
|
||||||
print 'or even better:'
|
print 'or even better:'
|
||||||
print 'get a full archive at http://gogs.velt.biz/velt.biz/MyMonPlugins/releases'
|
print 'get a hole archive at http://oss.teamix.org/projects/monitoringplugins/files\n'
|
||||||
print 'or a master snapshot at http://gogs.velt.biz/velt.biz/MyMonPlugins/archive/master.tar.gz\n'
|
|
||||||
sys.exit(127)
|
sys.exit(127)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4,12 +4,9 @@
|
||||||
#####################################################################
|
#####################################################################
|
||||||
# (c) 2005-2011 by Sven Velt and team(ix) GmbH, Nuernberg, Germany #
|
# (c) 2005-2011 by Sven Velt and team(ix) GmbH, Nuernberg, Germany #
|
||||||
# sv@teamix.net #
|
# sv@teamix.net #
|
||||||
# (c) 2016 by Sven Velt, Germany #
|
|
||||||
# sven-mymonplugins@velt.biz #
|
|
||||||
# #
|
# #
|
||||||
# This file is part of "velt.biz - My Monitoring Plugins" #
|
# This file is part of "team(ix) Monitoring Plugins" #
|
||||||
# a fork of "team(ix) Monitoring Plugins" in 2015 #
|
# URL: http://oss.teamix.org/projects/monitoringplugins/ #
|
||||||
# URL: https://gogs.velt.biz/velt.biz/MyMonPlugins/ #
|
|
||||||
# #
|
# #
|
||||||
# This file is free software: you can redistribute it and/or modify #
|
# This file is free software: you can redistribute it and/or modify #
|
||||||
# it under the terms of the GNU General Public License as published #
|
# it under the terms of the GNU General Public License as published #
|
||||||
|
@ -40,10 +37,9 @@ except ImportError:
|
||||||
print 'Did you download "%s"' % os.path.basename(sys.argv[0])
|
print 'Did you download "%s"' % os.path.basename(sys.argv[0])
|
||||||
print 'without "monitoringplugin.py"?\n'
|
print 'without "monitoringplugin.py"?\n'
|
||||||
print 'Please go back to'
|
print 'Please go back to'
|
||||||
print 'https://gogs.velt.biz/velt.biz/MyMonPlugins and download it,'
|
print 'http://oss.teamix.org/projects/monitoringplugins/ and download it,'
|
||||||
print 'or even better:'
|
print 'or even better:'
|
||||||
print 'get a full archive at http://gogs.velt.biz/velt.biz/MyMonPlugins/releases'
|
print 'get a hole archive at http://oss.teamix.org/projects/monitoringplugins/files\n'
|
||||||
print 'or a master snapshot at http://gogs.velt.biz/velt.biz/MyMonPlugins/archive/master.tar.gz\n'
|
|
||||||
sys.exit(127)
|
sys.exit(127)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4,12 +4,9 @@
|
||||||
#####################################################################
|
#####################################################################
|
||||||
# (c) 2010-2011 by Sven Velt and team(ix) GmbH, Nuernberg, Germany #
|
# (c) 2010-2011 by Sven Velt and team(ix) GmbH, Nuernberg, Germany #
|
||||||
# sv@teamix.net #
|
# sv@teamix.net #
|
||||||
# (c) 2016 by Sven Velt, Germany #
|
|
||||||
# sven-mymonplugins@velt.biz #
|
|
||||||
# #
|
# #
|
||||||
# This file is part of "velt.biz - My Monitoring Plugins" #
|
# This file is part of "team(ix) Monitoring Plugins" #
|
||||||
# a fork of "team(ix) Monitoring Plugins" in 2015 #
|
# URL: http://oss.teamix.org/projects/monitoringplugins/ #
|
||||||
# URL: https://gogs.velt.biz/velt.biz/MyMonPlugins/ #
|
|
||||||
# #
|
# #
|
||||||
# This file is free software: you can redistribute it and/or modify #
|
# This file is free software: you can redistribute it and/or modify #
|
||||||
# it under the terms of the GNU General Public License as published #
|
# it under the terms of the GNU General Public License as published #
|
||||||
|
@ -39,10 +36,9 @@ except ImportError:
|
||||||
print 'Did you download "%s"' % os.path.basename(sys.argv[0])
|
print 'Did you download "%s"' % os.path.basename(sys.argv[0])
|
||||||
print 'without "monitoringplugin.py"?\n'
|
print 'without "monitoringplugin.py"?\n'
|
||||||
print 'Please go back to'
|
print 'Please go back to'
|
||||||
print 'https://gogs.velt.biz/velt.biz/MyMonPlugins and download it,'
|
print 'http://oss.teamix.org/projects/monitoringplugins/ and download it,'
|
||||||
print 'or even better:'
|
print 'or even better:'
|
||||||
print 'get a full archive at http://gogs.velt.biz/velt.biz/MyMonPlugins/releases'
|
print 'get a hole archive at http://oss.teamix.org/projects/monitoringplugins/files\n'
|
||||||
print 'or a master snapshot at http://gogs.velt.biz/velt.biz/MyMonPlugins/archive/master.tar.gz\n'
|
|
||||||
sys.exit(127)
|
sys.exit(127)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4,12 +4,9 @@
|
||||||
#####################################################################
|
#####################################################################
|
||||||
# (c) 2010-2011 by Sven Velt and team(ix) GmbH, Nuernberg, Germany #
|
# (c) 2010-2011 by Sven Velt and team(ix) GmbH, Nuernberg, Germany #
|
||||||
# sv@teamix.net #
|
# sv@teamix.net #
|
||||||
# (c) 2016 by Sven Velt, Germany #
|
|
||||||
# sven-mymonplugins@velt.biz #
|
|
||||||
# #
|
# #
|
||||||
# This file is part of "velt.biz - My Monitoring Plugins" #
|
# This file is part of "team(ix) Monitoring Plugins" #
|
||||||
# a fork of "team(ix) Monitoring Plugins" in 2015 #
|
# URL: http://oss.teamix.org/projects/monitoringplugins/ #
|
||||||
# URL: https://gogs.velt.biz/velt.biz/MyMonPlugins/ #
|
|
||||||
# #
|
# #
|
||||||
# This file is free software: you can redistribute it and/or modify #
|
# This file is free software: you can redistribute it and/or modify #
|
||||||
# it under the terms of the GNU General Public License as published #
|
# it under the terms of the GNU General Public License as published #
|
||||||
|
@ -41,10 +38,9 @@ except ImportError:
|
||||||
print 'Did you download "%s"' % os.path.basename(sys.argv[0])
|
print 'Did you download "%s"' % os.path.basename(sys.argv[0])
|
||||||
print 'without "monitoringplugin.py"?\n'
|
print 'without "monitoringplugin.py"?\n'
|
||||||
print 'Please go back to'
|
print 'Please go back to'
|
||||||
print 'https://gogs.velt.biz/velt.biz/MyMonPlugins and download it,'
|
print 'http://oss.teamix.org/projects/monitoringplugins/ and download it,'
|
||||||
print 'or even better:'
|
print 'or even better:'
|
||||||
print 'get a full archive at http://gogs.velt.biz/velt.biz/MyMonPlugins/releases'
|
print 'get a hole archive at http://oss.teamix.org/projects/monitoringplugins/files\n'
|
||||||
print 'or a master snapshot at http://gogs.velt.biz/velt.biz/MyMonPlugins/archive/master.tar.gz\n'
|
|
||||||
sys.exit(127)
|
sys.exit(127)
|
||||||
|
|
||||||
|
|
||||||
|
|
210
check_xbps.py
210
check_xbps.py
|
@ -1,210 +0,0 @@
|
||||||
#!/usr/bin/env python2
|
|
||||||
# -*- encoding: utf-8 -*-
|
|
||||||
|
|
||||||
#####################################################################
|
|
||||||
# (c) 2016-2017 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/>. #
|
|
||||||
#####################################################################
|
|
||||||
|
|
||||||
import subprocess
|
|
||||||
import sys
|
|
||||||
import time
|
|
||||||
|
|
||||||
try:
|
|
||||||
from monitoringplugin import MonitoringPlugin
|
|
||||||
except ImportError:
|
|
||||||
print '=========================='
|
|
||||||
print 'AIKS! Python import error!'
|
|
||||||
print '==========================\n'
|
|
||||||
print 'Could not find "monitoringplugin.py"!\n'
|
|
||||||
print 'Did you download "%s"' % os.path.basename(sys.argv[0])
|
|
||||||
print 'without "monitoringplugin.py"?\n'
|
|
||||||
print 'Please go back to'
|
|
||||||
print 'https://gogs.velt.biz/velt.biz/MyMonPlugins and download it,'
|
|
||||||
print 'or even better:'
|
|
||||||
print 'get a full archive at http://gogs.velt.biz/velt.biz/MyMonPlugins/releases'
|
|
||||||
print 'or a master snapshot at http://gogs.velt.biz/velt.biz/MyMonPlugins/archive/master.tar.gz\n'
|
|
||||||
sys.exit(127)
|
|
||||||
|
|
||||||
|
|
||||||
plugin = MonitoringPlugin(
|
|
||||||
pluginname='check_xbps',
|
|
||||||
tagforstatusline='XBPS',
|
|
||||||
description='Check XBPS package manager for updates',
|
|
||||||
version='0.1',
|
|
||||||
)
|
|
||||||
|
|
||||||
plugin.add_cmdlineoption('-P', '--path-xbps-install', 'xbps_install', 'full path to xbps-install', default='/usr/bin/xbps-install')
|
|
||||||
plugin.add_cmdlineoption('-S', '--sync-repo-index', 'sync_repo_index', 'sync repository index files at startup', default=False, action='store_true')
|
|
||||||
plugin.add_cmdlineoption('', '--ignore-sync-failure', 'fail_on_sync_failure', 'ignore repo index sync failures', default=True, action='store_false')
|
|
||||||
plugin.add_cmdlineoption('', '--sudo', 'sudo', 'call "xbps-install" with sudo', default=False, action='store_true')
|
|
||||||
|
|
||||||
plugin.add_cmdlineoption('', '--mymonplugins-testmode', 'mymonplugins_testmode', None, default=False, action='store_true')
|
|
||||||
|
|
||||||
plugin.parse_cmdlineoptions()
|
|
||||||
|
|
||||||
##############################################################################
|
|
||||||
##### Testmode
|
|
||||||
|
|
||||||
if plugin.options.mymonplugins_testmode:
|
|
||||||
mymonplugins_testmode = {}
|
|
||||||
|
|
||||||
mymonplugins_testmode['xbps-install -S'] = '''[*] Updating `https://repo.voidlinux.eu/current/x86_64-repodata' ...
|
|
||||||
'''.split('\n')
|
|
||||||
|
|
||||||
mymonplugins_testmode['xbps-install -un'] = '''elementary-1.17.1_1 remove x86_64 https://repo.voidlinux.eu/current 19821495 12302924
|
|
||||||
bash-4.3.046_2 update x86_64 https://repo.voidlinux.eu/current 5019665 998440
|
|
||||||
libllvm3.9-3.9.0_2 install x86_64 https://repo.voidlinux.eu/current 51052672 12480860
|
|
||||||
linux4.7-4.7.4_1 install x86_64 https://repo.voidlinux.eu/current 61839987 55203908
|
|
||||||
linux-4.7_1 update x86_64 https://repo.voidlinux.eu/current 624
|
|
||||||
linux4.6-4.6.7_1 update x86_64 https://repo.voidlinux.eu/current 60995961 54434936
|
|
||||||
lxc-2.0.4_1 update x86_64 https://repo.voidlinux.eu/current 1837102 468024'''.split('\n')
|
|
||||||
|
|
||||||
##############################################################################
|
|
||||||
|
|
||||||
def run_command(cmdline, needs_sudo=False):
|
|
||||||
tstart = time.time()
|
|
||||||
if needs_sudo and plugin.options.sudo:
|
|
||||||
new = ['sudo', '-n', '--']
|
|
||||||
new.extend(cmdline)
|
|
||||||
cmdline = new
|
|
||||||
plugin.verbose(1, 'Running command line: %s' % subprocess.list2cmdline(cmdline))
|
|
||||||
try:
|
|
||||||
cmd = subprocess.Popen(
|
|
||||||
cmdline,
|
|
||||||
stdout = subprocess.PIPE,
|
|
||||||
stderr = subprocess.PIPE
|
|
||||||
)
|
|
||||||
except OSError:
|
|
||||||
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, ) )
|
|
||||||
|
|
||||||
sout = sout.rstrip().split('\n')
|
|
||||||
if sout == ['']:
|
|
||||||
sout = []
|
|
||||||
serr = serr.rstrip().split('\n')
|
|
||||||
if serr == ['']:
|
|
||||||
serr = []
|
|
||||||
|
|
||||||
return( (sout, serr, cmd.returncode,) )
|
|
||||||
|
|
||||||
##############################################################################
|
|
||||||
|
|
||||||
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, 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)
|
|
||||||
|
|
||||||
##############################################################################
|
|
||||||
|
|
||||||
cmdline = [plugin.options.xbps_install, '-un',]
|
|
||||||
(sout, serr, rc) = run_command(cmdline)
|
|
||||||
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.sudo and 'sudo: ' in ' '.join(serr):
|
|
||||||
# Running with sudo
|
|
||||||
if rc == 1:
|
|
||||||
# sudo RC 1: a password is required
|
|
||||||
plugin.back2nagios(plugin.RETURNCODE['CRITICAL'], ' '.join(serr))
|
|
||||||
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':[], 'configure':[]}
|
|
||||||
arch = {}
|
|
||||||
repo = {}
|
|
||||||
downby = 0L
|
|
||||||
|
|
||||||
for line in sout:
|
|
||||||
cols = line.split(' ')
|
|
||||||
# Append package name to action type list
|
|
||||||
try:
|
|
||||||
action[cols[1]].append(cols[0])
|
|
||||||
except KeyError:
|
|
||||||
action[cols[1]] = [ cols[0], ]
|
|
||||||
|
|
||||||
# Count per arch
|
|
||||||
try:
|
|
||||||
arch[cols[2]] += 1
|
|
||||||
except KeyError:
|
|
||||||
arch[cols[2]] = 1
|
|
||||||
|
|
||||||
# Count per repo
|
|
||||||
try:
|
|
||||||
repo[cols[3]] += 1
|
|
||||||
except KeyError:
|
|
||||||
repo[cols[3]] = 1
|
|
||||||
|
|
||||||
# Count bytes to download
|
|
||||||
if len(cols) == 5:
|
|
||||||
downby += long(cols[4])
|
|
||||||
else:
|
|
||||||
downby += long(cols[5])
|
|
||||||
|
|
||||||
if len(sout) == 0:
|
|
||||||
plugin.remember_check('Updates', plugin.RETURNCODE['OK'], 'Everything uptodate')
|
|
||||||
else:
|
|
||||||
out = []
|
|
||||||
multiline = []
|
|
||||||
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.keys():
|
|
||||||
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)) )
|
|
||||||
|
|
||||||
out = ', '.join(out)
|
|
||||||
if downby:
|
|
||||||
out += ' - %s to download' % plugin.value_to_human_binary(downby, 'B')
|
|
||||||
|
|
||||||
stats = 'Statistics: '
|
|
||||||
for (k, v) in arch.iteritems():
|
|
||||||
stats += '%sx %s, ' % (v, k)
|
|
||||||
for (k, v) in repo.iteritems():
|
|
||||||
stats += '%s from %s, ' % (v, k)
|
|
||||||
multiline.append(stats[:-2])
|
|
||||||
|
|
||||||
plugin.remember_check('Updates', plugin.RETURNCODE['CRITICAL'], out, multilineoutput=multiline)
|
|
||||||
|
|
||||||
# Exit
|
|
||||||
plugin.brain2output()
|
|
||||||
plugin.exit()
|
|
||||||
|
|
|
@ -3,12 +3,9 @@
|
||||||
#############################################################################
|
#############################################################################
|
||||||
# (c) 2011 Sven Velt <sven@velt.de #
|
# (c) 2011 Sven Velt <sven@velt.de #
|
||||||
# and team(ix) GmbH, Nuernberg, Germany #
|
# and team(ix) GmbH, Nuernberg, Germany #
|
||||||
# (c) 2016 by Sven Velt, Germany #
|
|
||||||
# sven-mymonplugins@velt.biz #
|
|
||||||
# #
|
# #
|
||||||
# This file is part of "velt.biz - My Monitoring Plugins" #
|
# This file is part of "team(ix) Monitoring Plugins" #
|
||||||
# a fork of "team(ix) Monitoring Plugins" in 2015 #
|
# URL: http://oss.teamix.org/projects/monitoringplugins/ #
|
||||||
# URL: https://gogs.velt.biz/velt.biz/MyMonPlugins/ #
|
|
||||||
# #
|
# #
|
||||||
# All rights reserved. #
|
# All rights reserved. #
|
||||||
# Redistribution and use in source and binary forms, with or without #
|
# Redistribution and use in source and binary forms, with or without #
|
||||||
|
|
68
commands.cfg
68
commands.cfg
|
@ -1,4 +1,4 @@
|
||||||
# We use "$USER3" as user macro for path to MyMonPlugins
|
# We use "$USER3" as user macro for path to teamix monitoring plugins
|
||||||
|
|
||||||
|
|
||||||
### check_apaches.py
|
### check_apaches.py
|
||||||
|
@ -7,45 +7,13 @@ define command {
|
||||||
command_name check_apaches
|
command_name check_apaches
|
||||||
command_line $USER3$/check_apaches.py -H $HOSTADDRESS$ -w $ARG1$ -c $ARG3$
|
command_line $USER3$/check_apaches.py -H $HOSTADDRESS$ -w $ARG1$ -c $ARG3$
|
||||||
}
|
}
|
||||||
# check_command check_apaches_full!https!webserver!443!/hidden-status!user:password!40!70
|
# check_command check_apaches_full
|
||||||
define command {
|
define command {
|
||||||
command_name check_apaches_full
|
command_name check_apaches_full!https!webserver!443!/hidden-status!user:password!40!70
|
||||||
command_line $USER3$/check_apaches.py -P $ARG1$ -H $ARG2$ -p $ARG3$ -u $ARG4$ -a $ARG5$ -w $ARG6$ -c $ARG7$
|
command_line $USER3$/check_apaches.py -P $ARG1$ -H $ARG2$ -p $ARG3$ -u $ARG4$ -a $ARG5$ -w $ARG6$ -c $ARG7$
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
### check_collectd.py (WIP!)
|
|
||||||
# check_command check_collectd!load/load!2!5
|
|
||||||
## $USER17$ contains the path to collectd's unixsock (e.g. "/var/run/collectd-unixsock")
|
|
||||||
define command {
|
|
||||||
command_name check_collectd
|
|
||||||
command_line $USER3$/check_collectd.py -S $USER17$ -H $HOSTNAME$ -V $ARG1$ -w $ARG2$ -c $ARG3$
|
|
||||||
# command_line $USER3$/check_collectd.py -S $USER17$ -H $HOSTALIAS$ -V $ARG1$ -w $ARG2$ -c $ARG3$
|
|
||||||
}
|
|
||||||
# Use "__collectd_name" in host definition if collectd's hostname differs from object host name
|
|
||||||
define command {
|
|
||||||
command_name check_collectd
|
|
||||||
command_line $USER3$/check_collectd.py -S $USER17$ -H $_HOST_COLLECTD_NAME$ -V $ARG1$ -w $ARG2$ -c $ARG3$
|
|
||||||
}
|
|
||||||
|
|
||||||
### check_cups.py
|
|
||||||
# check_command check_cups
|
|
||||||
define command {
|
|
||||||
command_name check_cups
|
|
||||||
command_line $USER3$/check_cups.py
|
|
||||||
}
|
|
||||||
# check_command check_cups_jobs
|
|
||||||
define command {
|
|
||||||
command_name check_cups_jobs
|
|
||||||
command_line $USER3$/check_cups.py --check-jobs
|
|
||||||
}
|
|
||||||
# check_command check_cups_printers
|
|
||||||
define command {
|
|
||||||
command_name check_cups_printers
|
|
||||||
command_line $USER3$/check_cups.py --check-printers
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
### check_iface-dns.py
|
### check_iface-dns.py
|
||||||
# check_command check_iface-dns!ppp0!your-name.dyndns.org,other-name.homeip.net
|
# check_command check_iface-dns!ppp0!your-name.dyndns.org,other-name.homeip.net
|
||||||
define command {
|
define command {
|
||||||
|
@ -54,19 +22,8 @@ define command {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
### check_livestatus_latency.py
|
### check_junos_bgp.pl
|
||||||
# check_command check_livestatus_latency
|
### check_junos_vc.pl
|
||||||
## $USER18$ contains the path to your livestatus socket
|
|
||||||
define command {
|
|
||||||
command_name check_livestatus_latency
|
|
||||||
command_line $USER3$/check_livestatus_latency.py
|
|
||||||
# command_line $USER3$/check_livestatus_latency.py -S $USER18$
|
|
||||||
}
|
|
||||||
# check_command check_livestatus_latency!10!20
|
|
||||||
define command {
|
|
||||||
command_name check_livestatus_latency
|
|
||||||
command_line $USER3$/check_livestatus_latency.py -w $ARG1$ -c $ARG2$
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
### check_naf.py
|
### check_naf.py
|
||||||
|
@ -100,6 +57,7 @@ define command {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### check_sensors.py
|
### check_sensors.py
|
||||||
# check_command check_sensors!20000,20001!16:20!14:24!40:60!30:70
|
# check_command check_sensors!20000,20001!16:20!14:24!40:60!30:70
|
||||||
define command {
|
define command {
|
||||||
|
@ -118,19 +76,6 @@ define command {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
### check_xbps.py
|
|
||||||
# check_command check_xbps
|
|
||||||
define command {
|
|
||||||
command_name check_xbps
|
|
||||||
command_line $USER3$/check_xbps.py
|
|
||||||
}
|
|
||||||
# check_command check_xbps
|
|
||||||
define command {
|
|
||||||
command_name check_xbps_syncrepoindex
|
|
||||||
command_line $USER3$/check_xbps.py -S
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
### check_zypper.sh
|
### check_zypper.sh
|
||||||
# check_command check_zypper
|
# check_command check_zypper
|
||||||
define command {
|
define command {
|
||||||
|
@ -138,4 +83,3 @@ define command {
|
||||||
command_line $USER3$/check_zypper.sh
|
command_line $USER3$/check_zypper.sh
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4,12 +4,9 @@
|
||||||
#####################################################################
|
#####################################################################
|
||||||
# (c) 2010-2011 by Sven Velt and team(ix) GmbH, Nuernberg, Germany #
|
# (c) 2010-2011 by Sven Velt and team(ix) GmbH, Nuernberg, Germany #
|
||||||
# sv@teamix.net #
|
# sv@teamix.net #
|
||||||
# (c) 2016 by Sven Velt, Germany #
|
|
||||||
# sven-mymonplugins@velt.biz #
|
|
||||||
# #
|
# #
|
||||||
# This file is part of "velt.biz - My Monitoring Plugins" #
|
# This file is part of "team(ix) Monitoring Plugins" #
|
||||||
# a fork of "team(ix) Monitoring Plugins" in 2015 #
|
# URL: http://oss.teamix.org/projects/monitoringplugins/ #
|
||||||
# URL: https://gogs.velt.biz/velt.biz/MyMonPlugins/ #
|
|
||||||
# #
|
# #
|
||||||
# This file is free software: you can redistribute it and/or modify #
|
# This file is free software: you can redistribute it and/or modify #
|
||||||
# it under the terms of the GNU General Public License as published #
|
# it under the terms of the GNU General Public License as published #
|
||||||
|
@ -25,7 +22,7 @@
|
||||||
# along with this file. If not, see <http://www.gnu.org/licenses/>. #
|
# along with this file. If not, see <http://www.gnu.org/licenses/>. #
|
||||||
#####################################################################
|
#####################################################################
|
||||||
|
|
||||||
__version__ = '0.0.161124'
|
__version__ = '0.0.110715'
|
||||||
__all__ = ['MonitoringPlugin', 'SNMPMonitoringPlugin']
|
__all__ = ['MonitoringPlugin', 'SNMPMonitoringPlugin']
|
||||||
|
|
||||||
import datetime, optparse, os, re, sys
|
import datetime, optparse, os, re, sys
|
||||||
|
@ -69,8 +66,6 @@ class MonitoringPlugin(object):
|
||||||
|
|
||||||
|
|
||||||
def add_cmdlineoption(self, shortoption, longoption, dest, help, **kwargs):
|
def add_cmdlineoption(self, shortoption, longoption, dest, help, **kwargs):
|
||||||
if help == None:
|
|
||||||
help = optparse.SUPPRESS_HELP
|
|
||||||
self.__optparser.add_option(shortoption, longoption, dest=dest, help=help, **kwargs)
|
self.__optparser.add_option(shortoption, longoption, dest=dest, help=help, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
@ -212,7 +207,7 @@ class MonitoringPlugin(object):
|
||||||
check['tag'] = tag
|
check['tag'] = tag
|
||||||
check['returncode'] = returncode
|
check['returncode'] = returncode
|
||||||
check['output'] = output
|
check['output'] = output
|
||||||
check['multilineoutput'] = multilineoutput
|
check['multilineoutout'] = multilineoutput
|
||||||
check['perfdata'] = perfdata
|
check['perfdata'] = perfdata
|
||||||
check['target'] = target
|
check['target'] = target
|
||||||
|
|
||||||
|
@ -360,17 +355,9 @@ class MonitoringPlugin(object):
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
|
|
||||||
def verbose(self, level, output, prefix=None):
|
def verbose(self, level, output):
|
||||||
if level <= self.options.verbose:
|
if level <= self.options.verbose:
|
||||||
bol = 'V' + str(level) + ':' + ' ' * level
|
print 'V' + str(level) + ': ' + output
|
||||||
if prefix:
|
|
||||||
bol += '%s' % prefix
|
|
||||||
if type(output) in [str, unicode, ]:
|
|
||||||
print(bol + output)
|
|
||||||
elif type(output) in [list, ]:
|
|
||||||
print('\n'.join( ['%s%s' % (bol, l) for l in output] ) )
|
|
||||||
else:
|
|
||||||
print('%s%s' % (bol, output) )
|
|
||||||
|
|
||||||
|
|
||||||
def max_returncode(self, returncodes):
|
def max_returncode(self, returncodes):
|
||||||
|
@ -408,9 +395,6 @@ class MonitoringPlugin(object):
|
||||||
if type(multiline) == str:
|
if type(multiline) == str:
|
||||||
out += '\n' + multiline.replace('|', ' ')
|
out += '\n' + multiline.replace('|', ' ')
|
||||||
elif type(multiline) in [list, tuple]:
|
elif type(multiline) in [list, tuple]:
|
||||||
if type(multiline[0]) in [list, tuple]:
|
|
||||||
out += '\n' + '\n'.join([item for sublist in multiline for item in sublist]).replace('|', ' ')
|
|
||||||
else:
|
|
||||||
out += '\n' + '\n'.join(multiline).replace('|', ' ')
|
out += '\n' + '\n'.join(multiline).replace('|', ' ')
|
||||||
|
|
||||||
# Check if there's perfdata
|
# Check if there's perfdata
|
||||||
|
|
Loading…
Reference in a new issue