Files

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

81 lines
2.9 KiB
PHP
Raw Permalink Normal View History

<?php
2012-05-25 12:24:34 +00:00
// Polls Apache statistics from script via SNMP
use LibreNMS\RRD\RrdDefinition;
$name = 'apache';
if (! empty($agent_data['app'][$name])) {
$apache = $agent_data['app'][$name];
} else {
2018-12-16 07:42:50 -06:00
$options = '-Oqv';
$oid = '.1.3.6.1.4.1.8072.1.3.2.3.1.2.6.97.112.97.99.104.101';
$apache = snmp_get($device, $oid, $options);
2012-04-19 15:36:46 +00:00
}
2023-10-16 01:40:40 -07:00
$apache_data = explode("\n", $apache);
if (count($apache_data) !== 20) {
echo " Incorrect number of datapoints returned from device, skipping\n";
return;
}
[$total_access, $total_kbyte, $cpuload, $uptime, $reqpersec, $bytespersec,
$bytesperreq, $busyworkers, $idleworkers, $score_wait, $score_start,
$score_reading, $score_writing, $score_keepalive, $score_dns,
2023-10-16 01:40:40 -07:00
$score_closing, $score_logging, $score_graceful, $score_idle, $score_open] = $apache_data;
$rrd_def = RrdDefinition::make()
->addDataset('access', 'DERIVE', 0, 125000000000)
->addDataset('kbyte', 'DERIVE', 0, 125000000000)
->addDataset('cpu', 'GAUGE', 0, 125000000000)
->addDataset('uptime', 'GAUGE', 0, 125000000000)
->addDataset('reqpersec', 'GAUGE', 0, 125000000000)
->addDataset('bytespersec', 'GAUGE', 0, 125000000000)
->addDataset('byesperreq', 'GAUGE', 0, 125000000000)
->addDataset('busyworkers', 'GAUGE', 0, 125000000000)
->addDataset('idleworkers', 'GAUGE', 0, 125000000000)
->addDataset('sb_wait', 'GAUGE', 0, 125000000000)
->addDataset('sb_start', 'GAUGE', 0, 125000000000)
->addDataset('sb_reading', 'GAUGE', 0, 125000000000)
->addDataset('sb_writing', 'GAUGE', 0, 125000000000)
->addDataset('sb_keepalive', 'GAUGE', 0, 125000000000)
->addDataset('sb_dns', 'GAUGE', 0, 125000000000)
->addDataset('sb_closing', 'GAUGE', 0, 125000000000)
->addDataset('sb_logging', 'GAUGE', 0, 125000000000)
->addDataset('sb_graceful', 'GAUGE', 0, 125000000000)
->addDataset('sb_idle', 'GAUGE', 0, 125000000000)
->addDataset('sb_open', 'GAUGE', 0, 125000000000);
$fields = [
2017-02-17 23:18:02 +01:00
'access' => intval(trim($total_access, '"')),
'kbyte' => $total_kbyte,
'cpu' => $cpuload,
'uptime' => $uptime,
'reqpersec' => $reqpersec,
'bytespersec' => $bytespersec,
'byesperreq' => $bytesperreq,
'busyworkers' => $busyworkers,
'idleworkers' => $idleworkers,
'sb_wait' => $score_wait,
'sb_start' => $score_start,
'sb_reading' => $score_reading,
'sb_writing' => $score_writing,
'sb_keepalive' => $score_keepalive,
'sb_dns' => $score_dns,
'sb_closing' => $score_closing,
'sb_logging' => $score_logging,
'sb_graceful' => $score_graceful,
'sb_idle' => $score_idle,
2017-02-17 23:18:02 +01:00
'sb_open' => intval(trim($score_open, '"')),
];
2023-10-16 01:40:40 -07:00
$tags = [
'name' => $name,
'app_id' => $app->app_id,
'rrd_name' => ['app', $name, $app->app_id],
'rrd_def' => $rrd_def,
];
data_update($device, 'app', $tags, $fields);
update_application($app, $apache, $fields);