コード例 #1
0
ファイル: CheckConfig.py プロジェクト: jianhuiz/cf-apps
        elif (key == "-l"):
            logFile = os.path.abspath(value)
        elif(key == "-i"):
            if (value.isdigit()):
                instanceIds.append(int(value))
            else:
                GaussLog.exitWithError("Parameter invalid. -i %s is not digit." % value)

    # check if user exist and is the right user
    PlatformCommand.checkUser(g_clusterUser)

    #check log dir
    if (logFile == ""):
        logFile = DefaultValue.getOMLogPath(DefaultValue.DEFAULT_LOG_FILE, g_clusterUser, "", "")

    #Init logger
    global g_logger
    g_logger = GaussLog(logFile, "CheckConfig")
    try:
        checker = CheckNodeEnv(cooParams, dataParams, instanceIds)
        checker.run()

        g_logger.log("Check config on node[%s] successfully!" % socket.gethostname())
        g_logger.closeLog()
        sys.exit(0)
    except Exception, e:
        g_logger.logExit(str(e))

if __name__ == '__main__':
    main()
コード例 #2
0
ファイル: LockCluster.py プロジェクト: jianhuiz/cf-apps
    port = connList[0][1]
    
    sql = "select case (select pgxc_lock_for_backup()) when true then (select pg_sleep(%d)) end;" % time_out
    cmd = "gsql -h %s -p %d postgres -X -c \"%s\"" % (ip, port, sql)
    cmd = "su - %s -c '%s'" % (user, cmd)
    sqlThread = CommandThread(cmd)
    sqlThread.start()
    time.sleep(5)
    while True:
        td = endTime - datetime.now()
        leftSeconds = (td.microseconds + (td.seconds + td.days * 24 * 3600) * 10**6) / 10**6
        if (leftSeconds <= 0):
            if (sqlThread.isAlive()):
                g_logger.log("Timeout!Release the cluster!")
                g_logger.closeLog()
                sys.exit(0)
            
        if (not sqlThread.isAlive()):
            if (sqlThread.cmdStauts != 0):
                g_logger.logExit("Lock cluster failed!Output: %s" % sqlThread.cmdOutput)
            else:
                g_logger.log("Execute SQL finished!Release the cluster!")
                g_logger.closeLog()
                sys.exit(0)
        
        g_logger.log("Thread is still alive!Left seconds[%s]" % leftSeconds)
        time.sleep(10)
        
if __name__ == '__main__':
    main()
コード例 #3
0
ファイル: ConfigHba.py プロジェクト: jianhuiz/cf-apps
        if (key == "-h" or key == "--help"):
            usage()
            sys.exit(0)
        elif (key == "-U"):
            g_clusterUser = value
        elif (key == "-l"):
            logFile = value

    if(g_clusterUser == ""):
        GaussLog.exitWithError("Parameter input error, need '-U' parameter.")
    PlatformCommand.checkUser(g_clusterUser)
        
    if(logFile == ""):
        logFile = DefaultValue.getOMLogPath(DefaultValue.DEFAULT_LOG_FILE, g_clusterUser, "")

    # Init logger
    global logger
    logger = GaussLog(logFile, "ConfigHba")
    try:
        configer = ConfigHba()
        configer.run()
        
        logger.log("Config all instances on node[%s] successfully!" % socket.gethostname())
        logger.closeLog()
        sys.exit(0)
    except Exception, e:
        logger.logExit(str(e))
                 
if __name__ == '__main__':
    main()
コード例 #4
0
ファイル: GaussStat.py プロジェクト: jianhuiz/cf-apps
        elif (key == "-p"):
            installPath = value.strip()
        elif (key == "-u"):
            user = value.strip()
        elif (key == "-c"):
            localPort = value.strip()
        elif (key == "-l" or key == "--logpath"):
            logFile = value.strip()
        elif (key == "-d" or key == "--detail"):
            detail = True
        else:
            GaussLog.exitWithError("Unknown parameter for GaussStat: %s" % key)
    
    if(not os.path.exists(installPath) or user == "" or localPort == ""):
        usage()
        GaussLog.exitWithError("indispensable paramter missed.")
        
    if(logFile == ""):
        logFile = "%s/om/gaussdb_local.log" % DefaultValue.getUserLogDirWithUser(user)
        
    logger = GaussLog(logFile, "GaussStat")
        
    try:  
        stat = GaussStat(installPath, user, localPort, logger, detail)
        stat.collect()
        stat.outPut()
    except Exception, e:
        logger.logExit("Can't get statistics, reason: %s" % str(e))
        
    logger.closeLog()
コード例 #5
0
ファイル: ReplaceConfig.py プロジェクト: jianhuiz/cf-apps
    if(installPath == ""):
        GaussLog.exitWithError("Parameter input error, need '-R' parameter.")
    if(not os.path.exists(installPath)):
        GaussLog.exitWithError("Parameter Invalid. -R %s is not existed." % installPath)
        
    if(logFile == ""):
        logFile = DefaultValue.getOMLogPath(DefaultValue.DEFAULT_LOG_FILE, g_clusterUser, installPath)

    hostname = socket.gethostname()
    if (hostname != nodename):
        GaussLog.exitWithError("The hostname %s is not match to the nodename %s." % (hostname, nodename)) 
        
    Deduplication(instanceIds)
    if (instanceIds == []):
        GaussLog.exitWithError("No specific instances to replace. Replace config finished.", 0)  

    global g_logger
    g_logger = GaussLog(logFile, "ReplaceConfig")
    try:
        replacer = ReplaceConfig(installPath, nodename, instanceIds)
        replacer.run()
        
        g_logger.closeLog()
        sys.exit(0)
    except Exception, e:
        g_logger.logExit("Replace config Failed! Error:%s" % str(e))

if __name__ == '__main__':

    main()