aboutsummaryrefslogtreecommitdiffstats
path: root/resources/tools
diff options
context:
space:
mode:
Diffstat (limited to 'resources/tools')
-rw-r--r--resources/tools/telemetry/bundle_bpf.py9
-rw-r--r--resources/tools/telemetry/constants.py12
-rw-r--r--resources/tools/telemetry/executor.py7
-rw-r--r--resources/tools/telemetry/parser.py7
4 files changed, 25 insertions, 10 deletions
diff --git a/resources/tools/telemetry/bundle_bpf.py b/resources/tools/telemetry/bundle_bpf.py
index 655152cb27..b9baeab7ca 100644
--- a/resources/tools/telemetry/bundle_bpf.py
+++ b/resources/tools/telemetry/bundle_bpf.py
@@ -17,6 +17,7 @@ from logging import getLogger
import sys
from bcc import BPF
+from .constants import Constants
class BundleBpf:
@@ -67,8 +68,8 @@ class BundleBpf:
sample_period=duration
)
except AttributeError:
- getLogger(__name__).error(u"Cannot attach BPF events!")
- sys.exit(1)
+ getLogger("console_stderr").error(u"Could not attach BPF events!")
+ sys.exit(Constants.err_linux_attach)
def detach(self):
"""
@@ -81,8 +82,8 @@ class BundleBpf:
ev_config=event[u"name"]
)
except AttributeError:
- getLogger(__name__).error(u"Cannot dettach BPF events!")
- sys.exit(1)
+ getLogger("console_stderr").error(u"Could not detach BPF events!")
+ sys.exit(Constants.err_linux_detach)
def fetch_data(self):
"""
diff --git a/resources/tools/telemetry/constants.py b/resources/tools/telemetry/constants.py
index fda558b0b4..4b47a39d21 100644
--- a/resources/tools/telemetry/constants.py
+++ b/resources/tools/telemetry/constants.py
@@ -26,6 +26,12 @@ class Constants:
# Failed when processing data
err_telemetry_process = 1
+ # Failed to read YAML file
+ err_telemetry_yaml = 2
+
+ # Error executing bundle
+ err_telemetry_bundle = 3
+
# Could not connect to VPP
err_vpp_connect = 11
@@ -35,3 +41,9 @@ class Constants:
# Failed when executing command
err_vpp_execute = 13
+ # Could not attach BPF events
+ err_linux_attach = 51
+
+ # Could not detach BPF events
+ err_linux_detach = 52
+
diff --git a/resources/tools/telemetry/executor.py b/resources/tools/telemetry/executor.py
index 75db4b6a40..4d335c187d 100644
--- a/resources/tools/telemetry/executor.py
+++ b/resources/tools/telemetry/executor.py
@@ -1,4 +1,4 @@
-# Copyright (c) 2021 Cisco and/or its affiliates.
+# Copyright (c) 2022 Cisco and/or its affiliates.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
@@ -20,6 +20,7 @@ import sys
from .parser import Parser
from .serializer import Serializer
+from .constants import Constants
class Executor:
@@ -103,5 +104,5 @@ class ExecutorError(Exception):
"""
super().__init__()
self.message = message
- getLogger(__name__).error(message)
- sys.exit(1)
+ getLogger("console_stderr").error(message)
+ sys.exit(Constants.err_telemetry_bundle)
diff --git a/resources/tools/telemetry/parser.py b/resources/tools/telemetry/parser.py
index c6cc167066..1570a4f047 100644
--- a/resources/tools/telemetry/parser.py
+++ b/resources/tools/telemetry/parser.py
@@ -1,4 +1,4 @@
-# Copyright (c) 2021 Cisco and/or its affiliates.
+# Copyright (c) 2022 Cisco and/or its affiliates.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
@@ -18,6 +18,7 @@ from pathlib import Path
import sys
from yaml import safe_load, YAMLError
+from .constants import Constants
class Parser:
@@ -103,5 +104,5 @@ class ParserError(Exception):
"""
super().__init__()
self.message = message
- getLogger(__name__).error(self.message)
- sys.exit(1)
+ getLogger("console_stderr").error(self.message)
+ sys.exit(Constants.err_telemetry_yaml)