PEPPLER.ORG
Michael Peppler
Sybase Consulting
Menu
Home
Sybase on Linux
Install Guide for Sybase on Linux
General Sybase Resources
General Perl Resources
Freeware
Sybperl
Sybase::Simple
DBD::Sybase
BCP Tool
Bug Tracker
Mailing List Archive
Downloads Directory
FAQs
Sybase on Linux FAQ
Sybperl FAQ
Personal
Michael Peppler's resume

sybperl-l Archive

Up    Prev    Next    

From: "Wechsler, Steven M" <WechslerSM at bernstein dot com>
Subject: RE: Beginner question - doing async communications with Sybase
Date: Dec 5 1997 3:20PM

The examples I gave (sp_who, sp_lock) are not what I'm going to be
executing; the actual commands are going to take a lot longer, and could
take a couple of minutes on some of our systems.  That's not practical
when you want to monitor multiple systems.

Here's what I want to do, in a sort of pseudocode:

for each server:
  {
    establish connection
    if server is down {
      raise alert
    } else {
      get list of blocked processes; raise alert if appropriate
(determined by server and database name; blocks on development servers
take longer to alert than those on production servers)
      check free space in tempdb;
      get list of databases;
      for each database {
        check size of syslogs; compare with logsegment size; if > some
percentage, raise alert
      }
    }
  }
etc.

I'll be doing something similar for our replication servers...

In the past I've implemented this in a ksh script, starting a whole
bunch of isql queries in the background at once, sending the output to
files, then reading the files.  Needless to say, this was hopelessly
klunky and I'd prefer not to do it that way this time.

Steve
--
Steven Wechsler/Sybase DBA/Sanford C. Bernstein 
WechslerSM@bernstein.com 

Support the Anti-SPAM amendment: http://www.cauce.org

>-----Original Message-----
>From:	Michael Peppler [SMTP:mpeppler@mbay.net]
>Sent:	Thursday, December 04, 1997 5:09 PM
>To:	SYBPERL-L@trln.lib.unc.edu
>Subject:	Re: Beginner question - doing async communications with Sybase
>
>Wechsler, Steven M wrote:
>> 
>> 
>> However, looking at the Sybperl CT-LIB documentation doesn't seem to
>> shed any light on how I can do this.  Sending commands and receiving
>> data back is fairly straightforward, but how can I tell that the SQL
>> server has sent the data before I start querying.  Can I do something
>> like this:
>> 
>> 
>> finished=1;     # flag
>> foreach $server (@dbh) { # dbh is an array of DB handles
>>   if (($rc = $server->ct_results(CS_CMD_DONE)) != CS_SUCCEED) {
>>     if ($rc == CS_FAIL) {
>>       # command failed; take appropriate action
>>     } elsif (($rc = $server->ct_results(CS_COMPUTE_RESULT)) ==
>> CS_SUCCEED {
>>       # does this mean that the command is still running?  if so,
>>       $finished=0;
>>       last; # in real life there'd be some sort of timeout, after
>>       # which we'd assume the server was down because it hadn't
>>       # responded in time.
>>     }
>>   }
>> }
>
>I'd do it like this:
>
>foreach $dbh (@dbh) {
>   $dbh->ct_execute($cmd);
>   while($dbh->ct_results($restype) == CS_SUCCEED) {
>      if($dbh->ct_fetchable($restype)) {
>          while(@dat = $dbh->ct_fetch) {
>   	     # do something with the data here
>          }
>      }
>   }
>}
>
>This way you query each server one after the other.
>Sybperl does not allow you to do asynchronous querying, so this
>way is simplest, and is usually good enough, especially if
>you're running simple things like sp_who, sp_locks, etc.
>
>Michael
>-- 
>Michael Peppler       -||-  Data Migrations Inc.
>mpeppler@datamig.com  -||-  http://www.mbay.net/~mpeppler