Perl DBI: DBI:ODBC always failing ...
Mr. James W. Laferriere
babydr at baby-dragons.com
Mon Jun 2 13:32:53 EDT 2014
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 at 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 at 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 at 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 |
| babydr at baby-dragons.com | Fairbanks, AK. 99709 | only on AXP |
+------------------------------------------------------------------+
More information about the Arguslist
mailing list