Comments (10)
from check_mssql_health.
Just sent you an email.
from check_mssql_health.
Now i see what's wrong. You updated from a very, very old version. With 2.0 check_mssql_health was completely rewritten and the "api" for my-modules changed. If fact i added some compatibility-routines which should guarantee that also old my-modules can be used, but it does not work with your code. Instead of putitng time in this, i simply changed your module to the new format.
package MyDatabases;
our @ISA = qw(Monitoring::GLPlugin::DB);
# zur Umrechnung in MB
my %tomb = (
'KB' => 1024,
'MB' => 1,
'GB' => 1/1024,
);
sub init {
my $self = shift;
if ($self->mode =~ /my::databases::dbspace/) {
my @dbs = $self->fetchall_array(q{SELECT name FROM master.sys.databases});
my %stats;
my $cmd = "EXEC sp_spaceused";
foreach (@dbs) {
my @dbstat = $self->fetchall_array("USE \"" . $_->[0] . "\" " . $cmd);
$stats{$_->[0]} = {
'dbsize' => $dbstat[0][1],
'unallocated' => $dbstat[0][2],
};
}
$self->{dbstat} = \%stats;
if (keys(%{$self->{dbstat}})) {
while ((my $key, $value) = each(%{$self->{dbstat}})) {
if ($self->opts->regexp) {
next if $key !~ /$self->opts->regexp/;
} elsif ($self->opts->name) {
next if lc $key ne lc $self->opts->name;
}
$value->{'dbsize'} =~ m/(\d+\.?\d*?) (GB|MB|KB)/;
my $totalmb = $1 / $tomb{$2};
$value->{'unallocated'} =~ m/(\d+\.?\d*?) (GB|MB|KB)/;
my $unusedmb = $1 / $tomb{$2};
my $usedmb = $totalmb - $unusedmb;
my $usedpct = ($usedmb / $totalmb) * 100;
$self->add_info(
#$self->check_thresholds($_->[2],80,90),
sprintf("DB \"%s\": %0.2f%% used (%0.2f of %0.2f MB)",
$key, $usedpct, $usedmb, $totalmb)
);
$self->add_ok();
$self->add_perfdata(
label => $key."_mbused",
value => $usedmb,
min => 0,
max => $totalmb,
uom => 'MB',
);
$self->add_perfdata(
label => $key."_mbtotal",
value => $totalmb,
uom => 'MB',
);
}
} else {
$self->add_unknown("No database size information found. ");
}
}
}
There is no more nagios method, only a init(). The fetch*-database-methods belong to $self, no longer to a params{handle}.
add_info(takes a string) which is output when you run the plugin with -v. The same string will be used in add_ok, add_warning,...
Also, add_perdata takes label,value,warn,crit,min,max,uom instead of a complete string.
Gerhard
from check_mssql_health.
from check_mssql_health.
--with-mymodules-dyn-dir /usr/local/nagios/libexec/conf
should do the trick.
from check_mssql_health.
from check_mssql_health.
mv CheckMSSQLHealthExt1.pm CheckMssqlHealthExt1.pm
The naming became more strict.
from check_mssql_health.
from check_mssql_health.
I'm reopening this issue, since ugpraded to script version 2.6.4.15 I have the same problem..
'/usr/lib/nagios/plugins/check_mssql_health' '--commit' '--mode' 'my-databases-dbspace' '--name' '^(?!.*_BK_MQDE01.SPDB0._IB.*)' '--password' 'xxx' '--regexp' '--report' 'short' '--server' 'xxx' '--username' 'xxx' --with-mymodules-dyn-dir /usr/lib/nagios/plugins
UNKNOWN - Class MyDatabases is not a subclass of Monitoring::GLPlugin
from check_mssql_health.
After some investigations i found this difference between previous version and this one:
$ diff /usr/lib/nagios/plugins/check_mssql_health /usr/lib/nagios/plugins/check_mssql_health.old | grep pm
< foreach my $extmod (glob $libpath."/".$plugin_name."*.pm") {
> foreach my $extmod (glob $libpath."/CheckMSSQLHealth*.pm") {
Then I have just changed that line with this one:
foreach my $extmod (glob $libpath."/CheckMSSQLHealthExt1.pm") {
Now it finds the module but there is an error:
Can't call method "fetchall_array" on an undefined value at /usr/lib/nagios/plugins/CheckMSSQLHealthExt1.pm line 13.
And this is the content of the file CheckMSSQLHealthExt1.pm:
1 package MyDatabases;
2 our @ISA = qw(DBD::MSSQL::Server);
3 # zur Umrechnung in MB
4 my %tomb = (
5 'KB' => 1024,
6 'MB' => 1,
7 'GB' => 1/1024,
8 );
9 sub init {
10 my $self = shift;
11 my %params = @_;
12 if ($params{mode} =~ /my::databases::dbspace/) {
13 my @dbs = $params{handle}->fetchall_array(q{
14 SELECT name FROM master.sys.databases
15 });
16 my %stats;
17 my $cmd = "EXEC sp_spaceused";
18 foreach (@dbs) {
19 my @dbstat = $params{handle}->fetchall_array("USE " . $_->[0] . " " . $cmd);
20 $stats{$_->[0]} = {
21 'dbsize' => $dbstat[0][1],
22 'unallocated' => $dbstat[0][2],
23 };
24 };
25 $self->{dbstat} = \%stats;
26 }
27 }
28 sub nagios {
29 if ($params{mode} =~ /my::databases::dbspace/) {
30 if (keys(%{$self->{dbstat}})) {
31 while ((my $key, $value) = each(%{$self->{dbstat}})) {
32 if ($params{regexp}) {
33 next if $params{selectname} && $key !~ /$params{selectname}/;
34 } else {
35 next if $params{selectname} && lc $params{selectname} ne lc $key;
36 }
37 $value->{'dbsize'} =~ m/(\d+\.?\d*?) (GB|MB|KB)/;
38 my $totalmb = $1 / $tomb{$2};
39 $value->{'unallocated'} =~ m/(\d+\.?\d*?) (GB|MB|KB)/;
40 my $unusedmb = $1 / $tomb{$2};
41 my $usedmb = $totalmb - $unusedmb;
42 my $usedpct = ($usedmb / $totalmb) * 100;
43 $self->add_nagios(
44 #$self->check_thresholds($_->[2],80,90),
45 0,sprintf("DB \"%s\": %0.2f%% used (%0.2f of %0.2f MB)",
46 $key, $usedpct, $usedmb, $totalmb)
47 );
48 $self->add_perfdata(sprintf("%s=%0.2fMB;;;0;%0.2f",
49 $key."_mbused", $usedmb,$totalmb));
50 $self->add_perfdata(sprintf("%s=%0.2fMB;;;;",
51 $key."_mbtotal", $totalmb));
52 }
53 } else { $self->add_nagios_unknown("No database size information found. ")}
54 }
55 }
Any idea how to fix it?
from check_mssql_health.
Related Issues (20)
- SQL Server Express 2014 check_mssql_health with on LibreNMS HOT 12
- sql-runtime does not work on v 2.6.4.10 HOT 1
- DBD:SYBASE Change to BBDD Mysql HOT 1
- failed-jobs undefined value as array on Microsoft SQL Server 2000 SP4 HOT 1
- Adaptive Server connection failed with V2.6.4.13 HOT 2
- need encoding...
- Not working in SQLServer 2016 HOT 1
- Fail at user creation HOT 1
- Blacklist is not working HOT 5
- configure does not exist
- Mode xxxxx is not implemented for this type of device
- connected_users should be connected_sessions
- Read query from file with SQL Mode HOT 1
- Database offline/deleted but Check status OK HOT 3
- Database not accepting connections - Because of "Auto Close"
- doesn't support Azure MSSQL
- The database-log-free mode does not show the correct free log space it has left
- No connect to MSSQL Server 2022 HOT 1
- Backup Status alerts on multiple Availability Groups when split over 2 or more hosts
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from check_mssql_health.