patch for ct.c

"Gerhard Lausser" <[email protected]>
Newsgroups gmane.comp.db.tds.freetds
Message-ID <8E8235AE95C044F9BBFBAA68B2447B29@it10>
Hi,

i am the author of check_mssql_health, a plugin for the Nagios monitoring
system, which is used to monitor MS SQL and Sybase databases. It uses
freetds and DBD::Sybase.
The plugin can be called as

check_mssql_health --server <an_entry_in_freetds.conf> --username ....
which internally uses DBI->connect("DBI:Sybase:server=...
or
check_mssql_health --hostname <host_or_ip> --port <port> --username ....
which internally uses DBI->connect("DBI:Sybase:host=...;port=...

This worked reliably so far with the libs and modules from the linux
distributions. 
Today i was compiling DBD::Sybase-1.15 and freetds-0.91 from source and with
this platform, calling check_mssql_health with --hostname no longer worked.
I got the error "Server name not found in configuration files"

Attached is a patch for freetds-0.91, which fixed the error for me. 

Cheers,
Gerhard

 

__________ Hinweis von ESET NOD32 Antivirus, Signaturdatenbank-Version 8718
(20130822) __________

E-Mail wurde gepruft mit ESET NOD32 Antivirus.

http://www.eset.com

_______________________________________________
FreeTDS mailing list
[email protected]
http://lists.ibiblio.org/mailman/listinfo/freetds
0001-ct_connect-fix-dbdsybase-host-arg.patch (application/octet-stream, 630 B)
diff -Naur a/src/ctlib/ct.c b/src/ctlib/ct.c
--- a/src/ctlib/ct.c	2013-08-22 19:05:52.000000000 +0200
+++ b/src/ctlib/ct.c	2013-08-22 19:50:46.000000000 +0200
@@ -615,8 +615,13 @@
 		con->tds_socket = NULL;
 		return CS_FAIL;
 	}
-	if (con->server_addr)
+	if (con->server_addr) {
+		char ip_addr[256];
 		tds_dstr_copy(&connection->server_host_name, con->server_addr);
+		if (tds_lookup_host(tds_dstr_cstr(&connection->server_host_name), ip_addr) == TDS_SUCCEED) {
+			tds_dstr_copy(&connection->ip_addr, ip_addr);
+                }
+	}
 
 	/* override locale settings with CS_CONNECTION settings, if any */
 	if (con->locale) {
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.