---1

#!/bin/sh

export ORACLE_SID=hdb
export ORACLE_BASE=/db/hdbdg/app/product/database
export ORACLE_HOME=/db/hdbdg/app/product/database/11g
export LANG=en_US
export NLS_LANG="AMERICAN_AMERICA.ZHS16GBK"
export PATH=$PATH:$ORACLE_HOME/bin:.

STATE_OK=0
STATE_WARNING=1
STATE_CRITICAL=2
STATE_UNKNOWN=3
#备库
get_result=`sqlplus '/ as sysdba'<<EOF
spool off;
select 'stdcseq1=' || max(sequence#) from v\\$archived_log where thread#=1 and applied='YES' group by thread#;
quit;
EOF`
stdcseq1=`echo "$get_result"|grep stdcseq1|cut -d "=" -f2`
echo $stdcseq1

get_result=`sqlplus '/ as sysdba'<<EOF
spool off;
select 'stdcseq2=' || max(sequence#) from v\\$archived_log where thread#=2 and applied='YES' group by thread#;
quit;
EOF`
stdcseq2=`echo "$get_result"|grep stdcseq2|cut -d "=" -f2`
echo $stdcseq2

#主库
get_result=`sqlplus dbmonopr/dbmonoprhdb11@hdb<<EOF
spool off;
select 'seq1=' || max(sequence#) from v\\$archived_log where thread#=1 group by thread#;
quit;
EOF`
echo "$get_result"
seq1=`echo "$get_result"|grep seq1|cut -d "=" -f2`
echo $seq1

seqdiff1=`expr $seq1 - $stdcseq1`

echo 'seqdiff1='$seqdiff1

if [ $seqdiff1 -ge 10 ]
then
echo "CRITICAL - hdb database dataguard error large than 10."
exit 2
fi

if [ $seqdiff1 -ge 6 ]
then
echo "WARNING - hdb database dataguard error large than 6."
exit 1
fi

if [ $seqdiff1 -lt 6 ]
then
echo "OK - hdb database dataguard ok."
exit 0
fi

############2:

version=`sqlplus -v|awk '{print $3}'|awk -F '.' '{print $1}'`

process_status='select status from v$managed_standby where process!='"'ARCH' and process like '%MRP%';"
status=`sqlplus -S / as sysdba<<EOF
set heading off
set feedback off
$process_status
exit
EOF`
echo mrp_status=$status

synctime="select to_char(first_time,'""yyyy-mm-dd hh24:mi:ss'"') from v$log_history where recid in (select max(recid) from v$log_history b group by thread#);'
time=`sqlplus -S / as sysdba<<EOF
set heading off
set feedback off
$synctime
exit
EOF`
echo synctime=$time

system=`uname`
case $system in
AIX)
disk_usage=`df -g|egrep -i "archive|fra" |awk '{print $(NF-3)}'`
if [ -n "$disk_usage" ];
then
echo archivedisk_usage=$disk_usage
fi
;;
HP-UX)
disk_usage=`bdf |egrep -i "archive|fra" |awk '{print $(NF-1)}'`
if [ -n "$disk_usage" ];
then
echo archivedisk_usage=$disk_usage
fi
;;
Linux)
disk_usage=`df -h|egrep -i "archive|fra" |awk '{print $(NF-1)}'`
if [ -n "$disk_usage" ];
then
echo archivedisk_usage=$disk_usage
fi
;;
esac

if [ -z "$disk_usage" ];
then
recovery_dest='select value from v$system_parameter where name = '"'db_recovery_file_dest';"
dest=`sqlplus -S / as sysdba<<EOF
set heading off
set feedback off
$recovery_dest
exit
EOF`
dest=${dest#*+}

asmdisk_usage_sql='select round((1-(free_mb/total_mb))*100,2) from v$asm_diskgroup where name='"'$dest';"
asmdisk_usage=`sqlplus -S / as sysdba<<EOF
set heading off
set feedback off
$asmdisk_usage_sql
exit
EOF`
echo archivedisk_usage=${asmdisk_usage}%
fi

if [ $version -eq 10 ];
then
recovery_dest_usage='select PERCENT_SPACE_USED from v$flash_recovery_area_usage where FILE_TYPE like '"'%ARCHIVE%';"
fi

if [ $version -eq 11 ];
then
recovery_dest_usage='select PERCENT_SPACE_USED from v$flash_recovery_area_usage where FILE_TYPE = '"'ARCHIVED LOG';"
fi

usage=`sqlplus -S / as sysdba<<EOF
set heading off
set feedback off
$recovery_dest_usage
exit
EOF`
echo fra_usage=${usage}%

###########3

#!/bin/bash
#env
PATH=/usr/local/bin:/usr/bin:$PATH:.
source /home/oracle11g/.bash_profile

f_getparameter(){
if [ -z "$3" ]; then
return
fi
PARAMETER=$1
sqlplus -s /nolog <<EOF | awk -F= "/^a=/ {print \$2}"
##sqlplus -s /nolog <<EOF
set head off pagesize 0 feedback off linesize 200
whenever sqlerror exit 1
##conn / as sysdba
##conn ${LOGIN_ID}@${db_name}
conn $2@$3
select 'a='||value from v\$parameter where name = '$PARAMETER';
EOF
}

f_getvalues(){
if [ -z "$3" ]; then
return
fi
PARAMETER=$1
sqlplus -s /nolog <<EOF | awk -F= "/^a=/ {print \$2}"
##sqlplus -s /nolog <<EOF
set head off pagesize 0 feedback off linesize 200
whenever sqlerror exit 1
##conn / as sysdba
##conn ${LOGIN_ID}@${db_name}
conn $2@$3
select 'a='||round(max_utilization/limit_value*100) from v\$resource_limit where resource_name='$PARAMETER';
EOF
}

f_getlist(){
if [ -z "$1" ]; then
return
fi
PARAMETER=$1
# sqlplus -s /nolog <<EOF | awk -F= "/^a=/ {print \$2}"
sqlplus -s /nolog <<EOF
set head off pagesize 0 feedack off linesize 50
whenever sqlerror exit 1
conn $2@$3
select status from v\$managed_standby where process!='ARCH' and process like '%MRP%';
select to_char(first_time,'yyyy-mm-dd hh24:mi:ss') from v\$log_history where recid in (select max(recid) from v\$log_history b group by thread#);
select PERCENT_SPACE_USED from v\$flash_recovery_area_usage where FILE_TYPE like 'ARCHIVE%';
EOF
}

db_list_checking(){

db_list="ora11g_test sdbs"
#db_list="sdbs"
##remove rdbs because 210.187 can't telnet 58.8.95.3 port 1528,need network check more
for db_name in ${db_list}

do
LOGIN_ID=dbmgr/t1234DBA

echo "###########$db_name###"

#echo $list
f_getlist ANY $LOGIN_ID $db_name

done

}
main()
{
echo '----------------'`date`'------------------checing konw---------------------------'

db_list_checking

echo '----------------'`date`'------------------over---------------------------'

}

main

standby checking script 3则 V1 shell 脚本的更多相关文章

  1. Linux Shell脚本面试25问

    Q:1 Shell脚本是什么.它是必需的吗? 答:一个Shell脚本是一个文本文件,包含一个或多个命令.作为系统管理员,我们经常需要使用多个命令来完成一项任务,我们可以添加这些所有命令在一个文本文件( ...

  2. 【转】Linux Shell脚本面试25问

    Q:1 Shell脚本是什么.它是必需的吗? 答:一个Shell脚本是一个文本文件,包含一个或多个命令.作为系统管理员,我们经常需要使用多个命令来完成一项任务,我们可以添加这些所有命令在一个文本文件( ...

  3. shell脚本面试题

    Q:1 Shell脚本是什么.它是必需的吗? 答:一个Shell脚本是一个文本文件,包含一个或多个命令.作为系统管理员,我们经常需要使用多个命令来完成一项任务,我们可以添加这些所有命令在一个文本文件( ...

  4. shell脚本调试运行

    1.在命令行提供参数:$sh -x script.sh   但是有的shell脚本只能用 ./xxx.sh的方式运行,不能用sh命令解析执行.则此方法会报错.2.脚本开头提供参数:#!/bin/sh ...

  5. 对shell脚本进行加密

    用shell脚本对系统进行自动化维护,简单,便捷而且可移植性好.但shell脚本是可读写的,很有可能会泄露敏感信息,如用户名,密码,路径,IP等.同样,在shell脚本运行时会也泄露敏感信息.请问如何 ...

  6. shell脚本从入门到精通(中级)之提高篇

    shell 脚本入门到精通(中级) 一.shell 脚本的执行 二.输出格式化 三.数据类型 四.重定向 五.变量 一.shell 脚本的执行 1. 脚本执行的4种方法 $ ls /tmp/test. ...

  7. Shell脚本编程(一):初识shell script

    Shell简介 Shell是一个命令解释器,它是一个用 C 语言编写的程序,它是用户使用 Linux 的桥梁.Shell 是指一种应用程序,这个应用程序提供了一个界面,用户通过这个界面访问操作系统内核 ...

  8. 利用shell脚本实现计划任务功能 V1.2

    2013.05.10  mytask 1.2 主程序休眠时间分成若干小的时间片断分段休眠,避免长时间的休眠不能及时响应系统信号. 2013.05.07 mytask 1.1 昨天发布了mytask1. ...

  9. shell脚本规划化模板

    shell脚本规划化模板 Linux运维过程中,shell脚本是不可缺少的工具,但是每个运维人员编程的习惯都不一样,很多时候就是实现某个功能,写出来的脚本都是烂七八糟的.脚本必须规范化,应该从以后几个 ...

随机推荐

  1. 一个关于前端页面的小标签<tbody>

    我们有时候希望将表格的内容分为多个模块,这时候就可以使用<tbody>标签,它是<table>的字标签,是<tr>的父标签,可以使用它达到一种设置样式的结果.

  2. 瞎写的树dfs序

    这里枚举了树的DFS序来解决树上问题的多个板子,自己最好多看看. ↓改↓ ↓求↓ 点 点 ————————>>>这个就算了 点 树 简单, BIT 点 链 重点! 树 树 简单, 线 ...

  3. bzoj 2251: 外星联络 后缀Trie

    题目大意 http://www.lydsy.com/JudgeOnline/problem.php?id=2251 题解 本来以为这道题应该从01序列的性质入手 结果就想歪了 等自己跳出了01序列这个 ...

  4. 【Lintcode】103.Linked List Cycle II

    题目: Given a linked list, return the node where the cycle begins. If there is no cycle, return null. ...

  5. 反射设置当前窗体所有控件的Text

    在我们编程的时候,有时需要动态的获取当前窗体控件的Text,但是又不能一个一个控件的设置,这个时候可以通过反射来动态设置. 第一步:先建立一个类来保存控件的Text信息. public class C ...

  6. 小程序[邮箱提取器-EmailSplider]总结

    1.背景情况     学东西做快的是付诸实践,写这个小程序的目的就是为了综合运用各个知识点,从而提升学习的效果.   2.涉及知识     A.Swing 的布局     B.Swing中,线程访问U ...

  7. Key and Certificate Conversion

    Key and Certificate Conversion Private keys and certificates can be stored in a variety of formats, ...

  8. 微信小程序开发之下拉菜单

    实现功能:点击维保人员,调出下拉菜单.选择子菜单时,显示右边的图标表示选中,并进行赋值并进行搜索筛选 Wxml: <view class="dtclass" bindtap= ...

  9. shell程序---编译目录下全部.c或.cpp文件

    今天大波又提起昨天我说的那个程序.这样的,起初我想写一个makefile,每次写完新代码后一键编译目录下所有的.cpp文件. 原因是用makefile的话,每次要把目标文件加紧去才能编译.感觉不方便. ...

  10. 结对项目-ExamGeneration-四则运算试题生成与计算程序

    目录 ExamGeneration 进展 功能 调用示例 PSP表格 结对分工 功能模块详解 Chernobyl: -Gaveu: 运行测试 -Gaveu: Chernobyl: 项目总结与反思 Ch ...