Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blacklist is not working #37

Open
Mikesch-mp opened this issue Aug 2, 2019 · 5 comments
Open

Blacklist is not working #37

Mikesch-mp opened this issue Aug 2, 2019 · 5 comments

Comments

@Mikesch-mp
Copy link

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
Copy link

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
Copy link
Owner

lausser commented Oct 19, 2020 via email

@akadaedalus
Copy link

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
Copy link
Owner

lausser commented Oct 19, 2020 via email

@akadaedalus
Copy link

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. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants