mirror of
				https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
				synced 2025-10-31 18:58:01 +00:00 
			
		
		
		
	Improve Grafana script integration with graph groups file, and add measurement variable
Signed-off-by: Matthew Stidham <stidmatt@gmail.com>
This commit is contained in:
		| @@ -178,13 +178,27 @@ def main(): | |||||||
|     parser.add_argument("--dut5_0", type=str, default="", |     parser.add_argument("--dut5_0", type=str, default="", | ||||||
|                         help="Specify 5Ghz DUT entry.  Syntax is somewhat tricky:  DUT-name SSID BSID (bssid-idx), example: linksys-8450 Default-SSID-5gl c4:41:1e:f5:3f:25 (2)") |                         help="Specify 5Ghz DUT entry.  Syntax is somewhat tricky:  DUT-name SSID BSID (bssid-idx), example: linksys-8450 Default-SSID-5gl c4:41:1e:f5:3f:25 (2)") | ||||||
|     parser.add_argument("--dut2_0", type=str, default="", |     parser.add_argument("--dut2_0", type=str, default="", | ||||||
|                         help="Specify 5Ghz DUT entry.  Syntax is somewhat tricky:  DUT-name SSID BSID (bssid-idx), example: linksys-8450 Default-SSID-2g c4:41:1e:f5:3f:24 (1)") |                         help="Specify 2Ghz DUT entry.  Syntax is somewhat tricky:  DUT-name SSID BSID (bssid-idx), example: linksys-8450 Default-SSID-2g c4:41:1e:f5:3f:24 (1)") | ||||||
|  |  | ||||||
|     parser.add_argument("--radio2", action='append', nargs=1, default=[], |     parser.add_argument("--radio2", action='append', nargs=1, default=[], | ||||||
|                         help="Specify 2.4Ghz radio.  May be specified multiple times.") |                         help="Specify 2.4Ghz radio.  May be specified multiple times.") | ||||||
|     parser.add_argument("--radio5", action='append', nargs=1, default=[], |     parser.add_argument("--radio5", action='append', nargs=1, default=[], | ||||||
|                         help="Specify 5Ghz radio.  May be specified multiple times.") |                         help="Specify 5Ghz radio.  May be specified multiple times.") | ||||||
|  |  | ||||||
|  |     #Flags for Grafana | ||||||
|  |  | ||||||
|  |     parser.add_argument('--dashboard_title', help='Titles of dashboards', default=None, action='append') | ||||||
|  |     parser.add_argument('--scripts', help='Scripts to graph in Grafana', default=None, action='append') | ||||||
|  |     parser.add_argument('--title', help='title of your Grafana Dashboard', default=None) | ||||||
|  |     parser.add_argument('--testbed', help='Which testbed you want to query', default=None) | ||||||
|  |     parser.add_argument('--graph_groups_file', help='File which determines how you want to filter your graphs on your dashboard', | ||||||
|  |                           default=None) | ||||||
|  |     parser.add_argument('--kpi', help='KPI file(s) which you want to graph form', action='append', default=None) | ||||||
|  |     parser.add_argument('--datasource', help='Name of Influx database if different from InfluxDB', default='InfluxDB') | ||||||
|  |     parser.add_argument('--from_date', help='Date you want to start your Grafana dashboard from', default='now-1y') | ||||||
|  |     parser.add_argument('--graph_height', help='Custom height for the graph on grafana dashboard', default=8) | ||||||
|  |     parser.add_argument('--graph_width', help='Custom width for the graph on grafana dashboard', default=12) | ||||||
|  |  | ||||||
|     args = parser.parse_args() |     args = parser.parse_args() | ||||||
|  |  | ||||||
|     cv_base_adjust_parser(args) |     cv_base_adjust_parser(args) | ||||||
| @@ -240,7 +254,8 @@ def main(): | |||||||
|                                      disables=args.disable, |                                      disables=args.disable, | ||||||
|                                      raw_lines=args.raw_line, |                                      raw_lines=args.raw_line, | ||||||
|                                      raw_lines_file=args.raw_lines_file, |                                      raw_lines_file=args.raw_lines_file, | ||||||
|                                      sets=args.set) |                                      sets=args.set, | ||||||
|  |                                      graph_groups=args.graph_groups_file) | ||||||
|     wifi_capacity.apply_cv_scenario(args.scenario) |     wifi_capacity.apply_cv_scenario(args.scenario) | ||||||
|     wifi_capacity.build_cv_scenario() |     wifi_capacity.build_cv_scenario() | ||||||
|     wifi_capacity.setup() |     wifi_capacity.setup() | ||||||
| @@ -268,7 +283,7 @@ def main(): | |||||||
|                             raw_lines=args.raw_line, |                             raw_lines=args.raw_line, | ||||||
|                             raw_lines_file=args.raw_lines_file, |                             raw_lines_file=args.raw_lines_file, | ||||||
|                             sets=args.set, |                             sets=args.set, | ||||||
|                             graph_groups=args.graph_groups |                             graph_groups=args.graph_groups_file | ||||||
|                             ) |                             ) | ||||||
|     CV_Test.setup() |     CV_Test.setup() | ||||||
|     CV_Test.run() |     CV_Test.run() | ||||||
| @@ -296,7 +311,8 @@ def main(): | |||||||
|                             disables=args.disable, |                             disables=args.disable, | ||||||
|                             raw_lines=args.raw_line, |                             raw_lines=args.raw_line, | ||||||
|                             raw_lines_file=args.raw_lines_file, |                             raw_lines_file=args.raw_lines_file, | ||||||
|                             sets=args.set |                             sets=args.set, | ||||||
|  |                             graph_groups=args.graph_groups_file | ||||||
|                             ) |                             ) | ||||||
|         ApAuto.setup() |         ApAuto.setup() | ||||||
|         ApAuto.run() |         ApAuto.run() | ||||||
|   | |||||||
| @@ -1,5 +1,10 @@ | |||||||
| #!/usr/bin/env python3 | #!/usr/bin/env python3 | ||||||
|  |  | ||||||
|  | """ | ||||||
|  | The best way to use create_custom_dashboard by creating a graph_groups_file | ||||||
|  | The Graph_groups_file command is a txt file which lists the files which are going to be added to the Grafana Dashboard | ||||||
|  | It gets the columns of the files and from that it automatically determines the necessary titles on your dashboard. | ||||||
|  | """ | ||||||
| import sys | import sys | ||||||
| import os | import os | ||||||
| import argparse | import argparse | ||||||
| @@ -67,6 +72,7 @@ class UseGrafana(LFCliBase): | |||||||
|                 'from(bucket: "%s")\n  ' |                 'from(bucket: "%s")\n  ' | ||||||
|                 '|> range(start: v.timeRangeStart, stop: v.timeRangeStop)\n  ' |                 '|> range(start: v.timeRangeStart, stop: v.timeRangeStop)\n  ' | ||||||
|                 '|> filter(fn: (r) => r["script"] == "%s")\n   ' |                 '|> filter(fn: (r) => r["script"] == "%s")\n   ' | ||||||
|  |                 '|> group(columns: ["_measurement"])\n ' | ||||||
|                 % (bucket, scriptname)) |                 % (bucket, scriptname)) | ||||||
|         queryend = ('|> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)\n  ' |         queryend = ('|> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)\n  ' | ||||||
|                     '|> yield(name: "mean")\n  ') |                     '|> yield(name: "mean")\n  ') | ||||||
|   | |||||||
| @@ -204,6 +204,7 @@ class ApAutoTest(cvtest): | |||||||
|                  raw_lines=[], |                  raw_lines=[], | ||||||
|                  raw_lines_file="", |                  raw_lines_file="", | ||||||
|                  sets=[], |                  sets=[], | ||||||
|  |                  graph_groups=None | ||||||
|                  ): |                  ): | ||||||
|         super().__init__(lfclient_host=lf_host, lfclient_port=lf_port) |         super().__init__(lfclient_host=lf_host, lfclient_port=lf_port) | ||||||
|  |  | ||||||
| @@ -229,6 +230,7 @@ class ApAutoTest(cvtest): | |||||||
|         self.raw_lines = raw_lines |         self.raw_lines = raw_lines | ||||||
|         self.raw_lines_file = raw_lines_file |         self.raw_lines_file = raw_lines_file | ||||||
|         self.sets = sets |         self.sets = sets | ||||||
|  |         self.graph_groups = graph_groups | ||||||
|  |  | ||||||
|     def setup(self): |     def setup(self): | ||||||
|         # Nothing to do at this time. |         # Nothing to do at this time. | ||||||
| @@ -281,7 +283,7 @@ class ApAutoTest(cvtest): | |||||||
|         self.create_and_run_test(self.load_old_cfg, self.test_name, self.instance_name, |         self.create_and_run_test(self.load_old_cfg, self.test_name, self.instance_name, | ||||||
|                                  self.config_name, self.sets, |                                  self.config_name, self.sets, | ||||||
|                                  self.pull_report, self.lf_host, self.lf_user, self.lf_password, |                                  self.pull_report, self.lf_host, self.lf_user, self.lf_password, | ||||||
|                                  cv_cmds) |                                  cv_cmds, graph_groups_file=self.graph_groups) | ||||||
|  |  | ||||||
|         self.rm_text_blob(self.config_name, blob_test)  # To delete old config with same name |         self.rm_text_blob(self.config_name, blob_test)  # To delete old config with same name | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Matthew Stidham
					Matthew Stidham