Search Exchange
Search All Sites
Nagios Live Webinars
Let our experts show you how Nagios can help your organization.Login
Directory Tree
check_mssql_health Popular
1.5.8
2010-12-20
- Nagios 1.x
- Nagios 2.x
- Nagios 3.x
- Nagios XI 2009R1
- Nagios Fusion 2010R1
1453769
Meet The New Nagios Core Services Platform
Built on over 25 years of monitoring experience, the Nagios Core Services Platform provides insightful monitoring dashboards, time-saving monitoring wizards, and unmatched ease of use. Use it for free indefinitely.
Monitoring Made Magically Better
- Nagios Core on Overdrive
- Powerful Monitoring Dashboards
- Time-Saving Configuration Wizards
- Open Source Powered Monitoring On Steroids
- And So Much More!
$ check_mssql_health --help
Copyright (c) 2009 Gerhard Lausser
Check various parameters of MSSQL databases
Usage:
check_mssql_health [-v] [-t ] --hostname=
--username= --password= [--port ]
--mode=
check_mssql_health [-v] [-t ] --server=
--username= --password=
--mode=
check_mssql_health [-h | --help]
check_mssql_health [-V | --version]
Options:
--hostname
the database server
--port
the database server's port
--server
the name of a predefined connection
--currentdb
the name of a database which is used as the current database
for the connection. (don't use this parameter unless you
know what you're doing)
--username
the mssql user
--password
the mssql user's password
--warning
the warning range
--critical
the critical range
--mode
the mode of the plugin. select one of the following keywords:
connection-time (Time to connect to the server)
cpu-busy (Cpu busy in percent)
io-busy (IO busy in percent)
full-scans (Full table scans per second)
connected-users (Number of currently connected users)
transactions (Transactions per second (per database))
batch-requests (Batch requests per second)
latches-waits (Number of latch requests that could not be granted immediately)
latches-wait-time (Average time for a latch to wait before the request is met)
locks-waits (The number of locks per second that had to wait)
locks-timeouts (The number of locks per second that timed out)
locks-deadlocks (The number of deadlocks per second)
sql-recompilations (Re-Compilations per second)
sql-initcompilations (Initial compilations per second)
total-server-memory (The amount of memory that SQL Server has allocated to it)
mem-pool-data-buffer-hit-ratio (Data Buffer Cache Hit Ratio)
lazy-writes (Lazy writes per second)
page-life-expectancy (Seconds a page is kept in memory before being flushed)
free-list-stalls (Requests per second that had to wait for a free page)
checkpoint-pages (Dirty pages flushed to disk per second. (usually by a checkpoint))
database-free (Free space in database)
database-backup-age (Elapsed time (in hours) since a database was last backupped)
sql (any sql command returning a single number)
list-databases (convenience function which lists all databases)
list-datafiles (convenience function which lists all datafiles)
list-locks (convenience function which lists all locks)
--name
the name of the database etc depending on the mode.
--name2
if name is a sql statement, this statement would appear in
the output and the performance data. This can be ugly, so
name2 can be used to appear instead.
--regexp
if this parameter is used, name will be interpreted as a
regular expression.
--units
one of %, KB, MB, GB. This is used for a better output of mode=sql
and for specifying thresholds for mode=tablespace-free
Database-related modes check all databases in one run by default.
If only a single database should be checked, use the --name parameter.
The same applies to datafile-related modes.
In mode sql you can url-encode the statement so you will not have to mess
around with special characters in your Nagios service definitions.
Instead of
--name="select count(*) from master..sysprocesses"
you can say
--name=select%20count%28%2A%29%20from%20master%2E%2Esysprocesses
For your convenience you can call check_mssql_health with the --encode
option and it will encode the standard input.
Reviews (13)
byReneKNAW, May 21, 2019
Call me noob but I don't get it. The documentation states the following...
Please keep in mind that check_mssql_health’s functionality is limited when using SQL Server authentication. This method is strongly discouraged . Normally there is already a Nagios-(Windows-)-user which can be used for the Windows authentication method.
So how is this possible on a Linux server? With an NRPE plugin on the remote machine? But how? What am I missing?
Please keep in mind that check_mssql_health’s functionality is limited when using SQL Server authentication. This method is strongly discouraged . Normally there is already a Nagios-(Windows-)-user which can be used for the Windows authentication method.
So how is this possible on a Linux server? With an NRPE plugin on the remote machine? But how? What am I missing?
byjdurand, October 9, 2018
Hi,
This script works fine for what I needed. Except for mode failed-job. Many error about uninitialized value and there is no way to filter on the job name.
So, I've debugged the script for this part and added a --filter parameter that take a regex and filter on the job name.
You can find my version of the script here : https://pastebin.com/1VvwuSfa
This script works fine for what I needed. Except for mode failed-job. Many error about uninitialized value and there is no way to filter on the job name.
So, I've debugged the script for this part and added a --filter parameter that take a regex and filter on the job name.
You can find my version of the script here : https://pastebin.com/1VvwuSfa
byadum, December 20, 2017
Plugin is working without error but only the connection-time mode seems to return some values. The others just return "OK"
Connecting to database with sa so I don't think it's permission related.
Connecting to database with sa so I don't think it's permission related.
bycelticpiping, May 26, 2017
I say average because:
1) It obviously works for SOMEONE here
2) My experience mirrors the user from 2009, who said:
"Not easy to get working, still having hell of a time getting DBD::Sybase to install. Really would like to have this but most likely wont due to sybase requirement."
It's a pity that linux software/tool config&install details have to remain cryptic and/or non-existent.
I'm not a newbie, but just trying to get this thing up & running is fairly painful..
;(
I REALLY want(ed) it to work..
1) It obviously works for SOMEONE here
2) My experience mirrors the user from 2009, who said:
"Not easy to get working, still having hell of a time getting DBD::Sybase to install. Really would like to have this but most likely wont due to sybase requirement."
It's a pity that linux software/tool config&install details have to remain cryptic and/or non-existent.
I'm not a newbie, but just trying to get this thing up & running is fairly painful..
;(
I REALLY want(ed) it to work..
byRicardo27, November 29, 2016
1 of 1 people found this review helpful
Hello!
I want to ask you about the check_mssql_health plug in. The plug in works properly in the server in any mode but this does not happen in Nagios web version. Could you help me with this please?
Error: UNKNOWN - cannot create status dir /var/tmp/check_mssql_health! check your filesystem (permissions/usage/integrity) and disk devices, cannot write status file /var/tmp/check_mssql_health/cpu-busy_secs_busy_ip-server
I want to ask you about the check_mssql_health plug in. The plug in works properly in the server in any mode but this does not happen in Nagios web version. Could you help me with this please?
Error: UNKNOWN - cannot create status dir /var/tmp/check_mssql_health! check your filesystem (permissions/usage/integrity) and disk devices, cannot write status file /var/tmp/check_mssql_health/cpu-busy_secs_busy_ip-server
bymad12, November 8, 2016
how can i check multiple databases with --name options ? , can i check all database but not system databases (tempdb,model ecc) ?
bymarc, June 14, 2015
Hi there
Unfortunately on the labs.consol.de page there is an issue with the download link to the plugins. The links are pointing to "download/nagios/check_mssql_health-1.5.20.6.tar.gz" which is not working.
Regards
Marc
Unfortunately on the labs.consol.de page there is an issue with the download link to the plugins. The links are pointing to "download/nagios/check_mssql_health-1.5.20.6.tar.gz" which is not working.
Regards
Marc
byrhousand, March 31, 2014
Script errored due to empty $minutessincestart:
sub nagios {
my $self = shift;
my %params = @_;
if (! $self->{nagios_level}) {
if ($params{mode} =~ /server::jobs::failed/) {
if ($self->{lastrunstatus} ne "succeeded") {
if ($self->{lastrunstatus} eq "failed") {
$self->add_nagios_critical(
sprintf "%s failed: %s", $self->{name}, $self->{lastrunstatusmessage});
} elsif ($self->{lastrunstatus} eq "retry" || $self->{lastrunstatus} eq "canceled") {
$self->add_nagios_warning(
sprintf "%s %s: %s", $self->{name}, $self->{lastrunstatus}, $self->{lastrunstatusmessage});
} else {
if ($self->{lastrunstatus}) {
print "else: $params{mode} $self->{name} $self->{lastrunstatus}
";
$self->add_nagios(
$self->check_thresholds($self->{lastrundurationseconds}, 60, 300),
#sprintf("job %s ran for %d seconds (started %s)
", $self->{name},
sprintf("job %s ran for %d seconds (started %s)", $self->{name},
$self->{lastrundurationseconds}, $self->{lastrundatetime}));
}
}
} else {
print "OK - $self->{name}, $self->{lastrundurationseconds}, $self->{lastrundatetime}
";
}
}
}
}
Script alerted if lastrunstatus was not set:
sub nagios {
my $self = shift;
my %params = @_;
if (! $self->{nagios_level}) {
if ($params{mode} =~ /server::jobs::failed/) {
if ($self->{lastrunstatus} ne "succeeded") {
if ($self->{lastrunstatus} eq "failed") {
$self->add_nagios_critical(
sprintf "%s failed: %s", $self->{name}, $self->{lastrunstatusmessage});
} elsif ($self->{lastrunstatus} eq "retry" || $self->{lastrunstatus} eq "canceled") {
$self->add_nagios_warning(
sprintf "%s %s: %s", $self->{name}, $self->{lastrunstatus}, $self->{lastrunstatusmessage});
} else {
if ($self->{lastrunstatus}) {
print "else: $params{mode} $self->{name} $self->{lastrunstatus}
";
$self->add_nagios(
$self->check_thresholds($self->{lastrundurationseconds}, 60, 300),
#sprintf("job %s ran for %d seconds (started %s)
", $self->{name},
sprintf("job %s ran for %d seconds (started %s)", $self->{name},
$self->{lastrundurationseconds}, $self->{lastrundatetime}));
}
}
} else {
print "OK - $self->{name}, $self->{lastrundurationseconds}, $self->{lastrundatetime}
";
}
}
}
}
sub nagios {
my $self = shift;
my %params = @_;
if (! $self->{nagios_level}) {
if ($params{mode} =~ /server::jobs::failed/) {
if ($self->{lastrunstatus} ne "succeeded") {
if ($self->{lastrunstatus} eq "failed") {
$self->add_nagios_critical(
sprintf "%s failed: %s", $self->{name}, $self->{lastrunstatusmessage});
} elsif ($self->{lastrunstatus} eq "retry" || $self->{lastrunstatus} eq "canceled") {
$self->add_nagios_warning(
sprintf "%s %s: %s", $self->{name}, $self->{lastrunstatus}, $self->{lastrunstatusmessage});
} else {
if ($self->{lastrunstatus}) {
print "else: $params{mode} $self->{name} $self->{lastrunstatus}
";
$self->add_nagios(
$self->check_thresholds($self->{lastrundurationseconds}, 60, 300),
#sprintf("job %s ran for %d seconds (started %s)
", $self->{name},
sprintf("job %s ran for %d seconds (started %s)", $self->{name},
$self->{lastrundurationseconds}, $self->{lastrundatetime}));
}
}
} else {
print "OK - $self->{name}, $self->{lastrundurationseconds}, $self->{lastrundatetime}
";
}
}
}
}
Script alerted if lastrunstatus was not set:
sub nagios {
my $self = shift;
my %params = @_;
if (! $self->{nagios_level}) {
if ($params{mode} =~ /server::jobs::failed/) {
if ($self->{lastrunstatus} ne "succeeded") {
if ($self->{lastrunstatus} eq "failed") {
$self->add_nagios_critical(
sprintf "%s failed: %s", $self->{name}, $self->{lastrunstatusmessage});
} elsif ($self->{lastrunstatus} eq "retry" || $self->{lastrunstatus} eq "canceled") {
$self->add_nagios_warning(
sprintf "%s %s: %s", $self->{name}, $self->{lastrunstatus}, $self->{lastrunstatusmessage});
} else {
if ($self->{lastrunstatus}) {
print "else: $params{mode} $self->{name} $self->{lastrunstatus}
";
$self->add_nagios(
$self->check_thresholds($self->{lastrundurationseconds}, 60, 300),
#sprintf("job %s ran for %d seconds (started %s)
", $self->{name},
sprintf("job %s ran for %d seconds (started %s)", $self->{name},
$self->{lastrundurationseconds}, $self->{lastrundatetime}));
}
}
} else {
print "OK - $self->{name}, $self->{lastrundurationseconds}, $self->{lastrundatetime}
";
}
}
}
}
bymrtexasfreedom, October 13, 2011
There is an english translation on the project site.
Connecting with the perl Sybase module can be somewhat tricky.
I finally got a succesfull connection this way:
1 - Edit /etc/freetds/freetds.conf
[sqlhost1]
host = 192.168.1.1
port = 1433
tds version = 8.0
2 - Use the --server command line option instead of the --hostname option:
check_mssql_health --server=sqlhost1 --username=nagiosuser --password=nagiospass --mode connected-users
Connecting with the perl Sybase module can be somewhat tricky.
I finally got a succesfull connection this way:
1 - Edit /etc/freetds/freetds.conf
[sqlhost1]
host = 192.168.1.1
port = 1433
tds version = 8.0
2 - Use the --server command line option instead of the --hostname option:
check_mssql_health --server=sqlhost1 --username=nagiosuser --password=nagiospass --mode connected-users
The document is in german, I didn't found any how-to install :(
Not easy to get working, still having hell of a time getting DBD::Sybase to install. Really would like to have this but most likely wont due to sybase requirement.