mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Modernize mempools (#12282)
* mempools to modern module quick hacky hrstorage port * port ucd-snmp-mib to Mempools * Populate DB for ucd Prep for yaml * initial yaml attempt * more complex conversions fixes to YamlDiscovery, make leading $ optional and allow mib::oid format * walk full tables and skip values normalize percentages above 100 * handle precent only ones (specify total as 100) * Move default polling out of YamlMempoolsDiscovery * fixes * Update test data hrstorage should be correct. * perc_warn for hrstorage * Host Resources, record buffer, cached, and shared * Host Resources is always better, don't do both HR and UCD * fix unix, include warning levels * variable size * consolidate skip_values * define mempools schema * number instead of integer * more schema refactor * one more skip_values reference * throw error for invalid oid translation aos6 * a* and Cisco * updated test data * update almost all hrstorage data files * b* * c* with test data use standard cache for hrStorage * use cache for storage module too * hand bsnmp properly * bdcom * exclude total oid from yaml so it is not polled May add a way to ignore this behavior and poll it, but I don't know if that is needed. * automatically handle percent only values * ciscowlc * only poll used or free if we have used, free, and total. * fix skipping * the dlinkoning fix find value when value "name" is numeric * support numeric oids * dnos/ftos attempt * I guess we can't filter on total > 0 * edgecos * e* * f WIP * f* * gwd (aka g*) * h* + procurve * i* * j* * m* * support 0% used memory (however unlikely) * n* * CISCO-PROCESS-MIB memory, share cache with processors module * ignore mempools with invalid total * p* * quanta * r* fix raisecom mibs terribly broken * s-z * style fixes * Move VRP back to PHP and make it actually work * fix zynos * update schema * Update Cisco processor data for description bug fixes * fix comware processors * comware mempools with memory size default precision to 1 * sophos-xg updated data * hrstorage use ram size for buffers, cache, and shared * Show memory available instead of free in device overview * UCD, use same rrd format, store available instead of free in the db. * Calculate availability for HOST-RESOURCES-MIB * Convert UCD to standard polling * rename old rrd files * initial graph work * graph WIP * Graph looking decent * Graph looking decent for hr * remove old ucd_graph code * handle availability mempool more graph cleanup * color adjustments * remove accidental free calculation * Update test data and fix corner cases * fis pfsense * update schema * add default value for mempool_class * fix whitespace * update schema * update schema correctly * one more time * fortigate_1500d-sensors missing oids * Update docs. * fix indent * add implements MempoolsDiscovery explicitly to OS * remove ucd_memory graph references remove unused device_memory graph * remove unused functions * set devices with mempools to rediscover to prevent/minimize gaps * use a subquery * add overview graph * port health mempools table * Update device mempool * only show overview if multiple * Don't override user set warn percentages in discovery * fix missed usage * fix style * Safety check to not rename rrd files incorrectly if migration has not been run. * Fix overview percent bar and represent available and used on the bar * missed an item to convert to mempool_class * percent on the wrong side
This commit is contained in:
@@ -17,7 +17,6 @@ use LibreNMS\Config;
|
||||
use LibreNMS\Device\YamlDiscovery;
|
||||
use LibreNMS\Exceptions\HostExistsException;
|
||||
use LibreNMS\Exceptions\InvalidIpException;
|
||||
use LibreNMS\OS;
|
||||
use LibreNMS\Util\IP;
|
||||
use LibreNMS\Util\IPv6;
|
||||
|
||||
@@ -598,102 +597,6 @@ function discover_storage(&$valid, $device, $index, $type, $mib, $descr, $size,
|
||||
}//end if
|
||||
}
|
||||
|
||||
//end discover_storage()
|
||||
|
||||
function discover_processor(&$valid, $device, $oid, $index, $type, $descr, $precision = '1', $current = null, $entPhysicalIndex = null, $hrDeviceIndex = null)
|
||||
{
|
||||
d_echo("Discover Processor: $oid, $index, $type, $descr, $precision, $current, $entPhysicalIndex, $hrDeviceIndex\n");
|
||||
|
||||
if ($descr) {
|
||||
$descr = trim(str_replace('"', '', $descr));
|
||||
if (dbFetchCell('SELECT COUNT(processor_id) FROM `processors` WHERE `processor_index` = ? AND `device_id` = ? AND `processor_type` = ?', [$index, $device['device_id'], $type]) == '0') {
|
||||
$insert_data = [
|
||||
'device_id' => $device['device_id'],
|
||||
'processor_descr' => $descr,
|
||||
'processor_index' => $index,
|
||||
'processor_oid' => $oid,
|
||||
'processor_usage' => $current,
|
||||
'processor_type' => $type,
|
||||
'processor_precision' => $precision,
|
||||
];
|
||||
|
||||
$insert_data['hrDeviceIndex'] = (int) $hrDeviceIndex;
|
||||
$insert_data['entPhysicalIndex'] = (int) $entPhysicalIndex;
|
||||
|
||||
$inserted = dbInsert($insert_data, 'processors');
|
||||
echo '+';
|
||||
log_event('Processor added: type ' . $type . ' index ' . $index . ' descr ' . $descr, $device, 'processor', 3, $inserted);
|
||||
} else {
|
||||
echo '.';
|
||||
$update_data = [
|
||||
'processor_descr' => $descr,
|
||||
'processor_oid' => $oid,
|
||||
'processor_usage' => $current,
|
||||
'processor_precision' => $precision,
|
||||
];
|
||||
dbUpdate($update_data, 'processors', '`device_id`=? AND `processor_index`=? AND `processor_type`=?', [$device['device_id'], $index, $type]);
|
||||
}//end if
|
||||
$valid[$type][$index] = 1;
|
||||
}//end if
|
||||
}
|
||||
|
||||
//end discover_processor()
|
||||
|
||||
function discover_mempool(&$valid, $device, $index, $type, $descr, $precision = '1', $entPhysicalIndex = null, $hrDeviceIndex = null, $perc_warn = '90')
|
||||
{
|
||||
$descr = substr($descr, 0, 64);
|
||||
|
||||
d_echo("Discover Mempool: $index, $type, $descr, $precision, $entPhysicalIndex, $hrDeviceIndex, $perc_warn\n");
|
||||
|
||||
// FIXME implement the mempool_perc, mempool_used, etc.
|
||||
if ($descr) {
|
||||
if (dbFetchCell('SELECT COUNT(mempool_id) FROM `mempools` WHERE `mempool_index` = ? AND `device_id` = ? AND `mempool_type` = ?', [$index, $device['device_id'], $type]) == '0') {
|
||||
$insert_data = [
|
||||
'device_id' => $device['device_id'],
|
||||
'mempool_descr' => $descr,
|
||||
'mempool_index' => $index,
|
||||
'mempool_type' => $type,
|
||||
'mempool_precision' => $precision,
|
||||
'mempool_perc' => 0,
|
||||
'mempool_used' => 0,
|
||||
'mempool_free' => 0,
|
||||
'mempool_total' => 0,
|
||||
'mempool_perc_warn' => $perc_warn,
|
||||
];
|
||||
|
||||
if (is_numeric($entPhysicalIndex)) {
|
||||
$insert_data['entPhysicalIndex'] = $entPhysicalIndex;
|
||||
}
|
||||
|
||||
if (is_numeric($hrDeviceIndex)) {
|
||||
$insert_data['hrDeviceIndex'] = $hrDeviceIndex;
|
||||
}
|
||||
|
||||
$inserted = dbInsert($insert_data, 'mempools');
|
||||
echo '+';
|
||||
log_event('Memory pool added: type ' . $type . ' index ' . $index . ' descr ' . $descr, $device, 'mempool', 3, $inserted);
|
||||
} else {
|
||||
echo '.';
|
||||
$update_data = [
|
||||
'mempool_descr' => $descr,
|
||||
];
|
||||
|
||||
if (is_numeric($entPhysicalIndex)) {
|
||||
$update_data['entPhysicalIndex'] = $entPhysicalIndex;
|
||||
}
|
||||
|
||||
if (is_numeric($hrDeviceIndex)) {
|
||||
$update_data['hrDeviceIndex'] = $hrDeviceIndex;
|
||||
}
|
||||
|
||||
dbUpdate($update_data, 'mempools', 'device_id=? AND mempool_index=? AND mempool_type=?', [$device['device_id'], $index, $type]);
|
||||
}//end if
|
||||
$valid[$type][$index] = 1;
|
||||
}//end if
|
||||
}
|
||||
|
||||
//end discover_mempool()
|
||||
|
||||
function discover_toner(&$valid, $device, $oid, $index, $type, $descr, $capacity_oid = null, $capacity = null, $current = null)
|
||||
{
|
||||
d_echo("Discover Toner: $oid, $index, $type, $descr, $capacity_oid, $capacity, $current\n");
|
||||
|
Reference in New Issue
Block a user