Example #1
0
 def getGUCvalue(self, name):
     if (len(name) < 1):
         return -1
     cmd = "show " + name
     out = PSQL.run_sql_command(cmd)
     result = out.split('\n')
     return result[3].strip()
Example #2
0
 def getGUCvalue(self, name):
     if(len(name) < 1):
         return -1
     cmd = "show " + name 
     out = PSQL.run_sql_command(cmd)
     result = out.split('\n')
     return result[3].strip()
Example #3
0
    def getHostProcess(self, searchStr):

        # Get one segment name after searching pg_catalog
        cmdsql = 'SELECT hostname, port FROM pg_catalog.gp_segment_configuration WHERE content > -1 AND role=\'p\' AND status=\'u\' ORDER BY dbid DESC LIMIT 1;'
        out = PSQL.run_sql_command(cmdsql)        
        result = out.split('\n')
    
        (hostname,port) = result[3].strip().split('|')
        hostname = hostname.strip()
        port = port.strip()

        # find the target process id
        cmdshell = "gpssh -h " + hostname + " 'ps -ef | grep " + searchStr + "'"
        (out, rc) = runShellCommand(cmdshell)

        print(out)

        result = out.split('\n')

	processID = "" 
        for line in result:
            if(line.find("primary") != -1):
                processID = line.split()[2].strip()
                break                
       
        return (hostname, processID)
    def getHostProcess(self, searchStr):

        # Get one segment name after searching pg_catalog
        cmdsql = 'SELECT hostname, port FROM pg_catalog.gp_segment_configuration WHERE content > -1 AND role=\'p\' AND status=\'u\' ORDER BY dbid DESC LIMIT 1;'
        out = PSQL.run_sql_command(cmdsql)
        result = out.split('\n')

        (hostname, port) = result[3].strip().split('|')
        hostname = hostname.strip()
        port = port.strip()

        # find the target process id
        cmdshell = "gpssh -h " + hostname + " 'ps -ef | grep " + searchStr + "'"
        (out, rc) = runShellCommand(cmdshell)

        print(out)

        result = out.split('\n')

        processID = ""
        for line in result:
            if (line.find("primary") != -1):
                processID = line.split()[2].strip()
                break

        return (hostname, processID)
Example #5
0
    def setUpClass(cls):
        cmdsql = 'SELECT hostname FROM pg_catalog.gp_segment_configuration WHERE content > -1 AND status = \'u\' GROUP BY hostname ORDER by hostname;'
        ret = PSQL.run_sql_command(cmdsql)
        hostlist = ret.split('\n') 
        if (len(hostlist) < 5):
            raise AssertionError('Get segment host list failed') 
        for i in range(3, len(hostlist)):
            if (hostlist[i].find('(') >= 0):
                break
            cls.hostlist.append(hostlist[i].strip()) 
        for host in cls.hostlist:
            cls.hoststr = cls.hoststr + ' -h ' + host

        '''
    def getHostNIC(self):

        # Get one segment name after searching pg_catalog
        cmdsql = 'SELECT hostname, port FROM pg_catalog.gp_segment_configuration WHERE content > -1 AND role=\'p\' AND status=\'u\' ORDER BY dbid ASC LIMIT 1;'
        out = PSQL.run_sql_command(cmdsql)
        result = out.split('\n')

        (hostname, port) = result[3].strip().split('|')
        hostname = hostname.strip()
        port = port.strip()
        print(hostname)

        # Get the interface IP through /etc/hosts file
        cmd_str = "cat /etc/hosts"
        (out, rc) = runShellCommand(cmd_str)
        result = out.split('\n')
        for line in result:
            if ((line.find(hostname) != -1)
                    and (line.find(hostname + "-cm") == -1)):
                ipAddress = line.split()[0].strip()

        # ipAddress contain the last interface ic use
        cmd_str = "gpssh -h " + hostname + " 'ifconfig'"
        (out, rc) = runShellCommand(cmd_str)
        result = out.split('\n')

        # find the nic name through the ip address
        for line in result:
            if (len(line) < 10):
                continue
            if (line.split()[1].find("eth") != -1):
                ethname = line.split()[1].strip()
            if (line.find(ipAddress) != -1):
                break
        print(ethname)

        return (hostname, ethname)
Example #7
0
    def getHostNIC(self):

        # Get one segment name after searching pg_catalog
        cmdsql = 'SELECT hostname, port FROM pg_catalog.gp_segment_configuration WHERE content > -1 AND role=\'p\' AND status=\'u\' ORDER BY dbid ASC LIMIT 1;'
        out = PSQL.run_sql_command(cmdsql)        
        result = out.split('\n')
    
        (hostname,port) = result[3].strip().split('|')
        hostname = hostname.strip()
        port = port.strip()
        print(hostname)

        # Get the interface IP through /etc/hosts file
        cmd_str = "cat /etc/hosts"
        (out, rc) = runShellCommand(cmd_str)
        result = out.split('\n')
        for line in result:
            if((line.find(hostname) != -1) and (line.find(hostname + "-cm")==-1)):
                ipAddress = line.split()[0].strip() 
        
        # ipAddress contain the last interface ic use
        cmd_str = "gpssh -h " + hostname + " 'ifconfig'"
        (out, rc) = runShellCommand(cmd_str)
        result = out.split('\n')
      
        # find the nic name through the ip address 
        for line in result:
            if(len(line) < 10):
                continue
            if(line.split()[1].find("eth") != -1):
                ethname = line.split()[1].strip()
            if(line.find(ipAddress) != -1):
                break
        print(ethname)

        return (hostname, ethname)
Example #8
0
 def setGUCvalue(self, name, value):
     if (len(name) < 1):
         return -1
     cmd = "set " + name + " = " + value
     out = PSQL.run_sql_command(cmd)
Example #9
0
 def checkGUC(self, name):
     if (len(name) < 1):
         return -1
     cmd = "show " + name
     out = PSQL.run_sql_command(cmd)
     return out.split('\n')
Example #10
0
 def checkGUC(self, name):
     if (len(name) <1):
         return -1
     cmd = "show " + name
     out = PSQL.run_sql_command(cmd)
     return out.split('\n')
Example #11
0
 def setGUCvalue(self, name, value):
     if(len(name) < 1):
         return -1
     cmd = "set " + name + " = " + value
     out = PSQL.run_sql_command(cmd)