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: Michael Peppler <mpeppler at peppler dot org>
Subject: Re: Naming one's hostname for sp_who
Date: Oct 9 2001 4:51PM

David LANDGREN writes:
 > |kiruna (8:56AM):1 > perl -MSybase::DBlib -e 'my $dbh = new Sybase::DBlib
 > |"sa"; sleep(100);'
 > |
 > |(yeah - I've still got the null sa password :-) and I get:
 > 
 > Hmm. And I thought I was the only one :)
 > 
 > |So this sets it correctly for me.
 > |
 > |Maybe your gethostname() (or whatever) call doesn't work right?
 > |
 > | > Rats. I cleared the source of the machine a few weeks ago. I'll
 > download it
 > | > again and tell you how it went.
 > |
 > |OK.
 > 
 > Our mails crossed. I think gethostname() is working ok. I running this code
 > from the same server that Sybase is running on, so it's normal that it
 > returns the name of the server.
 > 
 > However, I have lots of different scripts that tend to eat CPU when we're
 > not watching, so I need to be able to differentiate between them.
 > 
 > This was easy to do with the older scripts that are dreadful shell hacks
 > that talk to isql, because I was able to override the hostname column with
 > the -H flag of isql, which makes it possible to identify them. I would like
 > to emulate doing that via the more recent scripts that use Sybase::DBlib to
 > connect.

The DBSETLHOST() patch will do that. You can also use the appname bit
(although that doesn't show in sp_who, it does show in sp__who, and
you can of course query master..sysprocesses directly and get the
appropriate fields)

BTW - I use the following query to list "active" connections:

    select spid,
        suser_name(suid) loginname,
        cmd,
        status,
        object_name(id, dbid) procname,
        linenum,
        blocked,
        time_blocked,
        hostname,
        program_name
  from master..sysprocesses
  where spid != @@spid
    and status != 'recv sleep'
    and cmd not like '%HANDLER'
    and cmd not like 'DEADLOCK%'
    and cmd not like 'CHECKPOINT%'
    and cmd != 'HOUSEKEEPER'

I've put that in a cgi script that reloads every X seconds, works
pretty well...

Michael
-- 
Michael Peppler - Data Migrations Inc. - http://www.mbay.net/~mpeppler
mpeppler@peppler.org - mpeppler@mbay.net
International Sybase User Group - http://www.isug.com