자율 학습/학습
[Zabbix] 서버 모니터링 방법 (UserParameter)
60cod
2024. 6. 14. 14:34
zabbix_agentd.conf
- Zabbix Agent 설정 파일
- 경로: /etc/zabbix/zabbix_agentd.conf
모니터링 시키기
1. 'ZABBIX 에이전트' 아이템 작성
기본적으로 지원되는 item key가 있어서 그 키를 사용해도 되고, 임의의 키를 만들어서 원하는 특정 커맨드를 실행시킬 수 있다.
서버에 설치된 자빅스 에이전트에게 이 키로 모니터링을 시킬 것이다.
2. Zabbix Agent 'UserParameter' 키 지정
- 방법 1. 설정 파일 UserParameter 옵션
- zabbix_agentd.conf 안에 UserParamter 작성
- Format에 친절하게 나와있듯이, 콤마로 구분해서 키와 명령어를 순서대로 쓰면 된다.
- 방법 2. zabbix_agentd.d 하위에 .conf 파일 작성
- 아래 Include 옵션 보면, zabbix_agentd.d 폴더 하위 .conf 파일 전부 include 하고 있다. (기본)
- 그렇기 때문에 따로 UserParameter 작성한 .conf 파일을 경로만 맞춰 넣어주면 알아서 연결한다.
참고로 인자가 필요한 sh 파일을 실행시킨다면 아래와 같이..
대괄호로 인자를 넘겨주고, UserParameter에는 아스테리스크(*)로, 실행시키는 커맨드는 똑같이 순서 맞춰서 작성하면 된다.
인자를 넘길 때는 기본 매크로 뿐 아니라 내가 추가한 호스트 매크로도 넣을 수 있다.
UserParameter=check.test[*],sh /etc/zabbix/zabbix_agentd.d/test_script.sh $1 $2
📑 공식 문서 링크
- Configuration > Items > User parameters
https://www.zabbix.com/documentation/current/en/manual/config/items/userparameters - Configuration > Items > Item types > Zabbix agent
https://www.zabbix.com/documentation/current/en/manual/config/items/itemtypes/zabbix_agent