Exemple #1
0
def setLocalIP():
    #强写本地IP地址到配置文件中去
    cf1 = ConfigParser.ConfigParser()
    cf1.read(MyUtil.cur_file_dir() + "/auto.ini")
    ipMac = ServerInfo.GetinnerIPMac()
    innerIP = str(ipMac[0])
    cf1.set("Configuration", "localIP", innerIP)
    cf1.write(open(MyUtil.cur_file_dir() + "/auto.ini", "w"))
Exemple #2
0
def getComputerId():
    """获取本机的唯一标识,如果从未安装过,则自动从UUID和MAC计算一个新ID出来
取19位长,并保存在操作系统目录下windows/system32/agentid
    """
    try:
        if os.path.isfile(ServerInfo.sysDir()+"/agentid"):
            f = getProperties(ServerInfo.sysDir()+"/agentid")
            return f['agentid']
        else:
            uid = str(uuid.uuid1())
            mac = str(ServerInfo.GetinnerIPMac()[1])
            tempid = base64.b64encode(uid+'_'+mac)
            tempid = tempid[:18]
            f = open(ServerInfo.sysDir()+"/agentid","w")
            #加上一个回车符,否则会取agentid错误
            f.write('agentid='+tempid+'\n')
            f.close()
            return tempid
    except:
        return "getDiskId_error"
Exemple #3
0
    cf1.set("Configuration", "OuterIP", setWAIIP)
    cf1.set("Configuration", "OS", setOS)
    cf1.set("Configuration", "CodeSet", setCodeSet)
    cf1.set("Configuration", "CPUCores", setCPUCores)
    cf1.set("Configuration", "hostname", setHostname)
    cf1.set("Configuration", "Platform", setPlatform)
    cf1.set("Configuration", "CPUInfo", setCPUInfo)
    cf1.set("Configuration", "SystemDirectory", setSysDir)
    cf1.set("Configuration", "Physicalmemory", setPHMEM)
    cf1.write(open(MyUtil.cur_file_dir() + "/auto.ini", "w"))


if __name__ == '__main__':
    try:
        #配置文件获取
        ipMac = ServerInfo.GetinnerIPMac()
        waiIP = ServerInfo.getWaiIP()
        innerIP = str(ipMac[0])
        innerMAC = str(ipMac[1])
        swaiIP = waiIP[0]
        setOS = ServerInfo.getOS()
        CodeSet = ServerInfo.codeset()
        Cores = ServerInfo.getCPUCores()
        sHostname = ServerInfo.hostname()
        sPlatform = ServerInfo.getSYSTEM()
        sCPUInfo = ServerInfo.cpuInfo()
        sSysDir = ServerInfo.sysDir()
        sPHMEM = str(ServerInfo.getPhyMem()[0])
        writeCfgfile(innerIP, innerMAC, swaiIP, setOS, CodeSet, Cores,
                     sHostname, sPlatform, sSysDir, sCPUInfo, sPHMEM)
        print "CheckOK.检查配置文件完成".decode('utf-8')