python - 如何使用python获取所有没有特定标签的mysql实例?

标签 python mysql

我正在尝试建立一个警报系统,如果某些实例没有警报,该系统将发送电子邮件。但对于某些测试实例,我不希望它们包含在内,因此我将在其中添加“NoAlarms”标签。我想在我现有的 python 脚本中添加此功能。

这基本上就是我现在所拥有的。

from RDSFunctions import GetListRDSEndpoints
from RDSFunctions import GetListRDSIdentifiers
from boto.ec2.cloudwatch import CloudWatchConnection
from SMTPMail import SendSMTPMail
from boto import ec2
lst_instances = GetListRDSIdentifiers(accesskey, secretkey)
lst_expected_alarms = []
for inst in lst_instances:
    if "relprac" not in inst.lower():
        lst_expected_alarms.append(inst + ' - ' + 'CPUUtilization')

由于我们对这些实例使用 RDS 而不是 EC2,我应该如何查找所有没有“NoAlarms”标签的实例?

最佳答案

这样的东西有用吗?

import boto.ec2

conn = boto.ec2.connect_to_region("your_region", accesskey, secretkey)

lst_instances = conn.get_only_instances() #gets all instances

for instance in lst_instances:

    if instance.tags['NoAlarms']: #tags are a dictionary ie.['Name': 'NoAlarms']
        pass
    else:
        #add alarms

关于python - 如何使用python获取所有没有特定标签的mysql实例?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36223377/

相关文章:

python - Odoo 向导 : How to populate with active fields from parent view

python - 相同结构的不同图可以使用tensorflow Saver吗

mysql。同一个表中重复的自增键

java - 使用文档监听器实时显示搜索结果?

mysql - 插入查询不是在表​​中插入值

python - base64.standard_b64decode(s) 的目的是什么?

python - 如何序列化作为 XML Exporter 中的项目列表的 Scrapy 字段

python - 为什么在将属性更改为引用外部函数后不传递 self?

php - 查看与您的 MariaDB 服务器版本对应的手册,了解在 '"Array"SQL 附近使用的正确语法

Java:如何通过调用父类来获取子类的对象