当前位置: 首页>大数据>正文

zabbix企业微信告警提示找不到脚本

故障现象:

zabbix企业微信告警提示找不到脚本,第1张

系统环境:

  1. 脚本所属用户和组:zabbix:zabbix,权限:777
root@localhost:/usr/lib/zabbix/alertscripts# ll
-rwxrwxrwx 1 zabbix zabbix 1925 Jul  1 23:48 wechat.py*
  1. 脚本可手动测试运行成功
root@localhost:~# /usr/bin/python3.8 /usr/lib/zabbix/alertscripts/wechat.py 123 "123" "123"
returned value : b'{"errcode":0,"errmsg":"ok","msgid":"mrVtVXE39it1tWVvd57npJd6BGR5pqbCL2rWeZ46kb1whexozJM0Kp4gqLiEHe7AoXgYZstzB4HZSgvyqczG4g"}'
  1. OS环境
  Operating System: Ubuntu 20.04.4 LTS
            Kernel: Linux 5.4.0-121-generic
      Architecture: x86-64

解决方案:

  1. 查找python的环境变量
root@localhost:~# whereis python3
python3: /usr/bin/python3.8 /usr/bin/python3 /usr/bin/python3.8-config /usr/lib/python3.8 /usr/lib/python3 /usr/lib/python3.9 /etc/python3.8 /etc/python3 /usr/local/lib/python3.8 /usr/include/python3.8 /usr/share/python3 /usr/share/man/man1/python3.1.gz
  1. 使用/usr/bin/python3修改系统bash变量,编辑.bashrc文件

vim ~/.bashrc

# some more ls aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'
alias python='/usr/bin/python3' #增加这行环境变量

source ~/.bashrc

此时直接执行python即可进入python3.8环境,zabbix调用python3.8报错的问题也就解决了!

特别感谢:Zabbix 开源社区8群的 深紫深紫的紫罗兰


https://www.xamrdz.com/bigdata/7q61997508.html

相关文章: