mirror of
				https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
				synced 2025-11-04 04:38:02 +00:00 
			
		
		
		
	Correct y axis labels on Grafana graphs
Signed-off-by: Matthew Stidham <stidmatt@gmail.com>
This commit is contained in:
		@@ -126,6 +126,11 @@ class UseGrafana(LFCliBase):
 | 
				
			|||||||
            print("graph_groups_file: %s" % graph_groups_file)
 | 
					            print("graph_groups_file: %s" % graph_groups_file)
 | 
				
			||||||
            target_csvs = open(graph_groups_file).read().split('\n')
 | 
					            target_csvs = open(graph_groups_file).read().split('\n')
 | 
				
			||||||
            graph_groups = self.get_graph_groups(target_csvs)  # Get the list of graph groups which are in the tests we ran
 | 
					            graph_groups = self.get_graph_groups(target_csvs)  # Get the list of graph groups which are in the tests we ran
 | 
				
			||||||
 | 
					            unit_dict = dict()
 | 
				
			||||||
 | 
					            for csv in target_csvs:
 | 
				
			||||||
 | 
					                if len(csv)>1:
 | 
				
			||||||
 | 
					                    print(csv)
 | 
				
			||||||
 | 
					                    unit_dict.update(self.get_units(csv))
 | 
				
			||||||
        for scriptname in graph_groups.keys():
 | 
					        for scriptname in graph_groups.keys():
 | 
				
			||||||
            for graph_group in graph_groups[scriptname]:
 | 
					            for graph_group in graph_groups[scriptname]:
 | 
				
			||||||
                panel = dict()
 | 
					                panel = dict()
 | 
				
			||||||
@@ -177,7 +182,7 @@ class UseGrafana(LFCliBase):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
                yaxis = dict()
 | 
					                yaxis = dict()
 | 
				
			||||||
                yaxis['format'] = 'short'
 | 
					                yaxis['format'] = 'short'
 | 
				
			||||||
                yaxis['label'] = None
 | 
					                yaxis['label'] = unit_dict[graph_group]
 | 
				
			||||||
                yaxis['logBase'] = 1
 | 
					                yaxis['logBase'] = 1
 | 
				
			||||||
                yaxis['max'] = None
 | 
					                yaxis['max'] = None
 | 
				
			||||||
                yaxis['min'] = None
 | 
					                yaxis['min'] = None
 | 
				
			||||||
@@ -246,28 +251,28 @@ class UseGrafana(LFCliBase):
 | 
				
			|||||||
        input1['time'] = timedict
 | 
					        input1['time'] = timedict
 | 
				
			||||||
        input1['timepicker'] = dict()
 | 
					        input1['timepicker'] = dict()
 | 
				
			||||||
        input1['timezone'] = ''
 | 
					        input1['timezone'] = ''
 | 
				
			||||||
        input1['title'] = title
 | 
					        input1['title'] = ("Testbed: %s" % title)
 | 
				
			||||||
        input1['uid'] = uid
 | 
					        input1['uid'] = uid
 | 
				
			||||||
        input1['version'] = 11
 | 
					        input1['version'] = 11
 | 
				
			||||||
        return self.GR.create_dashboard_from_dict(dictionary=json.dumps(input1))
 | 
					        return self.GR.create_dashboard_from_dict(dictionary=json.dumps(input1))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def read_csv(self, file):
 | 
					    def read_csv(self, file):
 | 
				
			||||||
        csv=open(file).read().split('\n')
 | 
					        csv = open(file).read().split('\n')
 | 
				
			||||||
        rows=list()
 | 
					        rows = list()
 | 
				
			||||||
        for x in csv:
 | 
					        for x in csv:
 | 
				
			||||||
            if len(x) > 0:
 | 
					            if len(x) > 0:
 | 
				
			||||||
                rows.append(x.split('\t'))
 | 
					                rows.append(x.split('\t'))
 | 
				
			||||||
        return rows
 | 
					        return rows
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def get_values(self, csv, target):
 | 
					    def get_values(self, csv, target):
 | 
				
			||||||
        value=csv[0].index(target)
 | 
					        value = csv[0].index(target)
 | 
				
			||||||
        results=[]
 | 
					        results = []
 | 
				
			||||||
        for row in csv[1:]:
 | 
					        for row in csv[1:]:
 | 
				
			||||||
            results.append(row[value])
 | 
					            results.append(row[value])
 | 
				
			||||||
        return results
 | 
					        return results
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def get_graph_groups(self,target_csvs): # Get the unique values in the Graph-Group column
 | 
					    def get_graph_groups(self,target_csvs): # Get the unique values in the Graph-Group column
 | 
				
			||||||
        dictionary=dict()
 | 
					        dictionary = dict()
 | 
				
			||||||
        for target_csv in target_csvs:
 | 
					        for target_csv in target_csvs:
 | 
				
			||||||
            if len(target_csv) > 1:
 | 
					            if len(target_csv) > 1:
 | 
				
			||||||
                csv = self.read_csv(target_csv)
 | 
					                csv = self.read_csv(target_csv)
 | 
				
			||||||
@@ -280,6 +285,13 @@ class UseGrafana(LFCliBase):
 | 
				
			|||||||
        print(dictionary)
 | 
					        print(dictionary)
 | 
				
			||||||
        return dictionary
 | 
					        return dictionary
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def get_units(self, target_csv):
 | 
				
			||||||
 | 
					        csv = self.read_csv(target_csv)
 | 
				
			||||||
 | 
					        graph_group = self.get_values(csv, 'Graph-Group')
 | 
				
			||||||
 | 
					        units = self.get_values(csv, 'Units')
 | 
				
			||||||
 | 
					        return dict(zip(graph_group, units))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def main():
 | 
					def main():
 | 
				
			||||||
    parser = LFCliBase.create_basic_argparse(
 | 
					    parser = LFCliBase.create_basic_argparse(
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -5,11 +5,11 @@
 | 
				
			|||||||
# into influxdb.  As final step, it builds a grafana dashboard for the KPI information.
 | 
					# into influxdb.  As final step, it builds a grafana dashboard for the KPI information.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Define some common variables.  This will need to be changed to match your own testbed.
 | 
					# Define some common variables.  This will need to be changed to match your own testbed.
 | 
				
			||||||
MGR=192.168.1.6
 | 
					MGR=10.0.0.202
 | 
				
			||||||
INFLUX_MGR=192.168.100.201
 | 
					INFLUX_MGR=192.168.100.201
 | 
				
			||||||
#INFLUXTOKEN=Tdxwq5KRbj1oNbZ_ErPL5tw_HUH2wJ1VR4dwZNugJ-APz__mEFIwnqHZdoobmQpt2fa1VdWMlHQClR8XNotwbg==
 | 
					#INFLUXTOKEN=Tdxwq5KRbj1oNbZ_ErPL5tw_HUH2wJ1VR4dwZNugJ-APz__mEFIwnqHZdoobmQpt2fa1VdWMlHQClR8XNotwbg==
 | 
				
			||||||
INFLUXTOKEN=31N9QDhjJHBu4eMUlMBwbK3sOjXLRAhZuCzZGeO8WVCj-xvR8gZWWvRHOcuw-5RHeB7xBFnLs7ZV023k4koR1A==
 | 
					INFLUXTOKEN=31N9QDhjJHBu4eMUlMBwbK3sOjXLRAhZuCzZGeO8WVCj-xvR8gZWWvRHOcuw-5RHeB7xBFnLs7ZV023k4koR1A==
 | 
				
			||||||
TESTBED=Stidmatt-02
 | 
					TESTBED=Stidmatt-01
 | 
				
			||||||
INFLUXBUCKET=stidmatt
 | 
					INFLUXBUCKET=stidmatt
 | 
				
			||||||
#GRAFANATOKEN=eyJrIjoiZTJwZkZlemhLQVNpY3hiemRjUkNBZ3k2RWc3bWpQWEkiLCJuIjoibWFzdGVyIiwiaWQiOjF9
 | 
					#GRAFANATOKEN=eyJrIjoiZTJwZkZlemhLQVNpY3hiemRjUkNBZ3k2RWc3bWpQWEkiLCJuIjoibWFzdGVyIiwiaWQiOjF9
 | 
				
			||||||
GRAFANATOKEN=eyJrIjoiS1NGRU8xcTVBQW9lUmlTM2dNRFpqNjFqV05MZkM0dzciLCJuIjoibWF0dGhldyIsImlkIjoxfQ==
 | 
					GRAFANATOKEN=eyJrIjoiS1NGRU8xcTVBQW9lUmlTM2dNRFpqNjFqV05MZkM0dzciLCJuIjoibWF0dGhldyIsImlkIjoxfQ==
 | 
				
			||||||
@@ -47,7 +47,7 @@ echo "run Dataplane test"
 | 
				
			|||||||
--influx_bucket ${INFLUXBUCKET} --influx_tag testbed ${TESTBED} --graph_groups lf_cv_rpt_filelocation.txt --duration 15s
 | 
					--influx_bucket ${INFLUXBUCKET} --influx_tag testbed ${TESTBED} --graph_groups lf_cv_rpt_filelocation.txt --duration 15s
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Build grafana dashboard and graphs view for the KPI in the capacity test.
 | 
					# Build grafana dashboard and graphs view for the KPI in the capacity test.
 | 
				
			||||||
./grafana_profile.py --create_custom --title 'Stidmatt-02' --influx_bucket ${INFLUXBUCKET} --mgr ${MGR} --grafana_token \
 | 
					./grafana_profile.py --create_custom --title ${TESTBED} --influx_bucket ${INFLUXBUCKET} --mgr ${MGR} --grafana_token \
 | 
				
			||||||
${GRAFANATOKEN} --grafana_host ${INFLUX_MGR} --testbed ${TESTBED} --graph_groups_file lf_cv_rpt_filelocation.txt \
 | 
					${GRAFANATOKEN} --grafana_host ${INFLUX_MGR} --testbed ${TESTBED} --graph_groups_file lf_cv_rpt_filelocation.txt \
 | 
				
			||||||
--scripts Dataplane --datasource 'InfluxDB stidmatt bucket'
 | 
					--scripts Dataplane --datasource 'InfluxDB stidmatt bucket'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user