Exemple #1
0
def get_data():
    conf_dict = config_handle.config()
    if conf_dict !=None:
        hostname = conf_dict["hostname"]
        for k,v in conf_dict.items():
            if k =="status":
                pass
            elif k == 'hostname':
                pass
            elif k == "port":
                pass
            else:
                service_name,interval,plugin_name,last_run_time = k,v[0],v[1],v[2]

                if xtime.timestamp() - last_run_time > interval:
                    t = Thread(target=run,args=[(service_name,interval,plugin_name,hostname),])
                    t.start()
                    conf_dict[service_name][2] = xtime.timestamp()
                    config_handle.save_conf(conf_dict)
                    t.join()
                    return m_queue
                else:
                    next_run_time = interval -(xtime.timestamp() - last_run_time)
                    #print "%s next run time %ss"% (service_name,next_run_time)


    else:
        return m_queue
Exemple #2
0
    Qmsg = server_target.get_data()
    if Qmsg:

        host_info = Qmsg.get(timeout=1)

        info=json.dumps(host_info)

        result = ci.send(info+"\r\n")

        if result ==1:
            #重连服务器
            while True:
                try:
                    ci = TcpClient(config.Server,config.Port)
                    print ("%s reconnect success") % xtime.strdatetimefromats(xtime.timestamp())
                    break
                except Exception,e:
                    print("%s %s %s") % (xtime.strdatetimefromats(xtime.timestamp()),config.Server,e[1])
                sleep(5)
        sleep(1)