zabbix-- create a trigger

trigger

 Outline

A trigger is "evaluating" the monitoring data collected items and represents a logical representation of the current state of the system.

When monitoring items for the data acquisition system, always follow these data are not very practical, because these data are always worth worrying or waiting in a state of concern. However, this work "assessment" of data can be left to trigger expression.

What allows the definition of a trigger expression status data is "acceptable" threshold. Thus, if the received data exceeds an acceptable state, the trigger is triggered - or change the status is abnormal.

A trigger can have several states the following:

value description
OK This is a normal trigger state. FALSE called in the old version of Zabbix in.
PROBLEM Usually it means that something happened. For example, high processor load. TRUE called in the old version of Zabbix in.

Zabbix server each time a new value is received as part of an expression, a trigger condition is recalculated (expression).

If you use a time-based function (nodata (), date (), dayofmonth (), dayofweek (), time (), now ()), the trigger will be re-calculated by Zabbix history syncer process every 30 seconds in the expression once. If both time based and non time-based function, when receiving a new value is recalculated every 30 seconds in the state where the trigger expression.

You can build different levels of complexity touch trigger expressions

For more information please read the official document zabbix: https: //www.zabbix.com/documentation/4.0/zh/manual/config/triggers/trigger

Let's configure a trigger to detect whether there is http service to start

1, install and enable the http service agent

[root@localhost ~]# service httpd status
httpd is stopped
[root@localhost ~]# service httpd start
Starting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain for ServerName
                                                           [  OK  ]
[root@localhost ~]#
[root@localhost ~]# netstat -ntlp|grep http
tcp        0      0 :::80                       :::*                        LISTEN      30275/httpd         
[root@localhost ~]#

 

2. Create item

 

 Use zabbix-get tested at

#返回1表服务运行中,0表服务挂了
[root@localhost ~]# zabbix_get  -s 192.168.190.131 -k net.tcp.service[http,192.168.190.131,80]
1
[root@localhost ~]# zabbix_get  -s 192.168.190.131 -k net.tcp.service[http,192.168.190.131,80]
0

创建触发器:

在官网可以查看所有触发器支持的函数:https://www.zabbix.com/documentation/4.0/zh/manual/appendix/triggers/functions

 

 
参数:
参数 描述
名称 触发器名称.
名称中可以包含支持的 : {HOST.HOST}, {HOST.NAME}, {HOST.CONN}, {HOST.DNS}, {HOST.IP}, {ITEM.VALUE}, {ITEM.LASTVALUE}{$MACRO}
$1, $2…$9 宏可以用来指第一,第二…第九表达式的常量。
备注: 如果引用了相对简单的常量或明确的表达式,$1-$9宏将会正确解析。例如, 如果表达式是{New host:system.cpu.load[percpu,avg1].last()}>5,则“Processor load above $1 on {HOST.NAME}“将会自动更改成 “Processor load above 5 on New host”
严重性 通过点击对应的按钮来设置所需的触发器严重性
异常表达式 用于定义异常条件的逻辑表达式
事件成功迭代 事件成功迭代选项:
表达式 - OK事件基于与问题事件相同的表达式生成;
恢复表达式 - 如果问题表达式计算为false,恢复表达式计算为true,则生成OK事件;
None - 在这种情况下,触发器将永远不会返回到OK状态。
从Zabbix 3.2.0开始支持
恢复表达式 逻辑表达式用于定义问题解决的条件。
只有在表达式表达式计算为FALSE之后才对恢复表达式进行评估。如果问题条件仍然存在,则不可能通过恢复表达式来解决问题。
此字段是可选的,仅在OK 事件生成选择恢复表达式。
从Zabbix 3.2.0开始支持
异常事件生成模式 生成异常事件的模式:
单个 - 当触发器第一次进入‘异常‘状态时,生成一条单个事件。;
多重 - 每一个触发器“异常”评估都将生产一条事件。
事件成功关闭 如果选择事件成功关闭:
所有问题 - 此触发器的所有问题
所有问题如果标签值匹配 - 只有那些匹配事件标签值引发的问题。
从Zabbix 3.2.0开始支持。
匹配标记 输入事件标记名称以用于事件关联。
如果在事件成功关闭中选择了‘所有问题如果标签值匹配’,在这种情况下是强制性的。
从Zabbix 3.2.0开始支持。
标记  

 

在agent stop http
[root@localhost ~]# service httpd stop 
Stopping httpd:                                            [  OK  ]
[root@localhost ~]# service httpd start
Starting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain for ServerName
            

View results:

 

 

 


 

 

 

 

Guess you like

Origin www.cnblogs.com/laonicc/p/11084390.html