check_mssql_health icon indicating copy to clipboard operation
check_mssql_health copied to clipboard

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

Open rchekaluk opened this issue 10 years ago • 4 comments

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

rchekaluk avatar Aug 12 '14 17:08 rchekaluk

A possibly relevant clue from https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/issues/168#issuecomment-4204268:

You are using dataserver and host, one trumps the other.

rchekaluk avatar Aug 12 '14 17:08 rchekaluk

I have similarly found that the script can't connect to a MS SQL server using IP and port. However I don't receive that error, in fact there is nothing more helpful than "(no error string)", even enabling full DBI trace adds little. I tried many variations of the connection string to no avail. I thought it might be that the TDS version is incorrect or a bug in one of the libraries.

The only way it works for me is using server name with matching entries in freetds.conf, which is kind of annoying as more servers are involved.

historicbruno avatar Jul 15 '15 21:07 historicbruno

I can confirm the problem Tested with DBD::Sybase: 1.15 freetds: 0.95.67 It looks like the work on DBD::Sybase has stopped.

use DBI;
use strict;

my $username = "sa";
my $password = "password";
my $dsn = "DBI:Sybase:;host=myhost.com;port=61234";
if (my $dbh = DBI->connect(
    $dsn, $username, $password,
    { RaiseError => 1, AutoCommit => 0, PrintError => 1 })) {
  printf "connection succeeded\n";
} else {
  printf "connection failed\n";
}

Error message:

DBI connect(';host=myhost.com;port=61234','sa',...) 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.

gitmopp avatar Dec 17 '15 13:12 gitmopp

Problem solved in freetds https://github.com/FreeTDS/freetds/commit/49333d5b35190ca27c0d53d3648276b012887812

gitmopp avatar Dec 22 '15 10:12 gitmopp