Cover V05, I12
Article
Listing 1
Listing 2
Listing 3
Listing 4

dec96.tar


Listing 2: promon script

#!/opt/gnu/bin/expect --
# promon.exp

#
# This script monitors PROGRESS database performance by running
# "promon" as a background process, extracting data from it, and
# writing that data to a log file.  It will run continuously as long
# as the database servers are running.
#

#
# First, I tell expect not to time out on reads, and not to display
# promon output to stdout.
#

set timeout -1
log_user 0

#
# Next, I create a log file with a time-stamp embedded in the name.
#

set home_dir [set env(HOME)]
set out_file "$home_dir/logs/promon.exp_[ timestamp -format
"%y%m%d_%H%M%S" ]"
set log_file [ open $out_file "w" ]

#
# By tradition, the executables that make up the Progress RDBMS are
# kept in a directory referenced by the $DLC envirnonment variable.
#

set dlc [set env(DLC)]

#
# I choose to set the database name explicitly. It never changes. ;-)
#

set dbname "/progdb/progfs05/d1prod"

#
# Start the promon process ("mprshut" is Progress' internal alias
# for promon).
#

spawn "$dlc/bin/_mprshut" "-0" $dbname

#
# First, set some default values within promon.  Setting the page
# size to "999999" prevents promon from pausing after it prints out
# a "screenful" of data.  Setting the pause interval to "300" tells
# promon to report on database performance every 300 seconds, or
# 5 minutes.
#

expect "selection:"
send "M\r"

expect "selection:"
send "1\r"

expect "size:"
send "999999\r"

expect "selection:"
send "4\r"

expect "pause:"
send "300\r"

expect "selection:"
send "Q\r"

#
# Now tell promon to go into a loop, reporting database activity
# every 5 minutes.  My script sets up a loop of its own, iterating
# every time the activity screen is received from the spawned
# process.  It is necessary to throw out the results of the first
# iteration, since I don't want any data from before the first
# 5-minute cycle.
#

expect "selection:"
send "5\r"

expect "Q - quit:"
send "U\r"

set first 1
while 1 {
expect {
-re "Record Updates *(\[0-9]+)" {
set rec_updates $expect_out(1,string)
}
-re "Record Creates *(\[0-9]+)" {
set rec_creates $expect_out(1,string)
}
-re "Record Deletes *(\[0-9]+)" {
set rec_deletes $expect_out(1,string)
}
-re "DB Writes *(\[0-9]+)" {
set db_writes $expect_out(1,string)
}
-re "(\[0-9]+) Users" {
set user_count $expect_out(1,string)
set logical_writes [ expr $rec_updates + $rec_creates +
$rec_deletes ]
if $first {
set first 0
continue
} else {
set time_stamp [ timestamp -format "%D %X" ]
puts $log_file "$time_stamp $user_count $db_writes
$rec_updates $rec_creates

$rec_deletes $logical_writes"
flush $log_file
}
}
}
}

#
# promon.exp ends here
# End of File