mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Replace usages of array_combine() that match array_by_column() (#7863)
Also, fix up some usages where just array_column() will do.
This commit is contained in:
committed by
Neil Lathwood
parent
8b97d01be6
commit
cdf5b05934
@@ -858,7 +858,7 @@ class IRCBot
|
||||
$srvign = dbFetchCell("SELECT COUNT(*) FROM services WHERE service_ignore = 1".$d_a);
|
||||
$srvdis = dbFetchCell("SELECT COUNT(*) FROM services WHERE service_disabled = 1".$d_a);
|
||||
$service_status = dbFetchRows("SELECT `service_status`, COUNT(*) AS `count` FROM `services` WHERE `service_disabled`=0 AND `service_ignore`=0 $d_a GROUP BY `service_status`");
|
||||
$service_status = array_combine(array_column($service_status, 'service_status'), array_column($service_status, 'count')); // key by status
|
||||
$service_status = array_column($service_status, 'count', 'service_status'); // key by status
|
||||
|
||||
foreach ($status_colors as $status => $color) {
|
||||
if (isset($service_status[$status])) {
|
||||
|
@@ -31,13 +31,10 @@ $entPhysical = dbFetchRows(
|
||||
if (!empty($entPhysical)) {
|
||||
echo "\nEntity States: ";
|
||||
|
||||
$entPhysical = array_combine(
|
||||
array_column($entPhysical, 'entPhysicalIndex'),
|
||||
array_column($entPhysical, 'entPhysical_id')
|
||||
);
|
||||
$entPhysical = array_column($entPhysical, 'entPhysical_id', 'entPhysicalIndex');
|
||||
$state_data = snmpwalk_group($device, 'entStateTable', 'ENTITY-STATE-MIB');
|
||||
$db_states = dbFetchRows('SELECT * FROM entityState WHERE device_id=?', array($device['device_id']));
|
||||
$db_states = array_combine(array_column($db_states, 'entPhysical_id'), $db_states);
|
||||
$db_states = array_by_column($db_states, 'entPhysical_id');
|
||||
|
||||
foreach ($state_data as $index => $state) {
|
||||
if (isset($entPhysical[$index])) {
|
||||
|
@@ -33,7 +33,7 @@ if (!empty($entityStatesIndexes)) {
|
||||
echo "\nEntity States: ";
|
||||
|
||||
// index by entPhysicalIndex
|
||||
$entityStatesIndexes = array_combine(array_column($entityStatesIndexes, 'entPhysicalIndex'), $entityStatesIndexes);
|
||||
$entityStatesIndexes = array_by_column($entityStatesIndexes, 'entPhysicalIndex');
|
||||
|
||||
$entLC = snmpwalk_group($device, 'entStateLastChanged', 'ENTITY-STATE-MIB', 0);
|
||||
|
||||
|
Reference in New Issue
Block a user