telemetry: linux telemetry with perf-stat
[csit.git] / resources / tools / telemetry / __main__.py
1 #!/usr/bin/env python3
2
3 # Copyright (c) 2022 Cisco and/or its affiliates.
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at:
7 #
8 #     http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15
16 """Telemetry Exporter."""
17
18 from argparse import ArgumentParser, RawDescriptionHelpFormatter
19
20 from .executor import Executor
21
22
23 def main():
24     """
25     Main entry function when called from cli
26     """
27     parser = ArgumentParser(
28         description=u"Telemetry Exporter.",
29         formatter_class=RawDescriptionHelpFormatter
30     )
31     parser.add_argument(
32         u"--config", required=True, type=str,
33         help=u"YAML configuration file."
34     )
35     parser.add_argument(
36         u"--hook", required=False, type=str,
37         help=u"Process ID or socket."
38     )
39     parser.add_argument(
40         u"--daemon", required=False, type=bool,
41         help=u"Run as daemon."
42     )
43     args = parser.parse_args()
44     if args.daemon:
45         Executor(args.config).execute_daemon(args.hook)
46     else:
47         Executor(args.config).execute(args.hook)
48
49
50 if __name__ == u"__main__":
51     main()