Report: Add vsap
[csit.git] / resources / tools / telemetry / __main__.py
1 #!/usr/bin/env python3
2
3 # Copyright (c) 2021 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 def main():
23     """
24     Main entry function when called from cli
25     """
26     parser = ArgumentParser(
27         description=u"Telemetry Exporter.",
28         formatter_class=RawDescriptionHelpFormatter
29     )
30     parser.add_argument(
31         u"--config", required=True, type=str,
32         help=u"YAML configuration file."
33     )
34     parser.add_argument(
35         u"--hook", required=False, type=str,
36         help=u"Process ID or socket."
37     )
38     parser.add_argument(
39         u"--daemon", required=False, type=bool,
40         help=u"Run as daemon."
41     )
42     args = parser.parse_args()
43     if args.daemon:
44         Executor(args.config).execute_daemon(args.hook)
45     else:
46         Executor(args.config).execute(args.hook)
47
48 if __name__ == u"__main__":
49     main()