Subject: Perl DBI: DBI:ODBC always failing ...

From: "Mr. James W. Laferriere" <[email-masked]>
Date: Mon, 2 Jun 2014 09:32:53 -0800 (AKDT)

Hello All ,  the foloowing perl script sworks flawlessly ,  but the 
following that's Argus config entry keeps saying ...

 	Can anyone shed some light on what I am doing wrong or assuming 
incorrectly ?

 		Tia ,  JimL

root@dsb-mntr01:~# cat ~/bin/perlDBI_dbd-odbc-example.pl
use DBI;
# DBD::ODBC
my $dsn = 'DBI:ODBC:Driver={TDS}';
my $host = 'dsb-synsqlsvr';
my $database = '';
my $user = 'USERNAME';
my $auth = 'PASSWORD';

# Connect via DBD::ODBC by specifying the DSN dynamically.
my $dbh = DBI->connect("$dsn;Servername=$host;Port=1433",
         $user,
         $auth,
         { RaiseError => 1, AutoCommit => 1}
         ) || die "Database connection not made: $DBI::errstr";

#Prepare a SQL statement
my $sql = "SELECT GetDate()";
my $sth = $dbh->prepare( $sql );

#Execute the statement
$sth->execute();
my( $id );

# Bind the results to the local variables
$sth->bind_columns( undef, \$id );

#Retrieve values from the result set
while( $sth->fetch() ) {
         print "$id\n";
}

#Close the connections
$sth->finish();
$dbh->disconnect();

 	Execution ...
root@dsb-mntr01:~# perl -W ~/bin/perlDBI_dbd-odbc-example.pl
2014-06-02 09:16:52.710

#Windows Server 2008 R2 & M$Sql 2008
Host "dsb-synsqlsvr" {
   hostname: dsb-synsqlsvr.dsb.local
   Service Ping {
     frequency!: 60
     retries!: 3
     timeout!: 5
     label: 01 dsb-synsqlsvr.dsb.local ping response time
     ylabel: milli-seconds
     drawgrid:  yes
     graph: yes
   }
   Service DB {
#    dsn:       dbi:ODBC:Driver={TDS};Servername=dsb-synsqlsvr;Port=1433
     dsn:        dbi:ODBC:Driver={TDS};host=dsb-synsqlsvr
     user:       USERNAME
     pass:       PASSWORD
     sql:        SELECT GetDate()
   }
}

 	argusctl run to get full error message ...

root@dsb-mntr01:~# argusctl getchildrenparam 
object=Top:DSB:02_Main_Office:05_Servers:dsb-synsqlsvr param=db::rbuffer | sed 
-e's/~x20/ /g' -e's/~x2F/\//g'
ARGUS/2.0 200 OK
Top:DSB:02_Main_Office:05_Servers:dsb-synsqlsvr:DB_dbi:ODBC:Driver={TDS};host=dsb-synsqlsvr: 
DBERROR: could not connect to database: install_driver(ODBC) failed: Unable to 
get DBI state function. DBI not loaded. at 
/usr/lib/perl5/5.12.3/i486-linux-thread-multi/DynaLoader.pm line 
223.~x0ACompilation failed in require at (eval 9) line 3.~x0A~x0A at 
/usr/local/lib/argus/DataBase.pm line 132~x0A~x0A

-- 
+------------------------------------------------------------------+
| James   W.   Laferriere | System    Techniques | Give me VMS     |
| Network&System Engineer | 3237     Holden Road |  Give me Linux  |
| [email-masked] | Fairbanks, AK. 99709 |   only  on  AXP |
+------------------------------------------------------------------+

---

From: "Mr. James W. Laferriere" <[email-masked]>
Date: Wed, 4 Jun 2014 15:26:12 -0800 (AKDT)

Hello All ,

> 	Can anyone shed some light on what I am doing wrong or assuming 

 	Fix was easy ,  Upgrade to 3.7 & make these changes in the config .

root@dsb-mntr01:~# diff -U1 dsb-synsqlsvr-20140602 dsb-synsqlsvr-20140604
--- dsb-synsqlsvr-20140602      2014-06-04 15:24:54.000000000 -0800
+++ dsb-synsqlsvr-20140604      2014-06-04 15:23:21.000000000 -0800
@@ -13,3 +13,3 @@
    Service DB {
-    dsn:       dbi:ODBC:Driver={TDS};host=dsb-synsqlsvr
+    dsn:       dbi:ODBC:Driver={TDS};Servername=dsb-synsqlsvr.dsb.local
      user:      USERNAME
@@ -17,2 +17,3 @@
      sql:       SELECT GetDate()
+    label: 02 dsb-synsqlsvr.dsb.local M$Sql responds:
    }

 		Hthse ,  JimL