Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unix Agent and Application fixes #15460

Merged
merged 2 commits into from Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions LibreNMS/Modules/LegacyModule.php
Expand Up @@ -114,6 +114,7 @@ public function poll(OS $os, DataStorageInterface $datastore): void

$device = &$os->getDeviceArray();
Debug::disableErrorReporting(); // ignore errors in legacy code
global $agent_data;

include_once base_path('includes/datastore.inc.php');
include_once base_path('includes/dbFacile.php');
Expand Down
4 changes: 2 additions & 2 deletions includes/discovery/hr-device.inc.php
@@ -1,8 +1,8 @@
<?php

$hrDevice_oids = [
'hrDeviceTable',
'hrProcessorTable',
'hrDeviceTable',
];

$hrDevices = [];
Expand All @@ -22,7 +22,7 @@
'hrDeviceStatus' => $hrDevice['hrDeviceStatus'] ?? 'unknown',
'hrDeviceErrors' => $hrDevice['hrDeviceErrors'] ?? 0,
];
if ($hrDevice['hrDeviceType'] == 'hrDeviceProcessor') {
if ($hrDevice['hrDeviceType'] == 'hrDeviceProcessor' && isset($hrDevice['hrProcessorLoad'])) {
$update_array['hrProcessorLoad'] = $hrDevice['hrProcessorLoad'];
}

Expand Down
2 changes: 1 addition & 1 deletion includes/discovery/ucd-diskio.inc.php
Expand Up @@ -10,7 +10,7 @@
if (dbFetchCell('SELECT COUNT(*) FROM `ucd_diskio` WHERE `device_id` = ? AND `diskio_index` = ? and `diskio_descr` = ?', [$device['device_id'], $index, $entry['diskIODevice']]) == '0') {
$inserted = dbInsert(['device_id' => $device['device_id'], 'diskio_index' => $index, 'diskio_descr' => $entry['diskIODevice']], 'ucd_diskio');
echo '+';
d_echo($sql . " - $inserted inserted ");
d_echo("$inserted inserted ");
} else {
echo '.';
// FIXME Need update code here!
Expand Down
17 changes: 14 additions & 3 deletions includes/polling/applications/apache.inc.php
Expand Up @@ -13,12 +13,18 @@
$apache = snmp_get($device, $oid, $options);
}

$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,
$score_closing, $score_logging, $score_graceful, $score_idle, $score_open] = explode("\n", $apache);
$score_closing, $score_logging, $score_graceful, $score_idle, $score_open] = $apache_data;

$rrd_name = ['app', $name, $app->app_id];
$rrd_def = RrdDefinition::make()
->addDataset('access', 'DERIVE', 0, 125000000000)
->addDataset('kbyte', 'DERIVE', 0, 125000000000)
Expand Down Expand Up @@ -64,6 +70,11 @@
'sb_open' => intval(trim($score_open, '"')),
];

$tags = compact('name', 'app_id', 'rrd_name', 'rrd_def');
$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);
21 changes: 15 additions & 6 deletions includes/polling/applications/asterisk.inc.php
Expand Up @@ -3,7 +3,6 @@
use LibreNMS\RRD\RrdDefinition;

$name = 'asterisk';
$app_id = $app->app_id;

if (! empty($agent_data[$name])) {
$rawdata = $agent_data[$name];
Expand Down Expand Up @@ -46,13 +45,17 @@
];

$asterisk_metrics['stats'] = $sip_fields;
$sip_tags = compact('name', 'app_id', 'rrd_name', 'rrd_def');
$sip_tags = [
'name' => $name,
'app_id' => $app->app_id,
'rrd_name' => $rrd_name,
'rrd_def' => $rrd_def,
];
data_update($device, 'app', $sip_tags, $sip_fields);

unset($rrd_name, $rrd_def, $sip_fields, $sip_tags);

// Additional iax2 stats
$rrd_name = ['app', $name, 'iax2', $app->app_id];
$rrd_def = RrdDefinition::make()
->addDataset('iax2peers', 'GAUGE', 0, 10000)
->addDataset('iax2online', 'GAUGE', 0, 10000)
Expand All @@ -67,11 +70,17 @@
];

$asterisk_metrics['iax2'] = $iax2_fields;
$iax2_tags = compact('name', 'app_id', 'rrd_name', 'rrd_def');
$iax2_tags = [
'name' => $name,
'app_id' => $app->app_id,
'type' => 'iax2',
'rrd_name' => ['app', $name, 'iax2', $app->app_id],
'rrd_def' => $rrd_def,
];
data_update($device, 'app', $iax2_tags, $iax2_fields);

update_application($app, $rawdata, $asterisk_metrics);

unset($rrd_name, $rrd_def, $iax2_fields, $iax2_tags);
unset($rrd_def, $iax2_fields, $iax2_tags);

unset($asterisk, $asterisk_metrics, $rawdata, $app_id); // these are used for all rrds
unset($asterisk, $asterisk_metrics, $rawdata); // these are used for all rrds
17 changes: 14 additions & 3 deletions includes/polling/applications/bind.inc.php
Expand Up @@ -13,7 +13,14 @@
$bind = snmp_get($device, $oid, $options, $mib);
}

[$incoming, $outgoing, $server, $resolver, $cache, $rrsets, $adb, $sockets] = explode("\n", $bind);
$bind_data = explode("\n", $bind);
if (count($bind_data) !== 8) {
echo " Incorrect number of datapoints returned from device, skipping\n";

return;
}

[$incoming, $outgoing, $server, $resolver, $cache, $rrsets, $adb, $sockets] = $bind_data;

//
// INCOMING PROCESSING
Expand Down Expand Up @@ -359,7 +366,6 @@
[$ch, $cm, $chfq, $cmfq, $crddtme, $crddtte, $cdn, $cdhb, $ctmt, $ctmiu, $cthmiu,
$chmt, $chmiu, $chhmiu] = explode(',', $cache);

$rrd_name = ['app', $name, $app->app_id, 'cache'];
$rrd_def = RrdDefinition::make()
->addDataset('ch', 'DERIVE', 0)
->addDataset('cm', 'DERIVE', 0)
Expand Down Expand Up @@ -394,7 +400,12 @@
];
$metrics['cache'] = $fields;

$tags = compact('name', 'app_id', 'rrd_name', 'rrd_def');
$tags = [
'name' => $name,
'app_id' => $app->app_id,
'rrd_name' => ['app', $name, $app->app_id, 'cache'],
'rrd_def' => $rrd_def,
];
data_update($device, 'app', $tags, $fields);

//
Expand Down