Results 1 to 10 of 10
  1. #1
    Join Date
    May 2009
    Posts
    1

    Arrow Unanswered: How to check the Database connection?

    Dear All,

    I am new to this SYBASE. Can anyone please help me?
    We are using SYBASE database.

    I want to check the DB connection status for every 60 secs without doing any operation (like ct_send, ct_results.....). Its like watchdog or heartbeat check fuunctionality.

    Is there any in-built method in CT-Lib??

  2. #2
    Join Date
    Mar 2008
    Posts
    96
    If u r using Unix OS you can make cron job to check that.

  3. #3
    Join Date
    Jun 2009
    Posts
    2
    Friend,
    Please Use cron job + shell script if u are using UNIX Machine

    In Shell script U can check for active or not
    isql -S Machine -U Username -P Password

    If it is active we can get a value as 1<
    Let me know if any further information is needed.
    Thanks Arun

  4. #4
    Join Date
    May 2008
    Location
    Cambridge
    Posts
    26
    The isql from a shell script doesn't always work if ASE is hanging, which can happen, and if you're running your shell script from cron every 5 minutes, then you can end up with lots of instances of the script in memory all hanging.

    Best to write a little script with the following two functions:

    check_ase_up()
    {
    if [ $(ps -ef | grep dataserver | grep -v grep | wc -l) -eq 0 ]
    then
    # dataserver is not running
    echo ASE not running.
    # can send out email or sms alert here
    exit
    fi
    }


    check_previous_instance()
    {
    if [ $(ps -ef | grep $SCRIPTNAME | egrep -v "vi|grep" | grep -v "sh -c" | wc -l | awk '{print $1}') -gt 8 ]
    then
    # previous instance still running - probably hanging
    echo $$SCRIPTNAME: Previous instance still running. ASE hanging?
    # can send out email or sms alert here
    exit
    fi
    }

    Hope that helps.
    Incidentally, I'd love to know if anyone has a better (and neater) method for checking to see if ASE is hanging.

    Bob
    Last edited by harq; 06-03-09 at 09:47.
    Bob Holmes
    Sybase ASE/Replication Server Administrator
    Digital Data Safe - managed database services
    Email: bob.holmes@ddsafe.co.uk

  5. #5
    Join Date
    Jun 2009
    Posts
    2
    Mr Bob,

    The solution u given is Good for ASE is up or not.
    and not sure about ASE hanging. & here also we need to use the cron job the script .Because Mr Mathan is expecting that to work continuously with out his intention.

    I am eager to know if any one is giving better methoed Structure.

  6. #6
    Join Date
    May 2008
    Location
    Cambridge
    Posts
    26
    Yup. Basically, you cron the script (at your preferred frequency), and if it runs silently then no problem. However, if you start getting emails or sms alerts (not coded in my example) then you know there's a problem.
    Bob Holmes
    Sybase ASE/Replication Server Administrator
    Digital Data Safe - managed database services
    Email: bob.holmes@ddsafe.co.uk

  7. #7
    Join Date
    Sep 2003
    Location
    Switzerland
    Posts
    443
    Quote Originally Posted by harq
    The isql from a shell script doesn't always work if ASE is hanging, which can happen, and if you're running your shell script from cron every 5 minutes, then you can end up with lots of instances of the script in memory all hanging.

    Bob
    Bob,
    This is not true necessarily. As long you have a proper interfaces file with interval/timeout next to server name, isql will be ok.

    To the OP (Original Poster),

    You need a lot more than just a heartbeat if you are the sole responsibility for monitoring the server. For eg., a transaction log full on a user database will not be reported in your heartbeat. Theres quite a bit of free monitoring scripts available in google. So, please do ur research.

  8. #8
    Join Date
    May 2008
    Location
    Cambridge
    Posts
    26
    Ah right. I don't remember seeing an interval/timeout in the interfaces file before - is it undocumented? Could you give an example entry?
    Thanks
    Bob
    Bob Holmes
    Sybase ASE/Replication Server Administrator
    Digital Data Safe - managed database services
    Email: bob.holmes@ddsafe.co.uk

  9. #9
    Join Date
    Sep 2003
    Location
    Switzerland
    Posts
    443
    Quote Originally Posted by harq
    Ah right. I don't remember seeing an interval/timeout in the interfaces file before - is it undocumented? Could you give an example entry?
    Thanks
    Bob
    Hi Bob,

    As far as I know its pretty straight forward.


    SyBooks Online

    MYSERVER 3 5

    In the above example 3 is the retry attempts. 5 is the number of seconds between connection attempts.

    For eg., if you have nothing on the numbers, it will forever try to connect.


    Another interesting point is you could have multiple query entries if you have a retry/no. of seconds limit. So, in the above case if it fails 3 retry attempts on 5 second intervals, and if you do have a second query entry, it will try to connect thro that query entry. So you could make a single isql connection connect to 2 different servers if the data are the same and the primary is down for eg.

  10. #10
    Join Date
    Nov 2011
    Posts
    43

    Red face DataBase Autometically disconneting after 30 mins DB2

    Hi all

    its really helpful posts


    Thanks & Regards
    Siddhu
    Last edited by siddhu.pandu0854; 11-23-11 at 08:33.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •