def get_monitor(ctx, monitor, raw):
with Spinner('Fetching monitor: '):
monitor = newrelic.get_monitor(ctx.obj['ACCOUNT'], monitor)
if raw:
print(json.dumps(monitor))
return
severity = monitor.get('severity', 0)
if severity == 2:
health = click.style(u'?', fg='green')
elif severity == 1:
health = click.style(u'?', fg='yellow')
else:
health = click.style(u'?', fg='red')
monitor['health'] = health
status = monitor['status'].lower()
if status in ('muted', 'disabled'):
status = click.style(u'? {}'.format(status), fg='yellow')
else:
status = click.style(u'? OK', fg='green')
data = [
['Monitor', monitor['id']],
['Status', status],
['Health', health],
['Name', monitor['name']],
['URI', monitor['uri']],
['Type', monitor['type']],
['Locations', ', '.join(monitor['locations'])],
['slaThreshold', monitor['slaThreshold']],
['Emails', ', '.join(monitor['emails'])],
['Frequency', monitor['frequency']],
['Created', monitor['createdAt']],
['Modified', monitor['modifiedAt']],
]
table = SingleTable(data)
table.title = click.style('Monitor', fg='black')
print(table.table)
评论列表
文章目录