zabbix5.0安装文档

https://www.zabbix.com/documentation/current/manual/concepts/server

server安装

#yum仓库下载配置

# rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
# yum clean all

# vim  /etc/yum.repos.d/zabbix.repo
    [zabbix-frontend]
    ...
    enabled=1
    ... 

#zabbix软件包下载

# yum -y install zabbix-server-mysql zabbix-agent 
# yum -y install centos-release-scl 		#如不安装这个,下一步安装会报错

# yum -y install zabbix-web-mysql-scl zabbix-apache-conf-scl 

#安装数据库

# yum install mariadb-server -y 
# systemctl enable --now mariadb
# mysql_secure_installation
。。。
中间可设置数据库密码
。。。

# mysql -uroot -p
password
mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> create user zabbix@localhost identified by 'password';
mysql> grant all privileges on zabbix.* to zabbix@localhost;
mysql> quit;

#数据模板导入数据库

# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -ppassword zabbix

#修改配置文件

# vim /etc/zabbix/zabbix_server.conf 
    DBHost=localhost		#数据库主机地址
    DBName=zabbix 			#数据库库名
    DBUser=zabbix 			#数据库用户
    DBPassword=123456		#数据库用户密码

#修改时区

vim /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf
    ...
    php_value[date.timezone] = Asia/Shanghai
    ...

#启动zabbix服务

# systemctl restart zabbix-server zabbix-agent httpd rh-php72-php-fpm
# systemctl enable --now zabbix-server zabbix-agent httpd rh-php72-php-fpm 

web配置

浏览器访问:

​ http://zabbix_server/zabbix

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-N0BDHErh-1638713785756)(img\1.png)]

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-Si7MDBCz-1638713785761)(img\2.png)]

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-WcN5c3N7-1638713785764)(img\3.png)]

​ 登录用户:Admin

​ 密码:zabbix

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-Pv6ymSJT-1638713785767)(img\4.png)]

设置中文:

​ usersettings--------------language----chinese(zh_CN)
在这里插入图片描述

agent安装

zabbix-agent安装配置

# yum -y install zabbix-agent

# vi /etc/zabbix/zabbix_agentd.conf
	Server=192.168.112.21			#指定zabbix-server的地址
	ServerActive=192.168.112.21		#自动注册时的zabbix-server地址
	Hostname=host1					#添加主机时的主机名

# systemctl enable --now zabbix-agent

zabbix-server添加主机

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-M6DztVy6-1638713785770)(img\6.png)]

在这里插入图片描述

添加模板

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-CX0lJ9Wg-1638713785774)(img\8.png)]

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-TS9rsPHF-1638713785776)(img\10.png)]

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-jMNy0LQf-1638713785778)(img\11.png)]

自定义监控项

#自定义key值(修改zabbix_agentd.conf文件)
# vi /etc/zabbix/zabbix_agentd.conf
	# 格式:UserParameter=key_name,command
	UserParameter=tcp_conn,ss -ant | grep ESTAB | wc -l



# 手动编写命令获取你所要获取的值
UserParameter=mysql.questions,mysqladmin -uroot -pxyh,.123 status | cut -f4 -d":" | cut -f1 -d"S"
UserParameter=sys.mem.free,free -h | awk 'NR==2{print $4}'

#注意当使用的$1不是位参时,需要用两个$
UserParameter=disk.space[*],df -h | grep $1 | awk '{print $$2}'

重启zabbix_agent

在这里插入图片描述

通过zabbix-get测试设置的键是否有效,在服务端

[root@k8s-master1 ~]# zabbix_get -s 192.168.112.22 -p 10050 -k tcp_conn
2


[root@localhost yum.repos.d]# zabbix_get -s 127.0.0.1 -p 10050 -k sys.mem.free
549M
[root@localhost yum.repos.d]# zabbix_get -s 127.0.0.1 -p 10050 -k mysql.questions
 287254
[root@localhost yum.repos.d]# zabbix_get -s 127.0.0.1 -p 10050 -k disk.space['/dev/sda1']
1014M

在web端配置监控项

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-9ESM2V8F-1638713785780)(img\12.png)]

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-2J0vb719-1638713785782)(img\13.png)]

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-FiR6Z9AJ-1638713785783)(img\14.png)]

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-pMjaAApY-1638713785784)(img\16.png)]

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-cefYZsYU-1638713785785)(img\17.png)]

查看定义监控项

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-3hUThaZu-1638713785787)(img\18.png)]

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-uXmLi6sV-1638713785788)(img\19.png)]

如果需要获取的值通过一条命令取不到

编写脚本

vi /etc/zabbix/get_tcp.sh
function  ESTAB { 
/usr/sbin/ss  -ant |  awk  '{++s[$1]} END {for(k in s) print k,s[k]}'  |  grep  'ESTAB'  |  awk  '{print $2}'
} 
function  TIMEWAIT { 
/usr/sbin/ss  -ant |  awk  '{++s[$1]} END {for(k in s) print k,s[k]}'  |  grep  'TIME-WAIT'  |  awk  '{print $2}'
} 
function  LISTEN { 
/usr/sbin/ss  -ant |  awk  '{++s[$1]} END {for(k in s) print k,s[k]}'  |  grep  'LISTEN'  |  awk  '{print $2}'
} 
$1

在这里插入图片描述

vi /etc/zabbix/zabbix_agentd.d/zabbix_get.conf
	UserParameter=tcp[*],bash /etc/zabbix/get_tcp.sh $1
	
systemctl restart zabbix-agent

zabbix-get测试

[root@k8s-master1 ~]# zabbix_get -s 192.168.112.22 -p 10050 -k tcp[TIMEWAIT]
38
[root@k8s-master1 ~]# zabbix_get -s 192.168.112.22 -p 10050 -k tcp[ESTAB]
2
[root@k8s-master1 ~]# zabbix_get -s 192.168.112.22 -p 10050 -k tcp[LISTEN]
6

web端配置

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-Ie2apVki-1638713785791)(img\20.png)]

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-kwJgyMO3-1638713785792)(img\21.png)]

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-cgg1F1XP-1638713785801)(img\22.png)]

模板添加自定义监控项

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-Uua3T45L-1638713785803)(img\24.png)]

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-NBWI39MU-1638713785804)(img\25.png)]

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-u7H0w7Sq-1638713785805)(img\26.png)]

添加触发器

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-fddNjESb-1638713785807)(img\27.png)]

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-lWG3ESO2-1638713785808)(img\28.png)]

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-4WoFo6PK-1638713785809)(img\29.png)]

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-2IxYjCeb-1638713785811)(img\30.png)]

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-V01ArDyH-1638713785813)(img\32.png)]

配置监控报警声音

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-N3Z8285P-1638713785814)(img\33.png)]

图形绘制

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-Lq10qQRe-1638713785818)(img\36.png)]

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-GzO4QP22-1638713785819)(img\37.png)]

乱码更改

  • 找到Windows目录C:\Windows\Fonts
  • 复制该字体文件到桌面。切记复制,不要剪切
  • 上传到服务器目录/usr/share/fonts/dejavu,这里建议使用黑体simhei.ttf,试啦几种字体乱码无法修改
cd /usr/share/fonts/dejavu
mv DejaVuSans.ttf DejaVuSans.ttf_bak
mv ALGER.TTF DejaVuSans.ttf

# 注意,很多文档都建议修改/usr/share/zabbix/assets/fonts/,但仔细的就会发现其实这个目录只是软链接,最终还是指向啦上面目录

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-HHG6EZcA-1638713785820)(img\39.png)]

触发器配置

邮件报警

1、配置发件人

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-TOTUvxxS-1638713785822)(img\40.png)]

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-YSAHU3nV-1638713785823)(img\41.png)]

生成授权码

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-HDODyLzF-1638713785824)(img\42.png)]

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-CrYnnpEV-1638713785825)(img\43.png)]

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-CasLvv1v-1638713785826)(img\44.png)]

2、收件人配置

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-F65l4Enx-1638713785828)(img\46.png)]

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-fuD0jI4k-1638713785829)(img\47.png)]

定义动作

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-5ZlyI1N4-1638713785830)(img\48.png)]

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-o5VYHhpM-1638713785831)(img\49.png)]
在这里插入图片描述

企业微信报警

1、最下方企业id

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-ZA8bOFQK-1638713785834)(img\51.png)]

创建一个应用

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-nGh7b5Ep-1638713785836)(img\53.png)]

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-giZAGbbw-1638713785837)(img\54.png)]

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-eExjE9Xy-1638713785838)(img\55.png)]

编写发送企业微信信息脚本

  • 主要修改
    • corpid 为你的企业ID
    • appsecret 为你的应用Secret
    • agentid 为你应用的agentid
#!/usr/bin/env python
#-*- coding: utf-8 -*-


import requests
import sys
import os
import json
import logging

logging.basicConfig(level = logging.DEBUG, format = '%(asctime)s, %(filename)s, %(levelname)s, %(message)s',
                datefmt = '%a, %d %b %Y %H:%M:%S',
                filename = os.path.join('/tmp','weixin.log'),
                filemode = 'a')


corpid='ww7cc01b78a88e8a46'
appsecret='Kba8A5Ok_N3RAXTYq0Uyy30A1zepyuGKjhBDVjRECXY'
agentid=1000002
#获取accesstoken
token_url='https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=' + corpid + '&corpsecret=' + appsecret
req=requests.get(token_url)
accesstoken=req.json()['access_token']

#发送消息
msgsend_url='https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=' + accesstoken

touser=sys.argv[1]
subject=sys.argv[2]
#toparty='3|4|5|6'
message=sys.argv[2] + "\n\n" +sys.argv[3]

params={
        "touser": touser,
#       "toparty": toparty,
        "msgtype": "text",
        "agentid": agentid,
        "text": {
                "content": message
        },
        "safe":0
}

req=requests.post(msgsend_url, data=json.dumps(params))

logging.info('sendto:' + touser + ';;subject:' + subject + ';;message:' + message)
# 测试

python weixin.py '$自己的ID' '$消息标题' '$消息内容'

python weixin.py XiongYunHua hello 你好
# 将脚本放置在zabbix-server存放脚本的目录
cp -a ~/weixin.py /usr/lib/zabbix/alertscripts
chmod +x weixin.py


web端配置

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-ngFMFw5z-1638713785839)(img\56.png)]

{ALERT.SENDTO}
{ALERT.SUBJECT}
{ALERT.MESSAGE}

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-U5H2vHLH-1638713785873)(img\58.png)]

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-nZomlTVN-1638713785875)(img\59.png)]

信息发送失败

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-2cttUJcY-1638713785877)(img\61.png)]

**[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-VBmcQJrQ-1638713785879)(img\62.png)]**

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-cbVnNZNH-1638713785880)(img\63.png)]

zabbix常用选项

[root@localhost yum.repos.d]# zabbix_server -h
usage:
  zabbix_server [-c config-file]
  zabbix_server [-c config-file] -R runtime-option
  zabbix_server -h
  zabbix_server -V

The core daemon of Zabbix software.

Options:
  -c --config config-file        指定配置文件启动
                                 (default: "/etc/zabbix/zabbix_server.conf")
  -f --foreground                前台运行server
  -R --runtime-control runtime-option  启动时指定参数

    Runtime control options:
      config_cache_reload        重载配置缓存
      housekeeper_execute        执行清理器
      log_level_increase=target  Increase log level, affects all processes if
                                 target is not specified
      log_level_decrease=target  Decrease log level, affects all processes if
                                 target is not specified
      snmp_cache_reload          Reload SNMP cache
      diaginfo=section           Log internal diagnostic information of the
                                 section (historycache, preprocessing, alerting,
                                 lld, valuecache, locks) or everything if section is
                                 not specified

      Log level control targets:
        process-type             All processes of specified type,进程的名称
                                 (alerter, alert manager, configuration syncer,
                                 discoverer, escalator, history syncer,
                                 housekeeper, http poller, icmp pinger,
                                 ipmi manager, ipmi poller, java poller,
                                 poller, preprocessing manager,
                                 preprocessing worker, proxy poller,
                                 self-monitoring, snmp trapper, task manager,
                                 timer, trapper, unreachable poller,
                                 vmware collector)
        process-type,N           Process type and number (e.g., poller,3)
        pid                      Process identifier, up to 65535. For larger
                                 values specify target as "process-type,N"

  -h --help                      Display this help message
  -V --version                   Display version number

Some configuration parameter default locations:
  AlertScriptsPath               "/usr/share/zabbix/alertscripts"		#脚本存放位置
  ExternalScripts                "/usr/share/zabbix/externalscripts"	
  SSLCertLocation                "/usr/share/zabbix/ssl/certs"			#证书存放位置
  SSLKeyLocation                 "/usr/share/zabbix/ssl/keys"			#公钥存放位置
  LoadModulePath                 "/usr/lib64/zabbix/modules"			#模块存放位置

使用运行时控件重新加载服务器配置缓存的示例:

shell> zabbix_server -c /usr/local/etc/zabbix_server.conf -R config_cache_reload

使用运行时控件收集诊断信息的示例:

收集服务器日志文件中的所有可用诊断信息:
外壳> zabbix_server -R diaginfo

在服务器日志文件中收集历史记录缓存统计信息:
外壳> zabbix_server -R diaginfo = historycache

使用运行时控件重新加载SNMP缓存的示例:

外壳> zabbix_server -R snmp_cache_reload  

使用运行时控件触发管家执行的示例:

shell> zabbix_server -c /usr/local/etc/zabbix_server.conf -R管家执行

使用运行时控件更改日志级别的示例:

增加所有进程的日志级别:
shell> zabbix_server -c /usr/local/etc/zabbix_server.conf -R log_level_increase

增加第二个轮询程序的日志级别:
shell> zabbix_server -c /usr/local/etc/zabbix_server.conf -R log_level_increase = poller,2

使用PID 1234增加过程的日志级别:
shell> zabbix_server -c /usr/local/etc/zabbix_server.conf -R log_level_increase = 1234

降低所有http轮询程序的日志级别:
shell> zabbix_server -c /usr/local/etc/zabbix_server.conf -R log_level_decrease =“ http poller”

处理用户

Zabbix服务器被设计为以非root用户身份运行。它将以启动时使用的任何非root用户身份运行。因此,您可以以任何非root用户身份运行服务器,而不会出现任何问题。

如果您尝试以“ root”用户身份运行它,它将切换到硬编码的“ zabbix”用户,该用户必须存在于系统中。如果您在服务器配置文件中相应地修改了“ AllowRoot”参数,则只能以“ root”身份运行服务器。

如果Zabbix服务器和代理程序在同一台计算机上运行,建议使用与运行代理程序不同的用户来运行服务器。否则,如果两者都以同一用户身份运行,则代理可以访问服务器配置文件,并且Zabbix中的任何管理员级别用户都可以很容易地检索到例如数据库密码。

配置文件

有关配置zabbix_server的详细信息,请参见配置文件选项。

启动脚本

这些脚本用于在系统启动/关闭期间自动启动/停止Zabbix进程。脚本位于目录misc / init.d下。

服务器进程类型

  • alert manager -警报任务的经理
  • alerter -发送通知的过程
  • availability manager -主机可用性更新过程
  • configuration syncer -管理配置数据的内存缓存的过程
  • discoverer -设备发现过程
  • escalator -行动升级的过程
  • history poller -处理需要数据库连接的计算,汇总和内部检查的过程
  • history syncer -历史数据库作者
  • housekeeper -删除旧历史数据的过程
  • http poller -网络监控轮询器
  • icmp pinger -用于轮询检查的轮询器
  • ipmi manager -IPMI轮询管理器
  • ipmi poller -用于IPMI检查的轮询器
  • java poller -用于Java检查的轮询器
  • lld manager -低级发现任务的管理器过程
  • lld worker -低级发现任务的工作进程
  • poller -普通轮询器,用于被动检查
  • preprocessing manager -预处理任务经理
  • preprocessing worker -数据预处理过程
  • proxy poller -被动代理轮询器
  • report manager-计划报告生成任务的经理
  • report writer -生成预定报告的过程
  • self-monitoring -收集内部服务器统计信息的过程
  • snmp trapper -SNMP陷阱的陷阱
  • task manager -远程执行其他组件请求的任务的过程(例如,关闭问题,确认问题,立即检查项目值,远程命令功能)
  • timer -处理维护的计时器
  • trapper -用于主动检查,陷阱,代理通信的陷阱器
  • unreachable poller -轮询无法访问的设备
  • vmware collector -VMware数据收集器,负责从VMware服务收集数据

服务器日志文件可用于观察这些过程类型。

可以使用zabbix **[process,,,]**内部项目监视各种类型的Zabbix服务器进程。


zabbix_get

RUNNING ZABBIX GET

An example of running Zabbix get under UNIX to get the processor load value from the agent:

shell> cd bin
shell> ./zabbix_get -s 127.0.0.1 -p 10050 -k system.cpu.load[all,avg1]

Another example of running Zabbix get for capturing a string from a website:

shell> yum -y install zabbix-get
shell> ./zabbix_get -s 192.168.1.1 -p 10050 -k "web.page.regexp[www.zabbix.com,,,\"USA: ([a-zA-Z0-9.-]+)\",,\1]"

Note that the item key here contains a space so quotes are used to mark the item key to the shell. The quotes are not part of the item key; they will be trimmed by the shell and will not be passed to Zabbix agent.

Zabbix get accepts the following command line parameters:

  -s --host <host name or IP>      Specify host name or IP address of a host.
  -p --port <port number>          Specify port number of agent running on the host. Default is 10050.
  -I --source-address <IP address> Specify source IP address.
  -k --key <item key>              Specify key of item to retrieve value of.
  -h --help                        Give this help.
  -V --version                     Display version number.

See also Zabbix get manpage for more information.

Zabbix get on Windows can be run similarly:

zabbix_get.exe [options]
[root@localhost yum.repos.d]# egrep -v "(^#|^$)" /etc/zabbix/zabbix_agentd.conf 
PidFile=/var/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
LogFileSize=0
Server=127.0.0.1			#server地址
ServerActive=127.0.0.1		#主动模式,server地址
Hostname=Zabbix server
Include=/etc/zabbix/zabbix_agentd.d/*.conf

监控项键值

#自定义key值(修改zabbix_agentd.conf文件)
格式
	UserParameter=key_name,获取value命令
	
UserParameter=mysql.questions,mysqladmin -uroot -pxyh,.123 status | cut -f4 -d":" | cut -f1 -d"S"
UserParameter=sys.mem.free,free -h | awk 'NR==2{print $4}'

#注意当使用的$1不是位参时,需要用两个$
UserParameter=disk.space[*],df -h | grep $1 | awk '{print $$2}'

重启zabbix_agent

测试

[root@localhost yum.repos.d]# zabbix_agentd -t mysql.questions
mysql.questions                               [t| 282228]
[root@localhost yum.repos.d]# zabbix_agentd -t sys.mem.free
sys.mem.free                                  [t|549M]

[root@localhost yum.repos.d]# zabbix_get -s 127.0.0.1 -p 10050 -k sys.mem.free
549M
[root@localhost yum.repos.d]# zabbix_get -s 127.0.0.1 -p 10050 -k mysql.questions
 287254
[root@localhost yum.repos.d]# zabbix_get -s 127.0.0.1 -p 10050 -k disk.space['/dev/sda1']
1014M


#手动传参给Key(利用位置变量)
UserParameter=test[*],echo $1

重启zabbix_agent
[root@localhost yum.repos.d]# systemctl restart zabbix-agent


[root@localhost yum.repos.d]# zabbix_get -s 127.0.0.1 -p 10050 -k test['aa','bb']
aa

注意:自定义的参数可以用在监控项里的key值,但是必须把"UnsafeUserParameters=1"改为1,才能在服务端使用

否则会报错:

  • Special characters ", ', “, `, *, ?, [, ], {, }, ~, $, !, &, ;, (, ), <, >, |, #, @, 0x0a” are not allowed in the parameters.
定义键值需要下列符号,需要将该参数改为1

### Option: UnsafeUserParameters
#       Allow all characters to be passed in arguments to user-defined parameters.
#       The following characters are not allowed:
#       \ ' " ` * ? [ ] { } ~ $ ! & ; ( ) < > | # @
#       Additionally, newline characters are not allowed.
#       0 - do not allow
#       1 - allow
#
# Mandatory: no
# Range: 0-1
# Default:
# UnsafeUserParameters=0

触发器表达式

格式:
{<server>:<key>.<function>(<parameter>)}<operator><constant>
{<服务器>:<键>.<功能>(<参数>)} <运算符> <常量>

FUNCTION PARAMETERS

FUNCTION CALLMEANING
sum(600)最近600秒内获取的数据和
sum(#5)最近获取的5个值的和
last()最新值
min()
max()
diff()大于0,表示内容是否更改
avg(5m)最近5分钟的平均值

OPERATORS

PriorityOperatorDefinitionNotes for unknown valuesForce cast operand to float 1
1-Unary minus**-**Unknown → UnknownYes
2notLogical NOTnot Unknown → UnknownYes
3*****Multiplication0 ***** Unknown → Unknown (yes, Unknown, not 0 - to not lose Unknown in arithmetic operations) 1.2 ***** Unknown → UnknownYes
/DivisionUnknown / 0 → error Unknown / 1.2 → Unknown 0.0 / Unknown → UnknownYes
4+Arithmetical plus1.2 + Unknown → UnknownYes
-Arithmetical minus1.2 - Unknown → UnknownYes
5<Less than. The operator is defined as: A<B ⇔ (A<B-0.000001)1.2 < Unknown → UnknownYes
<=Less than or equal to. The operator is defined as: A<=B ⇔ (A≤B+0.000001)Unknown <= Unknown → UnknownYes
>More than. The operator is defined as: A>B ⇔ (A>B+0.000001)Yes
>=More than or equal to. The operator is defined as: A>=B ⇔ (A≥B-0.000001)Yes
6=Is equal. The operator is defined as: A=B ⇔ (A≥B-0.000001) and (A≤B+0.000001)No 1
<>Not equal. The operator is defined as: A<>B ⇔ (A<B-0.000001) or (A>B+0.000001)No 1
7andLogical AND0 and Unknown → 0 1 and Unknown → Unknown Unknown and Unknown → UnknownYes
8orLogical OR1 or Unknown → 1 0 or Unknown → Unknown Unknown or Unknown → UnknownYes

an or equal to. The operator is defined as: A>=B ⇔ (A≥B-0.000001) | | Yes |
| 6 | = | Is equal. The operator is defined as: A=B ⇔ (A≥B-0.000001) and (A≤B+0.000001) | | No 1 |
| | <> | Not equal. The operator is defined as: A<>B ⇔ (A<B-0.000001) or (A>B+0.000001) | | No 1 |
| 7 | and | Logical AND | 0 and Unknown → 0 1 and Unknown → Unknown Unknown and Unknown → Unknown | Yes |
| 8 | or | Logical OR | 1 or Unknown → 1 0 or Unknown → Unknown Unknown or Unknown → Unknown | Yes |

1 String operand is still cast to numeric if:

转载至https://blog.csdn.net/weixin_47677347/article/details/121736803

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值