Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Server \ Zabbix API and PHP configuration     - MongoDB query timeout exception SocketTimeoutException (Database)

- Oracle 11g Export guide problem not an empty table (Database)

- CentOS 6 adds disk quota limit (Linux)

- Linux System Getting Started Learning: Linux command in w (Linux)

- Configuration OpenOCD + FT2232 under Ubuntu (Linux)

- Linux C programming and Shell Programming in the development of practical tools similarities summary (Programming)

- Let OS X support NTFS write file (Linux)

- Based on Google Cloud Storage Mirroring open Maven Central Repository (Server)

- Linux Getting Started Tutorial: / var / spool / clientmqueue fill the root directory (Linux)

- Static member variable modified (Programming)

- To execute the cp command prompt type skip folder under CentOS (Linux)

- Security Configuration SQL Server 2000 database tutorial (Linux)

- Use read command to read user input (Programming)

- Android 4.2 compilation notes (Programming)

- Linux network security strategy (Linux)

- Nodejs mysql pool Example (Programming)

- Linux System Tutorial: How to Check MariaDB server versions (Database)

- Configuring Sublime Text Python runtime environment 2 (Linux)

- Oracle Enterprise Linux 64-bit install apache-tomcat-7.0.53 step (Server)

- On the design of Oracle database backup (Database)

 
         
  Zabbix API and PHP configuration
     
  Add Date : 2018-11-21      
         
         
         
  Because of the recent online Hadoop cluster to upgrade from mrv1 mrv2, and monitoring changes in the template followed. .

The line is about 200 cluster module uses a link way to add that link a large number of modules under the template, and then add the host to the template.
In so doing a machine almost 215 item.

In order to increase NM monitor, also used the link way to connect template, when link has been found on the page returns a blank page.

For fast on-line, under the changed method used host.update the api, NM directly to the host link to the template.

Looking back this question:

In adopting the template page link, in fact, it is called zabbix template related api (specifically called template.update method)

Directly to the test by calling api script:

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 = "linuxhost_Template_OS_Linux_Hadoop_Datanode_Pro"

    url = 'xxxx'

    username = 'admin'

    password = 'xxxx'

    auth = authenticate (url, username, password)

    idx = getTemplate (hostname, url, auth)

    temlist = [ 'linuxhost_Template_LB_Tengine_8090', 'linuxhost_Template_Redis_6379', 'linuxhost_Template_Redis_6380', 'linuxhost_Template_Redis_6381', 'linuxhost_Template_Redis_6382', 'linuxhost_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 actually sent a request to post jason format manually using 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 "} '


Return 500 error (ie, when the back-end processing encountered errors php), adjust the php configuration, log into the debug format:

php-fpm.conf:

log_level = debug


Find the following error in the error log:

[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

That is doing link template, you need the relevant data on the php memory, and the default setting is 128M, if the item and host more time, can easily exceed this limit.

change to

memory_limit = 1280M

Retest returned 502 Bad Gateway error, which led to the back-end execution timeout.

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

Request_terminate_timeout execution time exceeds the setting. 502 lead generation.

Change request_terminate_timeout = 1800 (default is 10s), max_execution_time = 0 (default 30s), test again. ok.

Summary:

zabbix Unlike online application, when you call the api be updated, is a batch of behavior, memory and execution time have certain requirements.

Therefore, to a reasonable set php-related parameters in the debug log level to reduce the time and turn slow log to facilitate locating the problem.
     
         
         
         
  More:      
 
- Linux server dual-card dual-IP and single-card dual-IP configuration method (ReHat / CentOS) (Server)
- SQL Server memory Misunderstanding (Database)
- Linux Variable content removal and replacement (Linux)
- How to Install Foreman under Ubuntu (Server)
- Error: Unable to establish connection with FTP SFTP server (Server)
- A well-known but rarely used skills: object pool (Programming)
- CentOS 6.4 RPM install MySQL-5.6.22-1 (Database)
- TeamCity continuous integration in the Linux installation (Linux)
- To use Android RecyclerView (Programming)
- Talk about the Linux folder permissions issue again (Linux)
- Use ARChon runtime environment to run Android apps on Ubuntu (Linux)
- Install Mac OS X 10.9 systems VMware10 (Linux)
- Hadoop 2.7.1 Installation and Configuration under RedHat Linux 6.5 (Server)
- cp: omitting directory error solutions under Linux (Linux)
- How to use GRUB2 files directly from the hard disk to run ISO (Linux)
- Linux system boot process ARM platforms (Linux)
- Linux ACL permissions (Linux)
- Source install Python3.4 on CentOS (Linux)
- sed and awk in shell usage and some examples (Linux)
- How to Check notebook CPU temperature in Ubuntu (Linux)
     
           
     
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.