DATA 전문가로 가는 길

[Unix/Linux] System Check List(시스템 체크 리스트) 본문

OS/Fundamental

[Unix/Linux] System Check List(시스템 체크 리스트)

EstenPark 2010. 12. 1. 03:29
작성자 : 박상수
작성일자 : 2010.11.30
작업환경 : VMware7 [ RHEL4 ]

1. 시스템 체크리스트 (bash shell source)
 
[설명] CPU, Memory, Swap, Process, Oracle Database 10g Tablespace
위에 나열한 항목 외에 수많은 시스템 체크리스트를 작성 할 수 있습니다. 대표적으로 사용하는 시스템 체크를 하였고 그외 항목은 약간 수정하면 가능 할 것으로 판단 됩니다.
[2010-12-02 03:20:47]-[oracle@server102:~/scripts]
$ cat system_check.sh
#!/bin/bash
# RedHat Enterprise 4 System Check
# estenpark

tmp_fn="temp.tmp"

cpu_stat=`sar 1 3 |grep Average |perl -ane 'printf "$F[2]%"'`
mem_stat=`free -m |grep Mem |perl -ane 'printf "$F[2]M"'`
swap_stat=`free -m |grep Swap |perl -ane 'printf "$F[2]M"'`
echo "========================================================="
echo "System Cehck (Cpu, Memory, Swap)"
echo
echo "CPU    : " $cpu_stat
echo "MEMORY : " $mem_stat
echo "SWAP   : " $swap_stat
echo "========================================================="
ps_sshd=`ps -ef |grep -v grep |perl -ne 'printf 0 < $.  if /sshd$/'`
ps_crond=`ps -ef |grep -v grep |perl -ne 'printf 0 < $.  if /crond$/'`
echo "========================================================="
echo "Process Cehck (sshd, crond)"
echo
if [ $ps_sshd ]; then
        echo "SSH Process Success"
else
        echo "SSH Process Fail"
fi

if [ $ps_crond ]; then
        echo "Cron Process Success"
else
        echo "Cron Process Fail"
fi
echo "========================================================="
echo

sqlplus system/oracle @/home/oracle/tbs_check.sql |perl -ne 'printf"$_" if /\d\d\.\d\d\%$/' > $tmp_fn
echo "========================================================="
echo "Oracle 10g Tablespace Cehck"
echo
echo "Tablespace Used"
echo "---------------------------------------------------------"
cat $tmp_fn
echo "---------------------------------------------------------"
echo
echo "80% higher Tablespace"
echo "---------------------------------------------------------"
perl -ane 'printf"$_" if $F[4] >= 80' $tmp_fn
echo "---------------------------------------------------------"
echo
echo "========================================================="

cat /dev/null > $tmp_fn


[설명] Tablespac 사용량을 체크하기 위해서 작성한 SQL 문입니다.
[2010-12-02 03:24:48]-[oracle@server102:~]
$ cat tbs_check.sql
-- SQLPLUS CONFIGURE --
SET ECHO OFF
SET NEWPAGE 0
SET SPACE 0
SET PAGESIZE 0
SET FEEDBACK OFF
SET HEADING OFF
SET TRIMSPOOL ON
SET LINE 200

COL file# for 999
COL ts_name for a10
COL total_blocks for 9999999
COL used_blocks for 9999999
COL pct_used for a10

-- Tablespace Used SQL --
SELECT
--      distinct d.file_id      file#,
        d.tablespace_name       ts_name,
        d.bytes/1024/1024       MB,
        d.bytes/8192            total_blocks,
        sum(e.blocks)           used_blocks,
        to_char(nvl(round(sum(e.blocks)/(d.bytes/8192),4),0) * 100, '09.00') || '%' pct_used
FROM dba_extents e, dba_data_files d
WHERE d.file_id = e.file_id(+)
GROUP BY d.file_id, d.tablespace_name, d.bytes
ORDER BY 1,2
/
exit


2. 결과화면
[설명] 스크립트를 실행하면 아래와 같이 시스템 체크리스트를 하실 수 있습니다.
[2010-12-02 03:27:18]-[oracle@server102:~/scripts]
$ ./system_check.sh
=========================================================
System Cehck (Cpu, Memory, Swap)

CPU    :  1.01%
MEMORY :  458M
SWAP   :  22M
=========================================================
=========================================================
Process Cehck (sshd, crond)

SSH Process Success
Cron Process Success
=========================================================

=========================================================
Oracle 10g Tablespace Cehck

Tablespace Used
---------------------------------------------------------
EXAMPLE          100       12800       8728     68.19%
HAKSA                20        2560        128      05.00%
HAKSA                                        128       00.00%
SYSAUX           250       32000      31912     99.73%
SYSTEM           490       62720      61448     97.97%
UNDO01              14        1792        872      48.66%
UNDOTBS1          35        4480       1520     33.93%
USERS                5         640        376       58.75%
---------------------------------------------------------

80% higher Tablespace
---------------------------------------------------------
SYSAUX           250       32000      31912   99.73%
SYSTEM           490       62720      61448   97.97%
---------------------------------------------------------

=========================================================



Comments