Muchas veces nos comentan los usuarios que un servidor esta lento. Para esto en la version 15 de ASE las tablas MDA ya estan instaladas por lo que podemos hacer uso del siguiente script

#!/bin/ksh
# ************************************************************ #
# * SCRIPT: sysmon.ksh #
# * PURPOSE: Run the SQL specified #
# * AUTHOR: Miguel C #
# # USAGE: sysmon.ksh <DATASERVER> #
# # HISTORY: 2008.12.28 #
# #*********************************************************** #

SRV="${1}"
DAT=$(date +%Y%m%d%H:%M:%S)

# # VALIDATION
if [[ $# < 1 ]]
then
echo " USAGE: ${0} <DATASERVER>"
echo " DESC: DataServer must be specified!"
echo "Exit[1]"
exit 1
fi

# # ACTION
ISQL ${SRV} << EOF >>${SRV}.sysmon.${DAT}.rpt
sp_sysmon "00:00:20",'kernel',noclear
go
PRINT '<<< MONITOR >>>'
go
sp_monitor
go
PRINT '==============================================================================='
go
PRINT ' Current transactions, LOG SUSPEND processes and Blocked Processes '
go
PRINT '==============================================================================='
go
select db_name(dbid) 'DataBase', * from master..syslogshold
go
select * from master..monProcess where Command like 'LOG%'
go
select @@servername "Sybase Server", getdate() "Currrent Date"
select sl.name Login,sp.spid "Bloqued Process",sp.status Status,sp.blocked 'CULPRIT SPID',sp.hostname Hostname,
sp.program_name Programname,sp.cmd Command,sp.loggedindatetime
from master..sysprocesses sp,master..syslogins sl
where blocked!=0 and sp.suid=sl.suid
go
PRINT '==============================================================================='
go
PRINT ' User Connection Information '
go
PRINT '==============================================================================='
go
select spid, "loginname"=suser_name(suid), "dbname"=db_name(dbid), hostname, ipaddr, program_name, blocked from master..sysprocesses
go
select "LOGIN"=suser_name(suid),"DATABASE NAME"=db_name(dbid),"LOGIN CONNECTIONS"=count(*) from sysprocesses group by suser_name(suid),db_name(dbid)
go
select @@servername "Sybase Server", getdate() "Currrent Date"
select PR.spid,PR.fid, substring(suser_name(PR.suid),1,10) Login_name,substring(PR.program_name,1,10) Program,PR.status,PR.cmd,
substring(db_name(PR.dbid),1,19) db_name,substring(PR.tran_name,1,22) tran_name,PR.blocked, PR.physical_io
from master..sysprocesses PR
go
select count(*) 'Current USERS connections' from master..sysprocesses p, master..syslogins l
where p.suid = l.suid
and l.name <> 'NULL'
and l.name <> 'sa'
go
sp_configure "user connections"
go
sp_monitorconfig "user connections"
go
PRINT '==============================================================================='
go
PRINT ' top cpu users '
go
PRINT '==============================================================================='
go
exec sp_monitor 'connection', 'cpu'
go
PRINT '==============================================================================='
go
PRINT ' top i/o performers '
go
PRINT '==============================================================================='
go
exec sp_monitor 'connection', 'diskio'
go
PRINT '==============================================================================='
go
PRINT ' long running queries '
go
PRINT '==============================================================================='
go
exec sp_monitor 'connection', 'elapsed time'
go
PRINT '==============================================================================='
go
PRINT ' Current locks '
go
PRINT '==============================================================================='
go
sp_lock
go
PRINT '==============================================================================='
go
PRINT ' Usage transaction log '
go
PRINT '==============================================================================='
go
select name 'DATABASE NAME',
lct_admin('num_logpages', dbid) 'USED PAGES',
lct_admin('logsegment_freepages', dbid) 'AVAILABLE PAGES',
str(lct_admin('num_logpages', dbid) * 100.0 / lct_admin('logsegment_freepages', dbid), 5, 1) 'CURRENT % LOG TRANSACTION'
from master..sysdatabases
go
EOF
# # SEND EMAIL
mailx -s "Performances Report Of ${SRV}" "Esta dirección de correo electrónico está siendo protegida contra los robots de spam. Necesita tener JavaScript habilitado para poder verlo." < ${SRV}.sysmon.${DAT}.rpt

Puedes crear el script de ISQL de la siguiente forma

#!/bin/ksh
# ************************************************************ #
# * SCRIPT: ISQL #
# * PURPOSE: Connect into all Data Servers #
# * AUTHOR: Miguel C. Ch. #
# # USAGE: ISQL <DATASERVER> #
# # #
# #*********************************************************** #

SRV="${1}"
SAPASS=/sybase/passwords/dbpassword #Aqui es donde especificas el archive donde tienes los passwords de sa
pass=`grep $SRV:sa: $SAPASS|awk -F":" '{print $NF}'` #Este es solo un ejemplo de como puede estar ese archivo

# # VALIDATION
if [[ $# < 1 ]]
then
echo " USAGE: ${0} <DATASERVER>"
echo " DESC: DataServer must be specified!"
echo "Exit[1]"
exit 1
fi

#*******************************************************************************
# Connect to Server
#*******************************************************************************

echo ""
echo "Connected to $SRV "
echo ""

isql -Usa -S$SRV -P$pass -w2000

sino te gusta el ISQL pues cambia esa parte por isql normal

Espero les guste
Like it on Facebook, +1 on Google, Tweet it or share this topic on other bookmarking websites.
You do not have permissions to reply to this topic.
Powered by CjForum