티스토리 뷰

카테고리 없음

[zabbix] zabbix_get 명령어

변군 변군이글루 2020. 6. 18. 13:34

zabbix_get 명령어

 : zabbix_get은 원격 Zabbix 에이전트에서 데이터를 가져오기 위한 명령 행 유틸리티입니다

 

이름 

zabbix_get - Zabbix get utility.

문법

zabbix_get [-hV] [-s <host name or IP>] [-p <port number>] [-I <IP address>] [-k <item key>]

zabbix_get -s 127.0.0.1 -p 10050 -k """system.cpu.load[all,avg1]"""

 

Zabbix 네트워크 모니터링 2/e
국내도서
저자 : 리하르즈 올룹스(Rihards Olups) / 전우성,김길종,김지연역
출판 : 에이콘출판사 2018.01.25
상세보기

 

[zabbix server : 10.255.255.100]

$ zabbix_get -s 10.255.255.200 -p 10050 -k "z_c[uptime]"
 13:20:38 up 1 day,  3:22,  1 user,  load average: 0.00, 0.01, 0.05

$ zabbix_get -s 10.255.255.200 -p 10050 -k "z_cs[tail /var/log/messages]"
Jun 18 15:10:02 dev-213 systemd: Removed slice User Slice of root.
Jun 18 15:11:01 dev-213 systemd: Created slice User Slice of root.
Jun 18 15:11:01 dev-213 systemd: Started Session 2142 of user root.
Jun 18 15:11:02 dev-213 systemd: Time has been changed
Jun 18 15:11:02 dev-213 systemd: Removed slice User Slice of root.
Jun 18 15:11:11 dev-213 systemd: Created slice User Slice of root.
Jun 18 15:11:11 dev-213 systemd: Started Session c2 of user root.
Jun 18 15:11:11 dev-213 systemd: Removed slice User Slice of root.
Jun 18 15:11:13 dev-213 systemd: Created slice User Slice of root.
Jun 18 15:11:13 dev-213 systemd: Started Session c3 of user root.

$ zabbix_get -s 10.255.255.200 -p 10050 -k "z_ps.status[ssh]"
1

 

[zabbix agent : 10.255.255.200]

 

$ vim /etc/zabbix_agentd.conf

PidFile=/var/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
LogFileSize=0

DenyKey=system.run[*]

EnableRemoteCommands=1

LogRemoteCommands=1

Server=zbx.4wxyz.com

ServerActive=zbx.4wxyz.com

Hostname=dev-213

Timeout=30

Include=/usr/local/etc/zabbix_agentd.userparams.conf

 

$ vim /usr/local/etc/zabbix_agentd.userparams.conf

UnsafeUserParameters=1

UserParameter=z_c[*],$1
UserParameter=z_cs[*],sudo $1

UserParameter=z_ps.status[*],ps -ef | grep $1 | awk '{if($$3 == 1) print $$0}' | wc -l
UserParameter=z_port.status[*],ss -lnp | grep $1 | wc -l
#UserParameter=z_port.status[*],ss -lnp | grep LISTEN | grep $1 | awk '{if($$3 == 1) print $$0}' | wc -l

UserParameter=z_nc.tcp.port[*],nc -4 -z "$1" "$2" -w "$3"; echo $?
UserParameter=z_nc.udp.port[*],nc --udp -4 -z "$1" "$2" -w "$3"; echo $?

UserParameter=z_uptime,uptime
UserParameter=z_cpu,mpstat | tail -1 | awk '{print 100-$NF}'
UserParameter=z_free,free -h
UserParameter=z_memory,free | awk '/Mem/{printf("used: %.2f%"), $3/$2*100} /buffers\/cache/{printf(", buffers: %.2f%"), $4/($3+$4)*100} /Swap/{printf(", swap: %.2f%\n"), $3/$2*100}'
UserParameter=z_disk,df -h | egrep -v '^Filesystem|tmpfs'
댓글
댓글쓰기 폼