[Date Prev] [Date Next] | [Thread Prev] [Thread Next] | [Date Index] [Thread Index] |
Re: [nocol-users] SQLMon
|
"Nathan Clemons [Staff]" wrote: > > I made some changes to the SQL monitor provided by Rick. Let me know how > this works for you all, seems to work beautifully for me. There are a few problems with it. foreach $item (@items ) { # ($host,$ipaddr) = split(/\t/,$item); $rc = 0; $failconnect = 0; <-- If you don't initialize this it retains its value for the next server print "(debug) dotest: connecting to database $data_source{$item} ($username{$item}, $password{$item})\n" if $debug; if ($dbh = DBI->connect($data_source{$item}, $username{$item}, $password{$item})) { print "(debug) dotest: running command $query_string{$item}\n" if $debug; if (!($rc = $dbh->do($query_string{$item}))) { print "(debug) $host : $dbh->errstr" if $debug; Because of the line commented out above, $host doesn't actually contain anything. Uncomment it or use $item. Also, I have trouble with $dbh->errstr printing out within quotes. I'm sure there's some special syntax but I simply changed the print statement to print "(debug) $item : ".$dbh->errstr."\n" if $debug; $failconnect = -1; } } else { print "(debug) $host : $DBI::errstr" if $debug; <-- same deal here $rc = $failconnect = -1; <-- Change this to -2 } Then down a bit further: if ($failconnect > -1) { $dbh->disconnect; } change that to if ($failconnect > -2) { $dbh->disconnect; } We need to differentiate between a failure of DBI->connect (which doesn't need a subsequent disconnect) and a failure of $dbh->do (which still needs the disconnect). -- _______________________________________________________________________ Rick Beebe (203) 785-6416 Manager, Systems & Network Engineering FAX: (203) 785-3978 ITS-Med Client & Technology Services Richard.Beebe@yale.edu Yale University School of Medicine P.O. Box 208078, New Haven, CT 06520-8078 _______________________________________________________________________ |