Commit 400c1f45 authored by Carlos Natalino's avatar Carlos Natalino
Browse files

Implementing the initial version of the communication with the monitoring service.

parent 6b470444
Loading
Loading
Loading
Loading

src/tests/p4/probe/deploy.sh

deleted100644 → 0
+0 −7
Original line number Diff line number Diff line
cd probe-tfs
cargo build --release --target=x86_64-unknown-linux-musl
cd ..

CONTAINER=`docker ps | grep mininet | cut -f1 -d" "`
docker cp ./probe-tfs/target/x86_64-unknown-linux-musl/release/tfsping $CONTAINER:/root
docker cp ./probe-tfs/target/x86_64-unknown-linux-musl/release/tfsagent $CONTAINER:/root
 No newline at end of file
+0 −1
Original line number Diff line number Diff line
docker ps | grep mininet | cut -f1 -d" "
 No newline at end of file
+63 −0
Original line number Diff line number Diff line
%% Cell type:markdown id: tags:

# Checking the monitoring component

%% Cell type:code id: tags:

``` python
import time
import datetime

from dotenv import load_dotenv
from IPython.display import clear_output, display, HTML

from common.proto.kpi_sample_types_pb2 import KpiSampleType
from common.proto.monitoring_pb2 import KpiDescriptor, KpiId, KpiQuery
from monitoring.client.MonitoringClient import MonitoringClient
```

%% Cell type:code id: tags:

``` python
load_dotenv()

monitoring_client = MonitoringClient()

kpi_id = input("What is the KPI ID?")
query = KpiQuery()
query.kpi_ids.append(KpiId(**{"kpi_id": {"uuid": kpi_id}}))
query.last_n_samples = 10

while True:
    response = monitoring_client.QueryKpiData(query)
    # print(response)
    table = f"""<table>
    <thead>
        <tr><th colspan=3>{datetime.datetime.now()}</th></tr>
        <tr><th>KPI ID</th><th>Timestamp</th><th>Value</th></tr>
    <thead>
    <tbody>"""
    for kpi in response.raw_kpi_lists:
        cur_kpi_id = kpi.kpi_id.kpi_id.uuid
        for raw_kpi in reversed(kpi.raw_kpis):
            # print(cur_kpi_id, raw_kpi.timestamp.timestamp, raw_kpi.kpi_value)
            table += "<tr><td>{}</td><td>{}</td><td>{}</td></tr>".format(
                cur_kpi_id, raw_kpi.timestamp.timestamp, raw_kpi.kpi_value
            )
    table += "</tbody></table>"
    display(HTML(table))
    time.sleep(5)
    clear_output(wait=True)
```

%% Output


    ---------------------------------------------------------------------------
    KeyboardInterrupt                         Traceback (most recent call last)
Cell     In [22], line 28
         26 table += "</tbody></table>"
         27 display(HTML(table))
    ---> 28 time.sleep(5)
         29 clear_output(wait=True)
    KeyboardInterrupt:
+2 −3
Original line number Diff line number Diff line
@@ -9,10 +9,9 @@ edition = "2021"
dotenv = "0.15.0"
futures = "0.3.26"
prost = "0.11.6"
rand = "0.8.5"
surge-ping = "0.7.3"
tokio = { version = "1.25", features = ["macros", "rt-multi-thread"] }
tonic = "0.8.1"
tonic = "0.8.3"

[[bin]]
name = "tfsping"
@@ -23,4 +22,4 @@ name = "tfsagent"
path = "src/agent.rs"

[build-dependencies]
tonic-build = "0.8.1"
tonic-build = "0.8.3"
+1 −3
Original line number Diff line number Diff line
@@ -11,6 +11,4 @@ fn main() {
            &["proto"]
        )
        .unwrap_or_else(|e| panic!("Failed to compile protos {:?}", e));
    // tonic_build::compile_protos("proto/*.proto")
    //     .unwrap_or_else(|e| panic!("Failed to compile protos {:?}", e));
}
Loading