본문 바로가기
리눅스 공부

DevOps Day 6 (3/14) – 리눅스 운영체제_시스템 모니터링

by Jackykim 2023. 3. 14.

Chapter 시스템 모니터링

Uname : 시스템과 커널의 정보
uname 명령어를 사용하면 시스템과 커널의 정보를 확인할 수 있습니다.

Top : 운영체제 작업 내역 모니터링
현재 OS의 상태를 아래와 같이 출력됩니다. 요약영역은 전체 프로세스가 OS에 대해서 리소스를 어느정도 차지하고 있는지를 알려줍니다. 요약 영역에 나타나는 대표적인 내용은 시간, 유저, 로드 애버리지(Load Average), 태스크(Tasks), CPU, 메모리(memory)입니다.

 

- 로드 애버리지(Load Average) : 해당 영역은 CPU가 수행하는 작업의 양을 순서대로 1, 5, 15분 간격의 평균값으로 표시합니다.
- 태스크(Task) : 현재 프로세스들의 상태를 나타내주는 영역으로, OS에 따라 Process라고도 합니다.
- CPU 사용량 : CPU가 어떻게 사용되고 있는지 그 사용률을 보여주는 영역입니다. 유저 영역, 커널 여역, 우선순위 설정 등, 각 영역 값의 총 합은 100%입니다.
- 메모리 사용량 : 첫번째 줄은 RAM의 메모리 영역으로 Mem이라 표시되어있는 부분이며, 두번째 줄은 디스크를 메모리처럼 이용하는 Swap 메모리 영역입니다. 일반적으로 Mem의 사용량이 가득 찼을때 Swap 메모리 영역을 사용합니다.

 

Ifconfig : 네트워크 기본 모니터링
인수가 없는 ifconfig 명령은 활성화된 네트워크의 세부 사항을 표시합니다. 다만 ifconfig만으로는 비활성화된 네트워크 사항은 볼 수 없습니다.

ifconfig를 사용하면 확인할 수 있는 사항은 아래와 같습니다.

- enp0s3 : 네트워크 인터페이스
- flags : 네트워크 카드의 상태 표시
- mtu : 네트워크 최대 전송 단위(Maximum Transfer Unit)
- inet : 네트워크에 할당된 IP 주소
- netmask : 네트워크에 할당된 넷마스크 주소
- broadcast : 네트워크에 할당된 브로드캐스트 주소
- inet6 : 네트워크에 할당된 IPv6 주소
- prefixlen : IP 주소에서 서브 넷 마스크로 사용될 비트 수
- scopeid : IPv6의 범위. LOOPBACK / LINKLOCAL / SITELOCAL / COMPATv4 / GLOBAL
- ether : 네트워크 인터페이스의 하드웨어 주소
- RX packets : 받은 패킷 정보
- TX packets : 보낸 패킷 정보
- collision : 충돌된 패킷 수
- Interrupt : 네트워크 인터페이스가 사용하는 인터럽트 번호

 

lsof : 열린 파일 목록 출력
lsof list open files의 약자로, 시스템에서 열려있는 모든 파일에 대한 정보를 출력합니다.

COMMAND : 실행 명령어

·         PID : 프로세스 ID

·         USER : 실행한 사용자

·         FD: File Descriptor, 파일의 종류.

o    cwd : current working directory

o    rtd : root directory

o    mem : memory-mapped file

o    txt : program text (code and data)

·         TYPE : 파일 종류

o    DIR : 디렉토리

o    REG : Regular File

o    CHR : Character Special File

o    unix : UNIX domain socket

·         DEVICE : 장치 번호

·         SIZE/OFF: 파일의 크기나 오프셋

·         NODE : 노드 번호

·         NAME : 파일 경로 및 파일 이름

 

Netstat : 네트워크 상태 모니터링
network statistics 의 약자로 현재 시스템에 연결된 네트워크 상태, 라우팅 테이블, 인터페이스 상태 등을 볼 수 있습니다.

-n : IP, Port번호를 보여줍니다.

-a모든 네트워크상태를 보여줍니다.

-t : TCP 프로토콜만 보여줍니다.

-u : UDP 프로토콜만 보여줍니다.

-r라우팅 테이블 출력

-s프로토콜 별(IP, ICMP, TCP, UDP )로 통계를 보여줍니다.

-l대기중인 소켓 목록을 보여줍니다.

 

듣는 소켓 (연결 및 연결 대기중) 서버 라고 하고 듣는 소켓하고 연결이 필요한 소켓은 클라이언트라 라고 합니다.  

 

멀티캐스트 그룹 멤버쉽
멀티캐스트 전송을 사용하면 수신자 수에 관계 없이 패킷을 한번만 보낼 수 있습니다.

https://www.howtogeek.com/513003/how-to-use-netstat-on-linux/

추가 Command Line tools
- vmstat – Virtual Memory Statistics : Display Statistics of virtual memory, kernel threads, disks, system process, I/O blocks, interrupts, CPU activity, etc
- Tcpdump – Network Packet Analyzer : capture or filters TCP/IP packets that are received or transferred on a specific interface over a network.
- Htop – Linux Process Monitoring : real-time linux process monitoring tool
- lotop – Monitor linux Disk I/O : Similar to top command and htop program, but has an accounting function to monitor and display real-time Disk I/O and processes
- iostat – Input/Output statistics : collect and show system input and output storage devise statistics
- IPtraf – Real-Time IP LAN monitoring : open-source console based real time network (IP LAN) monitoring utility for Linux
- Psacct or Acct – Monitor user activity : Useful for monitoring each user’s activity on the system.
- Monit – Linux process and services monitoring : Free open source and web based process supervision utility that automatically monitors and manages system processes, programs, files, directories, etc
- Nethogs – Monitor per process network bandwidth : open source nice small program that keeps a tab on each process network activity on your system
- iftop – Network bandwidth monitoring : Terminal based free open source system monitoring utility that displays a frequently updated list of network bandwidth utilization
- Monitorix – System and networking monitoring : lightweight utility that is designed to run and monitor system and network resources
- Arpwatch – Ethernet Activity monitor : Monitor Address resolution of (MAC and IP address changes) of Ethernet network traffic on a linux network
- Suricata – Network security monitoring : open source network security and intrusion detection and prevention monitoring system for linux
- Vnstat PHP – Monitoring network bandwidth : monitors network traffic usage in nicely graphical mode
- Nagios – Network/server monitoring : open source monitoring system that enables network/system adminstrators to identify and resolve server-related problems before they affect business processes
- Nmon – Monitor linux performance : monitor all linux resoruces
- collectl : all in one performance monitoring tool : Gather information about the linux system resources such as CPU usage, memory, network, etc

 

https://www.tecmint.com/command-line-tools-to-monitor-linux-performance/