linux项目实战---lamp架构(十一)Zabbix云报警、API调用及数据迁移
作者:互联网
Zabbix云报警、API调用及数据迁移
一.睿象云报警
真机配置ip地址伪装:
iptables -t nat -I POSTROUTING -s 172.25.3.0/24 -j MASQUERADE
ping baidu.com
解压文件,配置连接:
cloudalert/ /usr/lib/zabbix/alertscripts/
tar zxf ca_zabbix_release-3.0.1.tar.gz
cd cloudalert/bin/
./install.sh 616d8b5138434cdc89d4423c381ae627
#用户名:Admin
#密码:zabbix
#访问地址:http://172.25.3.6/zabbix
cat /var/log/zabbix/zabbix_server.log
systemctl restart zabbix-server.service
查看报警类型:
动作详情:
睿象云配置:
关闭server8:
systemctl stop zabbix-agent.service
zabbix报警信息:
睿象云报警认领:
报警详情:
故障恢复:
systemctl start zabbix-agent.service
二.API调用
zabbix api
帮助文档:https://www.zabbix.com/documentation/4.0/zh/manual/api
获取身份验证令牌
curl -s -XPOST http://172.25.3.6/zabbix/api_jsonrpc.php -H 'Content-Type: application/json-rpc' -d '
{
"jsonrpc": "2.0",
"method": "user.login",
"params": {
"user": "Admin",
"password": "zabbix"
},
"id": 1,
"auth": null
}
' |python -m json.tool
检索主机
curl -s -XPOST http://172.25.3.6/zabbix/api_jsonrpc.php -H 'Content-Type: application/json-rpc' -d '
{
"jsonrpc": "2.0",
"method": "host.get",
"params": {
"output": [
"hostid",
"host"
],
"selectInterfaces": [
"interfaceid",
"ip"
]
},
"id": 2,
"auth": "98061be8c34a8495a30a9e473b558e3a"
}' | python -m json.tool
创建新监控项
curl -s -XPOST http://172.25.3.6/zabbix/api_jsonrpc.php -H 'Content-Type: application/json-rpc' -d '
{
"jsonrpc": "2.0",
"method": "item.create",
"params": {
"name": "Free disk space on $1",
"key_": "vfs.fs.size[/home/joe/,free]",
"hostid": "10084",
"type": 0,
"value_type": 3,
"interfaceid": "1",
"delay": 30
},
"id": 3,
"auth": "98061be8c34a8495a30a9e473b558e3a"
}' | python -m json.tool
刷新监控:
curl -s -XPOST http://172.25.3.6/zabbix/api_jsonrpc.php -H 'Content-Type: application/json-rpc' -d '
{
"jsonrpc": "2.0",
"method": "item.update",
"params": {
"itemid": "29285",
"status": 0
},
"id": 4,
"auth": "98061be8c34a8495a30a9e473b558e3a"
}' | python -m json.tool
三.数据迁移
将mysql
内数据迁移至tidb
解压tidb包:
tar zxf tidb-latest-linux-amd64.tar.gz
cd tidb-v5.0.1-linux-amd64/
后台执行pd_server:
./bin/pd-server --name=pd1 --data-dir=pd1 --client-urls="http://172.25.3.6:2379" --peer-urls="http://172.25.3.6:2380" --initial-cluster="pd1=http://172.25.3.6:2380" --log-file=pd.log &
netstat -antlp |grep :2379
netstat -antlp |grep :2380
运行tidb:
./bin/tidb-server &
netstat -antlp | grep 4000
mysql -h 172.25.3.6 -P 4000 -uroot
授予用户权限:
create database zabbix character set utf8 collate utf8_bin;
CREATE USER 'zabbix'@'%' IDENTIFIED BY 'westos';
grant all privileges on *.* to 'zabbix'@'%';
数据库备份及迁移:
mysqldump -uroot -pwestos zabbix >/mnt/zabbix.sql
cd /mnt/
ls
mysql -h 172.25.3.6 -P 4000 -uroot
use zabbix;
set tidb_batch_insert=1;
source /mnt/zabbix.sql;
修改server数据传输端口:
cd /etc/zabbix/
vim /etc/zabbix/zabbix_server.conf
DBPort=4000 ##修改端口为4000
修改监控网站访问ip及端口:
cd /etc/zabbix/web/
vim zabbix.conf.php
$DB['TYPE'] = 'MYSQL';
$DB['SERVER'] = '172.25.3.6'; ##修改远程主机
$DB['PORT'] = '4000'; ##修改端口
$DB['DATABASE'] = 'zabbix';
$DB['USER'] = 'zabbix';
$DB['PASSWORD'] = 'westos';
systemctl restart zabbix-server.service
systemctl restart zabbix-agent.service
系统功能未见异常,说明迁移成功。
标签:3.6,jsonrpc,json,zabbix,lamp,---,Zabbix,172.25,server 来源: https://blog.csdn.net/qq_42003848/article/details/118763198