nagiosenterprises / check_mssql_collection Goto Github PK
View Code? Open in Web Editor NEWSuite of Plugins For MSSQL Checks
Home Page: http://www.nagios.com
License: GNU General Public License v2.0
Suite of Plugins For MSSQL Checks
Home Page: http://www.nagios.com
License: GNU General Public License v2.0
Receive the following error on Ubuntu 14.04, Python 2.7.6:
$ /tmp/check_mssql_server.py -H $host -U $dbuser -P $dbpswd --lazywrites -w 20 -c 30
Traceback (most recent call last):
File "/tmp/check_mssql_server.py", line 464, in <module>
main()
File "/tmp/check_mssql_server.py", line 430, in main
execute_query(mssql, options, host)
File "/tmp/check_mssql_server.py", line 443, in execute_query
mssql_query.do(mssql)
File "/tmp/check_mssql_server.py", line 282, in do
self.run_on_connection(connection)
File "/tmp/check_mssql_server.py", line 269, in run_on_connection
self.query_result = cur.fetchone()[0]
TypeError: 'NoneType' object has no attribute '__getitem__'
However, time2connect works fine using the same credentials:
$ /tmp/check_mssql_server.py -H $host -U $dbuser -P $dbpswd --time2connect
OK: Time to connect was 0.0266668796539s|time=0.0266668796539s;;;;;
Using the check_mssql_server.py script there is one too many ; at the end of the performance data string, this causes problems with certain packages that process the performance data.
Here's the fix:
On line 246 remove the last ; so the line is as follows:
stdout = '%s%s|%s=%s%s;%s;%s;;' % (prefix, stdout, label, strresult, unit, options.warning or '', options.critical or '')
Hey guys
one questions, is possible use an AD User for monitor the SQLServer.
example
-p "DOMAIN\user" ?
The help should explain that Warning and Critical use the Nagios Plugin Threshold standards. I assume this is the case, the code doesn't have any comments and my Python knowledge isn't that great.
/usr/local/nagios/libexec/check_mssql_server.py --help
Usage: check_mssql_server.py -H hostname -U user -P password -T table --mode
xxxxxx
Nagios Plugin Information:
-w WARNING, --warning=WARNING
Specify warning range.
-c CRITICAL, --critical=CRITICAL
Specify critical range.
Same appears for check_mssql_database.py
.
sysperfinfo is depreciated.
Add to the plugin's output that the warning and critical thresholds levels are required.
Without them, the plugin will return an non-descriptive error.
./check_mssql_database.py -H mssql01.box293.local -U 'nagios' -P 'xxxxxx' -T 'Sample' -p 14333 --logcachehit --warning 0:95 --critical 0:97
<type 'exceptions.ZeroDivisionError'>
Caught unexpected error. This could be caused by your sysperfinfo not containing the proper entries for this query, and you may delete this service check.
Tested against an SQL 2016 server.
Perhaps a better error message or don't try and divide by zero.
Hi guys,
In the check_mssql_server.py file cpu label is lablel.
70 'lablel' : 'cpu',
Hello,
I have had an issue regarding result of --bufferhitratio and --cachehit results of the script check_mssql_server.py because the script doesn't contain the invert results code as the check_mssql_database.py does.
The result range wasn't correctly processed as the ideal value of buffer hit ratio is 100% and lower values mean that something goes wrong
eg. check_mssql_server.py -H db_ip -U user -P passwd --cachehit -w 90 -c 80 when the result was 85% returned Critical instead of Warning (c < 85 < w)
I have modified the script check_mssql_database.py inserting the part that inverts result range from check_mssql_database.py
For those who need this working I post bellow the code with quotation where are the modifications marked by
'>>>> for start of modification
<<<< for end of modification
Here you go:
file check_mssql_server.py:
231 def return_nagios(options, stdout='', result='', unit='', label=''):
232 >>>>>>>>>>>>>>>>>>>>>>>>
233 if int(options.critical) < int(options.warning):
234 invert = True
235 else:
236 invert = False
237
238 if is_within_range(options.critical, result, invert):
239 <<<<<<<<<<<<<<<<<<<<<<<
prefix = 'CRITICAL: '
240 code = 2
>>>>>>>>>>>>>>>>>>>>>>>>
241 elif is_within_range(options.warning, result, invert):
<<<<<<<<<<<<<<<<<<<<<<<
242 prefix = 'WARNING: '
243 code = 1
244 else:
245 prefix = 'OK: '
246 code = 0
247 strresult = str(result)
248 try:
249 stdout = stdout % (strresult)
250 except TypeError, e:
251 pass
252 stdout = '%s%s|%s=%s%s;%s;%s;;;' % (prefix, stdout, label, strresult, unit, options.warning or '', options.critical or '')
253 raise NagiosReturn(stdout, code)
>>>>>>>>>>>>>>>>>>>>>>>>
391 def is_within_range(nagstring, value, invert = False):
<<<<<<<<<<<<<<<<<<<<<<<
392 if not nagstring:
393 return False
394 import re
395 import operator
396 first_float = r'(?P<first>(-?[0-9]+(\.[0-9]+)?))'
397 second_float= r'(?P<second>(-?[0-9]+(\.[0-9]+)?))'
398 actions = [ (r'^%s$' % first_float,lambda y: (value > float(y.group('first'))) or (value < 0)),
399 (r'^%s:$' % first_float,lambda y: value < float(y.group('first'))),
400 (r'^~:%s$' % first_float,lambda y: value > float(y.group('first'))),
401 (r'^%s:%s$' % (first_float,second_float), lambda y: (value < float(y.group('first'))) or (value > float(y.group(' second')))),
402 (r'^@%s:%s$' % (first_float,second_float), lambda y: not((value < float(y.group('first'))) or (value > float(y.gr oup('second')))))]
403 for regstr,func in actions:
404 res = re.match(regstr,nagstring)
405 if res:
>>>>>>>>>>>>>>>>>>>>>>>>
406 if invert:
407 return not func(res)
408 else:
409 return func(res)
<<<<<<<<<<<<<<<<<<<<<<<
410 raise Exception('Improper warning/critical format.')
I hope it would save some of your time.
Tomas V.
Python 2 support is ending 1st January 2020. A simple 2to3
could be enough for this project to be able to run in Python 3.
Receive the following error on Ubuntu 14.04, Python 2.7.6
<type 'exceptions.TypeError'>
Caught unexpected error. This could be caused by your sysperfinfo not containing the proper entries for this query, and you may delete this service check.
After commenting out the final 4 lines of check_mssql_database.py, the exception is:
$ /tmp/check_mssql_database.py --hostname=$host --user=$dbuser --password=$dbpswd --table=dbadmin --datasize
Traceback (most recent call last):
File "/tmp/check_mssql_database.py", line 352, in <module>
main()
File "/tmp/check_mssql_database.py", line 318, in main
execute_query(mssql, options, host)
File "/tmp/check_mssql_database.py", line 331, in execute_query
mssql_query.do(mssql)
File "/tmp/check_mssql_database.py", line 167, in do
self.run_on_connection(connection)
File "/tmp/check_mssql_database.py", line 154, in run_on_connection
self.query_result = cur.fetchone()[0]
TypeError: 'NoneType' object has no attribute '__getitem__'
The solution mentioned in #1 (comment) does not help, even after installing cython:
$ pip freeze | egrep -i pymssql\|cython
Cython==0.20.2
pymssql==2.1.0
counters like totalpages not longer relevant
As per pymssql/pymssql#668, pymssql is now deprecated and won't be receiving any further updates.
In a very old version of this script I was able to check the transactions per second for all databases over the virtual table name _Total because the database name was hardcoded to 'master'
SELECT * FROM sys.sysperfinfo WHERE counter_name='Transactions/sec' AND instance_name='_Total'
In the actual version this is not longer possible because the table and the database are the same.
I changed the script according to my needs. Maybe someone else will find this useful as well.
Greetings
Barosch
According to Microsofts counter type definition (see https://blogs.msdn.microsoft.com/psssql/2013/09/23/interpreting-the-counter-values-from-sys-dm_os_performance_counters/) the "Average Wait Time (ms)" counter is of type PERF_AVERAGE_BULK, and should be measured from two samples.
Currently, as far as i understand, the "Average Wait Time" in the Script check_mssql_server.py, Version 2.1.0, 06/24/2016, is calculated from only one sample of counter "Average Wait Time (ms)" directly divided by counter "Average Wait Time Base". See attached picture current compared to expected:
Is there a chance that you could update the plugin so this metric is calculated more accurate?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.