mirror of
https://github.com/KevinMidboe/mktxp-no-cli.git
synced 2025-10-29 17:50:23 +00:00
DS refactor, fixes/optimizations
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
## GNU General Public License for more details.
|
||||
|
||||
|
||||
from timeit import default_timer
|
||||
from mktxp.collectors.dhcp_collector import DHCPCollector
|
||||
from mktxp.collectors.interface_collector import InterfaceCollector
|
||||
@@ -30,73 +31,73 @@ from mktxp.collectors.mktxp_collector import MKTXPCollector
|
||||
class CollectorsHandler:
|
||||
''' MKTXP Collectors Handler
|
||||
'''
|
||||
def __init__(self, metrics_handler):
|
||||
self.metrics_handler = metrics_handler
|
||||
def __init__(self, entries_handler):
|
||||
self.entries_handler = entries_handler
|
||||
self.bandwidthCollector = BandwidthCollector()
|
||||
|
||||
def collect(self):
|
||||
# process mktxp internal metrics
|
||||
yield from self.bandwidthCollector.collect()
|
||||
|
||||
for router_metric in self.metrics_handler.router_metrics:
|
||||
if not router_metric.api_connection.is_connected():
|
||||
for router_entry in self.entries_handler.router_entries:
|
||||
if not router_entry.api_connection.is_connected():
|
||||
# let's pick up on things in the next run
|
||||
router_metric.api_connection.connect()
|
||||
router_entry.api_connection.connect()
|
||||
continue
|
||||
|
||||
start = default_timer()
|
||||
yield from IdentityCollector.collect(router_metric)
|
||||
router_metric.time_spent['IdentityCollector'] += default_timer() - start
|
||||
yield from IdentityCollector.collect(router_entry)
|
||||
router_entry.time_spent['IdentityCollector'] += default_timer() - start
|
||||
|
||||
start = default_timer()
|
||||
yield from SystemResourceCollector.collect(router_metric)
|
||||
router_metric.time_spent['SystemResourceCollector'] += default_timer() - start
|
||||
yield from SystemResourceCollector.collect(router_entry)
|
||||
router_entry.time_spent['SystemResourceCollector'] += default_timer() - start
|
||||
|
||||
start = default_timer()
|
||||
yield from HealthCollector.collect(router_metric)
|
||||
router_metric.time_spent['HealthCollector'] += default_timer() - start
|
||||
yield from HealthCollector.collect(router_entry)
|
||||
router_entry.time_spent['HealthCollector'] += default_timer() - start
|
||||
|
||||
if router_metric.router_entry.dhcp:
|
||||
if router_entry.config_entry.dhcp:
|
||||
start = default_timer()
|
||||
yield from DHCPCollector.collect(router_metric)
|
||||
router_metric.time_spent['DHCPCollector'] += default_timer() - start
|
||||
yield from DHCPCollector.collect(router_entry)
|
||||
router_entry.time_spent['DHCPCollector'] += default_timer() - start
|
||||
|
||||
if router_metric.router_entry.pool:
|
||||
if router_entry.config_entry.pool:
|
||||
start = default_timer()
|
||||
yield from PoolCollector.collect(router_metric)
|
||||
router_metric.time_spent['PoolCollector'] += default_timer() - start
|
||||
yield from PoolCollector.collect(router_entry)
|
||||
router_entry.time_spent['PoolCollector'] += default_timer() - start
|
||||
|
||||
if router_metric.router_entry.interface:
|
||||
if router_entry.config_entry.interface:
|
||||
start = default_timer()
|
||||
yield from InterfaceCollector.collect(router_metric)
|
||||
router_metric.time_spent['InterfaceCollector'] += default_timer() - start
|
||||
yield from InterfaceCollector.collect(router_entry)
|
||||
router_entry.time_spent['InterfaceCollector'] += default_timer() - start
|
||||
|
||||
if router_metric.router_entry.firewall:
|
||||
if router_entry.config_entry.firewall:
|
||||
start = default_timer()
|
||||
yield from FirewallCollector.collect(router_metric)
|
||||
router_metric.time_spent['FirewallCollector'] += default_timer() - start
|
||||
yield from FirewallCollector.collect(router_entry)
|
||||
router_entry.time_spent['FirewallCollector'] += default_timer() - start
|
||||
|
||||
if router_metric.router_entry.monitor:
|
||||
if router_entry.config_entry.monitor:
|
||||
start = default_timer()
|
||||
yield from MonitorCollector.collect(router_metric)
|
||||
router_metric.time_spent['MonitorCollector'] += default_timer() - start
|
||||
yield from MonitorCollector.collect(router_entry)
|
||||
router_entry.time_spent['MonitorCollector'] += default_timer() - start
|
||||
|
||||
if router_metric.router_entry.route:
|
||||
if router_entry.config_entry.route:
|
||||
start = default_timer()
|
||||
yield from RouteCollector.collect(router_metric)
|
||||
router_metric.time_spent['RouteCollector'] += default_timer() - start
|
||||
yield from RouteCollector.collect(router_entry)
|
||||
router_entry.time_spent['RouteCollector'] += default_timer() - start
|
||||
|
||||
if router_metric.router_entry.wireless:
|
||||
if router_entry.config_entry.wireless:
|
||||
start = default_timer()
|
||||
yield from WLANCollector.collect(router_metric)
|
||||
router_metric.time_spent['WLANCollector'] += default_timer() - start
|
||||
yield from WLANCollector.collect(router_entry)
|
||||
router_entry.time_spent['WLANCollector'] += default_timer() - start
|
||||
|
||||
if router_metric.router_entry.capsman:
|
||||
if router_entry.config_entry.capsman:
|
||||
start = default_timer()
|
||||
yield from CapsmanCollector.collect(router_metric)
|
||||
router_metric.time_spent['CapsmanCollector'] += default_timer() - start
|
||||
yield from CapsmanCollector.collect(router_entry)
|
||||
router_entry.time_spent['CapsmanCollector'] += default_timer() - start
|
||||
|
||||
yield from MKTXPCollector.collect(router_metric)
|
||||
yield from MKTXPCollector.collect(router_entry)
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user