cli.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:neres 作者: glogiotatidis 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号