zabbix-redis/memcache监控/邮件分级报警及nginx自治愈
Posted 小怪獣55
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了zabbix-redis/memcache监控/邮件分级报警及nginx自治愈相关的知识,希望对你有一定的参考价值。
主动模式
主动模式参考:https://blog.51cto.com/u_14814545/4869452
memcached
apt-get install memcached
systemctl start memcached #端口11211
apt-get install nmap
测试
echo -e "stats\\nquit" | nc 127.0.0.1 11211
root@ubuntu:~# echo -e "stats\\nquit" | nc 127.0.0.1 11211 | grep "total_connections" | awk print $3
监控脚本
root@ubuntu:/etc/zabbix/zabbix_agentd.d# ls
memcached.conf memcached.sh
vim /etc/zabbix/zabbix_agentd.d/memcached.conf
-------------------------------------------------------------------------------------
UserParameter=memcached_status[*],/bin/bash /etc/zabbix/zabbix_agentd.d/memcached.sh $1 $2 $3
-------------------------------------------------------------------------------------
memcached.sh 这个脚本是加了执行权限的,但是为啥前面要加上/bin/bash,zabbix_get才能获取到值??
#脚本
--------------------------------------------------------------------------
#!/bin/bash
memcached_status()
M_PORT=$1
M_COMMAND=$2
echo -e "stats\\nquit" | nc 127.0.0.1 "$M_PORT" | grep "STAT $M_COMMAND " | awk print $3
main()
case $1 in
memcached_status)
memcached_status $2 $3
;;
esac
main $1 $2 $3
--------------------------------------------------------------------------
chmod a+x memcached.sh
#测试脚本
root@ubuntu:/etc/zabbix/zabbix_agentd.d# bash memcached.sh memcached_status 11211 total_connections
#在主配置文件打开,默认是打开的
vim /etc/zabbix/zabbix_agentd.conf
------------------------------------------------------
Include=/etc/zabbix/zabbix_agentd.d/*.conf
------------------------------------------------------
在[192.168.47.104测试]
/apps/zabbix_agent/bin/zabbix_get -s 192.168.47.105 -p 10050 -k "memcached_status[memcached_status,11211,total_connections]"
模板
<zabbix_export>
<version>4.0</version>
<date>2019-04-15T10:15:11Z</date>
<groups>
<group>
<name>Templates</name>
</group>
</groups>
<templates>
<template>
<template>memcached</template>
<name>memcached-zabbix4.2</name>
<description/>
<groups>
<group>
<name>Templates</name>
</group>
</groups>
<applications>
<application>
<name>memcached</name>
</application>
</applications>
<items>
<item>
<name>memcached-curr_connections</name>
<type>7</type>
<snmp_community/>
<snmp_oid/>
<key>memcached_status["memcached_status","11211","curr_connections"]</key>
<delay>5s</delay>
<history>30d</history>
<trends>365d</trends>
<status>0</status>
<value_type>3</value_type>
<allowed_hosts/>
<units/>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<params/>
<ipmi_sensor/>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0</inventory_link>
<applications>
<application>
<name>memcached</name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
<preprocessing/>
<jmx_endpoint/>
<timeout>3s</timeout>
<url/>
<query_fields/>
<posts/>
<status_codes>200</status_codes>
<follow_redirects>1</follow_redirects>
<post_type>0</post_type>
<http_proxy/>
<headers/>
<retrieve_mode>0</retrieve_mode>
<request_method>0</request_method>
<output_format>0</output_format>
<allow_traps>0</allow_traps>
<ssl_cert_file/>
<ssl_key_file/>
<ssl_key_password/>
<verify_peer>0</verify_peer>
<verify_host>0</verify_host>
<master_item/>
</item>
<item>
<name>memcached_threads</name>
<type>7</type>
<snmp_community/>
<snmp_oid/>
<key>memcached_status["memcached_status","11211","threads"]</key>
<delay>5s</delay>
<history>30d</history>
<trends>365d</trends>
<status>0</status>
<value_type>3</value_type>
<allowed_hosts/>
<units/>
<snmpv3_contextname/>
<snmpv3_securityname/>
<snmpv3_securitylevel>0</snmpv3_securitylevel>
<snmpv3_authprotocol>0</snmpv3_authprotocol>
<snmpv3_authpassphrase/>
<snmpv3_privprotocol>0</snmpv3_privprotocol>
<snmpv3_privpassphrase/>
<params/>
<ipmi_sensor/>
<authtype>0</authtype>
<username/>
<password/>
<publickey/>
<privatekey/>
<port/>
<description/>
<inventory_link>0</inventory_link>
<applications>
<application>
<name>memcached</name>
</application>
</applications>
<valuemap/>
<logtimefmt/>
<preprocessing/>
<jmx_endpoint/>
<timeout>3s</timeout>
<url/>
<query_fields/>
<posts/>
<status_codes>200</status_codes>
<follow_redirects>1</follow_redirects>
<post_type>0</post_type>
<http_proxy/>
<headers/>
<retrieve_mode>0</retrieve_mode>
<request_method>0</request_method>
<output_format>0</output_format>
<allow_traps>0</allow_traps>
<ssl_cert_file/>
<ssl_key_file/>
<ssl_key_password/>
<verify_peer>0</verify_peer>
<verify_host>0</verify_host>
<master_item/>
</item>
</items>
<discovery_rules/>
<httptests/>
<macros/>
<templates/>
<screens/>
</template>
</templates>
<triggers>
<trigger>
<expression>memcached:memcached_status["memcached_status","11211","curr_connections"].last()>12</expression>
<recovery_mode>0</recovery_mode>
<recovery_expression/>
<name>memcached-curr_connections</name>
<correlation_mode>0</correlation_mode>
<correlation_tag/>
<url/>
<status>0</status>
<priority>4</priority>
<description/>
<type>0</type>
<manual_close>0</manual_close>
<dependencies/>
<tags/>
</trigger>
<trigger>
<expression>memcached:memcached_status["memcached_status","11211","threads"].last()>5</expression>
<recovery_mode>0</recovery_mode>
<recovery_expression/>
<name>memcached_线程数</name>
<correlation_mode>0</correlation_mode>
<correlation_tag/>
<url/>
<status>0</status>
<priority>4</priority>
<description/>
<type>0</type>
<manual_close>0</manual_close>
<dependencies/>
<tags/>
</trigger>
</triggers>
<graphs>
<graph>
<name>memcached-curr_connections</name>
<width南邮数据结构考试时间