0

New Issue:

I am trying to run my check_sql command and am running into this problem

./odbcinst -j
unixODBC 2.3.0
DRIVERS............: /usr/local/unixODBC/etc/odbcinst.ini
SYSTEM DATA SOURCES: /usr/local/unixODBC/etc/odbc.ini
FILE DATA SOURCES..: /usr/local/unixODBC/etc/ODBCDataSources
USER DATA SOURCES..: /root/.odbc.ini
SQLULEN Size.......: 8
SQLLEN Size........: 8
SQLSETPOSIROW Size.: 8

[root@]# /usr/lib64/nagios/plugins/check_sql.pl -v -s -d "DBI:ODBC:Driver={SQL Server};Server=10.125.243.4;dbname=test" -U TEST -P PASS
Trying to connect. Connect string: 'DBI:ODBC:Driver={SQL Server};Server=10.125.243.4;dbname=test'
DBI connect('Driver={SQL Server};Server=10.125.243.4;dbname=test','TEST',...) failed: [unixODBC][Driver Manager]Data source name not found, and no default driver specified (SQL-IM002)(DBD: db_login/SQLConnect err=-1) at /usr/lib64/nagios/plugins/check_sql.pl line 212
CHECK_SQL.PL CRITICAL - [unixODBC][Driver Manager]Data source name not found, and no default driver specified (SQL-IM002)(DBD: db_login/SQLConnect err=-1)

[root@]# /usr/lib64/nagios/plugins/check_sql.pl -v -s -d "DBI:ODBC:Driver={ODBC Driver 11 for SQL Server};Server=10.125.243.4;dbname=test" -U TEST -P PASS
Trying to connect. Connect string: 'DBI:ODBC:Driver={ODBC Driver 11 for SQL Server};Server=10.125.243.4;dbname=test'
DBI connect('Driver={ODBC Driver 11 for SQL Server};Server=10.125.243.4;dbname=test','TEST',...) failed: [unixODBC][Driver Manager]Data source name not found, and no default driver specified (SQL-IM002)(DBD: db_login/SQLConnect err=-1) at /usr/lib64/nagios/plugins/check_sql.pl line 212
CHECK_SQL.PL CRITICAL - [unixODBC][Driver Manager]Data source name not found, and no default driver specified (SQL-IM002)(DBD: db_login/SQLConnect err=-1)

---------- FIXED --------- DOWNLOADED AND INSTALLED 1.48 WITH NO ERRORS

------ OLD ISSUE with 1.1X ODBC ----------

I am currently in the DBD-ODBC-1.13 directory

export LD_LIBRARY_PATH=/usr/lib:/usr/local/unixODBC
export ODBCHOME=/usr
export DBI_DSN=dbi:ODBC:JDBC 
export DBI_USER=guest
export DBI_PASS=sybase

perl Makefile.PL

perl Makefile.PL 
Useless use of private variable in void context at Makefile.PL line 431.
Argument "6.55_02" isn't numeric in numeric ge (>=) at Makefile.PL line 33.

Configuring DBD::ODBC ...

>>> Remember to actually *READ* the README file!
    And re-read it if you have any problems.

Using DBI 1.609 (for perl 5.010001 on x86_64-linux-thread-multi) installed in /usr/lib64/perl5/auto/DBI/
Using ODBC in /usr/local/unixODBC

Umm, this looks like a unixodbc type of driver manager.
We expect to find the sql.h, sqlext.h and (which were
supplied with unixODBC) in $ODBCHOME/include directory alongside
the /usr/local/unixODBC/lib/libodbc.so library. in $ODBCHOME/lib

Use of uninitialized value in pattern match (m//) at Makefile.PL line 272.
Warning: LD_LIBRARY_PATH doesn't include /usr/local/unixODBC

Injecting selected odbc driver into cc command
Injecting selected odbc driver into cc command
Using DBI 1.609 (for perl 5.010001 on x86_64-linux-thread-multi) installed in /usr/lib64/perl5/auto/DBI/
Writing Makefile for DBD::ODBC

The DBD::ODBC tests will use these values for the database connection:
    DBI_DSN=dbi:ODBC:JDBC       e.g. dbi:ODBC:demo
    DBI_USER=guest
    DBI_PASS=sybase

Thanks in advance!

John Z
  • 464
  • 1
  • 6
  • 17
  • 1
    Firstly DBD-ODBC-1.13 is ancient - download a newer one if you can. Secondly, you have not shown us an error. The output you point to is not an error, it is a statement of what is expected. Show us the complete build log. – bohica Apr 10 '14 at 09:11
  • You're very right. Did not notice that when I first downloaded it. I am upgraded to the 1.48 and it installed perfectly fine. I am now having problems with the command above. Please let me know if I am missing anything. – John Z Apr 10 '14 at 19:59
  • I don't get the "I am not having problems with the command above". What did you do and what was the outcome? I cannot work out what your /new/ problem is from your post. – bohica Apr 11 '14 at 00:25
  • BI connect('Driver={SQL Server};Server=10.125.243.4;dbname=test','TEST',...) failed: [unixODBC][Driver Manager]Data source name not found, and no default driver specified (SQL-IM002 – John Z Apr 11 '14 at 16:48
  • Trying to find out what would be causing no data source name not being found. From my research it appears to be from a .ini file, just having trouble find out the right settings. – John Z Apr 11 '14 at 16:49

1 Answers1

1

I had to properly setup my system for unixODBC to talk with FreeTDS:

I did this by configuring FreeTDS the following way: taken from http://www.unixodbc.org/doc/FreeTDS.html

./configure --with-tdsver=8.0 --prefix=/usr/local/freetds --with-unixodbc=/usr/local/unixODBC
make && make install 

cd /usr/local/unixODBC/
mkdir templates && cd templates

vim tds.driver.template
[FreeTDS]
Description     = v0.91 with protocol v8.0
Driver          = /usr/local/freetds/lib/libtdsodbc.so
# Register ODBC Driver 
../bin/odbcinst -i -d -f tds.driver.template 

# Setup default DB - easily add or remove DSNs 
vim tds.datasource.template
[ODBCTestServer]
Driver = FreeTDS
Description = Test
Trace = No
Server = 5.5.5.5
Port = 1433
Database = Test
# Create ODBC data source 
../bin/odbcinst -i -d -f tds.datasource.template

/usr/lib64/nagios/plugins/check_sql.pl -v -s -d "DBI:ODBC:DRIVER={FreeTDS};Server=5.5.5.5;dbname=test" -U TEST -P PASS

This finally allows for connections to occur.

John Z
  • 464
  • 1
  • 6
  • 17