首页 > 代码库 > zabbix 邮件报警配置
zabbix 邮件报警配置
vim /usr/local/zabbix/etc/zabbix_server.conf
# 添加如下行
AlertScriptsPath=/usr/local/zabbix/alertscripts
# 创建这个目录 定义一个脚本
# 定义脚本前必须先安装sendEmail这个软件
cat mail.sh
#!/bin/bash
to=$1
subject=$2
body=$3
# 这里是直接转码
subject_gb2312=`iconv -t GB2312 -f UTF-8 << EOF
$subject
EOF`
message_gb2312=`iconv -t GB2312 -f UTF-8 << EOF
$body
EOF`
/usr/local/bin/sendEmail -f 要发送的邮件名称比如123.qq.com -t "$to" -s smtp地址定义 -u "$subject_gb2312" -o tls=auto -o message-content-type=html -o message-charset=utf8 -xu 要发送的邮件名称比如123.qq.com -xp 这里来个密码 -m "$message_gb2312"
# 以下是操作步骤以模板的方式
# 最后附加上模板到主机上就齐活了,这里是超过90报警之后的信息
### 最后附上zabbix 定义好的监控项模板信息,监控操作步骤:
# 路径地址:http://xiong51.blog.51cto.com/5239058/1946056
# 复制出来之后将文件命令*.xml格式: 如xx.xml然后导入
<?xml version="1.0" encoding="UTF-8"?> <zabbix_export> <version>3.2</version> <date>2017-07-11T05:25:52Z</date> <groups> <group> <name>Templates</name> </group> </groups> <templates> <template> <template>Templates_oracle_status</template> <name>Templates_oracle_status</name> <description/> <groups> <group> <name>Templates</name> </group> </groups> <applications> <application> <name>oracles_status</name> </application> </applications> <items> <item> <name>oracle_process</name> <type>0</type> <snmp_community/> <multiplier>0</multiplier> <snmp_oid/> <key>oracle.status[Process]</key> <delay>90</delay> <history>10</history> <trends>30</trends> <status>0</status> <value_type>3</value_type> <allowed_hosts/> <units/> <delta>0</delta> <snmpv3_contextname/> <snmpv3_securityname/> <snmpv3_securitylevel>0</snmpv3_securitylevel> <snmpv3_authprotocol>0</snmpv3_authprotocol> <snmpv3_authpassphrase/> <snmpv3_privprotocol>0</snmpv3_privprotocol> <snmpv3_privpassphrase/> <formula>1</formula> <delay_flex/> <params/> <ipmi_sensor/> <data_type>0</data_type> <authtype>0</authtype> <username/> <password/> <publickey/> <privatekey/> <port/> <description/> <inventory_link>0</inventory_link> <applications> <application> <name>oracles_status</name> </application> </applications> <valuemap/> <logtimefmt/> </item> <item> <name>oracle_session</name> <type>0</type> <snmp_community/> <multiplier>0</multiplier> <snmp_oid/> <key>oracle.status[Sessions]</key> <delay>90</delay> <history>10</history> <trends>30</trends> <status>0</status> <value_type>3</value_type> <allowed_hosts/> <units/> <delta>0</delta> <snmpv3_contextname/> <snmpv3_securityname/> <snmpv3_securitylevel>0</snmpv3_securitylevel> <snmpv3_authprotocol>0</snmpv3_authprotocol> <snmpv3_authpassphrase/> <snmpv3_privprotocol>0</snmpv3_privprotocol> <snmpv3_privpassphrase/> <formula>1</formula> <delay_flex/> <params/> <ipmi_sensor/> <data_type>0</data_type> <authtype>0</authtype> <username/> <password/> <publickey/> <privatekey/> <port/> <description/> <inventory_link>0</inventory_link> <applications> <application> <name>oracles_status</name> </application> </applications> <valuemap/> <logtimefmt/> </item> </items> <discovery_rules/> <httptests/> <macros/> <templates/> <screens/> </template> </templates> <triggers> <trigger> <expression>{Templates_oracle_status:oracle.status[Process].last(30)}>135</expression> <recovery_mode>0</recovery_mode> <recovery_expression/> <name>oraclce_process_warning</name> <correlation_mode>0</correlation_mode> <correlation_tag/> <url/> <status>0</status> <priority>2</priority> <description>oracle_process_warning</description> <type>0</type> <manual_close>0</manual_close> <dependencies/> <tags/> </trigger> <trigger> <expression>{Templates_oracle_status:oracle.status[Sessions].last(30)}>135</expression> <recovery_mode>0</recovery_mode> <recovery_expression/> <name>oraclce_session_warning</name> <correlation_mode>0</correlation_mode> <correlation_tag/> <url/> <status>0</status> <priority>2</priority> <description/> <type>0</type> <manual_close>0</manual_close> <dependencies/> <tags/> </trigger> </triggers> <graphs> <graph> <name>oracle_status</name> <width>900</width> <height>200</height> <yaxismin>0.0000</yaxismin> <yaxismax>100.0000</yaxismax> <show_work_period>1</show_work_period> <show_triggers>1</show_triggers> <type>0</type> <show_legend>1</show_legend> <show_3d>0</show_3d> <percent_left>0.0000</percent_left> <percent_right>0.0000</percent_right> <ymin_type_1>0</ymin_type_1> <ymax_type_1>0</ymax_type_1> <ymin_item_1>0</ymin_item_1> <ymax_item_1>0</ymax_item_1> <graph_items> <graph_item> <sortorder>0</sortorder> <drawtype>2</drawtype> <color>000099</color> <yaxisside>0</yaxisside> <calc_fnc>2</calc_fnc> <type>0</type> <item> <host>Templates_oracle_status</host> <key>oracle.status[Process]</key> </item> </graph_item> <graph_item> <sortorder>1</sortorder> <drawtype>2</drawtype> <color>999900</color> <yaxisside>0</yaxisside> <calc_fnc>2</calc_fnc> <type>0</type> <item> <host>Templates_oracle_status</host> <key>oracle.status[Sessions]</key> </item> </graph_item> </graph_items> </graph> </graphs> </zabbix_export>
本文出自 “xiong” 博客,请务必保留此出处http://xiong51.blog.51cto.com/5239058/1946302
zabbix 邮件报警配置