Skip to content
This repository has been archived by the owner on Nov 21, 2024. It is now read-only.

TunnelHealth #31

Closed
wants to merge 10 commits into from
2 changes: 2 additions & 0 deletions catalystwan/endpoints/endpoints_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
from catalystwan.endpoints.monitoring.device_details import MonitoringDeviceDetails
from catalystwan.endpoints.monitoring.server_info import ServerInfo
from catalystwan.endpoints.monitoring.status import MonitoringStatus
from catalystwan.endpoints.monitoring.tunnelhealth import TunnelHealth
from catalystwan.endpoints.real_time_monitoring.reboot_history import RealTimeMonitoringRebootHistory
from catalystwan.endpoints.sdavc_cloud_connector import SDAVCCloudConnector
from catalystwan.endpoints.tenant_backup_restore import TenantBackupRestore
Expand Down Expand Up @@ -201,6 +202,7 @@ def __init__(self, session: ManagerSession):
self.monitoring_device_details = MonitoringDeviceDetails(session)
self.monitoring_server_info = ServerInfo(session)
self.monitoring_status = MonitoringStatus(session)
self.monitoring_tunnelhealth = TunnelHealth(session)
self.sdavc_cloud_connector = SDAVCCloudConnector(session)
self.tenant_backup_restore = TenantBackupRestore(session)
self.tenant_management = TenantManagement(session)
Expand Down
27 changes: 27 additions & 0 deletions catalystwan/endpoints/monitoring/tunnelhealth.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright 2024 Cisco Systems, Inc. and its affiliates

# mypy: disable-error-code="empty-body"

from typing import Optional

from catalystwan.endpoints import APIEndpoints, get
from catalystwan.models.monitoring.tunnelhealth import (
TunnelHealthHistoryItem,
TunnelHealthOverview,
TunnelHealthRequest,
)
from catalystwan.typed_list import DataSequence


class TunnelHealth(APIEndpoints):
@get("/statistics/tunnelhealth/history")
def get_tunnelhealth_history(
self, params: Optional[TunnelHealthRequest] = None
) -> DataSequence[TunnelHealthHistoryItem]:
...

@get("/statistics/tunnelhealth/overview/{type}")
def get_tunnelhealth_overview(
self, type: str, params: Optional[TunnelHealthRequest] = None
) -> TunnelHealthOverview:
...
80 changes: 80 additions & 0 deletions catalystwan/models/monitoring/tunnelhealth.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
from typing import Dict, List, Literal, Optional

from pydantic import BaseModel, Field

HealthValues = Literal["fair", "good", "n/a", "poor"]
StateValues = Literal["Down", "Up"]


# Optional Params for both endpoints.
class TunnelHealthRequest(BaseModel):
last_n_hours: int = Field(default=12, description="Time range for the data in hours.")
site: Optional[str] = Field(default=None, description="Specific site to filter the data.")
limit: int = Field(default=30, description="Limit for the number of records returned.")


# Models for tunnelhealth/history
class DeviceHealthEntryItem(BaseModel):
cpu_load: Optional[float] = None
data: Dict = Field(default_factory=dict) # Empty dictionary by default
entry_time: int
health: HealthValues
health_score: float
memory_utilization: Optional[float] = None


class TunnelHealthData(BaseModel):
jitter: float
latency: float
loss_percentage: float
rx_octets: int
state: StateValues
tx_octets: int
vqoe_score: float


class TunnelHealthHistoryItem(BaseModel):
health: HealthValues
health_score: float
history: List[DeviceHealthEntryItem]
local_color: str
local_system_ip: str
name: str
remote_color: str
remote_system_ip: str
summary: TunnelHealthData


# Models for tunnelhealth/overview/<type>
class TunnelHealthOverviewEntry(BaseModel):
health: HealthValues
health_score: float
jitter: float
latency: float
local_color: str
local_system_ip: str
loss_percentage: float
name: str
remote_color: str
remote_system_ip: str
rx_octets: int
state: StateValues
tx_octets: int
vqoe_score: float


class TunnelHealthOverviewDetail(BaseModel):
fair: List[TunnelHealthOverviewEntry]
good: List[TunnelHealthOverviewEntry]
poor: List[TunnelHealthOverviewEntry]


class TunnelHealthOverviewTotal(BaseModel):
fair: int
good: int
poor: int


class TunnelHealthOverview(BaseModel):
detail: TunnelHealthOverviewDetail
total: TunnelHealthOverviewTotal
Loading