SMART 검사 결과
D="$( esxcli storage core device list | grep "Devfs Path:" | awk -F ': ' '{print $2}' | awk -F '/' '{print $NF}' )";
for d in $D
do
echo -e "\nDISK:$d"
esxcli storage core device smart get -d $d
done
명령어 분석
이 명령어는 ESXi 서버에서 연결된 디스크들의 SMART 정보를 가져오는 스크립트입니다. SMART(S.M.A.R.T., Self-Monitoring, Analysis, and Reporting Technology)는 하드 디스크의 상태를 모니터링하고, 디스크에 문제가 발생하기 전에 예고하는 기술입니다. 이 명령어는 디스크의 상태를 점검하고, 각 디스크의 SMART 정보를 출력하는 데 사용됩니다.
명령어를 한 줄씩 분석해보겠습니다.
1.D="$( esxcli storage core device list | grep "Devfs Path:" | awk -F ': ' '{print $2}' | awk -F '/' '{print $NF}' )"
이 부분은 ESXi에서 연결된 모든 스토리지 디바이스의 디바이스 이름을 추출합니다.
esxcli storage core device list
: ESXi에서 연결된 스토리지 디바이스의 정보를 출력하는 명령어입니다. 이 명령어는 각 디바이스에 대한 상세 정보를 포함한 목록을 제공합니다.grep "Devfs Path:"
:esxcli storage core device list
명령어의 출력에서 "Devfs Path:"를 포함한 줄만 필터링합니다. Devfs Path는 각 디바이스의 경로를 나타냅니다.awk -F ': ' '{print $2}'
::
를 구분자로 사용하여, 각 줄에서 경로 뒤의 디바이스 이름을 추출합니다. 예를 들어/vmfs/devices/disks/naa.6000c2928012345f
에서naa.6000c2928012345f
를 추출합니다.awk -F '/' '{print $NF}'
: 슬래시(/
)를 구분자로 사용하여, 경로에서 마지막 부분, 즉 디바이스의 고유 ID를 출력합니다. 예를 들어 위 예시에서naa.6000c2928012345f
를 추출합니다.
이 명령어의 결과는 D
변수에 저장됩니다. 즉, D
는 ESXi 시스템에 연결된 모든 디스크의 고유 ID 목록을 담고 있게 됩니다.
2. for d in $D
이 부분은 D
변수에 저장된 디스크 목록에 대해 루프를 실행합니다. D
는 여러 개의 디스크 ID를 담고 있기 때문에, 각 디스크 ID에 대해 반복 작업을 수행합니다.
3. do
루프 내에서 각 디스크에 대해 실행할 작업이 시작됩니다.
4. echo -e "\nDISK:$d"
각 디스크 ID 앞에 "DISK:"를 출력하여 어떤 디스크에 대한 SMART 정보를 가져오는지 표시합니다. -e
옵션은 이스케이프 문자를 해석하게 하여, \n
이 줄바꿈을 일으키게 만듭니다.
5. esxcli storage core device smart get -d $d
이 명령어는 각 디스크의 SMART 정보를 가져옵니다. -d
옵션은 디스크 ID를 지정하는 데 사용됩니다. esxcli storage core device smart get
명령어는 해당 디스크의 SMART 상태, 예를 들어 재배치된 섹터 수, 온도, 읽기 오류, 예측된 수명 등을 출력합니다.
6. done
루프가 종료됩니다. 각 디스크에 대해 SMART 정보를 출력하는 작업이 완료됩니다.
요약
이 스크립트는 ESXi 서버에 연결된 모든 디스크에 대해 SMART 상태를 확인하고, 각 디스크의 상세 상태 정보를 출력하는 역할을 합니다. 이를 통해 디스크의 건강 상태를 모니터링하고, 문제가 발생할 수 있는 디스크를 조기에 발견할 수 있습니다. ESXi에서 디스크의 SMART 정보를 수동으로 확인하는 대신 이 스크립트를 사용하면 자동화된 방식으로 여러 디스크의 상태를 한 번에 점검할 수 있어 매우 유용합니다.
2024.11.12
1. DISK: t10.NVMe____SHGP312D1000GM___________________________FFFFFFFFFFFFFFFF
- Health Status: OK
- Power-on Hours: 6313
- Power Cycle Count: 29
- Reallocated Sector Count: 0
- Drive Temperature: 39°C
2. DISK: t10.ATA_____ST20000NM004E2D3HR103________________________________ZX20YQZR
- Health Status: OK
- Write Error Count: 100
- Read Error Count: 82
- Power-on Hours: 93
- Power Cycle Count: 100
- Reallocated Sector Count: 100
- Drive Temperature: 36°C
- Write Sectors TOT Count: 100
- Read Sectors TOT Count: 100
- Uncorrectable Error Count: 100
- Pending Sector Reallocation Count: 100
- Uncorrectable Sector Count: 100
3. DISK: t10.ATA_____ST20000NM004E2D3HR103________________________________ZX20YV1Q
- Health Status: OK
- Write Error Count: 100
- Read Error Count: 78
- Power-on Hours: 93
- Power Cycle Count: 100
- Reallocated Sector Count: 100
- Drive Temperature: 41°C
- Write Sectors TOT Count: 100
- Read Sectors TOT Count: 100
- Uncorrectable Error Count: 100
- Pending Sector Reallocation Count: 100
- Uncorrectable Sector Count: 100
4. DISK: t10.ATA_____ST20000NM004E2D3HR103________________________________ZX21M5CK
- Health Status: OK
- Write Error Count: 100
- Read Error Count: 64
- Power-on Hours: 93
- Power Cycle Count: 100
- Reallocated Sector Count: 100
- Drive Temperature: 39°C
- Write Sectors TOT Count: 100
- Read Sectors TOT Count: 100
- Uncorrectable Error Count: 100
- Pending Sector Reallocation Count: 100
- Uncorrectable Sector Count: 100
5. DISK: t10.ATA_____ST20000NM004E2D3HR103________________________________ZX21GRC9
- Health Status: OK
- Write Error Count: 100
- Read Error Count: 79
- Power-on Hours: 93
- Power Cycle Count: 100
- Reallocated Sector Count: 100
- Drive Temperature: 41°C
- Write Sectors TOT Count: 100
- Read Sectors TOT Count: 100
- Uncorrectable Error Count: 100
- Pending Sector Reallocation Count: 100
- Uncorrectable Sector Count: 100
6. DISK: t10.ATA_____ST20000NM004E2D3HR103________________________________ZX21GR0V
- Health Status: OK
- Write Error Count: 100
- Read Error Count: 84
- Power-on Hours: 93
- Power Cycle Count: 100
- Reallocated Sector Count: 100
- Drive Temperature: 40°C
- Write Sectors TOT Count: 100
- Read Sectors TOT Count: 100
- Uncorrectable Error Count: 100
- Pending Sector Reallocation Count: 100
- Uncorrectable Sector Count: 100
No Comments