Code Monkey home page Code Monkey logo

lausser / check_mssql_health Goto Github PK

View Code? Open in Web Editor NEW
38.0 12.0 27.0 557 KB

Wenn du dich für Plugins (oder OMD oder allgemein Monitoring) interessierst oder von deiner Installation erzählen willst...die Tradition der deutschsprachigen Monitoring-Workshops wird wiederbelebt: https://discord.gg/jDfPZ63FcJ A plugin, which checks various parameters of Microsoft SQL database servers.

Home Page: http://labs.consol.de/nagios/check_mssql_health

License: GNU General Public License v2.0

PHP 12.05% Shell 8.78% Perl 73.36% Awk 0.57% Makefile 1.44% M4 1.93% TSQL 1.88%

check_mssql_health's Introduction

check_mssql_health Nagios Plugin README

Buy Me A Coffee

This plugin is used to monitor a variety of MS SQL Server database metrics.

  • For instructions on installing this plugin for use with Nagios, see below. In addition, generic instructions for the GNU toolchain can be found in the INSTALL file.

  • For major changes between releases, read the CHANGES file.

  • For information on detailed changes that have been made, read the Changelog file.

  • This plugin is self documenting. All plugins that comply with the basic guidelines for development will provide detailed help when invoked with the '-h' or '--help' options.

You can check for the latest plugin at: http://www.consol.com/opensource/nagios/check-mssql-health

The documentation in this README covers only the most common features. To view the full documentation and examples, go to http://www.consol.com/opensource/nagios/check-mssql-health or http://www.consol.de/opensource/nagios/check-mssql-health

Send mail to [email protected] for assistance. Please include the OS type/version and the Perl DBI/DBD version that you are using. Also, run the plugin with the '-vvv' option and provide the resulting version information. Of course, there may be additional diagnostic information required as well. Use good judgment.

For patch submissions and bug reports, please send me a mail. You can also find me at http://www.nagios-portal.de

Requirements

You need to install the Perl module DBD::Sybase first. It is very important to set the protocol version in /etc/freetds.conf to 8.0 Otherwise your database password will be visible on the network.

[global] # TDS protocol version tds version = 8.0

How to "compile" the check_mssql_health script.

  1. Run the configure script to initialize variables and create a Makefile, etc.

    ./configure --prefix=BASEDIRECTORY --with-nagios-user=SOMEUSER --with-nagios-group=SOMEGROUP --with-perl=PATH_TO_PERL --with-statefiles-dir=STATE_PATH

    a) Replace BASEDIRECTORY with the path of the directory under which Nagios is installed (default is '/usr/local/nagios') b) Replace SOMEUSER with the name of a user on your system that will be assigned permissions to the installed plugins (default is 'nagios') c) Replace SOMEGRP with the name of a group on your system that will be assigned permissions to the installed plugins (default is 'nagios') d) Replace PATH_TO_PERL with the path where a perl binary can be found. Besides the system wide perl you might have installed a private perl just for the nagios plugins (default is the perl in your path). e) Replace STATE_PATH with the directory where you want the script to write state files which transport information from one run to the next. (default is /tmp)

    Simply running ./configure will be sufficient to create a check_mssql_health script which you can customize later.

  2. "Compile" the plugin with the following command:

    make

    This will produce a "check_mssql_health" script. You will also find a "check_mssql_health.pl" which you better ignore. It is the base for the compilation filled with placeholders. These will be replaced during the make process.

  3. Install the compiled plugin script with the following command:

    make install

    The installation procedure will attempt to place the plugin in a 'libexec/' subdirectory in the base directory you specified with the --prefix argument to the configure script.

  4. Verify that your configuration files for Nagios contains the correct paths to the new plugin.

Command line parameters

--hostname= This is the hostname or the ip-address.

--port= This is the port where an instance listens. Default: 1433

--server= This can be used instead of a hostname/port combination. The servername given here is used for a lookup in /etc/freetds.conf

--user= This is the user which reads the system tables.

--password= This is the user's password.

--mode= This parameter tells the plugin what it should check. The list of known modes may grow frequently. Please look at http://www.consol.com/opensource/nagios/check-mssql-health for a list of features.

--database= Database-related modes check all databases in one run by default. If only a single database should be checked, use this parameter.

--warning= If the metric is out of this range, the plugin returns a warning.

--critical= If the metric is out of this range, the plugin returns a critical.

Connecting

You can call the plugin with "--hostname [--port ]" This bypasses the freetds.conf file and directly connects you to whatever is listening on port 1433 or This will surely be the default instance. If you have different (named) instances listening on the same port, you need to edit /etc/freetds.conf

[dbsrv1instance01] host = 192.168.1.1 port = 1433 instance = instance01

[dbsrv1instance02] host = 192.168.1.1 port = 1433 instance = instance02

....

Then you call the plugin with "--server dbsrv1instance02" for example.

Testing the connection

use DBI; use strict;

my $username = "xxxxx"; my $password = "xxxxx"; my $dsn = "DBI:Sybase:;host=127.0.1.1;port=1433"; #my $dsn = "DBI:Sybase:;server=dbsrv_in_freetds_conf"; if (my $dbh = DBI->connect( $dsn, $username, $password, { RaiseError => 1, AutoCommit => 0, PrintError => 1 })) { printf "connection succeeded\n"; } else { printf "connection failed\n"; }

In Sybase, login as sa and switch on auditing: sp_configure "log audit logon success", 1 sp_configure "log audit logon failure", 1 go shutdown go

Then startup again startserver -f /opt/sybase/ASE-15_0/install/RUN_backup_server -f /opt/sybase/ASE-15_0/install/RUN_ase_server -f /opt/sybase/ASE-15_0/install/RUN_monitor_server


That's it. If you have any problems or questions, feel free to send mail to [email protected]

check_mssql_health's People

Contributors

galipolix avatar julthomas avatar lausser avatar tectumopticum avatar ulikl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

check_mssql_health's Issues

Even with --offlineok the mode "database-free" stops

check_mssql_health -v --server=psrsql06 --username=dbamaint --password=xxxxxxx --mode database-free --offlineok

Thu Feb 11 15:01:18 2016: bumm DBD::Sybase::st execute failed: Server message number=942 severity=14 state=4 line=2 server=PSRSQL06 text=Database 'M4MIND' cannot be opened because it is offline. at /etc/nagios3/plugins/check_mssql_health line 3397.
Thu Feb 11 15:01:18 2016: stderr DBD::Sybase::st execute failed: Server message number=942 severity=14 state=4 line=2 server=PSRSQL06 text=Database 'M4MIND' cannot be opened because it is offline. at /etc/nagios3/plugins/check_mssql_health line 3334.
DBD::Sybase::st execute failed: Server message number=942 severity=14 state=4 line=2 server=PSRSQL06 text=Database 'M4MIND' cannot be opened because it is offline. at /etc/nagios3/plugins/check_mssql_health line 3397.
Use of uninitialized value in numeric gt (>) at /etc/nagios3/plugins/check_mssql_health line 1319.
Use of uninitialized value in subtraction (-) at /etc/nagios3/plugins/check_mssql_health line 1330.
Use of uninitialized value in division (/) at /etc/nagios3/plugins/check_mssql_health line 1331.
Illegal division by zero at /etc/nagios3/plugins/check_mssql_health li

Backup Status alerts on multiple Availability Groups when split over 2 or more hosts

Hi

We have a MSSQL Cluster with 2 availability groups, where each node runs an availability group. When we run the any of the following checks "database-logbackup-age" or "database-backup-age" we get critical status alerts from the passive nodes about the backup status of the databases in the availability groups they don't own.

Is there any easy fix for this? is any other information needed?

Regards

database-*file-auto-growths not working

It's reporting 0 regardless of autogrowth events happening. Here's an example using database-logfile-auto-growths, tempdb has had 11 log file growth events in the time period, the output is showing 0, but you can see the 11 count in the debugging output:

Thu Dec  8 10:48:44 2016: SQL:
 SELECT @@VERSION 
ARGS:
$VAR1 = [];


Thu Dec  8 10:48:44 2016: RESULT:
$VAR1 = [
          'Microsoft SQL Server 2014 (SP2-CU2-GDR) (KB3194718) - 12.0.5532.0 (X64) 
	Oct  5 2016 20:28:25 
	Copyright (c) Microsoft Corporation
	Standard Edition (64-bit) on Windows NT 6.3 <X64> (Build 9600: ) (Hypervisor)
'
        ];


Thu Dec  8 10:48:44 2016: AUTOLOAD Classes::MSSQL::DBI::override_opt

Thu Dec  8 10:48:44 2016: AUTOLOAD Classes::MSSQL::DBI::check_messages

Thu Dec  8 10:48:44 2016: SQL:
 SELECT SYSTEM_USER 
ARGS:
$VAR1 = [];


Thu Dec  8 10:48:44 2016: RESULT:
$VAR1 = [
          'adm\\nagios'
        ];


Thu Dec  8 10:48:44 2016: SQL:
 SELECT @@SERVICENAME 
ARGS:
$VAR1 = [];


Thu Dec  8 10:48:44 2016: RESULT:
$VAR1 = [
          'MSSQLSERVER'
        ];


Thu Dec  8 10:48:44 2016: SQL:
 SELECT CAST(COALESCE(SERVERPROPERTY('IsHadrEnabled'), 0) as int) 
ARGS:
$VAR1 = [];


Thu Dec  8 10:48:44 2016: RESULT:
$VAR1 = [
          0
        ];


Thu Dec  8 10:48:44 2016: AUTOLOAD Classes::MSSQL::DBI::analyze_and_check_database_subsystem

Thu Dec  8 10:48:44 2016: SQL:

        SELECT name FROM master.sys.databases
      
ARGS:
$VAR1 = [];


Thu Dec  8 10:48:44 2016: RESULT:
$VAR1 = [
          [
            'master'
          ],
          [
            'tempdb'
          ],
          [
            'model'
          ],
          [
            'msdb'
          ],
          [
            'DB_service'
          ],
          [
            'DB_service_test2'
          ]
        ];


Thu Dec  8 10:48:44 2016: AUTOLOAD Classes::MSSQL::Component::DatabaseSubsystem::Database::override_opt

Thu Dec  8 10:48:44 2016: SQL:

          DECLARE @path NVARCHAR(1000)
          SELECT
              @path = Substring(PATH, 1, Len(PATH) - Charindex('\', Reverse(PATH))) + '\log.trc'
          FROM
              sys.traces
          WHERE
              id = 1
          SELECT
              databasename, COUNT(*)
          FROM
              ::fn_trace_gettable(@path, 0)
          INNER JOIN
              sys.trace_events e
          ON
              eventclass = trace_event_id
          -- INNER JOIN
          --    sys.trace_categories AS cat
          -- ON
          --     e.category_id = cat.category_id
          WHERE
              e.name IN( 'Log File Auto Grow' ) AND datediff(Minute, starttime, current_timestamp) < ?
          GROUP BY
              databasename
      
ARGS:
$VAR1 = [
          '10000'
        ];


Thu Dec  8 10:48:44 2016: RESULT:
$VAR1 = [
          [
            'tempdb',
            11
          ]
        ];


Thu Dec  8 10:48:44 2016: $self->{components}->{database_subsystem} = Classes::MSSQL::Component::DatabaseSubsystem->new()
Thu Dec  8 10:48:44 2016: AUTOLOAD Classes::MSSQL::DBI::check_database_subsystem

Thu Dec  8 10:48:44 2016: AUTOLOAD Monitoring::GLPlugin::DB::SUPER::set_thresholds

Thu Dec  8 10:48:44 2016: AUTOLOAD Classes::MSSQL::Component::DatabaseSubsystem::Database::check_thresholds

Thu Dec  8 10:48:44 2016: AUTOLOAD Monitoring::GLPlugin::DB::SUPER::set_thresholds

Thu Dec  8 10:48:44 2016: AUTOLOAD Classes::MSSQL::Component::DatabaseSubsystem::Database::check_thresholds

Thu Dec  8 10:48:44 2016: AUTOLOAD Monitoring::GLPlugin::DB::SUPER::set_thresholds

Thu Dec  8 10:48:44 2016: AUTOLOAD Classes::MSSQL::Component::DatabaseSubsystem::Database::check_thresholds

Thu Dec  8 10:48:44 2016: AUTOLOAD Monitoring::GLPlugin::DB::SUPER::set_thresholds

Thu Dec  8 10:48:44 2016: AUTOLOAD Classes::MSSQL::Component::DatabaseSubsystem::Database::check_thresholds

Thu Dec  8 10:48:44 2016: AUTOLOAD Monitoring::GLPlugin::DB::SUPER::set_thresholds

Thu Dec  8 10:48:44 2016: AUTOLOAD Classes::MSSQL::Component::DatabaseSubsystem::Database::check_thresholds

Thu Dec  8 10:48:44 2016: AUTOLOAD Monitoring::GLPlugin::DB::SUPER::set_thresholds

Thu Dec  8 10:48:44 2016: AUTOLOAD Classes::MSSQL::Component::DatabaseSubsystem::Database::check_thresholds

[DATABASESUBSYSTEM]
info: checking databases

[DATABASE]
autogrowshrink: 0
full_name: tempdb
growshrinkinterval: 10000
name: tempdb

[DATABASE]
autogrowshrink: 0
full_name: msdb
growshrinkinterval: 10000
name: msdb

[DATABASE]
autogrowshrink: 0
full_name: model
growshrinkinterval: 10000
name: model

[DATABASE]
autogrowshrink: 0
full_name: master
growshrinkinterval: 10000
name: master

[DATABASE]
autogrowshrink: 0
full_name: DB_service_test2
growshrinkinterval: 10000
name: DB_service_test2

[DATABASE]
autogrowshrink: 0
full_name: DB_service
growshrinkinterval: 10000
name: DB_service

[DATABASE]
count: 11
full_name: tempdb
name: tempdb

Thu Dec  8 10:48:44 2016: AUTOLOAD Classes::MSSQL::DBI::reduce_messages_short

Thu Dec  8 10:48:44 2016: AUTOLOAD Classes::MSSQL::DBI::check_messages

Thu Dec  8 10:48:44 2016: AUTOLOAD Classes::MSSQL::DBI::check_messages

Thu Dec  8 10:48:44 2016: AUTOLOAD Classes::MSSQL::DBI::nagios_exit

OK - tempdb had 0 log file auto grow events in the last 10000 minutes, msdb had 0 log file auto grow events in the last 10000 minutes, model had 0 log file auto grow events in the last 10000 minutes, master had 0 log file auto grow events in the last 10000 minutes, DB_service_test2 had 0 log file auto grow events in the last 10000 minutes, DB_service had 0 log file auto grow events in the last 10000 minutes
checking databases
Thu Dec  8 10:48:44 2016: try to clean up command and result files
Thu Dec  8 10:48:44 2016: try to clean up command and result files
Thu Dec  8 10:48:44 2016: try to clean up command and result files
Thu Dec  8 10:48:44 2016: try to clean up command and result files
Thu Dec  8 10:48:44 2016: try to clean up command and result files
Thu Dec  8 10:48:44 2016: try to clean up command and result files
Thu Dec  8 10:48:44 2016: try to clean up command and result files
Thu Dec  8 10:48:44 2016: try to clean up command and result files
Thu Dec  8 10:48:44 2016: try to clean up command and result files

Monitoring Sybase Replication Server?

Hi,

I've made an uggly patch to monitor our Sybase Replication Server. Is it possible to include it in official version?

The main patch is:

  } elsif ($params{mode} =~ /^server::replication::status/) {
      my @health = $self->{handle}->fetchrow_array(q{
        ADMIN HEALTH
      });
      my $status = $health[2];
      if (! defined $status) {
        $self->add_nagios_unknown("unable to get replication info");
      } else {
        if ($status eq "HEALTHY") {
          $self->add_nagios_ok(sprintf "replication status: %s, all threads are executing as expected", $status);
        } elsif ($status eq "SUSPECT") {
          $self->add_nagios_critical(sprintf "replication status: %s, not all threads are executing as expected", $status);
        } else {
          $self->add_nagios_unknown(sprintf "replication status: %s", $status);
        }
      }

See there for the command: http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.help.rs_15.0.refman/html/refman/X15699.htm

The ugly patch part is to disable product detection just after the dbconnect (Sybase Replication Server is not a SQL database, so no SELECT statements).

Database not accepting connections - Because of "Auto Close"

Hello,

it seems that the mode "database-online" is not functional if the database option "auto close" is set. I get this message "DBNAME is online but not accepting connections". Connecting to this database works fine and after doing any select query the state changes to "OK" for a certain time.

This is the query used in the script to check if the database is accepting connections: SELECT name, state, state_desc, collation_name FROM master.sys.databases
If collation_name is NULL the check jumps to this error. But in the offical documentation of Microsoft the variable state NULL means "Database is not online or AUTO_CLOSE is set to ON and the database is closed." Wouldn't it be better to check it with the state column in master.sys.databases?

Regards
Marcel

Sybase mode not working with EPN

Hi,

I'm using check_mssql_health to monitor Sybase databases and created check_sybase_health as suggested somewhere.

It works fine in the CLI but these lines are not working when using EPN (Embedded Perl) mode:

    if (basename($0) =~ /_sybase_/) {
      $self->{dbi_options}->{syb_chained_txn} = 1;
      $self->{dsn} .= sprintf ";tdsLevel=CS_TDS_42";
    }

I see only two solution: either add a Sybase mode in the plugin options (perhaps something to override product detected: --product=ASE|MSSQL), or disable EPN in the plugin.

DBD:SYBASE Change to BBDD Mysql

Hello everyone

I find the following problem when I run the plugin from the command line, I return the correct values, when I implement it in my monitoring system "ICINGA2" gives me a problem.

image

I understand that you have to create your own DBD: Sybase, but it would be possible to use the data I have hosted in my MySQL database

Thank you, I hope answer

Regards!

Can't locate object method "requires_version" via package "self"

When trying to use "cpu-busy" or "io-busy" mode on an old database (2000, version 8) and no rights to execute "sp_monitor", I get an error:

Can't locate object method "requires_version" via package "self" (perhaps you forgot to load "self"?) at /usr/local/nagios/libexec/check_mssql_health line 4864.

Is there a missing function on GLPlugin?

Missing installation info on Monitoring::GLPlugin

Hi there,
the installation description (https://labs.consol.de/nagios/check_mssql_health/#installation) mentions the Perl module DBD::Sybase but it lacks info regarding your own Perl module:

Can't locate Monitoring/GLPlugin/Commandline/Extraopts.pm in @inc (you may need to install the Monitoring::GLPlugin::Commandline::Extraopts module) (@inc contains: /etc/perl /usr/local/lib/perl/5.18.2 /usr/local/share/perl/5.18.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.18 /usr/share/perl/5.18 /usr/local/lib/site_perl .) at /opt/check_mssql_health/libexec/check_mssql_health line 83.

I found it in CPAN:
CPAN_FILE L/LA/LAUSSER/Monitoring-GLPlugin-2.3.tar.gz

Maybe you want to add this requirement to your description.

Unable to connect when not utilizing freetds.conf for connection information

When trying to use the plugin without specifying the connection information in /etc/freetds.conf and using the flags "--hostname" and "--port" instead to remove the dependency on the configuration file, the plugin fails to connect to the database server.

Microsoft SQL Server 2012
CentOS release 6.7 (Final)
freetds-0.91-2.el6.x86_64
check_mssql_health (1.6.2.3)

The below error is displayed:
./check_mssql_health --hostname ref-sql-03.local --port 1433 --username "DEV\mon" --password "666-passWOR-D" -m database-online --name msdb CRITICAL - cannot connect to ref-sql-03.local. DBI connect(';host=ref-sql-03.local;port=1433','DEV\mon',...) failed: OpenClient message: LAYER = (0) ORIGIN = (0) SEVERITY = (78) NUMBER = (44) Server , database Message String: Server name not found in configuration files. OpenClient message: LAYER = (0) ORIGIN = (0) SEVERITY = (78) NUMBER = (45) Server , database Message String: Unknown host machine name. at /opt/plugins/check_mssql_health line 3273

The error message reports that the server name isn't found in configuration files, but that exactly what I want to avoid.

possible improvement

Hi,

It would be a good thing to add a parameter that checks how many databases were found and compares it to how many databases were requested. It happened (not only once) that some databases were missing and everybody thought they were OK 😆

E.g.:
I want to find out database transactions

/usr/local/nagios/libexec/check_mssql_health --server server --username nagios --password blabla --mode transactions --warning 10 --critical 15 --name='^((master|tempdb|testdatabase))' --regexp --commit
OK - tempdb has 0.0000 transactions / sec, master has 0.0000 transactions / sec | tempdb_transactions_per_sec=0.0000;10;15 master_transactions_per_sec=0.0000;10;15

As it can be seen, I submitted 3 databases for check, but got results for only 2 of them.

I think it would be a good improvement to double check how many databases were requested and how many databases were found and give a Warn / Crit message saying something like: you requested 7 databases but only 5 were found.

Transaction Error when running check_mssql_health

I am getting the following transaction error for all modes. It is the same with other DB servers. Please advice

[nagios@nagiosprodxi1 libexec]$ ./check_mssql_health -V
check_mssql_health (1.5.20.5)
This nagios plugin comes with ABSOLUTELY NO WARRANTY. You may redistribute
copies of this plugin under the terms of the GNU General Public License.

[nagios@nagiosprodxi1 libexec]$ ./check_mssql_health --server CRDE_SG_UAT --username appsmonitor --password abc1* --mode connection-time --warning 5 --critical 10
OK - 0.17 seconds to connect as appsmonitor | connection_time=0.17;5;10
DBD::Sybase::db DESTROY failed: Server message number=3903 severity=16 state=1 line=2 server=BHQKPK200020 text=The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION. Server message number=3903 severity=16 state=1 line=2 server=BHQKPK200020 text=The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION. during global destruction.
(in cleanup) DBD::Sybase::db DESTROY failed: Server message number=3903 severity=16 state=1 line=2 server=BHQKPK200020 text=The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION. Server message number=3903 severity=16 state=1 line=2 server=BHQKPK200020 text=The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION. during global destruction.

doesn't support Azure MSSQL

(might be feature not a bug)

The checks don't fail - just give an "OK"
If I break the SQL out & run directly on the Azure DB I get:

Reference to database and/or server name in 'SQL_ADMIN.dbo.current_alerts_dc' is not supported in this version of SQL Server.

connected_users should be connected_sessions

The connected_users query are evaluating all users and sessions there is no distinct to filter out double user datas. I think connected_users should be renamend to connected_sessions or it should be two functions (connected_users with a distinct function and a connected_sessions).

e. g.:

SELECT
count (distinct loginame)
......

"Server name not found in configuration files" when using --hostname

I'm unable to connect to MS SQL when using the --hostname switch:

$ check_mssql_health -v --hostname=redacted --username=redacted --password=redacted --mode=connection-time
CRITICAL - cannot connect to redacted. DBI connect(';host=redacted;port=1433','redacted',...) failed: OpenClient message: LAYER = (0) ORIGIN = (0) SEVERITY = (78) NUMBER = (44)
Server , database
Message String: Server name not found in configuration files.
OpenClient message: LAYER = (0) ORIGIN = (0) SEVERITY = (78) NUMBER = (45)
Server , database
Message String: Unknown host machine name.
 at /usr/local/bin/check_mssql_health line 3192.

Tue Aug 12 12:51:54 2014: disconnecting DBD without handle

However, I am able to connect when using the --server switch:

$ check_mssql_health --server=redacted --username=redacted --password=redacted --mode=connection-time
OK - 0.06 seconds to connect as redacted | connection_time=0.06;1;5

tsql successfully connects using both the -H and -S switches:

$ TDSVER=8.0 tsql -H redacted -U redacted -P redacted -p 1433
locale is "en_US.UTF-8"
locale charset is "UTF-8"
using default charset "UTF-8"
1> quit

$ TDSVER=8.0 tsql -S redacted -U redacted -P redacted
locale is "en_US.UTF-8"
locale charset is "UTF-8"
using default charset "UTF-8"
1> quit

mssql_miniscript.pl fails in the same manner as reported here.

Versions

  • Ubuntu 14.04 (this has also been reported for CentOS 6.3)
  • Perl v5.18.2
  • FreeTDS 0.91-5
  • check_mssql_health 1.5.20.6

Not working in SQLServer 2016

Hi,

I've been trying the plugin with SQLServer 2016 but I've dettected some problems like the above one.
Is the plugin compatible with SQLServer 2016 version?

/usr/lib64/nagios/plugins/contrib/check_mssql_health-2.6.4.14/libexec/check_mssql_health --server=10.14.0.224 --username=cacti --password=XXXX --mode full-scans --warning=100 --critical=500 --port=1433 -t 15 --commit
CRITICAL - DBD::Sybase::st DESTROY failed: Server message number=8179 severity=16 state=8 line=1 server=COMPENSA46 text=Could not find prepared statement with handle 0. , unable to aquire counter data SQLServer:Access Methods Full Scans/sec

/usr/lib64/nagios/plugins/contrib/check_mssql_health-2.6.4.14/libexec/check_mssql_health --server=10.14.0.224 --username=cacti --password=XXXXXXX --mode transactions --warning=10000 --critical=50000 --port=1433 -t 10
CRITICAL - DBD::Sybase::st execute failed: Server message number=262 severity=14 state=1 line=2 server=COMPENSA46 text=VIEW DATABASE STATE permission denied in database 'master'. Server message number=297 severity=16 state=1 line=2 server=COMPENSA46 text=The user does not have permission to perform this action.
DBD::Sybase::db DESTROY failed: Server message number=262 severity=14 state=1 line=2 server=COMPENSA46 text=VIEW DATABASE STATE permission denied in database 'master'. Server message number=297 severity=16 state=1 line=2 server=COMPENSA46 text=The user does not have permission to perform this action. Server message number=3903 severity=16 state=1 line=2 server=COMPENSA46 text=The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION. Server message number=3903 severity=16 state=1 line=2 server=COMPENSA46 text=The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION. during global destruction.

Database offline/deleted but Check status OK

We are currently running a remote MSSQL monitoring with the check (check_mssql_health).
Our database team noticed that this check does not notice when a database is offline or deleted. Although the check delivers a different output, it remains in the OK status and therefore does not send any notifications.
Output if everything is ok: OK - Database is online and accepting connections

Output if database is offline / deleted: OK
Is there a fix for this, if necessary, so that such cases are also recognized in the future and an alarm is generated?

SQL Server Express 2014 check_mssql_health with on LibreNMS

Hello,

I just installed check_mssql_health on LibreNMS running with Ubuntu 16.04 and I have a little problem.
With the commande line the plugin works fine, i get the correct result. Exemple testing connceted users.
I get this result :

root@srv-loki:/usr/lib/nagios/plugins# ./check_mssql_health --server MSSQLSERVER --username 'premtim\root' --password 'Super2010' --mode connection-time --commit
OK - 0.01 seconds to connect as premtim\root | 'connection_time'=0.01;1;5;;

I tried different --mode like list all databases or current users and have the same result.

But when I try to use the check_mssql_health on LibreNMS I get the instructions info.
Check the image :

capture

Thank you

need encoding...

We need Encoding for the check_mssql_health . ( TLS 1.xx or higher)..
Wenn we use the check in the Moment we get this Failure Message :

Encryption` is required to connect to this server but the client library does not support encryption; the connection has been closed. Please upgrade your client library. [CLIENT: 10.92.x.x]

Adaptive Server connection failed with V2.6.4.13

CRITICAL - DBI connect(';server=192.168.3.41','nagios',...) failed: Server message number=18456 severity=14 state=1 line=1 server=TEST01 text=Login failed for user 'nagios'. OpenClient message: LAYER = (0) ORIGIN = (0) SEVERITY = (78) NUMBER = (34)
Server 192.168.53.41, database
Message String: Adaptive Server connection failed
at ./check_mssql_health-2.6.4.13 line 6419.

Running V2.6.4.12 with the same parameters on the same machines works fine.

Target machine:
Microsoft SQL Server 2012 (SP2-GDR) (KB3194719) - 11.0.5388.0 (X64)
Sep 23 2016 16:56:29
Copyright (c) Microsoft Corporation
Standard Edition (64-bit) on Windows NT 6.1 (Build 7601: Service Pack 1) (Hypervisor)

BTW: We are using SQL Server authentication all the time

Read query from file with SQL Mode

In some cases is necessary to run query with a long text that simply will not fit on the command prompt (or it looks very ugly).
It is possible to pass a filename and read the query from it rather than the query itself?

configure does not exist

The README states that only the configure script must be executed.
This is not part of the repo, so how to handle it then?
Best,

sql-runtime does not work on v 2.6.4.10

**We just downloaded last version from Console Labs site. The other modes we use seem to work fine except --mode sql-runtime, which gives the output below.
It always generate 0s as sql_runtime in perfdata.

The former old version 1.5.19.3 gives a different output, see below. But the runtime seems to be correct.**

What is wrong ?
Thx

./check_mssql_health --server INSTANCE --username User --password Password --mode sql-runtime -t 90 -v -v -v
Thu May 11 17:15:14 2017: SQL:
SELECT @@Version
ARGS:
$VAR1 = [];

Thu May 11 17:15:14 2017: RESULT:
$VAR1 = [
'Microsoft SQL Server 2008 R2 (SP2) - 10.50.4000.0 (X64)
Jun 28 2012 08:36:30
Copyright (c) Microsoft Corporation
Standard Edition (64-bit) on Windows NT 6.1 (Build 7601: Service Pack 1) (Hypervisor)
'
];

Thu May 11 17:15:14 2017: AUTOLOAD Classes::MSSQL::DBI::override_opt

Thu May 11 17:15:14 2017: AUTOLOAD Classes::MSSQL::DBI::check_messages

Thu May 11 17:15:14 2017: SQL:
SELECT SYSTEM_USER
ARGS:
$VAR1 = [];

Thu May 11 17:15:14 2017: RESULT:
$VAR1 = [
'GOPSAMonitoring'
];

Thu May 11 17:15:14 2017: SQL:
SELECT @@SERVICENAME
ARGS:
$VAR1 = [];

Thu May 11 17:15:14 2017: RESULT:
$VAR1 = [
'RIMSES_PROD'
];

Thu May 11 17:15:14 2017: SQL:
SELECT CAST(COALESCE(SERVERPROPERTY('IsHadrEnabled'), 0) as int)
ARGS:
$VAR1 = [];

Thu May 11 17:15:14 2017: RESULT:
$VAR1 = [
0
];

Thu May 11 17:15:14 2017: SQL:

ARGS:
$VAR1 = [];

Thu May 11 17:15:14 2017: RESULT:
$VAR1 = [];

Thu May 11 17:15:14 2017: stderr Use of uninitialized value $sql in sprintf at ./check_mssql_health line 6382.
Use of uninitialized value in subroutine entry at /usr/local/lib64/perl5/DBD/Sybase.pm line 138.
Use of uninitialized value $sql in pattern match (m//) at ./check_mssql_health line 6390.
Use of uninitialized value $sql in pattern match (m//) at ./check_mssql_health line 6390.

Thu May 11 17:15:14 2017: AUTOLOAD Monitoring::GLPlugin::DB::check_messages

Thu May 11 17:15:14 2017: AUTOLOAD Monitoring::GLPlugin::DB::SUPER::set_thresholds

Thu May 11 17:15:14 2017: AUTOLOAD Monitoring::GLPlugin::DB::check_thresholds

Use of uninitialized value in sprintf at ./check_mssql_health line 2804.
Thu May 11 17:15:14 2017: AUTOLOAD Monitoring::GLPlugin::DB::add_perfdata

Thu May 11 17:15:14 2017: AUTOLOAD Monitoring::GLPlugin::DB::check_messages

Thu May 11 17:15:14 2017: AUTOLOAD Monitoring::GLPlugin::DB::check_messages

Thu May 11 17:15:14 2017: AUTOLOAD Monitoring::GLPlugin::DB::nagios_exit

WARNING - Use of uninitialized value $sql in sprintf at ./check_mssql_health line 6382.
Use of uninitialized value in subroutine entry at /usr/local/lib64/perl5/DBD/Sybase.pm line 138.
Use of uninitialized value $sql in pattern match (m//) at ./check_mssql_health line 6390.
Use of uninitialized value $sql in pattern match (m//) at ./check_mssql_health line 6390.

, 0.00 seconds to execute
| 'sql_runtime'=0.00s;1;5;;
Thu May 11 17:15:14 2017: try to clean up command and result files_

./check_mssql_health-1.5.19.3 --server DBSRV-000045 --username GOPSAMonitoring --password 'InspiretheNext2015!' --mode sql-runtime -t 90 -v -v -v
Thu May 11 17:21:42 2017: SQL:
SELECT @@Version
ARGS:
$VAR1 = [];

Thu May 11 17:21:42 2017: RESULT:
$VAR1 = [
'Microsoft SQL Server 2008 R2 (SP2) - 10.50.4000.0 (X64)
Jun 28 2012 08:36:30
Copyright (c) Microsoft Corporation
Standard Edition (64-bit) on Windows NT 6.1 (Build 7601: Service Pack 1) (Hypervisor)
'
];

Thu May 11 17:21:42 2017: SQL:
SELECT SYSTEM_USER
ARGS:
$VAR1 = [];

Thu May 11 17:21:42 2017: RESULT:
$VAR1 = [
'GOPSAMonitoring'
];

Thu May 11 17:21:42 2017: SQL:
SELECT @@SERVICENAME
ARGS:
$VAR1 = [];

Thu May 11 17:21:42 2017: RESULT:
$VAR1 = [
'RIMSES_PROD'
];

Thu May 11 17:21:42 2017: SQL:

ARGS:
$VAR1 = [];

Thu May 11 17:21:42 2017: RESULT:
$VAR1 = [];

Thu May 11 17:21:42 2017: stderr Use of uninitialized value $sql in sprintf at ./check_mssql_health-1.5.19.3 line 3098.
Use of uninitialized value in subroutine entry at /usr/local/lib64/perl5/DBD/Sybase.pm line 138.
Use of uninitialized value $sql in pattern match (m//) at ./check_mssql_health-1.5.19.3 line 3106.
Use of uninitialized value $sql in pattern match (m//) at ./check_mssql_health-1.5.19.3 line 3106.
Use of uninitialized value $params{"selectname"} in sprintf at ./check_mssql_health-1.5.19.3 line 2206.

OK - 0.00 seconds to execute | sql_runtime=0.0003;1;5

**ePN /usr/lib/nagios/plugins/check_mssql_health: "Use of uninitialized value in numeric gt (>) at (eval 1) line 1284,".

I'm having issues with mode "database-free", in some instances it gives me error. Even debugging nagios i can't understeand the error.

**ePN /usr/lib/nagios/plugins/check_mssql_health: "Use of uninitialized value in numeric gt (>) at (eval 1) line 1284,".

If i run in shell it works ok.

/etc/nagios3/plugins/check_mssql_health --server=xxxxxxxx --username=xxx--password=xxxx--mode database-free --offlineok

OK - database tempdb has 99.97% free space left, database msdb has 99.54% free space...

No connect to MSSQL Server 2022

Hello,

we want to use check_mssql_health for a mssql 2022 Server.

At first we try with our installed freetds 1.1.1 with mssql_health 2.7.2,

We got this message:
CRITICAL - DBI connect(';host=Host.domain.de;port=50100;encryptPassword=1','username',...) failed: OpenClient messag ORIGIN = (0) SEVERITY = (78) NUMBER = (44) Server , database Message String: Server name not found in configuration files. OpenClient message: LAYER = (0) ORIGIN = (0) SEVERITY = (78) NUMBER = (34) Server , database Message String: Adaptive Server connection failed at /usr/lib64/nagios/plugins_contrib/check_mssql_health line 6601.
Okay, with freetds 1.1.1 we're not able to connect against the server to,
so we updated to freetds 1.3.17 with openssl 1.1.1o and we get the last mssql_health_check (2.7.4)
Now wie could connect with freetds, but the mssql_health_check still throws an error.
After some tests, we find out, that the newest DBD-Sybase is not able to do the connection, and, in my opinion so the check_mssql_check, who use the DBD-Sybase can't connect.. is it right?

Here a test with dbd-sybase:
DBI connect(';host=Servername;port=50100','user',...) failed: OpenClient message: LAYER = (0) ORIGIN = (0) SEVERITY = (78) NUMBER = (44) Server , database Message String: Server name not found in configuration files. OpenClient message: LAYER = (0) ORIGIN = (0) SEVERITY = (78) NUMBER = (49) Server , database Message String: Unexpected EOF from the server OpenClient message: LAYER = (0) ORIGIN = (0) SEVERITY = (78) NUMBER = (34) Server , database Message String: Adaptive Server connection failed OpenClient message: LAYER = (0) ORIGIN = (0) SEVERITY = (78) NUMBER = (34) Server , database Message String: Adaptive Server connection failed at ./sqltest.pl line 9.
The same error..
How to connect to the mssql server 2022 with check_mssql_health?

failed-jobs undefined value as array on Microsoft SQL Server 2000 SP4

I'm hoping your able to help, we've got a few Microsoft SQL Server 2000 SP4 Servers which haven't been upgraded yet, the plugin is crashing with:

Can't use an undefined value as an ARRAY reference at ./check_mssql_health line 4789.

Any ideas or is this old version just not supported any more (I'm sure it worked in the past), SQL queries still work ok.

Thanks in advance.

./check_mssql_health --server 192.168.X.X --username "XXXXX" --password "XXXX" --warning 43200 --critical 86400 --mode=failed-jobs --lookback 10080 --mitigation=0 --commit -v -v -v

Thu Sep 21 11:21:41 2017: SQL:
SELECT @@Version
ARGS:
$VAR1 = [];

Thu Sep 21 11:21:41 2017: RESULT:
$VAR1 = [
'Microsoft SQL Server 2000 - 8.00.2282 (Intel X86)
Dec 30 2008 02:22:41
Copyright (c) 1988-2003 Microsoft Corporation
Standard Edition on Windows NT 5.2 (Build 3790: Service Pack 2)
'
];

Thu Sep 21 11:21:41 2017: AUTOLOAD Classes::MSSQL::DBI::override_opt

Thu Sep 21 11:21:41 2017: AUTOLOAD Classes::MSSQL::DBI::check_messages

Thu Sep 21 11:21:41 2017: SQL:
SELECT SYSTEM_USER
ARGS:
$VAR1 = [];

Thu Sep 21 11:21:41 2017: RESULT:
$VAR1 = [
'USER'
];

Thu Sep 21 11:21:41 2017: SQL:
SELECT @@SERVICENAME
ARGS:
$VAR1 = [];

Thu Sep 21 11:21:41 2017: RESULT:
$VAR1 = [
'MSSQLSERVER'
];

Thu Sep 21 11:21:41 2017: SQL:
SELECT CAST(COALESCE(SERVERPROPERTY('IsHadrEnabled'), 0) as int)
ARGS:
$VAR1 = [];

Thu Sep 21 11:21:41 2017: RESULT:
$VAR1 = [
0
];

Thu Sep 21 11:21:41 2017: AUTOLOAD Classes::MSSQL::DBI::analyze_and_check_job_subsystem

Thu Sep 21 11:21:41 2017: $self->{components}->{job_subsystem} = Classes::MSSQL::Component::JobSubsystem->new()
Thu Sep 21 11:21:41 2017: AUTOLOAD Classes::MSSQL::DBI::check_job_subsystem

Can't use an undefined value as an ARRAY reference at ./check_mssql_health_orig line 4789.

SQL Server 2012 database-free when auto growth enabled

Hi lausser,
Many thanks for the check_mssql_health plugin, it's very useful, I do see however to have found one issue.

With MSSQL Server 2012, if the database is set to unlimited growth, the plugin seems to return the amount of space free, in my case 0.4%, however this isn't an issue because the database will autogrow (until it runs out of disk space)

Is it possible for the plugin when autogrowth is set to unlimited to always return ok (unless your able to get the space on the remote partition, but then it's in the realm of check_wmi_plus), if the database has a growth limit then use this as a the maximum size.

You can get the size and growth by running SQL:
select name, type_desc, physical_name, state, state_desc, size, max_size, growth FROM sys.master_files
if max_size is -1 then growth is set to unlimited.

Many thanks, I would submit a pull request but my perl isn't too great I'm more of a PHP/Bash person, sorry.

Blacklist is not working

If i use --blacklist database1234 i only get error messages about use of uninitialzed values.

Think there is some code missing for that to work,

Regards,
Carsten

Class MyDatabases is not a subclass of Monitoring::GLPlugin

Hi,

Since I updated to version 2.6.4.12 the my-databases-dbspace mode is not working anymore, this is the error:

UNKNOWN - Class MyDatabases is not a subclass of Monitoring::GLPlugin

Monitoring::GLPlugin is already installed:

# cpan install Monitoring::GLPlugin
CPAN: Storable loaded ok (v2.39)
Reading '/root/.cpan/Metadata'
  Database was generated on Tue, 19 Dec 2017 05:17:03 GMT
CPAN: Module::CoreList loaded ok (v2.25)
Monitoring::GLPlugin is up to date (2.3).

Any idea how to fix it? I googled but didn't find a solution yet..

databasefree mode breaks on MSSQL DBs with unlimited max size and no permissions for xp_fixeddrives

Basically, databasefree mode returns bogus results in this case, because unlimited max size means the check script will default to 4GB, unless xp_fixeddrives can be used, but that seems to require sysadmin permissions or at least more permissions than we have granted the user (this is on a MSSQL 2012 server). Without the permissions, xp_fixeddrives gives no results and the DB drive size is unknown. In that case, unlimited size DBs over 4GB return negative free space, and the other results aren't accurate.

I don't see the value of the 4GB max calculation (maybe a FAT32 relic?), IMO it will almost always be wrong, and it would be better to clearly indicate unknown status to avoid confusion (like if xp_fixeddrives returns no results and the DBs have unlimited space).

Add argument to specify TDS version

It would be great if it was possible to specify TDS version with an argument.
I have recently configured monitoring for some MSSQL 2012 servers and it requires TDS version 8.0, so at the moment my only option is to change the version globally or add each server in the FreeTDS configuration file.

Thanks for a great plugin!

Mode xxxxx is not implemented for this type of device

Hello,

I’m using now check_mssql_health in version 2.6.4.15.
Sybase database running under Linux.

For almost all mode parameters, I get a message:

Mode cpu-busy is not implemented for this type of device
or
Mode full-scans is not implemented for this type of device

Only works in mode connection-time and connected-users

Where is problem here (missing user authorization) or?

Thx

database-free deadlock problem and maybe new mode "log-free"

Hello Mr. Lausser,

I have some deadlocks problem with the database-free mode in my environment. I think, it is related to the select on sysindexes. Maybe I have an solution for this. You should remove the select on sysindexes and use this instead:
use [?]
SELECT SUM(CONVERT(Decimal(15,2),ROUND(FILEPROPERTY(a.Name,'SpaceUsed')/128,2))) AS [Space Used (MB)]
FROM
[?].dbo.sysfiles a (NOLOCK)
WHERE
a.filename not like '%.ldf'

This works fine in my environment.

With this you could also add a new mode like "database-log-free"
Basically it is the same code as database-free, but you need to change the first query to:
use [?]
SELECT
SUM(CONVERT(Decimal(15,2),ROUND(FILEPROPERTY(a.Name,'SpaceUsed')/128,2))) AS [Space Used (MB)]
FROM
[?].dbo.sysfiles a (NOLOCK)
WHERE
a.filename like '%.ldf'

and the second query (to get the maxsize etc.):
SELECT
RTRIM(a.name), RTRIM(a.filename), CAST(a.size AS BIGINT),CAST(a.maxsize AS BIGINT), a.growth
FROM
[?].sys.sysfiles a
WHERE
a.groupid = 0

Maybe you have some time to "official" implement this, so I can use further updates of your plugin.

Thanks!

marcelfischer

The database-log-free mode does not show the correct free log space it has left

I have found an issue, where the database-log-free mode does not show the correct free log space it has left.

Auswahl_300

As seen in the unused data space should only be 6.8% but if we execute the check in database-log-free mode:

Auswahl_301

the check seems to find 75.19% of free space.
I did some approximate math and it seems that used space is compared against the total data space, but not the Trasaction Log Space.

I hope you will be able to fix it anytime soon.
Thank in advance.

Fail at user creation

Hi,

I've realized that there is a missing user creation at the documentation, I think it's necessari to perform this command
EXEC ('use msdb create user ' + @check_mssql_health_USER + ' from login ' + @check_mssql_health_USER)
before add permissions to the msdb database.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.