Difference between revisions of "Plugin:cURL-JSON/phpfpm"

From collectd Wiki
Jump to: navigation, search
 
(7 intermediate revisions by one other user not shown)
Line 1: Line 1:
 +
{{Example config|cURL-JSON}}
 +
 
You can use {{Plugin|cURL-JSON}} plugin to collect stats from php-fpm instances. The example of config is below.
 
You can use {{Plugin|cURL-JSON}} plugin to collect stats from php-fpm instances. The example of config is below.
  
 
== Config ==
 
== Config ==
 
 
 
  LoadPlugin curl_json
 
  LoadPlugin curl_json
 
  <Plugin curl_json>
 
  <Plugin curl_json>
 
  <URL "http://127.0.0.1/_fpmstatus?json">
 
  <URL "http://127.0.0.1/_fpmstatus?json">
  Instance "fpm"
+
  Instance 'main'
  <Key "accepted conn">
+
  <Key "accepted conn">
      Type "http_requests"
+
      Type "phpfpm_requests"
  </Key>
+
      Instance ""
  <Key "listen queue len">
+
  </Key>
      Type "listen_queue"
+
  <Key "slow requests">
  </Key>
+
      Type "phpfpm_slow_requests"
  <Key "active processes">
+
      Instance ""
      Type "active_processes"
+
  </Key>
  </Key>
+
  <Key "listen queue">
  <Key "total processes">
+
      Type "phpfpm_listen_queue"
      Type "total_processes"
+
      Instance ""
  </Key>
+
  </Key>
 +
  <Key "active processes">
 +
      Type "phpfpm_processes"
 +
      Instance "active"
 +
  </Key>
 +
  <Key "total processes">
 +
      Type "phpfpm_processes"
 +
      Instance "total"
 +
  </Key>
 
  </URL>
 
  </URL>
 
  </Plugin>
 
  </Plugin>
  
 
Please note that the metod used to access php-fpm stats is not FastCGI but HTTP. So you need to configure your web-server to pass such requests to php-fpm instance.
 
Please note that the metod used to access php-fpm stats is not FastCGI but HTTP. So you need to configure your web-server to pass such requests to php-fpm instance.
 +
You can check your web-server configuration using "curl". You had to get something similar to:
 +
 +
#curl http://127.0.0.1/_fpmstatus?json
 +
{"pool":"pool_name","process manager":"dynamic","start time":1562671972,"start since":347271,"accepted conn":1082924,"listen queue":0,"max listen queue":0,"listen queue len":0,"idle processes":4,"active
 +
processes":1,"total processes":5,"max active processes":25,"max children reached":8,"slow requests":0}
 +
 +
 +
== Types ==
 +
 +
You'll need to create a custom {{Manpage|types.db|5}} and add these [[type]]s:
 +
# types.db
 +
phpfpm_listen_queue  value:GAUGE:0:65535
 +
phpfpm_processes    value:GAUGE:0:65535
 +
phpfpm_requests      value:DERIVE:0:U
 +
phpfpm_slow_requests value:DERIVE:0:U
 +
 +
See `TypesDB' configuration option in collectd config file for locations of default and custom `types.db' files.
 +
 +
== Example graphs ==
 +
[[Image:phpfpm_processes.png]]
 +
 +
[[Image:phpfpm_req.png]]
 +
 +
[[Image:phpfpm_slow_req.png]]
  
== TODO ==
+
[[Image:phpfpm_listenq.png]]
* Add info about types used (i use gauges for types).
 
* Add chart examples.
 

Latest revision as of 01:24, 12 March 2020

This page contains some example configurations for the cURL-JSON plugin. This page is meant as a cookbook, so if you have a configuration for an aspect not handled here or a daemon not present, please feel free to add anything that's useful for you.

You can use cURL-JSON plugin plugin to collect stats from php-fpm instances. The example of config is below.

Config

LoadPlugin curl_json
<Plugin curl_json>
<URL "http://127.0.0.1/_fpmstatus?json">
 Instance 'main'
 <Key "accepted conn">
     Type "phpfpm_requests"
     Instance ""
 </Key>
 <Key "slow requests">
     Type "phpfpm_slow_requests"
     Instance ""
 </Key>
 <Key "listen queue">
     Type "phpfpm_listen_queue"
     Instance ""
 </Key>
 <Key "active processes">
     Type "phpfpm_processes"
     Instance "active"
 </Key>
 <Key "total processes">
     Type "phpfpm_processes"
     Instance "total"
 </Key>
</URL>
</Plugin>

Please note that the metod used to access php-fpm stats is not FastCGI but HTTP. So you need to configure your web-server to pass such requests to php-fpm instance. You can check your web-server configuration using "curl". You had to get something similar to:

#curl http://127.0.0.1/_fpmstatus?json
{"pool":"pool_name","process manager":"dynamic","start time":1562671972,"start since":347271,"accepted conn":1082924,"listen queue":0,"max listen queue":0,"listen queue len":0,"idle processes":4,"active 
processes":1,"total processes":5,"max active processes":25,"max children reached":8,"slow requests":0}


Types

You'll need to create a custom types.db(5) and add these types:

# types.db
phpfpm_listen_queue  value:GAUGE:0:65535
phpfpm_processes     value:GAUGE:0:65535
phpfpm_requests      value:DERIVE:0:U
phpfpm_slow_requests value:DERIVE:0:U

See `TypesDB' configuration option in collectd config file for locations of default and custom `types.db' files.

Example graphs

Phpfpm processes.png

Phpfpm req.png

Phpfpm slow req.png

Phpfpm listenq.png