mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Remove nfs requirement for distributed poller (with rrdtool 1.5+)
Use data_update instead of rrd_update/rrd_create and influx_update Centralize rrd file check so we can check against a remote rrdcached server too Use rrd_name() to generate rrd file names
This commit is contained in:
@@ -1,48 +1,39 @@
|
||||
<?php
|
||||
|
||||
if (!empty($agent_data['app']['nginx'])) {
|
||||
$nginx = $agent_data['app']['nginx'];
|
||||
$name = 'nginx';
|
||||
$app_id = $app['app_id'];
|
||||
if (!empty($agent_data['app'][$name])) {
|
||||
$nginx = $agent_data['app'][$name];
|
||||
}
|
||||
else {
|
||||
// Polls nginx statistics from script via SNMP
|
||||
$nginx = snmp_get($device, 'nsExtendOutputFull.5.110.103.105.110.120', '-Ovq', 'NET-SNMP-EXTEND-MIB');
|
||||
}
|
||||
|
||||
$nginx_rrd = $config['rrd_dir'].'/'.$device['hostname'].'/app-nginx-'.$app['app_id'].'.rrd';
|
||||
|
||||
echo ' nginx';
|
||||
|
||||
list($active, $reading, $writing, $waiting, $req) = explode("\n", $nginx);
|
||||
if (!is_file($nginx_rrd)) {
|
||||
rrdtool_create(
|
||||
$nginx_rrd,
|
||||
'--step 300
|
||||
DS:Requests:DERIVE:600:0:125000000000
|
||||
DS:Active:GAUGE:600:0:125000000000
|
||||
DS:Reading:GAUGE:600:0:125000000000
|
||||
DS:Writing:GAUGE:600:0:125000000000
|
||||
DS:Waiting:GAUGE:600:0:125000000000 '.$config['rrd_rra']
|
||||
);
|
||||
}
|
||||
|
||||
d_echo("active: $active reading: $reading writing: $writing waiting: $waiting Requests: $req");
|
||||
$fields = array(
|
||||
'Requests' => $req,
|
||||
'Active' => $active,
|
||||
'Reading' => $reading,
|
||||
'Writing' => $writing,
|
||||
'Waiting' => $waiting,
|
||||
|
||||
$rrd_name = array('app', $name, $app_id);
|
||||
$rrd_def = array(
|
||||
'DS:Requests:DERIVE:600:0:125000000000',
|
||||
'DS:Active:GAUGE:600:0:125000000000',
|
||||
'DS:Reading:GAUGE:600:0:125000000000',
|
||||
'DS:Writing:GAUGE:600:0:125000000000',
|
||||
'DS:Waiting:GAUGE:600:0:125000000000'
|
||||
);
|
||||
|
||||
rrdtool_update($nginx_rrd, $fields);
|
||||
$fields = array(
|
||||
'Requests' => $req,
|
||||
'Active' => $active,
|
||||
'Reading' => $reading,
|
||||
'Writing' => $writing,
|
||||
'Waiting' => $waiting,
|
||||
);
|
||||
|
||||
$tags = array('name' => 'nginx', 'app_id' => $app['app_id']);
|
||||
influx_update($device,'app',$tags,$fields);
|
||||
$tags = compact('name', 'app_id', 'rrd_name', 'rrd_def');
|
||||
data_update($device, 'app', $tags, $fields);
|
||||
|
||||
// Unset the variables we set here
|
||||
unset($nginx);
|
||||
unset($nginx_rrd);
|
||||
unset($active);
|
||||
unset($reading);
|
||||
unset($writing);
|
||||
unset($req);
|
||||
unset($nginx, $active, $reading, $writing, $req, $rrd_name, $rrd_def, $tags);
|
||||
|
Reference in New Issue
Block a user