Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 |
Tags
- SMS-P 인증 기준 안내서 요약
- AWS EKS
- The Sleuth Kit
- AWS Opensearch
- ISMS-P 인증심사원
- 모의해킹
- ISMS
- k8s
- 정보보안기사
- 쿠버네티스
- Autopsy
- 정보보안기사 실기
- isms-p
- 보안
- kubernetes
- AWS 쿠버네티스
- AWS EKS Udemy
- 보안기사
- CFReDS
- 해킹
- 포렌식
- TSK
- AWS
- 실습
- hacking case
- iam
- forensic
- artifacts
- AWS Elasticsearch
- 정보보안
Archives
- Today
- Total
Always-Try(정보보안 및 일상)
Linux 시스템 상태 확인 쉘 스크립트 (bash shell) 본문
#!/bin/bash
echo -e "-------------------------------System Information----------------------------"
echo -e "Hostname:\t\t"`hostname`
echo -e "uptime:\t\t\t"`uptime | awk '{print $3,$4}' | sed 's/,//'`
echo -e "Manufacturer:\t\t"`cat /sys/class/dmi/id/chassis_vendor`
echo -e "Product Name:\t\t"`cat /sys/class/dmi/id/product_name`
echo -e "Version:\t\t"`cat /sys/class/dmi/id/product_version`
echo -e "Serial Number:\t\t"`cat /sys/class/dmi/id/product_serial`
echo -e "Machine Type:\t\t"`vserver=$(lscpu | grep Hypervisor | wc -l); if [ $vserver -gt 0 ]; then echo "VM"; else echo "Physical"; fi`
echo -e "Operating System:\t"`hostnamectl | grep "Operating System" | cut -d ' ' -f5-`
echo -e "Kernel:\t\t\t"`uname -r`
echo -e "Architecture:\t\t"`arch`
echo -e "Active User:\t\t"`w | cut -d ' ' -f1 | grep -v USER | xargs -n1`
echo -e "System Main IP:\t\t"`hostname -I`
echo -e "System Date & Time:\t"`date`
echo ""
echo -e "-------------------------------CPU/Memory Usage------------------------------"
echo -e "CPU Model:\t\t"`awk -F':' '/^model name/ {print $2}' /proc/cpuinfo | uniq | sed -e 's/^[ \t]*//'`
echo -e "CPU Core:\t\t"`grep -c processor /proc/cpuinfo`" Core"
echo -e "CPU Processor:\t\t"`grep ^processor /proc/cpuinfo | wc -l`" Processor"
echo -e "CPU Usage:\t\t"`cat /proc/stat | awk '/cpu/{printf("%.2f%\n"), ($2+$4)*100/($2+$4+$5)}' | awk '{print $0}' | head -1`
echo ""
echo -e "---------------Checking for Currently Mounted File System[s]-----------------"
echo -e `df -H | grep -vE '^Filesystem|tmpfs|cdrom'`
echo ""
echo -e "-----------Mounted File System[s] Utilization (Percentage Used)--------------"
echo -e "( 0-90% = OK/HEALTHY, 90-95% = WARNING, 95-100% = CRITICAL )"
echo -e "Percentage Used\t\tmounted File System[s]:"
filesystem=$(df -H | grep -vE '^Filesystem|tmpfs|cdrom' | awk '{ print $5 " " $1 }')
usep=$(echo $filesystem | awk '{ print $1}' | cut -d'%' -f1 )
partition=$(echo $filesystem | awk '{ print $2 }' )
if [ $usep -lt 90 ]; then
echo -e "$usep\t\t\t$partition\t\t--------OK/HEALTHY"
elif [ $usep -ge 90 -a $usep -lt 95 ]; then
echo -e "$usep\t\t\t$partition\t\t\t--------WARNING"
else
echo -e "$usep\t\t\t$partiotion\t\t\t--------CRITICAL"
fi
echo ""
echo -e "------------------------Checking For INode Usage-----------------------------"
echo -e "( 0-90% = OK/HEALTHY, 90-95% = WARNING, 95-100% = CRITICAL )"
echo -e "Percentage Used\t\tmounted File System[s]:"
filesystem=$(df -i | grep -vE '^Filesystem|tmpfs|cdrom' | awk '{ print $5 " " $1 }')
usep=$(echo $filesystem | awk '{ print $1}' | cut -d'%' -f1 )
partition=$(echo $filesystem | awk '{ print $2 }' )
if [ $usep -lt 90 ]; then
echo -e "$usep\t\t\t$partition\t\t--------OK/HEALTHY"
elif [ $usep -ge 90 -a $usep -lt 95 ]; then
echo -e "$usep\t\t\t$partition\t\t\t--------WARNING"
else
echo -e "$usep\t\t\t$partiotion\t\t\t--------CRITICAL"
fi
echo ""
echo -e "-------------------------------SWAP Details----------------------------------"
free -h
echo ""
echo -e "-------------------Checking for Processor Utilization------------------------"
mpstat
echo ""
echo -e "------------------------Checking for Load Average----------------------------"
uptime=$(uptime)
echo $uptime | cut -c 36-
echo ""
echo -e "--------------------Top 5 Memory Resource Hog Processesge--------------------"
ps -eo %mem,%cpu,pid,ppid,user,stat,cmd --sort=-%mem | head -6
echo ""
echo -e "----------------------Top 5 CPU Resource Hog Processesge---------------------"
ps -eo %mem,%cpu,pid,ppid,user,stat,cmd --sort=-%cpu | head -6
echo ""
참고)
- 테스트 OS는 Centos 7이며, mpstat의 경우 설치 의존성 있을 수 있음.
'Unclassified' 카테고리의 다른 글
[OKTA] #1. OKTA란? (지원 기능 및 데이터 모델) (2) | 2022.05.01 |
---|---|
1Password 사용법(패스워드 관리 앱) (0) | 2022.03.02 |
[DevSecOps] Jenkins CI/CD 파이프라인 SonarQube 통합 (2/3) - Sonarqube 설치 및 Jenkins 연동 (0) | 2022.02.14 |
[DevSecOps] Jenkins CI/CD 파이프라인 SonarQube 통합 (1/3) - Jenkins 설치 및 Github 연동 (1) | 2022.02.14 |
Github Desktop 버전 설치 및 사용법 (0) | 2022.02.13 |
Comments