lausser / check_mssql_health

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.
http://labs.consol.de/nagios/check_mssql_health
GNU General Public License v2.0
38 stars 27 forks source link

Blacklist is not working #37

Open Mikesch-mp opened 4 years ago

Mikesch-mp commented 4 years ago

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

akadaedalus commented 3 years ago

this little patch works for me (internal_name doesn't exist). Version 2.6.4.15, I ignored a different section that never prints internal_name.

--- check_mssql_health  2019-09-25 11:17:46.608776257 -0700
+++ check_mssql_health.new      2020-10-15 10:19:58.710809895 -0700
@@ -2045,7 +2045,7 @@
   # FAN_459,FAN_203,TEMP_102229,ENVSUBSYSTEM
   if ($self->opts->blacklist =~ /_/) {
     foreach my $bl_item (split(/,/, $self->opts->blacklist)) {
-      if ($bl_item eq $self->internal_name()) {
+      if (exists $self->{name} && $bl_item eq $self->{name}) {
         $self->{blacklisted} = 1;
       }
     }
@@ -2055,12 +2055,12 @@
         my $bl_type = $1;
         my $bl_names = $2;
         foreach my $bl_name (split(/,/, $bl_names)) {
-          if ($bl_type."_".$bl_name eq $self->internal_name()) {
+          if ($bl_type."_".$bl_name eq $self->{name}) {
             $self->{blacklisted} = 1;
           }
         }
       } elsif ($bl_items =~ /^(\w+)$/) {
-        if ($bl_items eq $self->internal_name()) {
+        if ($bl_items eq $self->{name}) {
           $self->{blacklisted} = 1;
         }
       }
lausser commented 3 years ago

Can you please add an example of the command line and the output before/after?

Von: akadaedalus [mailto:notifications@github.com] Gesendet: Donnerstag, 15. Oktober 2020 19:26 An: lausser/check_mssql_health check_mssql_health@noreply.github.com Cc: Subscribed subscribed@noreply.github.com Betreff: Re: [lausser/check_mssql_health] Blacklist is not working (#37)

this little patch works for me (internal_name doesn't exist). Version 2.6.4.15, I ignored a different section that never prints internal_name.

--- check_mssql_health 2019-09-25 11:17:46.608776257 -0700 +++ check_mssql_health.new 2020-10-15 10:19:58.710809895 -0700 @@ -2045,7 +2045,7 @@

FAN_459,FAN_203,TEMP_102229,ENVSUBSYSTEM

if ($self->opts->blacklist =~ /_/) { foreach my $bl_item (split(/,/, $self->opts->blacklist)) {

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/lausser/check_mssql_health/issues/37#issuecomment-709475251 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AABQSOFOAQOMS2AD753RNWLSK4WDDANCNFSM4II2553Q . https://github.com/notifications/beacon/AABQSOCLPLVKQQCYC5RMBBTSK4WDDA5CNFSM4II25532YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOFJE3XMY.gif

akadaedalus commented 3 years ago

I need to sanitize it a little bit, so fake database names and I got tired of editing so the number of errors may not line up with the number of "online" databases.

I had to do if (exists $self->{name} && because for some reason it started the loop on an empty database name.

before:

-bash-4.2$ ./check_mssql_health.20201015 --server myserver --username nagiosro --password password --mode database-online --commit --multiline --blacklist 'BAD_DATABASE'
Use of uninitialized value in string eq at ./check_mssql_health.20201015 line 2048.
Use of uninitialized value in string eq at ./check_mssql_health.20201015 line 2048.
Use of uninitialized value in string eq at ./check_mssql_health.20201015 line 2048.
Use of uninitialized value in string eq at ./check_mssql_health.20201015 line 2048.
Use of uninitialized value in string eq at ./check_mssql_health.20201015 line 2048.
Use of uninitialized value in string eq at ./check_mssql_health.20201015 line 2048.
Use of uninitialized value in string eq at ./check_mssql_health.20201015 line 2048.
Use of uninitialized value in string eq at ./check_mssql_health.20201015 line 2048.
Use of uninitialized value in string eq at ./check_mssql_health.20201015 line 2048.
Use of uninitialized value in string eq at ./check_mssql_health.20201015 line 2048.
Use of uninitialized value in string eq at ./check_mssql_health.20201015 line 2048.
Use of uninitialized value in string eq at ./check_mssql_health.20201015 line 2048.
Use of uninitialized value in string eq at ./check_mssql_health.20201015 line 2048.
Use of uninitialized value in string eq at ./check_mssql_health.20201015 line 2048.
Use of uninitialized value in string eq at ./check_mssql_health.20201015 line 2048.
Use of uninitialized value in string eq at ./check_mssql_health.20201015 line 2048.
Use of uninitialized value in string eq at ./check_mssql_health.20201015 line 2048.
Use of uninitialized value in string eq at ./check_mssql_health.20201015 line 2048.
Use of uninitialized value in string eq at ./check_mssql_health.20201015 line 2048.
CRITICAL - BAD_DATABASE is offline, tempdb is online and accepting connections
db1 is online and accepting connections
db2 is online and accepting connections
db3 is online and accepting connections
db4 is online and accepting connections
db5 is online and accepting connections
db6 is online and accepting connections
db7 is online and accepting connections
db8 is online and accepting connections
db9 is online and accepting connections
db10 is online and accepting connections
db11 is online and accepting connections
db12 is online and accepting connections
db13 is online and accepting connections
db14 is online and accepting connections
db15 is online and accepting connections

After the patch:

-bash-4.2$ ./check_mssql_health --server myserver --username nagiosro --password password --mode database-online --commit --multiline --blacklist 'BAD_DATABASE'
OK - tempdb is online and accepting connections
db1 is online and accepting connections
db2 is online and accepting connections
db3 is online and accepting connections
db4 is online and accepting connections
db5 is online and accepting connections
db6 is online and accepting connections
db7 is online and accepting connections
db8 is online and accepting connections
db9 is online and accepting connections
db10 is online and accepting connections
db11 is online and accepting connections
db12 is online and accepting connections
db13 is online and accepting connections
db14 is online and accepting connections
db15 is online and accepting connections
lausser commented 3 years ago

Actually the –blacklist parameter was introduced for fans/powersupplies etc. of network and storage devices, for check_nwc_health etc.

For check_mssql_health I always recommended

--mode database-free --regexp --name '^(?!(BAD|BAD2))$'

Which means “match all of the database names except BAD or BAD2”

This is used mostly in setups where you have some supercritical databases, which get their own checks (--name supercrit1)

And then there is another check, which monitors all of the databases except these which already have their individual check.

Von: akadaedalus [mailto:notifications@github.com] Gesendet: Montag, 19. Oktober 2020 19:44 An: lausser/check_mssql_health check_mssql_health@noreply.github.com Cc: Gerhard Lausser Gerhard.Lausser@consol.de; Comment comment@noreply.github.com Betreff: Re: [lausser/check_mssql_health] Blacklist is not working (#37)

I need to sanitize it a little bit, so fake database names and I got tired of editing so the number of errors may not line up with the number of "online" databases.

I had to do if (exists $self->{name} && because for some reason it started the loop on an empty database name.

before:

-bash-4.2$ ./check_mssql_health.20201015 --server myserver --username nagiosro --password password --mode database-online --commit --multiline --blacklist 'BAD_DATABASE' Use of uninitialized value in string eq at ./check_mssql_health.20201015 line 2048. Use of uninitialized value in string eq at ./check_mssql_health.20201015 line 2048. Use of uninitialized value in string eq at ./check_mssql_health.20201015 line 2048. Use of uninitialized value in string eq at ./check_mssql_health.20201015 line 2048. Use of uninitialized value in string eq at ./check_mssql_health.20201015 line 2048. Use of uninitialized value in string eq at ./check_mssql_health.20201015 line 2048. Use of uninitialized value in string eq at ./check_mssql_health.20201015 line 2048. Use of uninitialized value in string eq at ./check_mssql_health.20201015 line 2048. Use of uninitialized value in string eq at ./check_mssql_health.20201015 line 2048. Use of uninitialized value in string eq at ./check_mssql_health.20201015 line 2048. Use of uninitialized value in string eq at ./check_mssql_health.20201015 line 2048. Use of uninitialized value in string eq at ./check_mssql_health.20201015 line 2048. Use of uninitialized value in string eq at ./check_mssql_health.20201015 line 2048. Use of uninitialized value in string eq at ./check_mssql_health.20201015 line 2048. Use of uninitialized value in string eq at ./check_mssql_health.20201015 line 2048. Use of uninitialized value in string eq at ./check_mssql_health.20201015 line 2048. Use of uninitialized value in string eq at ./check_mssql_health.20201015 line 2048. Use of uninitialized value in string eq at ./check_mssql_health.20201015 line 2048. Use of uninitialized value in string eq at ./check_mssql_health.20201015 line 2048. CRITICAL - BAD_DATABASE is offline, tempdb is online and accepting connections db1 is online and accepting connections db2 is online and accepting connections db3 is online and accepting connections db4 is online and accepting connections db5 is online and accepting connections db6 is online and accepting connections db7 is online and accepting connections db8 is online and accepting connections db9 is online and accepting connections db10 is online and accepting connections db11 is online and accepting connections db12 is online and accepting connections db13 is online and accepting connections db14 is online and accepting connections db15 is online and accepting connections

After the patch:

-bash-4.2$ ./check_mssql_health --server myserver --username nagiosro --password password --mode database-online --commit --multiline --blacklist 'BAD_DATABASE' OK - tempdb is online and accepting connections db1 is online and accepting connections db2 is online and accepting connections db3 is online and accepting connections db4 is online and accepting connections db5 is online and accepting connections db6 is online and accepting connections db7 is online and accepting connections db8 is online and accepting connections db9 is online and accepting connections db10 is online and accepting connections db11 is online and accepting connections db12 is online and accepting connections db13 is online and accepting connections db14 is online and accepting connections db15 is online and accepting connections

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/lausser/check_mssql_health/issues/37#issuecomment-712328679 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AABQSOEVTIX5EHTPN4XYSJ3SLR3HJANCNFSM4II2553Q . https://github.com/notifications/beacon/AABQSOB7B5ZZJGWZKHMUA3DSLR3HJA5CNFSM4II25532YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOFJ2ULZY.gif

akadaedalus commented 3 years ago

good to know about the regex option. If you want to keep it like that, possibly improve your documentation, and remove the broken functionality ("internal_name" is still nonexistent in the script). note that --blacklist was the intuitive option for me and probably the same for this issue's reporter.

I just wanted a quick fix when a database was intentionally turned off and I didn't want to create individual checks for every single database that was still running. :)