Skip to content

Commit

Permalink
PoE numeric data as gauge values
Browse files Browse the repository at this point in the history
  • Loading branch information
akpw committed Jun 11, 2024
1 parent 0c7f955 commit 2d7c037
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 44 deletions.
18 changes: 16 additions & 2 deletions mktxp/collector/poe_collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,20 @@ def collect(router_entry):
poe_records = POEMetricsDataSource.metric_records(router_entry, include_comments = True, metric_labels = poe_labels)

if poe_records:
poe_metrics = BaseCollector.info_collector('poe', 'POE Metrics', poe_records, poe_labels)
poe_info_labels = ['name', 'poe_out', 'poe_priority', 'poe_voltage', 'poe_out_status']
poe_metrics = BaseCollector.info_collector('poe', 'POE Info Metrics', poe_records, poe_info_labels)
yield poe_metrics


for poe_record in poe_records:
if 'poe_out_voltage' in poe_record:
poe_voltage_metrics = BaseCollector.gauge_collector('poe_out_voltage', 'POE Out Voltage', [poe_record, ], 'poe_out_voltage')
yield poe_voltage_metrics

if 'poe_out_current' in poe_record:
poe_current_metrics = BaseCollector.gauge_collector('poe_out_current', 'POE Out Current', [poe_record, ], 'poe_out_current')
yield poe_current_metrics

if 'poe_out_power' in poe_record:
poe_power_metrics = BaseCollector.gauge_collector('poe_out_power', 'POE Out Power', [poe_record, ], 'poe_out_power')
yield poe_power_metrics

18 changes: 0 additions & 18 deletions mktxp/flow/router_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,21 +122,3 @@ def _set_connect_state(self, success = False, connect_time = datetime.now(), exc
self.successive_failure_count += 1
self.last_failure_timestamp = connect_time.timestamp()
print(f'{connect_time.strftime("%Y-%m-%d %H:%M:%S")} Connection to router {self.router_name}@{self.config_entry.hostname} has failed: {exc}')


# def is_not_connected(self):
# if not (self.connection and self.connection.connected and self.api):
# return True
# def is_connected(self):
# if self.is_not_connected():
# return False
# try:
# self.api.get_resource('/system/identity').get()
# return True
# except (socket.error, socket.timeout, Exception) as exc:
# self._set_connect_state(success = False, exc = exc)
# return False




9 changes: 0 additions & 9 deletions mktxp/flow/router_entries_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,3 @@ def _set_child_entries(router_entry):
if router_entry.config_entry.remote_capsman_entry and config_handler.registered_entry(router_entry.config_entry.remote_capsman_entry):
router_entry.capsman_entry = RouterEntry(router_entry.config_entry.remote_capsman_entry)


#import sys
#_, ex_value, _ = sys.exc_info()
# def router_entry(self, entry_name, enabled_only = False):
# entry = self._router_entries.get(entry_name)
# if entry and (entry.config_entry.enabled or not enabled_only):
# return entry
# return None

14 changes: 0 additions & 14 deletions mktxp/flow/router_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,17 +181,3 @@ def is_done(self):
self._wireless_type = RouterEntryWirelessType.NONE

DHCPCacheEntry = namedtuple('DHCPCacheEntry', ['type', 'record'])




# def is_connected(self):
# if self.api_connection.is_connected():
# return True
# if self._dhcp_entry and self._dhcp_entry.api_connection.is_connected():
# return True
# if self._capsman_entry and self._capsman_entry.api_connection.is_connected():
# return True
# return False


2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

setup(
name='mktxp',
version='1.2.6',
version='1.2.7',

url='https://github.com/akpw/mktxp',

Expand Down

0 comments on commit 2d7c037

Please sign in to comment.