def config_check(): config_md5 = get_md5("./agent.conf") while True: time.sleep(1) new_md5 = get_md5("./agent.conf") if new_md5 != config_md5: str = "agent.conf was modified!" PrntLog.warning(str) print str config_md5 = new_md5 return
def selfcheckfunc(exepath, confpath="/etc/.sagent_hash"): try: selfok = True cmd = "cat %s" % confpath (status, ret) = commands.getstatusoutput(cmd) savedmd5 = ret.split()[0] calmd5 = get_md5(exepath) #print("calmd5:%s,savedmd5:%s"%(calmd5,savedmd5)) PrntLog.warning("calmd5:%s,savedmd5:%s" % (calmd5, savedmd5)) if savedmd5 != calmd5: self_exit() except: self_exit() return