zabbix 安装使用
server1:(centos7以上)ip=172.25.8.11
在server1中:
yum install -y php-bcmath-5.4.16-42.el7.x86_64.rpm php-mbstring-5.4.16-42.el7.x86_64.rpm zabbix-agent-3.4.6-1.el7.x86_64.rpm zabbix-server-mysql-3.4.6-1.el7.x86_64.rpm zabbix-web-3.4.6-1.el7.noarch.rpm zabbix-web-mysql-3.4.6-1.el7.noarch.rpm fping-3.10-1.el7.x86_64.rpm iksemel-1.4-2.el7.centos.x86_64.rpm
yum install -y mariadb mariadb-server
systemctl start mariadb
mysql
create database zabbix character set utf8 collate utf8_bin;??? ##創(chuàng)建zabbix庫
grant all privileges on zabbix.* to zabbix@localhost identified by 'westos';? ##授權(quán)
cd /usr/share/doc/zabbix-server-mysql-3.4.6/
ll create.sql.gz
zcat create.sql.gz | mysql -uzabbix -pwestos Zabbix??? ##導(dǎo)入庫
mysql
use zabbix
show tables;
?
cd /etc/zabbix/
?
vim zabbix_server.conf
DBPassword=westos
?
cd /etc/httpd/conf.d/
?
ll zabbix.conf
vim zabbix.conf
?
?
systemctl start zabbix-server
vim /etc/php.ini
date.timezone = Asia/Shanghai
systemctl start httpd
?
?
物理機firefox訪問172.25.4.11/zabbix
登陸
ZABBIX
Username Admin
Password zabbix
點擊右上角小人頭更改為中文
systemctl start zabbix-agent
主機中 zabbix server 啟用主機
?
server2:
[root@test2 ~]# rpm -ivh zabbix-agent-3.4.6-1.el7.x86_64.rpm
[root@test2 ~]# vim /etc/zabbix/zabbix_agentd.conf (需要本地解析)
?
Server=182.25.8.11
ServerActive=172.25.8.11
HostName=test2?
主機的幾種添加方式:
[root@test2 ~]# systemctl start zabbix-agent.service
[root@test2 ~]# netstat -antlp
?
在172.25.4.11/Zabbix
手動添加
添加主機
點擊配置—>主機—>創(chuàng)建主機
?
?
添加模版
自動發(fā)現(xiàn):
配置–>自動發(fā)現(xiàn)–>創(chuàng)建發(fā)現(xiàn)規(guī)則
?
?
?
?
自動注冊
?
?
?
?
Api;
通過api查看,刪除,添加監(jiān)控
cd ?? vim zabbix.apicurl -s -X POST -H 'Content-Type: application/json' -d ' { "jsonrpc": "2.0", "method": "user.login", "params": {
??????? "user":"Admin",
??????? "password": "zabbix" }, "id": 1,
??? "auth": null }' http://172.25.8.1/zabbix/api_jsonrpc.php | python -m json.tool
chmod +x zabbix.api [root@server1 mnt]# ./zabbix.api
{
??? "id": 1,
??? "jsonrpc": "2.0",
??? "result": "1309609a9fa442ac3ac560b45da35b01"
} 將獲得的resault寫入api
[root@test1 ~]# vim zabbicG.api ? ? ##獲取主機信息
[root@test1 ~]# ./zabbicG.api ? ? ? ? ?
curl -s -X POST -H 'Content-Type: application/json' -d '
{
??? "jsonrpc": "2.0",
??? "method": "host.get",
??? "params": {
??????? "output": ["host"]
??? },
??? "id": 1,
??? "auth": "1309609a9fa442ac3ac560b45da35b01"
}' http://172.25.8.11/zabbix/api_jsonrpc.php | python -m json.tool
?
?
?
[root@test1 ~]# vim zabbixD.zpi ???##刪除監(jiān)控
url -s -X POST -H 'Content-Type: application/json' -d '
{
??? "jsonrpc": "2.0",
??? "method": "host.delete",
??? "params": [
????? 10257
??? ],
??? "id": 1,
??? "auth": "1309609a9fa442ac3ac560b45da35b01"
}' http://172.25.8.11/zabbix/api_jsonrpc.php | python -m json.tool
?
?
?
[root@test1 ~]# vim zabbix.zpi ???##創(chuàng)建監(jiān)控
curl -s -X POST -H 'Content-Type: application/json' -d '
{
??????? "jsonrpc": "2.0",
??? "method": "host.create",
??? "params": {
??????? "host": "test2",
??????? "interfaces": [
??????????? {
??????????????? "type": 1,
??????????????? "main": 1,
??????????????? "useip": 1,
??????????????? "ip": "172.25.8.12",
??????????????? "dns": "",
??????????????? "port": "10050"
??????????? }
??????? ],
??????? "groups": [
??????????? {
??????????????? "groupid": "2"
??????????? }
??????? ],
??????? "templates": [
??????????? {
??????????????? "templateid": "10001"
??????????? }
??????? ]
??? },
?? ?"id": 1,
??? "auth": "1309609a9fa442ac3ac560b45da35b01"
}' http://172.25.8.11/zabbix/api_jsonrpc.php | python -m json.tool
?
轉(zhuǎn)載于:https://www.cnblogs.com/zhengyipengyou/p/9826673.html
總結(jié)
以上是生活随笔為你收集整理的zabbix 安装使用的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【LUOGU P1220】关路灯(区间d
- 下一篇: CryptoZombies学习笔记——L