溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

zabbix 自動監(jiān)控

發(fā)布時間:2020-07-13 13:23:14 來源:網(wǎng)絡(luò) 閱讀:574 作者:清晨soso 欄目:建站服務(wù)器

192.168.29.130  是安裝zabbix主服務(wù)器

192.168.29.129  是從服務(wù)器

1)自動發(fā)現(xiàn)

zabbix API

vim /etc/zabbix/zabbix_agentd.conf  在從服務(wù)器192.168.29.129 ip

ServerActive=192.168.29.129

Hostname=linux-node2.example.com

HostMetadataItem=system.uname

zabbix_get -s 192.168.29.130 -k system.uname   在主服務(wù)器測試

/etc/init.d/zabbix-agent  restart



zabbix  自動監(jiān)控

zabbix  自動監(jiān)控

zabbix  自動監(jiān)控

zabbix  自動監(jiān)控


2)網(wǎng)絡(luò)發(fā)現(xiàn)

關(guān)閉自動注冊

vim /etc/zabbix/zabbix_agentd.conf  在從服務(wù)器

Server=192.168.29.130

StartAgents=3

ServerActive=127.0.0.1

grep '^[a-Z]' /etc/zabbix/zabbix_agentd.conf

/etc/init.d/zabbix-agent  restart


http://192.168.29.130/zabbix/hosts.php?ddreset=1&sid=9d7240bdae42f8f3

在網(wǎng)頁中執(zhí)行相關(guān)操作


zabbix  自動監(jiān)控




3)API方式     關(guān)閉自動注冊 自動發(fā)現(xiàn)  刪除自動發(fā)現(xiàn)的機器

1.驗證

https://www.zabbix.com/documentation/2.4/manual/api/reference/user/login

curl -s -X POST -H 'Content-Type:application/json' -d '

{

"jsonrpc": "2.0",

"method": "user.login",

"params": {

"user": "Admin",

"password": "zabbix"

},

"id": 1

}' http://192.168.29.130/zabbix/api_jsonrpc.php |python -mjson.tool

返回數(shù)據(jù)

{

"id": 1,

"jsonrpc": "2.0",

"result": "72e104119c242914115b5221e5bf1672"

}

https://www.zabbix.com/documentation/2.4/manual/api/reference/host/get

2.請求api ,附帶上sessionid

curl -s -X POST -H 'Content-Type:application/json' -d '

{

"jsonrpc": "2.0",

"method": "host.get",

"params": {

"output": ["hostid"],

"selectGroups": "extend",

"filter": {

"host": [

"Zabbix server"

]

}

},

"auth": "72e104119c242914115b5221e5bf1672",

"id": 2

}' http://192.168.29.130/zabbix/api_jsonrpc.php |python -mjson.tool

https://www.zabbix.com/documentation/2.4/manual/api/reference/host/create

curl -s -X POST -H 'Content-Type:application/json' -d '

{

"jsonrpc": "2.0",

"method": "host.create",

"params": {

"host": "Linux server",

"interfaces": [

{

"type": 1,

"main": 1,

"useip": 1,

"ip": "192.168.29.129",

"dns": "",

"port": "10050"

}

],

"groups": [

{

"groupid": "2"

}

],

"templates": [

{

"templateid": "10001"

}

],

"inventory_mode": 0,

"inventory": {

"macaddress_a": "01234",

"macaddress_b": "56768"

}

},

"auth": "72e104119c242914115b5221e5bf1672",

"id": 5

}' http://192.168.29.130/zabbix/api_jsonrpc.php |python -mjson.tool

成功返回數(shù)據(jù)

{

"id": 5,

"jsonrpc": "2.0",

"result": {

"hostids": [

"10114"

]

}

}


向AI問一下細節(jié)

免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI