- Nagios - Switch Interface Traffic
- How To - Linux Server Performance
- Notes - Building New ESXi Host for iSCSI with Jumbo Frames
- Microsoft Office Version Numbers (XP, 2003, 2007, 2010)
- ESXi Custom Welcome Screen Text
- PHP - Read Data from a CSV file
- PHP - Input Variables from URL
- Fix - WMI Error EventID 10
- Fix - EventID 4007 DNS Server Error
- FIX - CHECK_ESX3.PL Script
Tweak: check_sql - Allow decimal values
- References:
While building another stored procedure that I execute by check_mssql in Nagios, I noticed a little hiccup. My stored procedure was returning a value like "85.67". When I executed the check_sql on the command line to run the procedure, I got a strange error...
# ./check_mssql -H mssqlclus1 -U username -P password -p 1433 -D database -w 20 -c 35 \ > -q "exec database.dbo.sp_GetDatabaseFileMetrics database,Used,Log,1" -W 90.00 -C 95.00 -s CHECK_MSSQL CRITICAL - Result is not numeric with result threshold defined (0.089992 seconds) \ | time=0.089992s;20;35
Now that does not make sense at all. I removed the -W and -C constraints and got:
CHECK_MSSQL OK - SQL Server result: 98.10 (0.122316 seconds) | time=0.122316s;20;35
I do not know about you, but "98.10" looks like a numeric to me. So I opened up the perl for the check_mssql and looked for the conditions that triggered the error. This was the regular expression it was evaluating to determine if the value returned was a numeric instead of a string.
$result =~ /^[-+]?\d+$/
Well, that does not do the trick if I have a value like "98.10". A value of "98" would have been fine. I freely admit I am no "code guru" by any means, but I figured I shoudl be able to come up with a fix for this. I copied the stored procedure to 'check_mssql2' and went to work. I created an OR condition to look for the integer regular expression or a decimal regular expression. There may be a better way, but this worked for me. I changed this:
!($result =~ /^[-+]?\d+$/)) {
to this:
!(($result =~ /^[-+]?\d+$/) || ($result =~ /^[-+]?\d+\.\d+$/))) {
I ran my tests and it worked great! A really useful link I found was this Regular Expression Validator at http://www.sweeting.org/mark/html/revalid.php. It also has some very handy reference info on the bottom which I found useful since I do not have the pleasure of writing them on a daily basis.
- Printer-friendly version
- Login to post comments
-
