Professional Documents
Culture Documents
Page 1 of 14
Table of Contents
Introduction ...............................................................................................................................................................3 1 Best Practices: ASE Monitoring ...............................................................................................................................................................4 1.1 ASE versions ...........................................................................................................................................................4 1.2 Operating systems ...........................................................................................................................................................4 1.3 Tools.............................................................................................................................................4 1.4 Monitoring aspects.......................................................................................................................4 1.5 What next? ...........................................................................................................................................................4 2. ASE resources ...............................................................................................................................................................6 2.1 The ASE itself...............................................................................................................................6 2.2 Licenses.......................................................................................................................................6 2.3 Database Availability....................................................................................................................7 2.4 Data Storage................................................................................................................................7 2.5 Disk Space...................................................................................................................................8 2.6 User Activity.................................................................................................................................9 2.7 Error Logs.....................................................................................................................................9 2.8 Blocking......................................................................................................................................10 2.9 Data Consistency.......................................................................................................................10 Appendix A ........................................................................................................................................11
Page 2 of 14
Introduction
This Best Practices document is setup to help a Sybase DBA understand the various aspects of ASE monitoring and also to provide a quick start for setting up such monitoring.
Page 3 of 14
1.3 Tools
Various tools are available in the market for monitoring an ASE, e.g. Sybase SCC, Sybase Central, sysmon, MDA Tables, DB Artisan, DB Virtualizer, or Nimbus. This document focuses on what to monitor rather than recommending a tool or method to monitor. As necessary, references are made to automatic/unattended monitoring through scripts and cronjobs (Unix environments only). The ASE server software includes software like Historical Server and Monitor Server, but these are separate products with their own manuals. As such these products are not described here either.
Page 4 of 14
you. This document does not spell out the actions to follow an alert from your monitoring tool, although certain recommendations may be made. Typical Sybase environments have multiple ASEs that cater to a variety of business applications. It is recommended to buy or build a tool that provides an enterprise view of these systems, with the ability to drill down to issues for any given system. A dashboard approach to the problem that is tied in to the monitoring system, allows for the monitoring script/feature to display the server status based on the alerts just received. For example, a server down status might mark the server icon red. A 1105 error might mark the server orange. A server with no monitoring alerts would stay green and so on. As alerts are attended to, the server status would change accordingly.
Page 5 of 14
2. ASE resources
2.1 The ASE itself
a. Is the server up and running? Ping the database server frequently to ensure it is alive and responding to commands. Check for the process at O/S level and also ping the database for a simple command. Ensure it returns the expect results. This confirms the basic availability of your server. Page the on call DBA if the server process does not show up or respond. Do the same for your Backup Server process. b. If it was just rebooted, Did it start up correctly with all options enabled? Is the license valid? Did it come up with async I/O? Did all the databases come up correctly? Check for anything abnormal
ASE startup messages are more or less standard server messages, like opening of the allocated devices and databases, but others, depending on configuration and/or traceflags, can show extra information about various aspects of the running ASE, like: connections (successful and failure logins), licenses etc. See sample startserver script file in Appendix A for in-built error checking. Once a server has started, the errorlog should be checked for startup behavior and nonstandard messages, whereas a running server should have its errorlog automatically and periodically be scanned and non-standard messages be emailed to the concerned DBA(s). To decide if a message is important enough for reporting, one could setup search strings per different type of messages, like errors (fatal or not), warnings and operational messages. A separate category would be messages that could be picked up as errors or warnings, but can be skipped during normal processing. This type of messages would include objects names with the word error or msg in it. Be sure to include keywords such as E(e)rror, stack, infected, warning, msg, instead, will shutdown, failed and any other keywords/phrases applicable to your environment. Filter on errors you know to be informational. See your ASE Error Messages Guide for details on informational errors. Error numbers of the pattern 6?? (6 followed by two digits) tend to be severe. Set up special alerts for this for example, email messages with the word PANIC or SEVERE ALERT in them.
2.2 Licenses
Page 6 of 14
Many Sybase products are offered with several editions and license types. Some features are not part of the core product and as such, require active licenses. Most customers use the SYSAM manager to manage licenses. Some may have a central licensing server. Monitor your license server process. Ensure it is up and running. Look for errors. If you use stand alone licensing, check for keywords such as grace, will shutdown, Failed to obtain and expire. You can specify the email address to send licensing warnings and errors during ASE installation or by using the sp_lmconfig command after installation.
In addition to alerts, one should check the general response time that will alert the DBA if a simple query such as sp_who does not return in a reasonable amount of time. Be sure to use a nonprivileged account when checking database availability as discussed in this section.
Page 7 of 14
existing devices can grow and fill up the filesystem they are stored on. Monitor growth on these devices.
Page 8 of 14
See Practical Use of MDA tables for examples and more information.
Page 9 of 14
Be sure to include keywords such as E(e)rror, stack, infected, warning, msg, instead, will shutdown, failed and any other keywords/phrases applicable to your environment. Filter on errors you know to be informational. See your ASE Error Messages Guide for details on informational errors. Error numbers of the pattern 6?? (6 followed by two digits) tend to be severe. Set up special alerts for this for example, email messages with the word PANIC or SEVERE ALERT in them. Be sure to monitor space for your ASE errorlogs. In the default setup, ASE always appends to the current errorlog, so this file is always growing and can become too large to query or edit with an editor. In case of an ASE reboot, it is therefore advised to rename the old errorlog (adding date/timestamp) and have the ASE create a new errorlog during every reboot.
2.8 Blocking
Most blocking conflicts are temporary in nature, and will resolve themselves eventually in a very short period of time. However, potentially bad application design or thoughtless adhoc user transactions can cause massive blocking impacting multiple users of the database. At such times, the server may be up and running, but for all practical purposes it is unavailable to the user. Setup your monitoring to check for blocking that is non-transient. Any process (spid) that blocks for more than say, 2 minutes should be watched. Depending on the tolerance level of your user base, setup the alert to page the oncall DBA upon reaching a certain threshold. Often times, agreements with the business allow for spids blocking > x minutes to be killed by the monitoring script. See script sp_block in Appendix A for an example.
Page 10 of 14
Appendix A
Each sample script below executes the tasks it is written for, stored output of the job to the scripts logfile, writes status information to a central logfile (per server) and where possible also writes timing and status information to a central database.
Sample directory structure Using a standard setup of script and log directories eases the way scripts can be used and copied to other hosts/ASEs.
Directory: -------------/dba/jobs /dba/input /dba/output /dba/log /dba/sysmon Contents: ----------------------------------------------------DBA scripts for standard ASE tasks and monitoring. DBA input files, used by the DBA scripts DBA output files, like *.bcp etc. DBA script logfiles and central server logfile(s). DBA script logfiles for a specific job, e.g.: run_sysmon
The above mentioned directories are used in the script samples, shown below.
# Traceflags # Print deadlock info in log # Show login records in log # (now config setting)
# ------------------------------------------------------------------------------# Check is server is already running (prevent logfile rename) # ------------------------------------------------------------------------------if [ `/usr/bin/ps -ef | grep dataserver | grep $SERVER | wc -l` -gt 0 ] then echo "WHOA ... $SERVER is already running !!!" exit 1 else # -----------------------------------------------------------# Check Async IO setting # -----------------------------------------------------------asyncERR=`grep -c "allow sql server async i/o = 0" $CFGFIL` if [ $asyncERR -gt 0 ] then echo ------------------------------------------------------------ echo " ERROR: Async IO not configured !!! echo ------------------------------------------------------------
Page 11 of 14
fi
[ -f $LOGFIL ] && { mv $LOGFIL $LOGFIL.`date +%y%m%d.%H%M` ; } # -----------------------------------------------------------# Start ASE, specifying special directories and options # -----------------------------------------------------------$SYBASE/$SYBASE_ASE/bin/dataserver -s$SERVER \ -e$LOGFIL \ -d$MASTER \ -c$CFGFIL \ -i$SYBASE \ -M$CFGDIR \ $TRACES > /dev/null &
fi
Page 12 of 14
Filename: Purpose:
#!/bin/sh
# -------------------------------------------------------------------------------------# db_spy Collect ASE information about currently running processes # -------------------------------------------------------------------------------------$RUNSQL <<-EOF | egrep -v "return status" >> $LOGFIL $USRPWD SET NOCOUNT ON go print " -------------------------" print " Current processes" print " -------------------------" EXEC go print " -------------------------" print " Current blocked processes" print " -------------------------" EXEC go print " -------------------------" print " Current locks" print " -------------------------" EXEC go print " -------------------------" print " Heavy hitters" print " -------------------------" EXEC go print " -------------------------" print " Monitor info" print " -------------------------" EXEC go EOF sp_monitor -- Standard proc sp_hogs -- Shows cpu and IO info from sysprocesses sp_lock sp_block -- Shows blocking info sp_who
Page 13 of 14
Filename: Purpose:
#!/bin/sh # -----------------------------------------------------------------------------# Runs sp_sysmon X times against the given server for a given time period # -----------------------------------------------------------------------------SCRIPT=`basename $0` SERVER=`echo $1 | tr "[a-z]" "[A-Z]"` RUNMAX="$2" PERIOD="$3" [ $# -lt 3 ] && { echo echo echo echo echo echo echo exit # Server name # nr of time to run # Duration to run in hh:mm:ss format "------------------------------------------------------" "Usage: $SCRIPT server times period " " " "Where: server = name of the dataserver to connect to " " times = nr of times to run sp_sysmon " " period = hh:mm:ss " "------------------------------------------------------" 1 ; } # Set SYBASE environment
FILNAM="/dba/sysmon/sysmon.out.$SERVER.${RUNMAX}x$PERIOD" RUNSQL="$SYBASE/$SYBASE_OCS/bin/isql -U$SYBUSR -S$SERVER" RUNCNT=1 while [ $RUNCNT -le $RUNMAX ] do OUTFIL=$FILNAM.$RUNCNT.`date +"%y%m%d.%H%M"` if [ $RUNMAX -ge 10 -a $RUNCNT -lt 10 ] then OUTFIL=$FILNAM.0$RUNCNT.`date +"%y%m%d.%H%M"` fi $RUNSQL <<- ENDSQL $SYBPWD exec sp_echotime "`basename $OUTFIL`" print 'Server: %1!', @@servername print 'Version: %1!', @@version exec sp_sysmon "$PERIOD", @dumpcounters='Y' | egrep -v "Password|return status = 0" > $OUTFIL
exec sp_echotime "`basename $OUTFIL`" go ENDSQL compress $OUTFIL RUNCNT=`expr $RUNCNT + 1` done
Page 14 of 14