zabbix监控接口返回值

DevOps Zabbix评论2,657字数 3764阅读12分32秒阅读模式

查看zabbix脚本存放地址

[centos@us-prod-liveroom-classroom-6 ~]$ cat /etc/zabbix/zabbix_agentd.conf
PidFile=/var/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
LogFileSize=0
Server=10.0.3.152
ServerActive=10.0.3.152
Hostname=10.0.1.82
AllowRoot=1
UnsafeUserParameters=1
Timeout=30
Include=/etc/zabbix/zabbix_agentd.d/
UserParameter=websocket[*], /etc/zabbix/shell/venv/bin/python3 /etc/zabbix/shell/socket_checker.py "$1"

配置监控接口脚本

[root@us-prod-liveroom-classroom-6 shell]# pwd
/etc/zabbix/shell
[root@us-prod-liveroom-classroom-6 shell]# ls entity.sh entry.sh pwd.sh 
entity.sh  entry.sh  pwd.sh
[root@us-prod-liveroom-classroom-6 shell]# cat entity.sh
#! /bin/bash
result_code=$(curl -X GET --header 'Accept: application/json' 'https://classroom.line.com/eduroom/live/525681/entity')
echo ${result_code} > /etc/zabbix/shell/code/entity.txt
biz_desc=$(cat /etc/zabbix/shell/code/entity.txt | sed 's/,/\n/g' | grep "code" | sed 's/:/\n/g' | sed '1d' | sed 's/}//g'| sed 's/"//g')
echo $biz_desc
[root@us-prod-liveroom-classroom-6 shell]# cat entry.sh
#! /bin/bash
result_code=$(curl -X POST -H Content-Type:application/json -d '{"roomUuid": "525681", "password": "9212", "role": "0", "userName": "teacher", "userUuid": 48135187364912}' https://classroom.line.com/eduroom/live/entry )
echo ${result_code} > /etc/zabbix/shell/code/entry.txt
biz_desc=$(cat /etc/zabbix/shell/code/entry.txt | sed 's/,/\n/g' | grep "code" | sed 's/:/\n/g' | sed '1d' | sed 's/}//g'| sed 's/"//g')
echo $biz_desc
[root@us-prod-liveroom-classroom-6 shell]# cat pwd.sh 
#! /bin/bash
result_code=$(curl -X POST -H Content-Type:application/json -d ' {"roomId": "525681", "role": "0", "password": "9212"}' https://classroom.line.com/eduroom/live/valid/pwd )
echo ${result_code} > /etc/zabbix/shell/code/pwd.txt
biz_desc=$(cat /etc/zabbix/shell/code/pwd.txt | sed 's/,/\n/g' | grep "code" | sed 's/:/\n/g' | sed '1d' | sed 's/}//g'| sed 's/"//g')
echo $biz_desc

验证返回值

[root@us-prod-liveroom-classroom-6 shell]# bash entity.sh
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1486    0  1486    0     0  55037      0 --:--:-- --:--:-- --:--:-- 55037
0
[root@us-prod-liveroom-classroom-6 shell]# bash entry.sh
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   709    0   603  100   106   8867   1558 --:--:-- --:--:-- --:--:-- 10426
0
[root@us-prod-liveroom-classroom-6 shell]# bash pwd.sh
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   147    0    93  100    54   3875   2250 --:--:-- --:--:-- --:--:--  6125
0

加载脚本

[root@us-prod-liveroom-classroom-6 zabbix]# pwd
/etc/zabbix
[root@us-prod-liveroom-classroom-6 zabbix]# vim zabbix_agentd.conf
PidFile=/var/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
LogFileSize=0
Server=10.0.3.152
ServerActive=10.0.3.152
Hostname=10.0.1.82
AllowRoot=1
UnsafeUserParameters=1
Timeout=30
Include=/etc/zabbix/zabbix_agentd.d/
UserParameter=websocket[*], /etc/zabbix/shell/venv/bin/python3 /etc/zabbix/shell/socket_checker.py "$1"
UserParameter=entity.code[*], /bin/bash /etc/zabbix/shell/entity.sh "$1"
UserParameter=entry.code[*], /bin/bash /etc/zabbix/shell/entry.sh "$1"
UserParameter=pwd.code[*], /bin/bash /etc/zabbix/shell/pwd.sh "$1"

重启zabbix

[root@us-prod-liveroom-classroom-6 zabbix]# systemctl restart zabbix-agent

zabbix服务端

验证接口返回值
[root@us-prod-sre-zabbix-1 ~]# /usr/bin/zabbix_get  -s 10.0.1.82 -k pwd.code
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   147    0    93  100    54   3720   2160 --:--:-- --:--:-- --:--:--  5880
0
[root@us-prod-sre-zabbix-1 ~]# /usr/bin/zabbix_get  -s 10.0.1.82 -k entry.code
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   709    0   603  100   106   7831   1376 --:--:-- --:--:-- --:--:--  9207
0
[root@us-prod-sre-zabbix-1 ~]# /usr/bin/zabbix_get  -s 10.0.1.82 -k entity.code
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1486    0  1486    0     0  57153      0 --:--:-- --:--:-- --:--:-- 57153
0

web端添加监控

zabbix监控接口返回值

参考地址

https://www.cnblogs.com/shaozhiqi/p/12545763.html

继续阅读
Zabbix最后更新:2022-7-22
DevOps
  • 本文由 发表于 2022年7月21日 15:48:04
  • 除非特殊声明,本站文章均为原创,转载请务必保留本文链接
zabbix监控证书 Zabbix

zabbix监控证书

进入zabbix服务端如下目录 [root@zabbix-service scripts]# pwd /etc/zabbix/scripts 创建监控脚本 [root@zabb...
评论  0  访客  0

发表评论