Monitoring Utilities 2018 08-98 6-189 1998 Informix Software, Inc.
Monitoring Utilities
Module6
Objectives
At the end of this module, you will be able to:
n List the utilities for monitoring a server
n Use the System Monitoring Interface to run SQL statements to obtain information about the server
Monitoring Utilities 6-190
Monitoring Utilities 2018 08-98 190
Monitoring Utilities
There are several utilities that you can use to monitor a server:n System Monitoring Interface (SMI)n onstatn oncheck
There are several utilities to monitor server activity. n The System Monitoring Interface (SMI) n The onstat utilityn The oncheck utilityMany of the options are used for debugging by Informix technical support only. The options that can be used for monitoring and tuning purposes are detailed in the following chapters.
Monitoring Utilities 6-191
Monitoring Utilities 2018 08-98 191
SMI
The System Monitoring Interface (SMI) is a read-only access method to administrative information related to a Dynamic Server system that:n Provides SQL access to shared memory structuresn Provides profile information for specific
user sessionsn Allows a Dynamic Server administrator to
easily automate the system monitoring process.
SharedMemory
SYSMASTERDatabase
SQL
The SMI provides you with point-in-time information about the contents of the Dynamic Servers shared memory data structures. The SMI is implemented via the sysmaster database. There is one sysmaster database for each Dynamic Server instance. The sysmaster database contains its own system catalog tables and a set of virtual tables that serve as pointers to shared memory data. The SMI is useful because it simplifies the task of programming monitoring functions for repetitive use. The sysmaster database is documented in the Informix Dynamic Server Administrators Guide. The sysmaster database schema is also provided and commented in the $INFORMIXDIR /etc/sysmaster.sql file.
Monitoring Utilities 6-192
Monitoring Utilities 2018 08-98 192
The sysmaster Database
n The sysmaster database is created automatically the first time a server initializes.
n The database contains data dictionary information that points to shared memory structures.
n Some sysmaster tables (used by ON-Archive) are real tables.
Shared Memory
Data Dictionary for sysmaster
The sysmaster database holds the tables used by SMI to retrieve diagnostic information. There is one sysmaster database created for each server instance. The database is created automatically the first time the server is initialized.Most of the SMI tables do not hold any data. Instead, the data dictionary structures for that table point to structures in shared memory.There are some tables included in the sysmaster database that are used by the ON-Archive utility. These tables actually hold the data in the table and are not pointing to shared memory structures.All users have permission to query the supported tables in sysmaster.
Monitoring Utilities 6-193
Monitoring Utilities 2018 08-98 193
How SMI Works
SELECT * from syslocks
Shared Memory
The server recognizes syslocks as an SMI
table, and reads from shared memory
instead of disk/buffer pool.
When a SELECT statement is executed on a regular table, the server reads the data dictionary information for the table to find the partition number and other information about the table. Then it will access the data from disk, if it is not in the buffer pool.When a SELECT statement is executed on an SMI table, the server still reads the data dictionary information for the table listed in the SELECT statement. The SMI tables have a special partition number (the dbspace number within the partition number is 0). When the server detects the special partition number, it knows to read a specific set of data in shared memory to satisfy the query. Because the SELECT statement is accessing real-time data in shared memory, the data between one SMI table and another may not be synchronized.
Monitoring Utilities 6-194
Monitoring Utilities 2018 08-98 194
SMI Restrictions
n You cannot lock SMI tables or use isolation levelsn INSERT, UPDATE, and DELETE statements are not
allowedn dbschema and dbexport cannot be used on the sysmaster
databasen SELECT rowid will return unpredictable results
There are a few restrictions in using SMI tables. They are listed below:n You cannot lock the non-permanent SMI tables or use isolation levels. Since
these tables are nothing but shared memory structures, the traditional SQL locking mechanisms are ineffective (and not desired).
n INSERT, UPDATE, and DELETE statements are not allowed against non-permanent SMI tables.
n The dbschema and dbexport utilities cannot be used for the sysmaster database. You will receive the following error:Database has pseudo tables - cant build schema
n The use of rowid in a SELECT statement is not relevant and will return inconsistent results.
Monitoring Utilities 6-195
Monitoring Utilities 2018 08-98 195
The Sysmaster Database
n sysdatabases - Databases in the servern systabnames - Tables within a databasen syslogs - Logical log informationn sysdbspaces - Dbspace informationn syschunks - Chunk informationn syslocks - Lock informationn sysvpprof - VP informationn syssessions - Session informationn syssesprof - Session level profile informationn sysextents - Extent informationn syschkio - I/O statistics by chunkn sysptprof -Tblspace profile informationn sysprofile - System profile information
The sysmaster database consists of over 50 tables. Of these tables, only some tables and some views are supported and documented by Informix. For your protection, only the supported tables and views should be used in any programs as the unsupported tables may change between releases. The supported tables and views are:n The sysdatabases table lists databases, owner and characteristics of the
database.n The systabnames table contains the names of all tables in the server. To
retrieve all tables in a database, run:SELECT tabname FROM systabnames WHERE dbsname = db_name
n The syslogs view contains information about the logical logs. You can use syslogs to determine if the logs need to be backed up. If size = used, then the log is full.
n The sysdbspaces view contains information about dbspaces.n The syschunks view contains the chunks in the server. The nfree column
shows the number of pages in the chunk that are free.n The syslocks view lists all active locks.n The sysvpprof view contains all the active virtual processors.n The syssessions view lists information about each session.
Monitoring Utilities 6-196
Continued
n The syssesprof view contains more information about each session.n The sysextents view lists extents allocated in the server.n The syschkio view contains I/O statistics by chunk.n The sysptprof view lists information about the tblspaces at any one point in
time. Only tables currently being used are listed in this view. Once the last user closes the table, the tblspace structure in shared memory is freed, and subsequently any profile statistics are lost.
n The sysprofile view lists certain events in the server such as disk reads, disk writes, roll backs, checkpoints, etc. Each row contains one profiled event and its value. Some of the values of the name column are shown below:
ExampleYou can use the syschunks table (it is actually a view) to find out the percent used space in all of the chunks in your server:Select chknum,(100 * (chksize - nfree)/chksize)
from sysmaster:syschunksThis information can also be derived from the following onstat command:onstat -d
dskreads bufreadsdskwrites bufwrites isamtotisopensisstartsisreadsiswritesisrewrites isdeletes iscommits isrollbacks ovtblsovlockovuserovtranscompressfgwriteslruwriteschunkwrites
latchreqslatchwtsbuffwtslockreqslockwtsckptwtsdeadlkslktoutsnumckptsplgpagewritesplgwrites llgrecsllgpagewritesllgwrites pagreadspagwrites flushesdprarapgs_used seqscansbtradata
Monitoring Utilities 6-197
Monitoring Utilities 2018 08-98 197
SMI Tables or Views (cont.)
n sysadtinfo - auditing configuration informationn sysaudit - auditing event masksn sysconfig - Configuration parameter valuesn sysdri - Data-replication informationn sysseswts - Users wait time on each of several objects
n The sysadtinfo table contains information about the auditing configuration for the server. You must be user informix to retrieve information from this table.
n The sysaudit table contains the hexadecimal representation of each defined audit mask. To list, modify, or add an audit mask you must use the onaudit utility. You must be user informix to retrieve information from the sysaudit table.
n The sysconfig table describes the effective, original, and default values of the configuration parameters.
n The sysdri table provides information on the data-replication status of the database server.
Monitoring Utilities 6-198
Continued
n The sysseswts table provides information on the amount of time users wait for the following database objects:
ExampleYou can join the syslocks and syssessions tables (they are actually views) to list the current locks, who owns them, and if any session is waiting for a lock:SELECT username, sid, waiter, dbsname, tabname,
rowidlk, keynum, type FROM sysmaster:syslocks, sysmaster:syssessionsWHERE syssessions.sid = syslocks.owner
Output from the above statement is similar to the output from the onstat -u and onstat -k commands.
unspecifiedbufferlockasynchronous I/Omt yield 0mt yield nmt yieldcheckpointlog I/Olog copycondition
lock mutexlockfree mutexlockfree mutexdeadlock mutexlrus mutextblsp mutexlog mutexckpt mutexmutexmt readymt yield xrunning
Monitoring Utilities 6-199
Monitoring Utilities 2018 08-98 199
The onstat Utility
Onstat:n Lists what is in the server shared memory structures at the
instant the command is runn No disk I/O is performedn No locking is performed, therefore, it does not impact the
performance of the server
The onstat utility will read the server shared memory structures and report the contents of shared memory at the instant that it is run. This means the contents of shared memory may be changing as they are being printed (as no memory locking is done by onstat). The onstat utility prints out the contents of the various internal tables (or data structures) maintained in shared memory. It does not print out the contents of the buffer pool. Since these tables keep track of all activity in the server, this tool gives a good picture of what is going on in the system at the time it is run.Generally, onstat does no disk I/O; it reads from shared memory alone (there are a few options that will read from disk files). Because it places no locks on shared memory resources, it does not impact the performance of the server.
Monitoring Utilities 6-200
Monitoring Utilities 2018 08-98 200
Onstat Options
n Interactive option:onstat -i
n Multithreaded options:onstat -g sub_options
n List all options:onstat --
n Show status of instance:onstat -
n Repeat/refresh:onstat -r
There are many onstat options available. Many of the options are used for debugging by Informix technical support only. The options that can be used for monitoring and tuning purposes are detailed in the following chapters.
Interactive OptionTo bypass the overhead of having to connect to shared memory every time an onstat command is run, you can connect to shared memory once using onstat -i. This option displays a prompt from which you can enter any onstat option (omit the hyphen (-) in front of the option). For example:onstat -i> uYou can also use the repeat option in interactive mode; for example:> r 5> uThis example will run the u option every five seconds. To discontinue the repeated option, press Control-c.To exit from the interactive option, press Control-c.
Monitoring Utilities 6-201
Continued
Multithreaded OptionsMost of the onstat options display activities in the servers multithreaded subsystem. These three letter options must be preceded by -g (unless being run with the interactive option). For example:onstat -g at h
Monitoring Utilities 6-202
Monitoring Utilities 2018 08-98 202
Onstat Header Output
Version X.XX.XXX -- On-Line -- Up 18:35:19 -- 8872 Kbytes
Mode Uptime shared memory sizen On-Linen Off-Linen Quiescentn Shutdownn Recoveryn (CKPT REQ) checkpoint requested, but not startedn (CKPT) checkpoint in progress
The first line in any onstat output is the header. It contains information about the current state of the server.
Monitoring Utilities 6-203
Continued
Onstat Syntax and Optionsusage: onstat [-abcdghklmpstuzBDFRX][-i] [-r seconds] [-o file] [infile]
-a Print all info
-b Print buffers
-c Print configuration file
-d Print dbspaces and chunks
-g MT sub-command (default: all)
-i Interactive mode
-h Print buffer hash chain info
-k Print locks
-l Print logging
-m Print message log
-p Print profile
-s Print latches
-t Print tblspaces
-u Print user threads
-z Zero profile counts
-B Print all buffers
-C Print btree cleaner requests
-D Print dbspaces and detailed chunk stats
-F Print page flushers
-R Print LRU queues
-x Print transactions
-X Print entire list of sharers and waiters for buffers
-r Repeat options every n seconds (default: 5)
-o Put shared memory into specified file (default: onstat.out)
Monitoring Utilities 6-204
Continued
Onstat Optionsonstat -g option
Multithreaded Optionsath Print all threads
wai Print waiting threads
act Print active threads
rea Print ready threads
sle Print all sleeping threads
spi Print spin locks with long spins
sch Print VP scheduler statistics
lmx Print all locked mutexes
wmx Print all mutexes with waiters
con Print conditions with waiters
stk Dump the stack of a specified thread
glo Print MT global information
mem Print pool statistics
seg Print memory segment statistics
rbm Print block map for resident segment
nbm Print block map for non-resident segments
afr Print allocated pool fragments
ffr Print free pool fragments
ufr Print pool usage breakdown
iov Print disk IO statistics by vp
iof Print disk IO statistics by chunk/file
ioq Print disk IO statistics by queue
iob Print big buffer usage by IO VP class
ppf [ | 0],Print partition profiles
tpf [ | 0], Print thread profiles
ntu Print net user thread profile information
ntt Print net user thread access times
ntm Print net message information
ntd Print net dispatch information
Monitoring Utilities 6-205
Continued
Onstat Options (cont.)
Multithreaded Options nss Print net shared memory status
nsc Print net shared memory status
nsd Print net shared memory data
ppf Print fragment read/write calls
sts Print max and current stack sizes
dic Print dictionary cache information
qst Print queue statistics
wst Print thread wait statistics
prc Print procedure cache information
dsc Print data distribution cache information
ses Print session information
sql Print sql information
dri Print data replication information
Monitoring Utilities 6-206
Monitoring Utilities 2018 08-98 206
The oncheck Utility
The oncheck utility is used to:n Locate index and data page corruption.n Repair index page corruption.n Examine data structures on disk.n Print reports on the various data structures.n Some oncheck options will place a shared lock on the table
it is processing. This will prevent other users from updating the table.
The oncheck utility is used to repair index and data page corruption on disk. It can also be used to examine other data structures on disk in the server. It also has the functionality to allow you to print reports containing information on the various data structures on disk and their usage. The oncheck utility can only work on the same computer as the server it is checking; it does not support network or distributed operations.Some oncheck commands (-pt or -pT) place a shared lock on the table it is processing. This will prevent other users from updating the table. For very large tables, examining every data and index page could take a long time.
The -c and -p OptionsThe syntax and options for the oncheck utility are shown on the following pages. Notice that there are two primary options, -c and -p, and that these primary options have their own sub-options. The -c options indicate that certain things should be checked. The -p options indicate that certain things should be checked and printed to the screen.
Monitoring Utilities 6-207
Continued
Oncheck Syntax and OptionsUsage: oncheck [-clist] [-plist] [-qny] [{ database[:[owner.]table]
| TBLSpace number | Chunk number } { rowid | page number } ]
-c Check
r Reserved pages
e Extents
c Database catalogs [database]
i Table indexes database[:[owner.]table]
I Table indexes and rowids in index database[:[owner.]table]
R Table index check against rows (must be accompanied by i or I)
d TBLSpace data rows including bitmaps database[:[owner.]table]
D TBLSpace data rows including bitmaps, remainder pages and blobs database[:[owner.]table]
-p Print
r Reserved pages (-cr)
e Extents report (-ce)
c Catalog report (-cc) [database]
k Keys in index (-ci) database[:[owner.]table]
K Keys and rowids in index (-pI) database[:[owner.]table]
l Leaf node keys only (-ci) database[:[owner.]table]
L Leaf node keys and rowids (-cI) database[:[owner.]table]
d TBLSpace data rows (-cd) database[:[owner.]table] [rowid]
D TBLSpace data rows including bitmaps, remainder pages and blobs (-cD) database[:[owner.]table] [page number]
t TBLSpace report database[:[owner.]table]
Monitoring Utilities 6-208
Continued
Oncheck OptionsT TBLSpace disk utilization report
database[:[owner.]table]p dump page for the given [table and rowid | TBLSpace and page number]
p Dump page for the given [table[,fragdbs] and rowid | TBLSpace and page number]
P Dump page for the given chunk number and page number [chunk num and page number]
B BLOBSpace utilization for given table(s) database[:[owner.]table]
-q Quiet mode - print only error messages
-n Answer NO to all questions
-y Answer YES to all questions
Monitoring Utilities 6-209
LabExercise
Lab ExerciseThis exercise requires the demonstration database. After this exercise, drop the demonstration database using DB-Access. You will create it again in a later module.Create the demonstration database by entering the following at the command line (verify that your INFORMIXSERVER environment variable is set first):dbaccessdemo7 stores# -logwhere # represents your student number.Answer N to abort when you are prompted by the script.Using sysmaster database tables and views, execute SQL commands to obtain the following information:1. The databases in the current system.2. A list of all chunks that are on-line.3. The table names in the demo database.4. The number of extents allocated in each of the tables in the demo database.5. The percentage of each of the logs that have been filled.6. The number of locks held by each session (list the user name and the process id
of the client).7. You may use the function dbinfo(sessionid) from within an SQL statement
to return your sessionid. Use this function to retrieve information from the sysmaster database regarding your session.
Execute dbaccess and connect to your database. In a separate window, use onstat to find out the following information:8. The Informix session id and the UNIX process id (PID) of your dbaccess
session.9. The status of your dbspaces and chunks.10. The status of your logical logs.Use oncheck to obtain the following information:11. A disk utilization report of the items table in your database.12. Any indexes and rowids in your database that are inconsistent.
Solutions
Monitoring Utilities 6-212
Solution
Solution
The SQL statements are:1. SELECT name database FROM sysmaster:sysdatabases;
2. SELECT c.chknum chunk_number, d.name dbspace,
On-Line status FROM sysmaster:syschunks c,
sysmaster:sysdbspaces d WHERE c.dbsnum = d.dbsnum AND c.is_offline = 0;
3. SELECT t.tabname FROM sysmaster:systabnames t WHERE t.dbsname = demo_database;
4. SELECT tabname, count(*) num_extents FROM sysmaster:sysextents WHERE dbsname = demo_database GROUP BY tabname ORDER BY tabname;
5. SELECT uniqid, ROUND ((used/size) * 100, 2) percent_used
FROM sysmaster:syslogs;
6. SELECT ss.username || - || ss.sid user_session, sp.locksheld, ss.pid FROM sysmaster:syssesprof sp, sysmaster:syssessions ss WHERE sp.sid = ss.sid;
Monitoring Utilities 6-213
Solution
Solution
7. SELECT * FROM sysmaster:syssessions ss,
sysmaster:syssesprof sp WHERE sp.sid = dbinfo ("sessionid")
AND sp.sid = ss.sid;
8. onstat -g ses
9. onstat -d
10. onstat -l
11. oncheck -pT demo_database:items
12. oncheck -cI demo_database
Top Related