当前位置:网站首页>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 .
边栏推荐
- 适合没口才的人做,加入中视频伙伴计划收益是真香,一个视频拿3份收益
- MIT团队使用图神经网络,加速无定形聚合物电解质筛选,促进下一代锂电池技术开发
- 基于价值量化的需求优先级排序方法
- 如何看待国企纷纷卸载微软Office改用金山WPS?
- Develop small programs and official account from zero [phase III]
- The first word of JVM -- detailed introduction to JVM and analysis of runtime data area
- Error-tf. function-decorated function tried to create variables on non-first call
- 期末琐碎知识点再整理
- 关于软件测试的一些思考
- [getting started with Django] 13 page Association MySQL "multi" field table (check)
猜你喜欢
随机推荐
JVM第一话 -- JVM入门详解以及运行时数据区分析
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
241. Design priorities for operational expressions
643. Maximum average number of subarrays I
[零基础学IoT Pwn] 复现Netgear WNAP320 RCE
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 navigation simulator industry
【14. 区间和(离散化)】
Opencv interpolation mode
Zabbix API与PHP的配置
MongoDB第二话 -- MongoDB高可用集群实现
MIT团队使用图神经网络,加速无定形聚合物电解质筛选,促进下一代锂电池技术开发
问题随记 —— Oracle 11g 卸载
SQLAchemy 常用操作
Ensure production safety! Guangzhou requires hazardous chemical enterprises to "not produce in an unsafe way, and keep constant communication"
Research Report on development trend and competitive strategy of global vibration polishing machine industry
使用net core 6 c# 的 NPOI 包,读取excel..xlsx单元格内的图片,并存储到指定服务器
Official announcement: Apache Doris graduated successfully and became the top project of ASF!
Salesforce, Johns Hopkins, Columbia | progen2: exploring the boundaries of protein language models
关于重载运算符的再整理