zabbix监控表空间使用率
Posted penny-pan
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了zabbix监控表空间使用率相关的知识,希望对你有一定的参考价值。
[[email protected] oraclescripts]$ cat check_tablespace.sh #!/bin/bash # tablespace usagep check source ~/.bash_profile function check { sqlplus -S "/ as sysdba" << EOF set linesize 200 set pagesize 200 spool /tmp/tablespace.log select a.tablespace_name, total, free,(total-free) as usage from (select tablespace_name, sum(bytes)/1024/1024 as total from dba_data_files group by tablespace_name) a, (select tablespace_name, sum(bytes)/1024/1024 as free from dba_free_space group by tablespace_name) b where a.tablespace_name = b.tablespace_name; spool off quit EOF };check &>/dev/null
[[email protected]10-10-40-2 oraclescripts]$ cat /tmp/tablespace.log TABLESPACE_NAME TOTAL FREE USAGE ------------------------------ ---------- ---------- ---------- ACTIVITY_TBS 50 49 1 SYSAUX 15168 10794.25 4373.75 UNDOTBS1 98078 4421.1875 93656.8125 UCEX_ACTIVITY_USER 50 48.0625 1.9375 UCEX_SERVICE_TBS 10290 10172.6875 117.3125 USERS 5 2.1875 2.8125 SYSTEM 11090 10236.625 853.375 SLUCEX_TBS 50 49 1 SLUCEXTWO 135135.563 38541.875 96593.6875 9 rows selected.
[[email protected] oraclescripts]$ cat discovery_oracle_tablespace.sh #!/bin/bash #zabbix discovery oracle tablespace table_spaces=(`cat /tmp/tablespace.log | sed -e "1,3d" -e "/^$/d" -e "/selected/d" | awk ‘{print $1}‘`) length=${#table_spaces[@]} printf "{ " printf ‘ ‘""data":[" for ((i=0;i<$length;i++)) do printf " {" printf ""{#TABLESPACE_NAME}":"${table_spaces[$i]}"}" if [ $i -lt $[$length-1] ];then printf "," fi done printf " ] " printf "} "
[[email protected]10-10-40-2 oraclescripts]$ bash discovery_oracle_tablespace.sh { "data":[ {"{#TABLESPACE_NAME}":"ACTIVITY_TBS"}, {"{#TABLESPACE_NAME}":"SYSAUX"}, {"{#TABLESPACE_NAME}":"UNDOTBS1"}, {"{#TABLESPACE_NAME}":"UCEX_ACTIVITY_USER"}, {"{#TABLESPACE_NAME}":"UCEX_SERVICE_TBS"}, {"{#TABLESPACE_NAME}":"USERS"}, {"{#TABLESPACE_NAME}":"SYSTEM"}, {"{#TABLESPACE_NAME}":"SLUCEX_TBS"}, {"{#TABLESPACE_NAME}":"SLUCEXTWO"} ] }
[[email protected] oraclescripts]$ cat tablespace_check.sh #!/bin/bash # oracle tablespace check CEHCK_TYPE=$1 TABLESPACE_NAME=$2 function usagepre { grep "$TABLESPACE_NAME" /tmp/tablespace.log | awk ‘{printf "%.f ",($2-$3)/$2*100}‘ } function available { grep "$TABLESPACE_NAME" /tmp/tablespace.log | awk ‘{printf $3*1024*1024}‘ } function check { if grep "$TABLESPACE_NAME" /tmp/tablespace.log | awk ‘{print $2}‘ | uniq | grep "YES" &>/dev/null;then echo 1 else echo 0 fi } case $CEHCK_TYPE in pre) usagepre ;; fre) available ;; check) check ;; *) echo -e "Usage: $0 [pre|fre|check] [TABLESPACE_NAME]" esac
[[email protected]10-10-40-2 oraclescripts]$ bash tablespace_check.sh pre SLUCEXTWO 71
以上是关于zabbix监控表空间使用率的主要内容,如果未能解决你的问题,请参考以下文章
[记录]Zabbix3.4配置监控Oracle12c的存活状态和表空间使用率