使用SecureCRT的按钮实现快速查询

背景:有这么个日常运维场景,客户因管理需求,不允许在服务器上部署任何自动化的脚本,需要人工登录到机器上查询Oracle ASM磁盘组的使用率情况,有上百套环境都需要查询。

使用的工具是SecureCRT,如何提升一些效率呢?

其实很简单,可以在SecureCRT的工具上新建一个按钮,比如叫ASM-DISKGROUP-USAGE,内容如下:

sqlplus / as sysasm <<EOF\n
set lines 140\n
col name for a15\n
select name, total_mb, free_mb, type, state from v\\$asm_diskgroup;\n
EOF\n

这样只需人工登录到grid用户,就可以点击此按钮,会自动查询出ASM磁盘组的空间使用率情况,要比EM等方式高效很多。
点击此按钮,效果如下:

[grid@jystdrac1 ~]$ sqlplus / as sysasm <<EOF
> set lines 140
> col name for a15
> select name, total_mb, free_mb, type, state from v\$asm_diskgroup;
> EOF

SQL*Plus: Release 11.2.0.4.0 Production on Wed Apr 29 22:58:17 2020

Copyright (c) 1982, 2013, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Real Application Clusters and Automatic Storage Management options

SQL> SQL> SQL> 
NAME              TOTAL_MB    FREE_MB TYPE         STATE
--------------- ---------- ---------- ------------ ----------------------
DATA                 15360       3610 EXTERN       MOUNTED
FRA                   5120       3834 EXTERN       MOUNTED
OCR                   3072       2146 NORMAL       MOUNTED

SQL> Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Real Application Clusters and Automatic Storage Management options
[grid@jystdrac1 ~]$ 

这样就可以很方便查询了,也比复制命令等方式简便,且还不容易出错。

This entry was posted in Oracle日常运维 and tagged , . Bookmark the permalink.