DBAtlas · 데이터베이스 운영 아틀라스

DB 내부에서 서버 자원 사용량 조회(CPU/IO)

Oracle

SELECT stat_name, value FROM v$osstat
WHERE stat_name IN ('NUM_CPUS','BUSY_TIME','IDLE_TIME','IOWAIT_TIME','PHYSICAL_MEMORY_BYTES');
-- Real-time metrics: SELECT metric_name, value FROM v$sysmetric WHERE group_id = 2;

v$osstat은 OS CPU/메모리 카운터를, v$sysmetric은 최근 구간의 실시간 DB 지표(CPU, IOPS)를 보여 준다.

PostgreSQL

SELECT backend_type, object, context, reads, writes, hits, evictions
FROM pg_stat_io
ORDER BY reads DESC;
-- Note: CPU usage is not visible from inside the DB; an OS tool (top, sar) is required.

pg_stat_io는 읽기/쓰기/캐시 적중 카운터를 보여 준다. PostgreSQL은 CPU 사용량을 노출하지 않으므로 운영 체제 도구가 필요하다.

MySQL

SELECT * FROM sys.host_summary;
-- For InnoDB I/O and thread details:
SHOW ENGINE INNODB STATUS\G

sys 스키마 요약 뷰(host_summary)는 IO/지연 분석을 보여 준다. SHOW ENGINE INNODB STATUS는 buffer pool과 IO 활동을 보여 준다.

SQL Server

SELECT object_name, counter_name, cntr_value
FROM sys.dm_os_performance_counters
WHERE counter_name LIKE '%CPU%' OR counter_name LIKE '%Page life expectancy%';
-- CPU history: sys.dm_os_ring_buffers (RING_BUFFER_SCHEDULER_MONITOR)

sys.dm_os_performance_counters는 DB 성능 카운터를, dm_os_ring_buffers는 최근 약 256분간의 SQL/기타 프로세스 CPU 비율을 보여 준다.

MongoDB

db.serverStatus().metrics
// Relevant fields: .opcounters, .network, .wiredTiger.cache, .mem, .extra_info.page_faults

serverStatus()는 메모리, 네트워크, opcounters, WiredTiger 캐시 지표를 보여 준다. 상세한 OS CPU/IO는 mongostat이나 운영 체제 도구를 사용한다.

Redis

INFO cpu
INFO stats
# used_cpu_sys, used_cpu_user, instantaneous_ops_per_sec, total_net_input_bytes

INFO cpu는 Redis 프로세스의 CPU 사용량을, INFO stats는 초당 작업 수와 네트워크 트래픽을 보고한다.

Elasticsearch

GET _nodes/stats/os,process
// Look at the os.cpu.percent, os.mem, process.cpu.percent, fs (disk) fields

_nodes/stats/os,process는 노드별 CPU 사용률, 메모리, 프로세스 지표를 보여 준다. 디스크는 fs 섹션을 사용한다.

DBAtlas에서 열기 →