You are looking at the HTML representation of the XML format.
HTML is good for debugging, but is unsuitable for application use.
Specify the format parameter to change the output format.
To see the non HTML representation of the XML format, set format=xml.
See the complete documentation, or
API help for more information.
<?xml version="1.0"?>
<api>
<query-continue>
<allpages gapcontinue="RepServer_Throughput_Script" />
</query-continue>
<query>
<pages>
<page pageid="1397" ns="0" title="Reorg rebuild">
<revisions>
<rev contentformat="text/x-wiki" contentmodel="wikitext" xml:space="preserve">Reorg rebuild is a command for Sybase ASE that you can use to reorganize tables.
==Short introduction==
Before ASE version 15 you could only run this command on tables with a datapages or datarows locking scheme, but that restriction has been dropped. Reorg rebuild can be used to defragment tables. To run the command you need to turn on the database option "select into/bulkcopy/pllsort" as in this example:
sp_dboption myDatabase,"select into/bulkcopy/pllsort",true
go
Then run the command like this
use myDatabase
go
reorg rebuild CustomerTable
go
During a reorg rebuild, the table is locked to users should have been informed or logged of from the system.
Remember to make a full database dump after you have run the reorg command, since the command creates unlogged transactions.
==Stored procedure to reorganize all tables in a database==
Here you can find a stored procedure to reorganize all user tables in a database. Since reorg rebuild effectively copies the table you need enough free space in a database that the largest table uses multiplied by two. The stored procedure will check for that. Some other features:
* Processing starts with smaller tables
* Proxy tables are skipped
* An sp_recompile is run after each table, to tell the server to generate new query plans.
Sample execution:
myDatase..sp_dba_reorg_rebuild
Stored procedure:
use sybsystemprocs
go
if exists (select *
from sysobjects where type = 'P' and name = 'sp_dba_reorg_rebuild')
begin
drop procedure sp_dba_reorg_rebuild
end
go
create proc sp_dba_reorg_rebuild
as
declare @user_name varchar(30),
@table_name varchar(255),
@reserved_pages int,
@free_space int,
@cmd varchar(1024),
@db_name varchar(30)
declare c2 cursor for
select user_name(uid),
name,
reserved_pages(db_id(@db_name),id)
from sysobjects
where type = "U" -- User tables
and not (sysstat2 & 1024 = 1024 or -- Remote
sysstat2 & 2048 = 2048) -- Proxy
order by 3
set flushmessage on
select @db_name = db_name()
print "reorg rebuild started for database %1!", @db_name
exec sp_flushstats
open c2
fetch c2 into @user_name, @table_name, @reserved_pages
while @@sqlstatus = 0
begin
select @free_space = sum(curunreservedpgs(db_id(), lstart, unreservedpgs))
from master..sysusages
where dbid = db_id()
and segmap != 4 -- logsegment
if @free_space < round(@reserved_pages * 2.0,0)
print "Skipping table %1!.%2! not enough space in database", @user_name, @table_name
else
begin
print "Table %1!.%2!", @user_name, @table_name
select @cmd = "reorg rebuild " + @user_name + "." + @table_name
exec (@cmd)
if @@error != 0
break
select @cmd = rtrim(@user_name) + "." + @table_name
exec sp_recompile @cmd
if @@error != 0
break
end
fetch c2 into @user_name, @table_name, @reserved_pages
end
close c2
deallocate cursor c2
return 0
go
[[Category:ASE]]</rev>
</revisions>
</page>
<page pageid="1398" ns="0" title="RepServer Errorlog checker">
<revisions>
<rev contentformat="text/x-wiki" contentmodel="wikitext" xml:space="preserve">The script below is for monitoring the repserver errorlog - it works with any version of repserver and does not need to write to the errorlog itself in order to monitor it. However, since it doesn't write to the errorlog, it does need a $ADMINDIR/control_files/ directory which you may wish to create as a non-transient file (rserrlogmarker.dat) is maintained there.
Also, as per the script notes, you can easily modify this script to monitor *any* log; be sure to give rserrlogmarker.dat and the other files in the config section different names or keep them elsewhere so that there is no conflict.
<pre>
#!/usr/bin/ksh
#
# Script: rs_log_checker.sh
# Author: Bob Holmes - email: cambob@gmail.com
# Date : 08/05/2008
# Version: 1.1
# Usage : rs_log_checker.sh [v|V] (verbose mode)
# Description: Script for checking the repserver errorlog
# --------------------------
# *** Variables for customisation can be found by searching for "!!" ***
# --------------------------
# Modification history:
#
# --------------------------
# Enhancement notes:
# BobH: V1.0: Modified to re-create rserrlogmarker file if not found, then re-run automatically.
# BobH: V1.1: Updated for detecting a new log file and resetting rserrlogmarker if so.
# --------------------------
# Comments: This script can easily be modified to monitor any log, including ASE.
# The log itself is never written to so this script maintains a control
# file to keep track of the last line it checked.
##############################################################################
# setup environment #
##############################################################################
HOSTNAME=`hostname`
##############################################################################
# config variables #
##############################################################################
# config
RSLOGFILE="/PATH_TO_ERRORLOG_HERE/servername_rs.log" # !! modify for your environment
ADMINDIR="/opt/home/sybase/admin" # !! modify for your environment
RSLOGMARKER="$ADMINDIR/control_files/rserrlogmarker.dat" # !! need $ADMINDIR/control_files/ directory
RECIPIENTS="user@domain.dom" # !! enter email address config here
# (separate with commas for multiple addresses)
# static
TEMPFILE1="$ADMINDIR/rslogchecker1.tmp" # transient file
TEMPFILE2="$ADMINDIR/rslogchecker2.tmp" # transient file
MAILFILE="$ADMINDIR/rslogchecker.mail" # transient file
SCRIPT_NAME=`basename $0`
##############################################################################
# main program #
##############################################################################
# check location of errorlog
if [ ! -f $RSLOGFILE ]
then
echo RS errorlog file not found. Please check config.
exit
fi
# get log marker value from file (or otherwise create it)
# V1.1: marker is now a line number
if [ ! -f $RSLOGMARKER ]
then
MARKER=$(cat -n $RSLOGFILE | tail -1 | awk '{print $1}')
echo $MARKER > $RSLOGMARKER
#echo "rs log marker reset"
$SCRIPT_NAME # must re-run after marker file reset
exit
else
MARKER=$(cat $RSLOGMARKER)
fi
# Compare number of lines in log file with current marker value to check
# if a new log has been created/repserver restarted.
if [ $(wc -l $RSLOGFILE | awk '{print $1}') -lt $MARKER ]
then
# new log file created/repserver restarted
printf "${SCRIPT_NAME}: New log file detected\n" > $TEMPFILE2
RESTARTDT=$(head -1 $RSLOGFILE | awk '{print $2,$3}')
printf "${SCRIPT_NAME}: Repserver restarted at: ${RESTARTDT}\n\n" >> $TEMPFILE2
printf "Errors/Warnings from startup follow:\n" >> $TEMPFILE2
printf "------------------------------------\n" >> $TEMPFILE2
# pick out any errors/or warnings from log file:
egrep "^E. |^W. " $RSLOGFILE >> $TEMPFILE2
mailx -s "$HOSTNAME: Repserver restarted!" $RECIPIENTS < $TEMPFILE2
rm $RSLOGMARKER # force reset of marker file
rm $TEMPFILE2
exit
fi
if [ "$1" = "V" ] || [ "$1" = "v" ] # verbose (diag) mode
then
echo Current marker value is: $MARKER
fi
# increment the marker (line number) to avoid re-reading same last line
((MARKER=MARKER+1))
sed -n "$MARKER,$ p" $RSLOGFILE > $TEMPFILE1
######### next executable line checks for errors #########
######### add your search terms to the egrep below #######
EMSGS=$(egrep -c "^E\. |^W\. " $TEMPFILE1)
if [ $EMSGS -ne 0 ]
then
if [ "$1" = "V" ] || [ "$1" = "v" ] # verbose (diag) mode
then
echo Error message found: $HOSTNAME: $EMSGS messages
cat $TEMPFILE1
echo END OF REPORT
else
cp $TEMPFILE1 $MAILFILE
printf "-------CALLOUT SYBASE DBA - ON CALL----------------\n" >> $MAILFILE # !! optional
mailx -s "$HOSTNAME: $EMSGS errors found in repserver errorlog" $RECIPIENTS < $MAILFILE
fi
fi
#update marker:
# Note: use line count from TEMPFILE1 + (MARKER-1) to avoid re-scanning the whole errorlog;
# cat/cp'ing large log files can cause load issues so we don't do that!
LINECOUNT=$(wc -l $TEMPFILE1 | awk '{print $1}')
((MARKER=MARKER+LINECOUNT-1))
echo $MARKER > $RSLOGMARKER
if [ "$1" = "V" ] || [ "$1" = "v" ] # verbose (diag) mode
then
echo New marker value is: $MARKER
fi
# housekeeping
if [ -e $TEMPFILE1 ]
then
rm $TEMPFILE1
fi
if [ -e $TEMPFILE2 ]
then
rm $TEMPFILE2
fi
#end script
</pre>
[[Category:RepServer]]</rev>
</revisions>
</page>
</pages>
</query>
</api>