mirror of
https://github.com/LibreQoE/LibreQoS.git
synced 2025-02-25 18:55:32 -06:00
@@ -328,26 +328,25 @@ def findNodesBranchedOffPtMP(siteList, dataLinks, sites, rootSite, foundAirFiber
|
||||
parent = site['parent']
|
||||
for link in dataLinks:
|
||||
if (link['to']['site'] is not None) and (link['to']['site']['identification'] is not None):
|
||||
if ('identification' in link['to']['site']) and (link['to']['site']['identification'] is not None):
|
||||
if ('identification' in link['from']['site']) and (link['from']['site']['identification'] is not None):
|
||||
# Respect parent defined by topology and overrides
|
||||
if link['from']['site']['identification']['id'] == trueParent:
|
||||
if link['to']['site']['identification']['id'] == id:
|
||||
if (link['from']['device']['overview']['wirelessMode'] == 'ap-ptmp') or (link['from']['device']['overview']['wirelessMode'] == 'ap'):
|
||||
if 'overview' in link['to']['device']:
|
||||
if ('downlinkCapacity' in link['to']['device']['overview']) and ('uplinkCapacity' in link['to']['device']['overview']):
|
||||
if (link['to']['device']['overview']['downlinkCapacity'] is not None) and (link['to']['device']['overview']['uplinkCapacity'] is not None):
|
||||
apID = link['from']['device']['identification']['id']
|
||||
# Capacity of the PtMP client radio feeding the PoP will be used as the site bandwidth limit
|
||||
download = int(round(link['to']['device']['overview']['downlinkCapacity']/1000000))
|
||||
upload = int(round(link['to']['device']['overview']['uplinkCapacity']/1000000))
|
||||
nodeOffPtMP[id] = {'download': download,
|
||||
'upload': upload,
|
||||
parent: apID
|
||||
}
|
||||
if usePtMPasParent:
|
||||
site['parent'] = apID
|
||||
print('Site ' + name + ' will use PtMP AP as parent.')
|
||||
if ('identification' in link['to']['site']) and (link['to']['site']['identification'] is not None) and link['from'] is not None and link['from']['site'] is not None and link['from']['site']['identification'] is not None:
|
||||
# Respect parent defined by topology and overrides
|
||||
if link['from']['site']['identification']['id'] == trueParent:
|
||||
if link['to']['site']['identification']['id'] == id:
|
||||
if (link['from']['device']['overview']['wirelessMode'] == 'ap-ptmp') or (link['from']['device']['overview']['wirelessMode'] == 'ap'):
|
||||
if 'overview' in link['to']['device']:
|
||||
if ('downlinkCapacity' in link['to']['device']['overview']) and ('uplinkCapacity' in link['to']['device']['overview']):
|
||||
if (link['to']['device']['overview']['downlinkCapacity'] is not None) and (link['to']['device']['overview']['uplinkCapacity'] is not None):
|
||||
apID = link['from']['device']['identification']['id']
|
||||
# Capacity of the PtMP client radio feeding the PoP will be used as the site bandwidth limit
|
||||
download = int(round(link['to']['device']['overview']['downlinkCapacity']/1000000))
|
||||
upload = int(round(link['to']['device']['overview']['uplinkCapacity']/1000000))
|
||||
nodeOffPtMP[id] = {'download': download,
|
||||
'upload': upload,
|
||||
parent: apID
|
||||
}
|
||||
if usePtMPasParent:
|
||||
site['parent'] = apID
|
||||
print('Site ' + name + ' will use PtMP AP as parent.')
|
||||
return siteList, nodeOffPtMP
|
||||
|
||||
def handleMultipleInternetNodes(sites, dataLinks, uispSite):
|
||||
|
||||
@@ -78,7 +78,7 @@ impl UnixSocketServer {
|
||||
}
|
||||
|
||||
fn make_socket_public() -> Result<(), UnixSocketServerError> {
|
||||
lqos_utils::run_success!(
|
||||
let _ = lqos_utils::run_success!(
|
||||
"/bin/chmod",
|
||||
"-R",
|
||||
"a+rwx",
|
||||
|
||||
@@ -7,6 +7,21 @@ pub(crate) struct MinMaxAvg<T> {
|
||||
pub(crate) avg: T,
|
||||
}
|
||||
|
||||
fn median<T>(stats: &[T]) -> T
|
||||
where
|
||||
T: Bounded + Zero + std::ops::AddAssign<T> + Copy + std::cmp::Ord + CheckedDiv + NumCast,
|
||||
{
|
||||
let mut sorted = stats.to_vec();
|
||||
sorted.sort();
|
||||
let len = sorted.len();
|
||||
let mid = len / 2;
|
||||
if len % 2 == 0 {
|
||||
(sorted[mid] + sorted[mid - 1]).checked_div(&T::from(2).unwrap()).unwrap_or(T::zero())
|
||||
} else {
|
||||
sorted[mid]
|
||||
}
|
||||
}
|
||||
|
||||
impl<
|
||||
T: Bounded
|
||||
+ Zero
|
||||
@@ -20,17 +35,13 @@ impl<
|
||||
pub(crate) fn from_slice(stats: &[T]) -> Self {
|
||||
let mut min = T::max_value();
|
||||
let mut max = T::min_value();
|
||||
let mut avg = T::zero();
|
||||
|
||||
stats.iter().for_each(|n| {
|
||||
avg += *n;
|
||||
min = T::min(min, *n);
|
||||
max = T::max(max, *n);
|
||||
});
|
||||
let len = T::from(stats.len()).unwrap();
|
||||
avg = avg.checked_div(&len).unwrap_or(T::zero());
|
||||
|
||||
Self { max, min, avg }
|
||||
Self { max, min, avg: median(stats) }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user