Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
joohanhong
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
JooHan Hong
joohanhong
Commits
3c04ad33
Commit
3c04ad33
authored
Mar 03, 2023
by
JooHan Hong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
memory 모니터링 업데이트8
parent
7e2a79d6
Pipeline
#7000
passed with stages
in 1 minute and 1 second
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
172 additions
and
1 deletion
+172
-1
README.md
OS/RISK/MEMORY/MONITORING/README.md
+172
-1
No files found.
OS/RISK/MEMORY/MONITORING/README.md
View file @
3c04ad33
...
...
@@ -9,6 +9,8 @@
# Memory Item 및 설명
시작하기 전에.. 아래의 리소스들은 리눅스의
`/proc/meminfo`
통계 파일을 참조하는 구조이다.
## Memory Extension
...
...
@@ -17,7 +19,7 @@
![
asis_mem
](
./images/04p_23-02-16_custom.png
)
그럼 위의 그래프가 아닌 다음의 그래프를 먼저 보자.
그럼 위의 그래프가 아닌 다음의 그래프를 먼저 보자.
아래부터는 이를
**to-be 그래프**
라고 정의한다.
![
tobe_mem
](
./images/03p_mem_ext.png
)
...
...
@@ -54,5 +56,174 @@
그럼 각 필드의 값은 다음과 같다.
-
`swap free`
: 전체 스왑 영역의 가용량 이다.
-
`swap in`
: 디스크 -> 메모리로의 페이지 이동량 이다.
-
`swap out`
: 메모리 -> 디스크로의 페이지 이동량 이다.
-
`swap used`
: 전체 스왑 영역의 사용량 이다.
# Memory Monitoring Bash Script
Zabbix에서 위의 그래프를 출력하기 위해서는 아이템이 반드시 필요한데, 다음은 수집 스크립트의 코드 내역이다.
```
bash
# cat /var/lib/zabbix/scripts/memory_ext.sh
#!/bin/bash
# Description : Zabbix Memory Resource Script
# Author : juhanida21@nate.com
if
[[
$1
==
"anon_pages"
]]
;
then
anon_pages_size
=
0
anon_pages_size
=
`
cat
/proc/meminfo |grep
"AnonPages:"
|awk
'{print $2}'
`
anon_pages_result
=
`
expr
$anon_pages_size
'*'
1024
`
echo
$anon_pages_result
elif
[[
$1
==
"mapped"
]]
;
then
mapped_size
=
0
mapped_size
=
`
cat
/proc/meminfo |grep
"Mapped:"
|awk
'{print $2}'
`
mapped_result
=
`
expr
$mapped_size
'*'
1024
`
echo
$mapped_result
elif
[[
$1
==
"shm"
]]
;
then
shm_size
=
0
shm_size
=
`
cat
/proc/meminfo |grep
"Shmem:"
|awk
'{print $2}'
`
shm_result
=
`
expr
$shm_size
'*'
1024
`
echo
$shm_result
elif
[[
$1
==
"slab"
]]
;
then
slab_size
=
0
slab_size
=
`
cat
/proc/meminfo |grep
"Slab:"
|awk
'{print $2}'
`
slab_result
=
`
expr
$slab_size
'*'
1024
`
echo
$slab_result
elif
[[
$1
==
"dirty"
]]
;
then
dirty_size
=
0
dirty_size
=
`
cat
/proc/meminfo |grep
"Dirty"
|awk
'{print $2}'
`
dirty_result
=
`
expr
$dirty_size
'*'
1024
`
echo
$dirty_result
elif
[[
$1
==
"active"
]]
;
then
active_size
=
0
active_size
=
`
cat
/proc/meminfo |grep
"Active:"
|awk
'{print $2}'
`
active_result
=
`
expr
$active_size
'*'
1024
`
echo
$active_result
elif
[[
$1
==
"active_anon"
]]
;
then
active_anon_size
=
0
active_anon_size
=
`
cat
/proc/meminfo |grep
"Active(anon)"
|awk
'{print $2}'
`
active_anon_result
=
`
expr
$active_anon_size
'*'
1024
`
echo
$active_anon_result
elif
[[
$1
==
"active_file"
]]
;
then
active_file_size
=
0
active_file_size
=
`
cat
/proc/meminfo |grep
"Active(file)"
|awk
'{print $2}'
`
active_file_result
=
`
expr
$active_file_size
'*'
1024
`
echo
$active_file_result
elif
[[
$1
==
"inactive"
]]
;
then
inactive_size
=
0
inactive_size
=
`
cat
/proc/meminfo |grep
"Inactive:"
|awk
'{print $2}'
`
inactive_result
=
`
expr
$inactive_size
'*'
1024
`
echo
$inactive_result
elif
[[
$1
==
"inactive_anon"
]]
;
then
inactive_anon_size
=
0
inactive_anon_size
=
`
cat
/proc/meminfo |grep
"Inactive(anon)"
|awk
'{print $2}'
`
inactive_anon_result
=
`
expr
$inactive_anon_size
'*'
1024
`
echo
$inactive_anon_result
elif
[[
$1
==
"inactive_file"
]]
;
then
inactive_file_size
=
0
inactive_file_size
=
`
cat
/proc/meminfo |grep
"Inactive(file)"
|awk
'{print $2}'
`
inactive_file_result
=
`
expr
$inactive_file_size
'*'
1024
`
echo
$inactive_file_result
elif
[[
$1
==
"swap_cache"
]]
;
then
swap_cache_size
=
0
swap_cache_size
=
`
cat
/proc/meminfo |grep
"SwapCached"
|awk
'{print $2}'
`
swap_cache_result
=
`
expr
$swap_cache_size
'*'
1024
`
echo
$swap_cache_result
elif
[[
$1
==
"writeback"
]]
;
then
writeback_size
=
0
writeback_size
=
`
cat
/proc/meminfo |grep
"Writeback:"
|awk
'{print $2}'
`
writeback_result
=
`
expr
$writeback_size
'*'
1024
`
echo
$writeback_result
elif
[[
$1
==
"sreclaim"
]]
;
then
sreclaim_size
=
0
sreclaim_size
=
`
cat
/proc/meminfo |grep
"SReclaimable:"
|awk
'{print $2}'
`
sreclaim_result
=
`
expr
$sreclaim_size
'*'
1024
`
echo
$sreclaim_result
elif
[[
$1
==
"sunreclaim"
]]
;
then
sunreclaim_size
=
0
sunreclaim_size
=
`
cat
/proc/meminfo |grep
"SUnreclaim:"
|awk
'{print $2}'
`
sunreclaim_result
=
`
expr
$sunreclaim_size
'*'
1024
`
echo
$sunreclaim_result
elif
[[
$1
==
"kernel_stack"
]]
;
then
kernel_stack_size
=
0
kernel_stack_size
=
`
cat
/proc/meminfo |grep
"KernelStack:"
|awk
'{print $2}'
`
kernel_stack_result
=
`
expr
$kernel_stack_size
'*'
1024
`
echo
$kernel_stack_result
elif
[[
$1
==
"page_tables"
]]
;
then
page_tables_size
=
0
page_tables_size
=
`
cat
/proc/meminfo |grep
"PageTables:"
|awk
'{print $2}'
`
page_tables_result
=
`
expr
$page_tables_size
'*'
1024
`
echo
$page_tables_result
elif
[[
$1
==
"writeback_tmp"
]]
;
then
writeback_tmp_size
=
0
writeback_tmp_size
=
`
cat
/proc/meminfo |grep
"WritebackTmp:"
|awk
'{print $2}'
`
writeback_tmp_result
=
`
expr
$writeback_tmp_size
'*'
1024
`
echo
$writeback_tmp_result
elif
[[
$1
==
"nfs_unstable"
]]
;
then
nfs_unstable_size
=
0
nfs_unstable_size
=
`
cat
/proc/meminfo |grep
"NFS_Unstable:"
|awk
'{print $2}'
`
nfs_unstable_result
=
`
expr
$nfs_unstable_size
'*'
1024
`
echo
$nfs_unstable_result
elif
[[
$1
==
"committed_as"
]]
;
then
committed_as_size
=
0
committed_as_size
=
`
cat
/proc/meminfo |grep
"Committed_AS:"
|awk
'{print $2}'
`
committed_as_result
=
`
expr
$committed_as_size
'*'
1024
`
echo
$committed_as_result
elif
[[
$1
==
"unevictable"
]]
;
then
unevictable_size
=
0
unevictable_size
=
`
cat
/proc/meminfo |grep
"Unevictable:"
|awk
'{print $2}'
`
unevictable_result
=
`
expr
$unevictable_size
'*'
1024
`
echo
$unevictable_result
elif
[[
$1
==
"mlocked"
]]
;
then
mlocked_size
=
0
mlocked_size
=
`
cat
/proc/meminfo |grep
"Mlocked:"
|awk
'{print $2}'
`
mlocked_result
=
`
expr
$mlocked_size
'*'
1024
`
echo
$mlocked_result
elif
[[
$1
==
"bounce"
]]
;
then
bounce_size
=
0
bounce_size
=
`
cat
/proc/meminfo |grep
"Bounce:"
|awk
'{print $2}'
`
bounce_result
=
`
expr
$bounce_size
'*'
1024
`
echo
$bounce_result
elif
[[
$1
==
"hardwarecorrupted"
]]
;
then
hardwarecorrupted_size
=
0
hardwarecorrupted_size
=
`
cat
/proc/meminfo |grep
"HardwareCorrupted:"
|awk
'{print $2}'
`
hardwarecorrupted_result
=
`
expr
$hardwarecorrupted_size
'*'
1024
`
echo
$hardwarecorrupted_result
fi
```
> 위의 스크립트는 간단하다. /proc/meminfo 현황파일의 필드를 잡아(grep) 이를 필드 위치(awk)에 맞게 가져온 후 이를 Zabbix의 수집단위인
Bytes에 맞게 단위를 환산(expr 명령)하면 된다.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment