-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Elad Gershon <egershon@nvidia.com>
- Loading branch information
1 parent
b9c9a5a
commit 03dd1a5
Showing
3 changed files
with
31 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
plugins/pdr_deterministic_plugin/ufm_sim_web_service/telemetry_collector.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import pandas as pd | ||
from constants import PDRConstants as Constants | ||
import logging | ||
import urllib | ||
|
||
|
||
class TelemetryCollector: | ||
""" | ||
Represent Telemetry collector which send DataFrame once telemetry is called. | ||
""" | ||
def __init__(self,test_mode) -> None: | ||
self.test_mode=test_mode | ||
|
||
def get_telemetry(self): | ||
""" | ||
get the telemetry from secondary telemetry, if it in test mode it get from the simulation | ||
return DataFrame of the telemetry | ||
""" | ||
if self.test_mode: | ||
url = f"http://127.0.0.1:9090/csv/xcset/simulated_telemetry" | ||
else: | ||
url = f"http://127.0.0.1:{Constants.SECONDARY_TELEMETRY_PORT}/csv/xcset/{Constants.SECONDARY_INSTANCE}" | ||
try: | ||
telemetry_data = pd.read_csv(url) | ||
except (pd.errors.ParserError, pd.errors.EmptyDataError, urllib.error.URLError) as e: | ||
logging.error(f"Failed to get telemetry data from UFM, fetched url={url}. Error: {e}") | ||
telemetry_data = None | ||
return telemetry_data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters