summary = [['Metrics','Status']]
try:
for i in output['responsetimes']:
if i['metric'] == 'ResponseTime':
k = i['value'].split(' ')
if int(k[0])<1000:
temp = ['Response Times','Green']
summary.append(temp)
else:
temp = ['Response Times','Red']
summary.append(temp)
except:
summary.append(['Response Times','NA'])
try:
for i in output['runtimedumps']:
if i['metric'] == 'Shortdumps Frequency':
k = i['value'].split(' ')
if int(k[0])==0:
temp = ['Runtime Dumps','Green']
summary.append(temp)
else:
temp = ['Runtime Dumps','Red']
summary.append(temp)
except:
summary.append(['Runtime Dumps','NA'])
try:
temp = []
for i in output['buffer']:
if (i['metric'] == 'HitRatio'):
k = i['value'].split(' ')
if int(k[0])>95:
temp.append('green')
else:
temp.append('red')
if 'red' in temp:
summary.append(['Buffer','Red'])
else:
summary.append(['Buffer','Green'])
except:
summary.append(['Buffer','NA'])
try:
for i in output['updatemonitoring']:
if i['metric'] == 'ErrorsInWpUD1':
if int(i['value'])==0:
temp = ['Update Monitoring','Green']
summary.append(temp)
else:
temp = ['Update Monitoring','Red']
summary.append(temp)
except:
summary.append(['Update Monitoring','NA'])
try:
for i in output['memory']:
if i['metric'] == 'Physical':
total = int(i['value'].split(' ')[0])
if i['metric'] == 'Free (Value)':
free = int(i['value'].split(' ')[0])
if int((free*100)/total)<5:
summary.append(['Memory Utilization','Red'])
else:
summary.append(['Memory Utilization','Green'])
except:
summary.append(['Memory Utilization','Green'])
try:
for i in output['cpu']:
if i['metric'] == 'CPU_Utilization':
used = int(i['value'].split(' ')[0])
if used>80:
summary.append(['CPU Utilization','Red'])
else:
summary.append(['CPU Utilization','Green'])
except:
summary.append(['CPU Utilization','NA'])
try:
temp = []
for i in output['fs']:
if int(i['perc'].split(' ')[0])>85:
temp.append('red')
else:
temp.append('green')
if 'red' in temp:
summary.append(['File System','Red'])
else:
summary.append(['File System','Green'])
except:
summary.append(['File System','NA'])
t=Table(summary,hAlign='LEFT')
GRID_STYLE = TableStyle(
[
('GRID',(0,0),(-1,-1),0.5,colors.black),
('BACKGROUND', (0, 0), (-1, 0), '#2766A8'),
('TEXTCOLOR', (0, 0), (-1, 0), colors.white),
]
)
t.setStyle(GRID_STYLE)
Story.append(t)
Story.append(Spacer(1, 12))
I am creating a table using report lab,
You can see how it looks in the image below:
I want to highlight the cell based on their values.
For example, Response Times cell would be green if its value is green or red otherwise.
I'm new at this, and can use some guidance on how to achieve this.
