把带有ip地址的文件放到 当前目录,名字为ips

使用如下脚本

#!/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")

mysql连接

登陆 falcon数据库所在主机

mysql
use falcon_portal;
Copyright © opschina.org 2017 with zzlyzq@gmail.com all right reserved,powered by Gitbook该文件修订时间: 2017-07-11 11:32:48

results matching ""

    No results matching ""