2010-10-22 18:14:59 +00:00
|
|
|
<?php
|
|
|
|
|
2015-07-10 13:36:21 +02:00
|
|
|
if (!empty($agent_data['app']['nginx'])) {
|
|
|
|
$nginx = $agent_data['app']['nginx'];
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Polls nginx statistics from script via SNMP
|
|
|
|
$nginx = snmp_get($device, 'nsExtendOutputFull.5.110.103.105.110.120', '-Ovq', 'NET-SNMP-EXTEND-MIB');
|
2012-05-07 21:56:38 +00:00
|
|
|
}
|
2010-10-22 18:14:59 +00:00
|
|
|
|
2015-07-10 13:36:21 +02:00
|
|
|
$nginx_rrd = $config['rrd_dir'].'/'.$device['hostname'].'/app-nginx-'.$app['app_id'].'.rrd';
|
2010-10-22 18:14:59 +00:00
|
|
|
|
2015-07-10 13:36:21 +02:00
|
|
|
echo " nginx statistics\n";
|
2010-10-22 18:14:59 +00:00
|
|
|
|
|
|
|
list($active, $reading, $writing, $waiting, $req) = explode("\n", $nginx);
|
2015-07-10 13:36:21 +02:00
|
|
|
if (!is_file($nginx_rrd)) {
|
|
|
|
rrdtool_create(
|
|
|
|
$nginx_rrd,
|
2015-09-28 08:24:57 +00:00
|
|
|
'--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
|
2015-07-10 13:36:21 +02:00
|
|
|
DS:Waiting:GAUGE:600:0:125000000000 '.$config['rrd_rra']
|
|
|
|
);
|
2010-10-22 18:14:59 +00:00
|
|
|
}
|
2012-05-07 21:56:38 +00:00
|
|
|
|
2010-10-22 18:14:59 +00:00
|
|
|
print "active: $active reading: $reading writing: $writing waiting: $waiting Requests: $req";
|
2015-08-18 16:26:55 +00:00
|
|
|
$fields = array(
|
|
|
|
'Requests' => $req,
|
|
|
|
'Active' => $active,
|
|
|
|
'Reading' => $reading,
|
|
|
|
'Writing' => $writing,
|
|
|
|
'Waiting' => $waiting,
|
|
|
|
);
|
|
|
|
|
|
|
|
rrdtool_update($nginx_rrd, $fields);
|
2010-10-22 18:14:59 +00:00
|
|
|
|
2015-08-19 20:58:02 +00:00
|
|
|
$tags = array('name' => 'nginx', 'app_id' => $app['app_id']);
|
|
|
|
influx_update($device,'app',$tags,$fields);
|
|
|
|
|
2012-05-25 12:24:34 +00:00
|
|
|
// Unset the variables we set here
|
2012-05-15 15:18:57 +00:00
|
|
|
unset($nginx);
|
|
|
|
unset($nginx_rrd);
|
|
|
|
unset($active);
|
|
|
|
unset($reading);
|
|
|
|
unset($writing);
|
2012-05-08 10:50:24 +00:00
|
|
|
unset($req);
|