当前位置:网站首页>Configuration of ZABBIX API and PHP
Configuration of ZABBIX API and PHP
2022-07-01 14:49:00 【Brother Xing plays with the clouds】
Because the nearest online Hadoop colony from mrv1 Upgrade to mrv2 了 , The monitoring template has also changed ..
Online is 200 Right and left colony , The module uses link To add , Under one template link A large number of modules , Then add the host to this template .
The editors recommend :
Installation and deployment Distributed The monitoring system Zabbix 2.06 http://www.linuxidc.com/Linux/2013-07/86942.htm
《 Installation and deployment Distributed The monitoring system Zabbix 2.06》 http://www.linuxidc.com/Linux/2013-07/86942.htm
CentOS 6.3 Next Zabbix Installation and deployment http://www.linuxidc.com/Linux/2013-05/83786.htm
Zabbix Distributed Monitoring system practice http://www.linuxidc.com/Linux/2013-06/85758.htm
CentOS 6.3 Next Zabbix monitor apache server-status http://www.linuxidc.com/Linux/2013-05/84740.htm
CentOS 6.3 Next Zabbix monitor MySQL Database parameters http://www.linuxidc.com/Linux/2013-05/84800.htm
In this way, a machine has almost 215 individual item.
To increase NM Monitoring of , It also uses link To connect templates , On the page link I found that a blank page has been returned .
In order to get online quickly , Changed the method , Used host.update Of api, Put... Directly host link To NM The template of .
Looking back on this question :
Through the page link Template time , In fact, it is called zabbix template dependent api( Specifically called template.update Method )
Call... Directly through a script api test :
The test script :
#!/usr/bin/env Python
import urllib2
import sys
import json
def requestJason(url,values):
data = json.dumps(values)
print data
req = urllib2.Request(url, data, {'Content-Type': 'application/json-rpc'})
response = urllib2.urlopen(req, data)
data_get = response.read()
output = json.loads(data_get)
print output
try:
message = output['result']
except:
message = output['error']['data']
quit()
print json.dumps(message)
return output
def authenticate(url, username, password):
values = {'jsonrpc': '2.0',
'method': 'user.login',
'params': {
'user': username,
'password': password
},
'id': '0'
}
idvalue = requestJason(url,values)
return idvalue['result']
def getTemplate(hostname,url,auth):
values = {'jsonrpc': '2.0',
'method': 'template.get',
'params': {
'output': "extend",
'filter': {
'host': hostname
}
},
'auth': auth,
'id': '2'
}
output = requestJason(url,values)
print output['result'][0]['hostid']
return output['result'][0]['hostid']
def changeTemplate(idx,id_list,url,auth):
values = {'jsonrpc': '2.0',
'method': 'template.update',
'params': {
"templateid":idx,
"templates":id_list
},
'auth': auth,
'id': '2'
}
output = requestJason(url,values)
print output
def main():
id_list = []
hostname = "linuxidc_Template_OS_Linux_Hadoop_Datanode_Pro"
url = 'xxxx'
username = 'admin'
password = 'xxxx'
auth = authenticate(url, username, password)
idx = getTemplate(hostname,url,auth)
temlist = ['linuxidc_Template_LB_Tengine_8090','linuxidc_Template_Redis_6379','linuxidc_Template_Redis_6380','linuxidc_Template_Redis_6381','linuxidc_Template_Redis_6382','linuxidc_Template_Redis_6383']
for tem in temlist:
idtemp = getTemplate(tem,url,auth)
id_list.append({"templateid":idtemp})
print id_list
#id_list = [{"templateid":'10843'},{"templateid":"10554"},{"templateid":"10467"},{"templateid":"10560"},{"templateid":"10566"},{"templateid":"10105"}]
changeTemplate(idx,id_list,url,auth)
if __name__ == '__main__':
main()
Script results :
urllib2.HTTPError: HTTP Error 500: Internal Server Error
because api In fact, it sent a jason Format post request , Manual use curl To verify :
curl -vvv -i -X POST -H 'Content-Type:application/json' -d
'{"params": {"templates": [{"templateid": "10117"}, {"templateid": "10132"}, {"templateid": "10133"}, {"templateid": "10134"},
{"templateid": "10135"}, {"templateid": "10136"}], "templateid": "10464"}, "jsonrpc": "2.0", "method": "template.update", "auth": "421a04b400e859834357b5681a586a5f", "id": "2"}'
http://zabbix.idc.linuxidc.com/api_jsonrpc.php
return 500 error ( Back end php Errors encountered during processing result in ), adjustment php Configuration of , Change the log to debug Format :
php-fpm.conf:
log_level = debug
stay error log The following errors were found in :
[04-May-2014 14:04:32.115189] WARNING: pid 6270, fpm_request_check_timed_out(), line 271: [pool www] child 6294, script '/apps/svr/zabbix/wwwroot/api_jsonrpc.php' (request: "POST /api_jsonrpc.php") executing too slow (1.269946 sec), logging
[04-May-2014 14:04:32.115327] DEBUG: pid 6270, fpm_got_signal(), line 72: received SIGCHLD
[04-May-2014 14:04:32.115371] NOTICE: pid 6270, fpm_children_bury(), line 227: child 6294 stopped for tracing
[04-May-2014 14:04:32.115385] NOTICE: pid 6270, fpm_php_trace(), line 142: about to trace 6294
[04-May-2014 14:04:32.115835] NOTICE: pid 6270, fpm_php_trace(), line 170: finished trace of 6294
[04-May-2014 14:04:32.115874] DEBUG: pid 6270, fpm_event_loop(), line 409: event module triggered 1 events
[04-May-2014 14:04:35.318614] WARNING: pid 6270, fpm_stdio_child_said(), line 166: [pool www] child 6294 said into stderr: "NOTICE: sapi_cgi_log_message(), line 663: PHP message: PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 512 bytes) in /apps/svr/zabbix/wwwroot/api/classes/CItem.php on line 1088"
[04-May-2014 14:04:35.318665] DEBUG: pid 6270, fpm_event_loop(), line 409: event module triggered 1 events
I'm doing it link Template time , You need to put the relevant data in php The memory of the , The default setting is 128M, If in item and host More often , It's easy to exceed that limit .
Change to
memory_limit = 1280M
To test , Back to 502 Bad Gateway error , That is, the back-end execution timeout leads to .
error log:
[04-May-2014 14:50:21.318071] WARNING: pid 4131, fpm_request_check_timed_out(), line 281: [pool www] child 4147, script '/apps/svr/zabbix/wwwroot/api_jsonrpc.php' (request: "POST /api_jsonrpc.php") execution timed out (10.030883 sec), terminating
Execution time exceeded request_terminate_timeout Set up . Lead to 502 produce .
change request_terminate_timeout = 1800( The default is 10s),max_execution_time = 0( Default 30s), To test .ok.
Summary :
zabbix Different from general online applications , Calling api When updating , It's a batch act , There are certain requirements for memory and execution time .
So set it reasonably php Related parameters of , stay debug Lower the log level and turn it on slow log To facilitate positioning problems .
边栏推荐
- Buuctf reinforcement question ezsql
- MongoDB第二話 -- MongoDB高可用集群實現
- Research Report on development trend and competitive strategy of global consumer glassware industry
- One of the data Lake series | you must love to read the history of minimalist data platforms, from data warehouse, data lake to Lake warehouse
- The first word of JVM -- detailed introduction to JVM and analysis of runtime data area
- [Verilog quick start of Niuke question series] ~ use functions to realize data size conversion
- Sorting learning sorting
- Provincial election + noi Part VIII fraction theory
- 微服务开发步骤(nacos)
- Is it reasonable and safe for securities companies to open accounts for 10000 free securities? How to say
猜你喜欢

Websocket (simple experience version)

C#学习笔记(5)类和继承

音乐播放器开发实例(可毕设)

What are the books that have greatly improved the thinking and ability of programming?

【14. 区间和(离散化)】
![[zero basic IOT pwn] reproduce Netgear wnap320 rce](/img/f7/d683df1d4b1b032164a529d3d94615.png)
[zero basic IOT pwn] reproduce Netgear wnap320 rce

What problems should be considered for outdoor LED display?

定了!2022海南二级造价工程师考试时间确定!报名通道已开启!

MIT team used graph neural network to accelerate the screening of amorphous polymer electrolytes and promote the development of next-generation lithium battery technology

建立自己的网站(14)
随机推荐
Tensorflow 2. X realizes iris classification
【牛客网刷题系列 之 Verilog快速入门】~ 使用函数实现数据大小端转换
One of the data Lake series | you must love to read the history of minimalist data platforms, from data warehouse, data lake to Lake warehouse
炎炎夏日,这份安全用气指南请街坊们收好!
tensorflow2-savedmodel convert to pb(frozen_graph)
Minimum spanning tree and bipartite graph in graph theory (acwing template)
643. Maximum average number of subarrays I
这3款在线PS工具,得试试
It's suitable for people who don't have eloquence. The benefits of joining the China Video partner program are really delicious. One video gets 3 benefits
One of the first steps to redis
手把手带你入门 API 开发
Research Report on the development trend and competitive strategy of the global diamond suspension industry
Research Report on the development trend and competitive strategy of the global traditional computer industry
JVM second conversation -- JVM memory model and garbage collection
Research Report on the development trend and competitive strategy of the global commercial glassware industry
Build your own website (14)
[Verilog quick start of Niuke series] ~ multi function data processor, calculate the difference between two numbers, use generate... For statement to simplify the code, and use sub modules to realize
Ubuntu 14.04下搭建MySQL主从服务器
三十之前一定要明白的职场潜规则
Research Report on the development trend and competitive strategy of the global CCTV robot industry