#!/bin/sh
export ORACLE_SID=myorcldb
#MEMORY 사용율
MEMORY_TOTAL=`free | grep ^Mem | awk '{print $2}'`
MEMORY_USED=`free | grep ^-/+ | awk '{print $3}'`
MEMORY_PERCENT=$((100*MEMORY_USED/MEMORY_TOTAL))
#CPU 사용율
CPU_PERCENT=`top -b -n 1 | grep -i cpu\(s\)| awk -F, '{print $4}' | tr -d "%id," | awk '{print 100-$1}'`
#DISK 사용율
DISK_TOTAL=`df -P | grep -v ^Filesystem | awk '{sum += $2} END { print sum; }'`
DISK_USED=`df -P | grep -v ^Filesystem | awk '{sum += $3} END { print sum; }'`
DISK_PERCENT=$((100*$DISK_USED/$DISK_TOTAL))
echo 'memorysued' $MEMORY_PERCENT 'cpuused' $CPU_PERCENT 'ioused' $DISK_PERCENT
free
uptime
mcpu=$[100-$(vmstat 1 2|tail -1|awk '{print $15}')]%
mmem=`free | grep Mem | awk '{print $3/$2 * 100.0}'`
echo "$mdate | $mcpu | $mmem"
sqlplus -s "/as sysdba" @query.sql
=================================================
SET LINESIZE 130;
--SET WRAP OFF
--COL sql_text FORMAT A80;
col time format 999999;
COL sid FORMAT 999999999;
COL serial# FORMAT 999999999;
COL TIME FORMAT 999999999;
COL program FORMAT a40;
col sql_text FORMAT a40;
SELECT program, sid,serial# , TIME,sql_text
FROM (
SELECT a.program
,a.SID
,a.serial#
,to_char(ELAPSED_TIME/(1000000 * decode(executions,null,1,0,1,executions)),999999.99 ) TIME
, substr(REPLACE(trim (b.sql_text),' ',''),1,30) sql_text
FROM v$session a
,v$sqlarea b
WHERE a.sql_address = b.address
AND A.STATUS ='ACTIVE') ;
SELECT '-----------SESSION LIST-----',
Count(*) TOTAL_SESSION,
Count( DECODE( Status, 'ACTIVE', 1, NULL)) active_cnt,
Count( DECODE( server, 'DEDICATED', 1, null)) dedicated_cnt,
Count( Decode (TYPE, 'BACKGROUND', 1, null)) back_cnt
FROM V$SESSIONWHERE TYPE <>'BACKGROUND';
select a.sid, a.serial#,
--b.type, c.object_name, a.program, a.lockwait,
--a.logon_time, a.process, a.osuser, a.terminal ,
d.sql_text
from v$session a, v$lock b, dba_objects c,v$sqlarea d
where a.sid = b.sid
and b.id1 = c.object_id
and b.type = 'TM'
AND a.sql_address=d.address(+);
exit;
<<EOF