falcon nodata

有的时候, nodata还是很有作用,针对某些指标突然没了数据,这个时候该如何报警呢?

其中有一个非常特殊的例子,就是机器挂了,或者监控进程掉了,这个时候,agent和monitor server之间就失去了联系,如果falcon没有应对这种情况的外挂,就会导致我们不知道机器挂了,有的时候会非常头疼的。

解决方案就是nodata, 我们可以在web界面直接配置,但是我们也可以直接将记录插入数据库。

mysql> use falcon_portal;
mysql> select * from mockcfg;
+----+--------------+--------------+----------+-------------+------+--------+------+------+---------+---------------------+---------------------+
| id | name         | obj          | obj_type | metric      | tags | dstype | step | mock | creator | t_create            | t_modify            |
+----+--------------+--------------+----------+-------------+------+--------+------+------+---------+---------------------+---------------------+
|  1 | 10.0.0.15    | 10.0.0.15    | host     | agent.live  |      | GAUGE  |   60 |   -1 | ops     | 2017-02-14 04:29:37 | 2017-02-14 04:42:52 |
|  2 | 10.0.0.39    | 10.0.0.39    | host     | agent.alive |      | GAUGE  |   60 |   -1 | ops     | 2017-02-14 04:30:02 | 2017-02-14 04:42:52 |
|  3 | 10.0.100.112 | 10.0.100.112 | host     | agent.alive |      | GAUGE  |   60 |   -1 | ops     | 2017-02-14 04:30:17 | 2017-02-14 04:42:52 |

另外,重要的是, obj_type,如果我们直接输入hostname,那么我们obj_type需要选择host。这个地方是可以用group的,可是我没有找到方法。

代码如下

#!/usr/bin/env python

import os
import sys
import re

ips=[]
with open('./ips') as f:
    for line in f:
        ip = re.findall("(\d+\.\d+\.\d+\.\d+)",line)[0]
        print ip
        ips.append(ip)
print ips

for ip in ips:
    print """insert into mockcfg (name, obj, obj_type, metric, dstype, step, mock, creator) values ("%s","%s","%s","%s","%s","%s","%s","%s");"""%(ip,ip,"host","agent.alive","GAUGE","60","-1","ops")
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值