Professional Documents
Culture Documents
6
Monitoring Utilities
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
6-189
Monitoring Utilities
There are several utilities that you can use to monitor a server:
n System Monitoring Interface (SMI)
n onstat
n oncheck
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 structures
n Provides profile information for specific
Shared
user sessions
Memory
n Allows a Dynamic Server administrator to
SYSMASTER
easily automate the system monitoring
Database
process.
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.
Data Dictionary
for sysmaster
Shared
Memory
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 ONArchive 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.
SELECT *
from
syslocks
Shared
Memory
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.
SMI Restrictions
n
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 nonpermanent 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.
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
n
n
n
n
n
syslogs to determine if the logs need to be backed up. If size = used, then the
log is full.
The sysdbspaces view contains information about dbspaces.
The syschunks view contains the chunks in the server. The nfree column
shows the number of pages in the chunk that are free.
The syslocks view lists all active locks.
The sysvpprof view contains all the active virtual processors.
The syssessions view lists information about each session.
Monitoring Utilities 6-195
Continued
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:
dskreads
bufreads
dskwrites
bufwrites
isamtot
isopens
isstarts
isreads
iswrites
isrewrites
isdeletes
iscommits
isrollbacks
ovtbls
ovlock
ovuser
ovtrans
compress
fgwrites
lruwrites
chunkwrites
latchreqs
latchwts
buffwts
lockreqs
lockwts
ckptwts
deadlks
lktouts
numckpts
plgpagewrites
plgwrites
llgrecs
llgpagewrites
llgwrites
pagreads
pagwrites
flushes
dpra
rapgs_used
seqscans
btradata
Example
You 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:syschunks
This information can also be derived from the following onstat command:
onstat -d
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.
n The sysseswts table provides information on the amount of time users wait for
Continued
unspecified
buffer
lock
asynchronous I/O
mt yield 0
mt yield n
mt yield
checkpoint
log I/O
log copy
condition
lock mutex
lockfree mutex
lockfree mutex
deadlock mutex
lrus mutex
tblsp mutex
log mutex
ckpt mutex
mutex
mt ready
mt yield x
running
Example
You 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:syssessions
WHERE syssessions.sid = syslocks.owner
Output from the above statement is similar to the output from the
onstat -u and onstat -k commands.
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.
Onstat Options
n
n
n
n
n
Interactive option:
onstat -i
Multithreaded options:
onstat -g sub_options
List all options:
onstat -Show status of instance:
onstat Repeat/refresh:
onstat -r <value>
Monitoring Utilities 2018 08-98 200
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 Option
To 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
> u
You can also use the repeat option in interactive mode; for example:
> r 5
> u
This 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.
Multithreaded Options
Continued
Most 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 ath
Uptime
n On-Line
n Off-Line
n Quiescent
n Shutdown
n Recovery
n (CKPT REQ) checkpoint requested, but not started
n (CKPT) checkpoint in progress
The first line in any onstat output is the header. It contains information about the
current state of the server.
Continued
Onstat Options
onstat -g option
Continued
Multithreaded Options
ath
wai
act
rea
sle
spi
sch
lmx
wmx
con
stk <tid>
glo
mem <pool name|session id>
seg
rbm
nbm
afr <pool name|session id>
ffr <pool name|session id>
ufr <pool name|session id>
iov
iof
ioq
iob
ppf [<partition number> | 0],
tpf [<tid> | 0],
ntu
ntt
ntm
ntd
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.
Oncheck
Syntax and Options
Continued
-p
r
e
c
k
K
l
L
d
D
t
Print
Reserved pages (-cr)
Extents report (-ce)
Catalog report (-cc) [database]
Keys in index (-ci) database[:[owner.]table]
Keys and rowids in index (-pI) database[:[owner.]table]
Leaf node keys only (-ci) database[:[owner.]table]
Leaf node keys and rowids (-cI) database[:[owner.]table]
TBLSpace data rows (-cd) database[:[owner.]table]
[rowid]
TBLSpace data rows including bitmaps, remainder pages
and blobs (-cD) database[:[owner.]table] [page number]
TBLSpace report database[:[owner.]table]
Oncheck Options
T
Continued
p
P
B
-q
-n
-y
Lab Exercise
Lab
Exercise
This 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# -log
where # 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
Solution
The SQL statements are:
Solution
1.
SELECT
FROM
name database
sysmaster:sysdatabases;
2.
SELECT
c.chknum chunk_number,
d.name dbspace,
On-Line status
sysmaster:syschunks c,
sysmaster:sysdbspaces d
c.dbsnum = d.dbsnum
c.is_offline = 0;
FROM
WHERE
AND
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.
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
Solution
10. onstat -l
11. oncheck -pT demo_database:items
12. oncheck
-cI demo_database