4 在信息中使用宏
概述
在消息主题和消息文本中,您可以使用宏来更有效的问题报告。
由Zabbix提供支持完整的宏列表 。
示例
这里的例子说明了如何在消息中使用宏。
示例 1
Message subject:
{TRIGGER.NAME}: {TRIGGER.STATUS}
收到消息后,消息主题将被替换为:
zabbix.zabbix.com服务器上的处理器负载太高: PROBLEM
示例 2
Message:
Processor load is: {zabbix.zabbix.com:system.cpu.load[,avg1].last()}
收到消息后,消息主题将被替换为:
Processor load is: 1.45
示例 3
Message:
Latest value: {{HOST.HOST}:{ITEM.KEY}.last()}
MAX for 15 minutes: {{HOST.HOST}:{ITEM.KEY}.max(900)}
MIN for 15 minutes: {{HOST.HOST}:{ITEM.KEY}.min(900)}
收到消息时,消息将被替换为:
Latest value: 1.45
MAX for 15 minutes: 2.33
MIN for 15 minutes: 1.01
示例 4
Message:
http://<server_ip_or_name>/zabbix/events.php?triggerid={TRIGGER.ID}&filter_set=1
收到消息时,它将包含一个有所有问题触发的事情的链接。
示例 5
Message:
Trigger: {TRIGGER.NAME}
Trigger expression: {TRIGGER.EXPRESSION}
1. Item value on {HOST.NAME1}: {ITEM.VALUE1} ({ITEM.NAME1})
2. Item value on {HOST.NAME2}: {ITEM.VALUE2} ({ITEM.NAME2})
收到消息时,消息将被替换为:
Problem name: Processor load is too high on a local host
Trigger expression: {Myhost:system.cpu.load[percpu,avg1].last()}>5 | {Myotherhost:system.cpu.load[percpu,avg1].last()}>5
1. Item value on Myhost: 0.83 (Processor load (1 min average per core))
2. Item value on Myotherhost: 5.125 (Processor load (1 min average per core))
示例6
Message:
Problem:
Event ID: {EVENT.ID}
Event value: {EVENT.VALUE}
Event status: {EVENT.STATUS}
Event time: {EVENT.TIME}
Event date: {EVENT.DATE}
Event age: {EVENT.AGE}
Event acknowledgement: {EVENT.ACK.STATUS}
Event update history: {EVENT.UPDATE.HISTORY}
Recovery:
Event ID: {EVENT.RECOVERY.ID}
Event value: {EVENT.RECOVERY.VALUE}
Event status: {EVENT.RECOVERY.STATUS}
Event time: {EVENT.RECOVERY.TIME}
Event date: {EVENT.RECOVERY.DATE}
收到消息时,消息将被替换为:
When you receive the message, the macros will be replaced by something like:
Problem:
Event ID: 21874
Event value: 1
Event status: PROBLEM
Event time: 13:04:30
Event date: 2018.01.02
Event age: 5m
Event acknowledgement: Yes
Event update history: 2018.01.02 13:05:51 "John Smith (Admin)"
Actions: acknowledged.
Recovery:
Event ID: 21896
Event value: 0
Event status: OK
Event time: 13:10:07
Event date: 2018.01.02
Zabbix 2.2.0之后支持把原始问题事件和恢复事件使用的通知宏分离开。