2010-10-22 18:14:59 +00:00
|
|
|
<?php
|
|
|
|
|
2012-05-07 21:56:38 +00:00
|
|
|
if (!empty($agent_data['app']['nginx']))
|
|
|
|
{
|
|
|
|
$nginx = $agent_data['app']['nginx'];
|
|
|
|
} else {
|
|
|
|
# Polls nginx statistics from script via SNMP
|
2012-05-08 10:50:24 +00:00
|
|
|
$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
|
|
|
|
2012-05-07 21:56:38 +00:00
|
|
|
$nginx_rrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/app-nginx-".$app['app_id'].".rrd";
|
2010-10-22 18:14:59 +00:00
|
|
|
|
2010-11-20 14:04:07 +00:00
|
|
|
echo(" nginx statistics\n");
|
2010-10-22 18:14:59 +00:00
|
|
|
|
|
|
|
list($active, $reading, $writing, $waiting, $req) = explode("\n", $nginx);
|
2012-05-07 21:56:38 +00:00
|
|
|
if (!is_file($nginx_rrd))
|
|
|
|
{
|
|
|
|
rrdtool_create ($nginx_rrd, "--step 300 \
|
2011-09-20 14:22:34 +00:00
|
|
|
DS:Requests:DERIVE:600:0:125000000000 \
|
|
|
|
DS:Active:GAUGE:600:0:125000000000 \
|
|
|
|
DS:Reading:GAUGE:600:0:125000000000 \
|
|
|
|
DS:Writing:GAUGE:600:0:125000000000 \
|
2012-04-20 17:37:58 +00: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";
|
|
|
|
rrdtool_update($nginx_rrd, "N:$req:$active:$reading:$writing:$waiting");
|
|
|
|
|
2012-05-25 12:24:34 +00:00
|
|
|
// Unset the variables we set here
|
2012-05-08 10:50:24 +00:00
|
|
|
|
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);
|
|
|
|
|
2010-10-22 18:14:59 +00:00
|
|
|
?>
|