zabbix of templates to create (memcache redis)

#; Find a host install redis and memcached (remember to install zabbix-agent)

root@ubuntu:~# apt install redis

root@ubuntu:~# apt install memcached

Listening port to modify the configuration file: #

root@ubuntu:~# vim /etc/redis/redis.conf

bind 0.0.0.0 ::1

root@ubuntu:~# vim /etc/memcached.conf

-l 0.0.0.0

#: Restart Service

root@ubuntu:~# systemctl restart redis memcached

#: Write a script, use ncat value (memcache connections)

root@ubuntu:~# cd /etc/zabbix/zabbix_agentd.conf.d/

root@ubuntu:/etc/zabbix/zabbix_agentd.conf.d# vim /etc/zabbix/zabbix_agentd.conf.d/memcache_status.sh

#!/bin/bash
echo -e "stats\nquit" |ncat 192.168.7.111 11211 |grep "STAT curr_connections" |awk '{print $3}'

#:Modify permissions

root@ubuntu:/etc/zabbix/zabbix_agentd.conf.d# chown zabbix.zabbix memcache_status.sh

root@ubuntu:/etc/zabbix/zabbix_agentd.conf.d# chmod +x memcache_status.sh

#: Server-side test

root@ubuntu:/apps/zabbix_server/share/zabbix/alertscripts# /apps/zabbix_server/bin/zabbix_get -s 192.168.7.111 -k "memcache.status"
1

 

 

#: Test no problem, began testing the web end

First add the associated host a template ----- ------ ----- add items to create graphics monitor

 

#: Detection

 

 

#: Memcache monitoring the ultimate script (a monitored item and graphics created earlier deleted)

 

#:创建脚本

root@ubuntu:/etc/zabbix/zabbix_agentd.conf.d# vim memcached_status.sh
#!/bin/bash
memcached_status(){
 M_PORT=$1
 M_COMMAND=$2
 echo -e "stats\nquit" | ncat 192.168.7.111 "$M_PORT" | grep "STAT $M_COMMAND" | awk '{print $3}'
}
main(){
case $1 in
memcached_status)
        $ memcached_status 2 $. 3 
;; 
Esac 
} 
main $ . 1 $ 2 $ . 3 

#: The agent configuration file annotation userparamenter 

the root @ Ubuntu: /etc/zabbix/zabbix_agentd.conf.d# Vim / etc / ZABBIX / zabbix_agentd.conf 
#UserParameter = memcache_conn , / etc / zabbix / zabbix_agentd.conf.d / memcached_status. SH 

#: write to a file ending in .conf configuration file (mandatory requirement to be in this directory) 

root @ Ubuntu: / etc / zabbix / zabbix_agentd. # Vim linux37.conf the conf.d 
UserParameter = memcache_status [*], / etc / ZABBIX / zabbix_agentd.conf.d / memcached_status. SH  " $. 1 "  " $ 2 "  " $. 3 "

#: Modify the owner is a group, restart Agent 

root @ Ubuntu: /etc/zabbix/zabbix_agentd.conf.d# chown zabbix.zabbix linux37.conf 
root @ Ubuntu: /etc/zabbix/zabbix_agentd.conf.d# systemctl restart zabbix- Agent .service 

#: server-side test 

root @ Ubuntu: ~ # / Apps / zabbix_server / bin / zabbix_get -s 192.168 . 7.111 -p 10050   -k " memcache_status [memcached_status, 11211, curr_connections] "

#: Creating a Template

 

 

 

 

 

 #: The graphic above steps and monitor items are done, what needs to be linked to a host template

Find the host ------- ------ selected template needs to find the host association ---- Add

#: This template so that you can monitor multiple values, and when the need to monitor other values ​​can be added to monitor items in this template, create graphics, or clone monitored item, my point here is that cloning monitored item

 

 #: Then add graphics on it

#; Start setting the trigger

Find a good set template to create a trigger ---- ---- click on the trigger

 

 

 

 

 

Monitoring redis

#: Create a value script 

root @ Ubuntu: . /Etc/zabbix/zabbix_agentd.conf.d# vim Redis SH 
# ! / Bin / bash 
redis_status () { 
R_PORT = $ 1 
R_COMMAND = $ 2 
( echo -en " INFO \ r \ the n- " ) | NCAT 127.0 . 0.1  " $ R_PORT " > / usr / local / zabbix / redis_ " $ R_PORT " .tmp 
REDIS_STAT_VALUE = $ ( grep  " " $ R_COMMAND " : " / usr / local / zabbix / redis_ "$R_PORT".tmp| cut -d ':' -f2)
echo $REDIS_STAT_VALUE
}
help(){
echo "${0} + redis_status+ PORT + COMMAND"
}
main(){
case $1 in
redis_status)
redis_status $2 $3
;;
*)
help
;;
esac
}
main $1 $2 $3

#:修改权限和属主属组

root@ubuntu:/etc/zabbix/zabbix_agentd.conf.d# chown zabbix.zabbix redis.SH 
root @ Ubuntu: /etc/zabbix/zabbix_agentd.conf.d# chmod . A + Redis the X- SH   

#: Create a directory 

root @ Ubuntu: /etc/zabbix/zabbix_agentd.conf.d# mkdir / usr / local / zabbix / 

root @ Ubuntu: /etc/zabbix/zabbix_agentd.conf.d# chown zabbix.zabbix / usr / local / zabbix / 


#: server-side test 
root @ Ubuntu: ~ # / Apps / zabbix_server / bin / zabbix_get -s 192.168 . 7.111 - the p- 10050 -k " redis_status [redis_status, 6379, total_connections_received] " 
23 

#; test no problem, add the web end

 

Create a template - add monitored items --- --- Add a trigger to add graphics applications ----

 

Guess you like

Origin www.cnblogs.com/maxuebin/p/11578651.html