示例#1
0
 def __init__(self, name):
     CompositePDSClient.__init__(self, name)
     self.socket = {}
     self.type = {}
     self.lastRcv = {}
     self.lastTrans = {}
     self.socketState = ''
     self.globalStatus = 0 # Is the circuit (at least partially) working? If not change for 1
     self.socketFlag = 0 # Are the sockets behaving normally? 0 = yes, 1 = no
     self.globalLastRcv = 'NOT FOUND'
     self.globalLastTrans = 'NOT FOUND'
示例#2
0
 def __init__(self, name):
     CompositePDSClient.__init__(self, name)
     self.socket = {}
     self.type = {}
     self.lastRcv = {}
     self.lastTrans = {}
     self.socketState = ''
     self.globalStatus = 0  # Is the circuit (at least partially) working? If not change for 1
     self.socketFlag = 0  # Are the sockets behaving normally? 0 = yes, 1 = no
     self.globalLastRcv = 'NOT FOUND'
     self.globalLastTrans = 'NOT FOUND'
示例#3
0
 def setSocketState(self):
     """
     Determines the connection global state and raise a flag based on the
     results.
     Returns -> Nothing
     """
     items = self.socket.items()
     established = 0 # Is the connection established somewhere (TRUE or FALSE)
     listening = 0 # Number or listening connections
     down = 0 # Number of socket down
     unknown = 0
     numberOfHost = len(CompositePDSClient.getHosts(self))
     
     for item in items:
         if item[1] != '':
             state = item[1].split()[0]
             if state.find('ESTABLISHED') != -1:
                 self.socketState = item[1]
                 established = 1
             elif state.find('DOWN') != -1:
                 down += 1
             elif state.find('LISTEN') != -1:
                 listening += 1
             else:
                 unknown += 1
         else: # This is not a circuit using sockets
             self.socketState = ''
             self.socketFlag = 0
             return
         # Because of our friend netstat the error code had to be changed in order to give the pagers a break
         if established:
             if down == 0 and unknown == 0: # None are down or in an unknown state
                 self.socketFlag = 0 # This means that everyone are up (GREEN)
             else:
                 # Should be 1
                 self.socketFlag = 0 # The connection is established but somehow one machine is in problem (YELLOW)
         else:
             if down == numberOfHost: # Worst case: everyone is down
                 self.socketState = 'DOWN'
                 # Should be 2
                 self.socketFlag = 0 # (RED)
             else: # The connection isn't established but some machine return something in their netstat
                 self.socketState = 'NOT ESTABLISHED'
                 # Should be 1
                 self.socketFlag = 0 # (YELLOW)
示例#4
0
    def setSocketState(self):
        """
        Determines the connection global state and raise a flag based on the
        results.
        Returns -> Nothing
        """
        items = self.socket.items()
        established = 0  # Is the connection established somewhere (TRUE or FALSE)
        listening = 0  # Number or listening connections
        down = 0  # Number of socket down
        unknown = 0
        numberOfHost = len(CompositePDSClient.getHosts(self))

        for item in items:
            if item[1] != '':
                state = item[1].split()[0]
                if state.find('ESTABLISHED') != -1:
                    self.socketState = item[1]
                    established = 1
                elif state.find('DOWN') != -1:
                    down += 1
                elif state.find('LISTEN') != -1:
                    listening += 1
                else:
                    unknown += 1
            else:  # This is not a circuit using sockets
                self.socketState = ''
                self.socketFlag = 0
                return
            # Because of our friend netstat the error code had to be changed in order to give the pagers a break
            if established:
                if down == 0 and unknown == 0:  # None are down or in an unknown state
                    self.socketFlag = 0  # This means that everyone are up (GREEN)
                else:
                    # Should be 1
                    self.socketFlag = 0  # The connection is established but somehow one machine is in problem (YELLOW)
            else:
                if down == numberOfHost:  # Worst case: everyone is down
                    self.socketState = 'DOWN'
                    # Should be 2
                    self.socketFlag = 0  # (RED)
                else:  # The connection isn't established but some machine return something in their netstat
                    self.socketState = 'NOT ESTABLISHED'
                    # Should be 1
                    self.socketFlag = 0  # (YELLOW)
示例#5
0
 def mergeClients(self):
     clients = self.clientDictDict[
         self.machines[0]].keys()  # We obtain the names of all PDS clients
     clients.sort()
     for client in clients:
         compositeClient = CompositePDSClient(client)
         for machine in self.machines:
             compositeClient.addHost(machine)
             compositeClient.setPid(
                 machine, self.clientDictDict[machine][client].pid)
             compositeClient.setStatus(
                 machine, self.clientDictDict[machine][client].status)
             compositeClient.setDate(
                 machine, self.clientDictDict[machine][client].date)
             compositeClient.setQueue(
                 machine, self.clientDictDict[machine][client].queue)
             compositeClient.setLastLog(
                 machine, self.clientDictDict[machine][client].logline)
         compositeClient.setCompositeQueue()
         compositeClient.setBestLog()
         print compositeClient
         self.compositeClientsDict[client] = compositeClient
示例#6
0
 def mergeClients(self):
    clients = self.clientDictDict[self.machines[0]].keys()   # We obtain the names of all PDS clients
    clients.sort()
    for client in clients:
       compositeClient = CompositePDSClient(client)
       for machine in self.machines:
          compositeClient.addHost(machine)
          compositeClient.setPid(machine, self.clientDictDict[machine][client].pid)
          compositeClient.setStatus(machine, self.clientDictDict[machine][client].status)
          compositeClient.setDate(machine, self.clientDictDict[machine][client].date)
          compositeClient.setQueue(machine, self.clientDictDict[machine][client].queue)
          compositeClient.setLastLog(machine,self.clientDictDict[machine][client].logline)
       compositeClient.setCompositeQueue()
       compositeClient.setBestLog()
       print compositeClient
       self.compositeClientsDict[client] = compositeClient