oracurad_查看游标使用情况

这是一个bash脚本,用于检查Oracle数据库的游标使用情况,包括session_cached_cursors和open_cursors的参数值及使用率。脚本首先检查是否以oracle用户运行,然后通过SQLPLUS命令获取系统统计信息,并以格式化的输出显示结果。
摘要由CSDN通过智能技术生成

oracurad_查看游标使用情况

#!/bin/bash
echo "\n=============`date`===================\n"
if [ "$LOGNAME" = "oracle" ]; then
   SQLPLUS_CMD="/ as sysdba";
else
   SQLPLUS_CMD="/";
fi
if [ $# -ne 0 ];then
        echo "Example: $0"
        exit
fi
sqlplus -s "$SQLPLUS_CMD" << EOF
set lin 2000;
column parameter format a29;
column value     format a5;
column usage     format a40;
select
  'session_cached_cursors'  parameter,
  lpad(value, 5)  value,
  decode(value, 0, '  n/a', to_char(100 * used / value, '999990') || '%')  usage
from
  ( select
      max(s.value)  used
    from
      sys.v_\$statname  n,
      sys.v_\$sesstat  s
    where
      n.name = 'session cursor cache count' and
      s.statistic# = n.statistic#
  ),
  ( select
      value
    from
      sys.v_\$parameter
    where
      name = 'session_cached_cursors'
  )
union all
select
  'open_cursors',
  lpad(value, 5),
  to_char(100 * used / value,  '990') || '%'
from
  ( select
      max(sum(s.value))  used
    from
      sys.v_\$statname  n,
      sys.v_\$sesstat  s
    where
      n.name in ('opened cursors current', 'session cursor cache count') and
      s.statistic# = n.statistic#
    group by
      s.sid
  ),
  ( select
      value
    from
      sys.v_\$parameter
    where
      name = 'open_cursors'
  )
/
EOF

脚本效果:
$./oracuradv

\n=============Mon Oct 19 16:51:19 CST 2020===================\n

PARAMETER		      VALUE USAGE
----------------------------- ----- ----------------------------------------
session_cached_cursors		 50  417406%
open_cursors			300  ####%
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

数哥

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值