MSSQL using NSClient++

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
ofadl
Posts: 201
Joined: Mon Jun 03, 2013 8:57 am

Re: MSSQL using NSClient++

Post by ofadl »

ok i edited that line, saved and restarted. Then checked again with :

/usr/lib/nagios/plugins/check_mssql_sproc.pl -H $HOSTADDRESS$ -p "sp_CheckCoreLastDeliveredBusHours" -u sa -P "dusT#Controle" -w $ARG1$ -c $ARG2$


and still got the same error as previous:

DBI connect('DRIVER={SQL Server};SERVER=10.200.50.176','sa',...) failed: [unixODBC][Driver Manager]Data source name not found, and no default driver specified (SQL-IM002) at /usr/lib/nagios/plugins/check_mssql_sproc.pl line 68
Error: Unable to connect to MS-SQL database!
[unixODBC][Driver Manager]Data source name not found, and no default driver specified (SQL-IM002)
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: MSSQL using NSClient++

Post by abrist »

What is the output of:

Code: Select all

sed -n '60,80p' /usr/lib/nagios/plugins/check_mssql_sproc.pl 
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
ofadl
Posts: 201
Joined: Mon Jun 03, 2013 8:57 am

Re: MSSQL using NSClient++

Post by ofadl »

as follows:

}

my $conn;

$conn{"username"} = $opt_user;
$conn{"server"} = $opt_host;
$conn{"password"} = $opt_pw;
$conn{"dsn"} = "dbi:ODBC:DRIVER={SQL Server};SERVER=" . $conn{"server"};
$conn{"dbh"} = DBI-> connect( $conn{"dsn"}, $conn{"username"}, $conn{"password"} )
or die "Error: Unable to connect to MS-SQL database!\n", $DBI::errstr,"\ n";


my $sql = qq{ use $opt_db exec $opt_proc };
my $sth = $conn{"dbh"}->prepare( $sql );
$sth->execute();
my( $result );
$sth->bind_columns( undef, \$results );


while( $sth->fetch() ) {
process_results($results);
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: MSSQL using NSClient++

Post by abrist »

Lets check the ini for ODBC

Code: Select all

find / -name odbcinst.ini
grep Driver /path/from/find/command
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
ofadl
Posts: 201
Joined: Mon Jun 03, 2013 8:57 am

Re: MSSQL using NSClient++

Post by ofadl »

ok i found it in :


/etc/odbcinst.ini

then did:

grep Driver /etc/odbcinst.ini

what do i do next?
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: MSSQL using NSClient++

Post by abrist »

You should have a had some output from that command. Could you post the contents of the file:

Code: Select all

/etc/odbcinst.ini
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
ofadl
Posts: 201
Joined: Mon Jun 03, 2013 8:57 am

Re: MSSQL using NSClient++

Post by ofadl »

its empty, there's nothing in it
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: MSSQL using NSClient++

Post by abrist »

That's not good. I can show you what is in one of my test boxes, but your mileage may vary (due to possible distro differences):

Code: Select all

# Example driver definitions

# Driver from the postgresql-odbc package
# Setup from the unixODBC package
[PostgreSQL]
Description     = ODBC for PostgreSQL
Driver          = /usr/lib/psqlodbc.so
Setup           = /usr/lib/libodbcpsqlS.so
Driver64        = /usr/lib64/psqlodbc.so
Setup64         = /usr/lib64/libodbcpsqlS.so
FileUsage       = 1


# Driver from the mysql-connector-odbc package
# Setup from the unixODBC package
[MySQL]
Description     = ODBC for MySQL
Driver          = /usr/lib/libmyodbc5.so
Setup           = /usr/lib/libodbcmyS.so
Driver64        = /usr/lib64/libmyodbc5.so
Setup64         = /usr/lib64/libodbcmyS.so
FileUsage       = 1
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
ofadl
Posts: 201
Joined: Mon Jun 03, 2013 8:57 am

Re: MSSQL using NSClient++

Post by ofadl »

maybe i downloaded the wrong thing? I dont understand why the file is empty
sreinhardt
-fno-stack-protector
Posts: 4366
Joined: Mon Nov 19, 2012 12:10 pm

Re: MSSQL using NSClient++

Post by sreinhardt »

Do you have any of the files listed in abrists config? If not can you do a "locate psqlodbc.so" and so on for the rest of the files? If you have them, you likely can replicate the same config as shows with your own paths.
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
Locked