feature: add PHP-FPM support for snmpd (#5912)

* add single pool based poller for php-fpm

* add the page for php-fpm

* add graph for php-fpm

* I agree to the conditions of the Contributor Agreement contained in doc/General/Contributing.md.

* use named OID as suggest by @laf

* document PHP-FPM monitoring

* link it in the index

* clean up the named oid

* add how to grab the script in question
This commit is contained in:
VVelox
2017-02-16 09:10:42 -06:00
committed by Neil Lathwood
parent cdd9238b32
commit 872eac10aa
5 changed files with 126 additions and 0 deletions

View File

@@ -181,6 +181,7 @@ LibreNMS contributors:
- Maclin Fuehr-Bush <macfuehrbush@gmail.com> (mobilemaclin)
- Robert Penziol <rpenziol@pdx.edu> (rpenziol)
- Stefan Behte <craig at haquarter.de> (craig)
- Zane C. Bowers-Hadley <vvelox@vvelox.net> (vvelox)
Observium was written by:
- Adam Armstrong

View File

@@ -27,6 +27,7 @@ Different applications support a variety of ways collect data: by direct connect
1. [UPS-apcups](#ups-apcups) - SNMP extend
1. [EXIM Stats](#exim-stats) - SNMP extend
1. [Munin](#munin) - Agent
1. [PHP-FPM](#php-fpm) - SNMP extend
### Apache
Either use SNMP extend or use the agent.
@@ -469,3 +470,20 @@ if [ "$1" = "config" ]; then
fi
echo -n "foobar.value " $(date +%s) #Populate a value, here unix-timestamp
```
#### PHP-FPM
##### SNMP Extend
1. Copy the shell script, phpfpm-sp, to the desired host (the host must be added to LibreNMS devices) (wget https://github.com/librenms/librenms-agent/raw/master/snmp/phpfpm-sp -O /etc/snmp/phpfpm-sp)
2. Make the script executable (chmod +x /etc/snmp/phpfpm-sp)
3. Edit your snmpd.conf file (usually /etc/snmp/phpfpm-sp) and add:
```
extend phpfpmsp /etc/snmp/phpfpm-sp
```
5: Edit /etc/snmp/phpfpm-sp to include the status URL for the PHP-FPM pool you are monitoring.
6. Restart snmpd on your host
7. On the device page in Librenms, edit your host and check `PHP-FPM` under the Applications tab.
It is worth noting that this only monitors a single pool. If you want to monitor multiple pools, this won't do it.

View File

@@ -0,0 +1,42 @@
<?php
require 'includes/graphs/common.inc.php';
$name = 'php-fpm';
$app_id = $app['app_id'];
$scale_min = 0;
$colours = 'mixed';
$unit_text = '';
$unitlen = 10;
$bigdescrlen = 15;
$smalldescrlen = 15;
$dostack = 0;
$printtotal = 0;
$addarea = 1;
$transparency = 15;
$rrd_filename = rrd_name($device['hostname'], array('app', $name, $app_id));
$array = array(
'lq' => array('descr' => 'Listen Queue','colour' => '582A72',),
'mlq' => array('descr' => 'Max Listen Queue','colour' => '28774F',),
'ip' => array('descr' => 'Idle Procs','colour' => '88CC88',),
'ap' => array('descr' => 'Active Procs','colour' => 'D46A6A',),
'tp' => array('descr' => 'Total Procs','colour' => 'FFD1AA',),
'map' => array('descr' => 'Max Active Procs','colour' => '582A72',),
'mcr' => array('descr' => 'Max Children Reached','colour' => 'AA5439',),
'sr' => array('descr' => 'Slow Reqs.','colour' => '28536C',),
);
$i = 0;
if (is_file($rrd_filename)) {
foreach ($array as $ds => $vars) {
$rrd_list[$i]['filename'] = $rrd_filename;
$rrd_list[$i]['descr'] = $vars['descr'];
$rrd_list[$i]['ds'] = $ds;
$rrd_list[$i]['colour'] = $vars['colour'];
$i++;
}
} else {
echo "file missing: $rrd_filename";
}
require 'includes/graphs/generic_v3_multiline.inc.php';

View File

@@ -0,0 +1,28 @@
<?php
global $config;
$graphs = array(
'php-fpm' => 'PHP-FPM',
);
foreach ($graphs as $key => $text) {
$graph_type = $key;
$graph_array['height'] = '100';
$graph_array['width'] = '215';
$graph_array['to'] = $config['time']['now'];
$graph_array['id'] = $app['app_id'];
$graph_array['type'] = 'application_'.$key;
echo '<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">'.$text.'</h3>
</div>
<div class="panel-body">
<div class="row">';
include 'includes/print-graphrow.inc.php';
echo '</div>';
echo '</div>';
echo '</div>';
}

View File

@@ -0,0 +1,37 @@
<?php
$name = 'php-fpm';
$app_id = $app['app_id'];
$options = '-O qv';
$mib = 'NET-SNMP-EXTEND-MIB';
$oid = 'nsExtendOutputFull.8.112.104.112.102.112.109.115.112';
$phpfpm = snmp_walk($device, $oid, $options, $mib);
list($pool,$start_time,$start_since,$accepted_conn,$listen_queue,$max_listen_queue,$listen_queue_len,$idle_processes,
$active_processes,$total_processes,$max_active_processes,$max_children_reached,$slow_requests) = explode("\n", $phpfpm);
$rrd_name = array('app', $name, $app_id);
$rrd_def = array(
'DS:lq:GAUGE:600:0:U',
'DS:mlq:GAUGE:600:0:U',
'DS:ip:GAUGE:600:0:U',
'DS:ap:GAUGE:600:0:U',
'DS:tp:GAUGE:600:0:U',
'DS:map:GAUGE:600:0:U',
'DS:mcr:GAUGE:600:0:U',
'DS:sr:GAUGE:600:0:U'
);
$fields = array(
'lq' => $listen_queue,
'mlq' => $max_listen_queue,
'ip' => $idle_processes,
'ap' => $active_processes,
'tp' => $total_processes,
'map' => $max_active_processes,
'mcr' => $max_children_reached,
'sr' => $slow_requests
);
$tags = array('name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name);
data_update($device, 'app', $tags, $fields);