コード例 #1
0
def createSharedResourceOsh(resource, containerOsh, oshVector):
    '''
    Shared resource OSH creation helper method
    @return: None, returned value are stored in parameter oshVector
    '''
    is90 = modeling.checkAttributeExists('file_system_export', LOCAL_NAMES)
    if is90:
        shareOsh = ObjectStateHolder(NETWORK_SHARE)
        shareOsh.setAttribute("data_name", resource.path)
        shareOsh.setAttribute("share_path", resource.path)
        stringVector = StringVector()
        for instance in resource.getInstances():
            stringVector.add(instance.name)
        shareOsh.setAttribute(LOCAL_NAMES, stringVector)
        shareOsh.setContainer(containerOsh)
        oshVector.add(shareOsh)
    else:
        for instance in resource.getInstances():
            shareOsh = ObjectStateHolder(NETWORK_SHARE)
            shareOsh.setAttribute("data_name", instance.name)
            shareOsh.setAttribute("share_path", resource.path)
            if instance.description:
                shareOsh.setAttribute("data_description", instance.description)
            shareOsh.setContainer(containerOsh)
            oshVector.add(shareOsh)
コード例 #2
0
    def report(self, oshVector, interaction):
        if self.acceptorEngine.accepts(interaction.srcNode) and self.acceptorEngine.accepts(interaction.dstNode)\
            and (interaction.srcNode.ip, interaction.dstNode.ip) not in self.reportedLinks:

            trafficLinkOSH = modeling.createLinkOSH('traffic', interaction.srcNode.ipOsh, interaction.dstNode.ipOsh)
            if self.reportTrafficDetails:
                from appilog.common.system.types import AttributeStateHolder
                from appilog.common.system.types.vectors import StringVector
                octets = 0
                packets = 0
                portsSet = StringVector()
                connections = self.ipToIpConnections.get((interaction.srcNode.ip, interaction.dstNode.ip), [])

                for connection in connections:
                    octets += connection.octetCount and int(connection.octetCount) or 0
                    packets += connection.packetCount and int(connection.packetCount) or 0
                    if portsSet.size() < self.maxPorts:
                        portsSet.add(str(connection.srcPort))
                    if portsSet.size() < self.maxPorts:
                        portsSet.add(str(connection.dstPort))

                ash = AttributeStateHolder('traffic_portlist', portsSet)
                trafficLinkOSH.addAttributeToList(ash)
                trafficLinkOSH.setLongAttribute('traffic_octets', octets)
                trafficLinkOSH.setLongAttribute('traffic_pkts', packets)
            oshVector.add(trafficLinkOSH)
            self.reportedLinks.append((interaction.srcNode.ip, interaction.dstNode.ip))
コード例 #3
0
def createSharedResourceOsh(resource, containerOsh, oshVector):
    '''
    Shared resource OSH creation helper method
    @return: None, returned value are stored in parameter oshVector
    '''
    is90 = modeling.checkAttributeExists('file_system_export', LOCAL_NAMES)
    if is90:
        shareOsh = ObjectStateHolder(NETWORK_SHARE)
        shareOsh.setAttribute("data_name", resource.path)
        shareOsh.setAttribute("share_path", resource.path)
        stringVector = StringVector()
        for instance in resource.getInstances():
            stringVector.add(instance.name)
        shareOsh.setAttribute(LOCAL_NAMES, stringVector)
        shareOsh.setContainer(containerOsh)
        oshVector.add(shareOsh)
    else:
        for instance in resource.getInstances():
            shareOsh = ObjectStateHolder(NETWORK_SHARE)
            shareOsh.setAttribute("data_name", instance.name)
            shareOsh.setAttribute("share_path", resource.path)
            if instance.description:
                shareOsh.setAttribute("data_description", instance.description)
            shareOsh.setContainer(containerOsh)
            oshVector.add(shareOsh)
コード例 #4
0
ファイル: jms.py プロジェクト: ddonnelly19/dd-git
    def __buildJmsDestination(self, destination, destinationType):
        '@types: jms.Destination, str -> ObjectStateHolder'
        osh = ObjectStateHolder('jmsdestination')
        osh.setAttribute('name', destination.getName())
        if destination.getObjectName():
            osh.setAttribute('j2eemanagedobject_objectname', destination.getObjectName())
        if destination.getJndiName():
            osh.setAttribute('j2eemanagedobject_jndiname', destination.getJndiName())
        if destinationType:
            osh.setAttribute('jmsdestination_type', destinationType)

        messagescurrent = destination.messagesCurrentCount.value()
        if messagescurrent is not None:
            osh.setIntegerAttribute('jmsdestination_messagescurrent', messagescurrent)
        messagespending = destination.messagesPendingCount.value()
        if messagespending is not None:
            osh.setIntegerAttribute('jmsdestination_messagespending', messagespending)
        messagesreceived = destination.messagesReceivedCount.value()
        if messagesreceived is not None:
            osh.setIntegerAttribute('jmsdestination_messagesreceived', messagesreceived)
        consumerscurrent = destination.consumersCurrentCount.value()
        if consumerscurrent is not None:
            osh.setIntegerAttribute('jmsdestination_consumerscurrent', consumerscurrent)
        subscribers = destination.getDurableSubscribers()
        if subscribers:
            vectorOfNames = StringVector()
            for subscriber in subscribers:
                vectorOfNames.add(subscriber.getName())
            ash = AttributeStateHolder('jmsdestination_durablesubscribers', vectorOfNames)
            osh.addAttributeToList(ash)
        return osh
コード例 #5
0
    def report(self, sharedResource, containerOsh):
        vector = self._createVector()
        sharedResourcesOshv = self.reportSharedResources(sharedResource, containerOsh)
        it = sharedResourcesOshv.iterator()
        while it.hasNext():
#        for sharedResOsh in self.reportSharedResources(sharedResource, containerOsh):
            sharedResOsh = it.next()
            # make linkage of shared resource with all its instances
            stringVector = StringVector()
            for instance in sharedResource.getInstances():
                stringVector.add(instance.name)
            sharedResOsh.setAttribute(LOCAL_NAMES, stringVector)
        vector.addAll(sharedResourcesOshv)
        return vector
コード例 #6
0
 def report(self, sharedResource, containerOsh):
     vector = self._createVector()
     sharedResourcesOshv = self.reportSharedResources(
         sharedResource, containerOsh)
     it = sharedResourcesOshv.iterator()
     while it.hasNext():
         #        for sharedResOsh in self.reportSharedResources(sharedResource, containerOsh):
         sharedResOsh = it.next()
         # make linkage of shared resource with all its instances
         stringVector = StringVector()
         for instance in sharedResource.getInstances():
             stringVector.add(instance.name)
         sharedResOsh.setAttribute(LOCAL_NAMES, stringVector)
     vector.addAll(sharedResourcesOshv)
     return vector
コード例 #7
0
    def __buildJmsDestination(self, destination, destinationType):
        '@types: jms.Destination, str -> ObjectStateHolder'
        osh = ObjectStateHolder('jmsdestination')
        osh.setAttribute('name', destination.getName())
        if destination.getObjectName():
            osh.setAttribute('j2eemanagedobject_objectname',
                             destination.getObjectName())
        if destination.getJndiName():
            osh.setAttribute('j2eemanagedobject_jndiname',
                             destination.getJndiName())
        if destinationType:
            osh.setAttribute('jmsdestination_type', destinationType)

        messagescurrent = destination.messagesCurrentCount.value()
        if messagescurrent is not None:
            osh.setIntegerAttribute('jmsdestination_messagescurrent',
                                    messagescurrent)
        messagespending = destination.messagesPendingCount.value()
        if messagespending is not None:
            osh.setIntegerAttribute('jmsdestination_messagespending',
                                    messagespending)
        messagesreceived = destination.messagesReceivedCount.value()
        if messagesreceived is not None:
            osh.setIntegerAttribute('jmsdestination_messagesreceived',
                                    messagesreceived)
        consumerscurrent = destination.consumersCurrentCount.value()
        if consumerscurrent is not None:
            osh.setIntegerAttribute('jmsdestination_consumerscurrent',
                                    consumerscurrent)
        subscribers = destination.getDurableSubscribers()
        if subscribers:
            vectorOfNames = StringVector()
            for subscriber in subscribers:
                vectorOfNames.add(subscriber.getName())
            ash = AttributeStateHolder('jmsdestination_durablesubscribers',
                                       vectorOfNames)
            osh.addAttributeToList(ash)
        return osh
コード例 #8
0
    def discover_private(self):
        maxPorts = Integer.parseInt(self.getParameterValue('maxPorts'))
        tcpOnly = Boolean.parseBoolean(self.getParameterValue('tcpOnly'))

        #WE ALWAYS CHECK ONLY ONE DIRECTION SINCE WE ALWAYS REPORT FLOWS IN BOTH DIRECTION SO
        #WE CAN COUNT CLIENTS ONLY ON ONE SIDE
        #WE ASSUME THAT NETFLOW ALWAYS REPORTS CONNECTIONS IN BOTH DIRECTIONS SO WE WILL GET
        #OCTETS AND PACKETS COUNT ALWAYS
        query = ' select SrcAddr ,DstAddr ,DstPort ,count(*) cnt, sum(dPkts) dPkts, sum(dOctets) dOctets, Prot,'
        query = query + ' case when Port is NULL then 0 else 1 end ListenPort  '
        query = query + ' from Agg_V5 left join Port_Process on DstAddr=ipaddress and DstPort=port and Prot = Protocol and listen '
        if tcpOnly:
            query = query + ' where Prot=6 '
        query = query + ' group by SrcAddr, DstAddr, DstPort '
        #for each ip -> ip traffic we first wnat get ports that are listen, than which have more clients
        #after all ports which have more traffic
        query = query + ' order by SrcAddr, DstAddr, ListenPort desc, cnt desc, dOctets desc, dPkts desc'

        #here Prot is asc since TCP ports have higher priority on UDP ports
        query = query + ', Prot asc '

        conn = self.Framework.getProbeDatabaseConnection('TCPDISCOVERY')
        st = None
        result = None
        try:
            st = conn.createStatement()
            result = st.executeQuery(query)
            currSrcAddr = None
            portsSet = StringVector()
            currDstAddr = None
            currLinkID = None
            octets = 0
            packets = 0
            dataFound = 0
            while result.next():
                dataFound = 1
                srcAddr = str(result.getString('SrcAddr'))
                dstAddr = str(result.getString('DstAddr'))
                dstPort = result.getString('DstPort')
                cnt = result.getString('cnt')
                listenPort = result.getInt('ListenPort')

                if not self.isServerPort(cnt, listenPort, dstPort):
                    continue

                if not self.shouldInclude(srcAddr, 0):
                    continue

                if not self.shouldInclude(dstAddr, 1):
                    continue

                linkID = self.createLinkID(srcAddr, dstAddr)

                if currLinkID == linkID:
                    octets = octets + result.getInt('dOctets')
                    packets = packets + result.getInt('dPkts')
                    if portsSet.size() < maxPorts:
                        portsSet.add(dstPort)
                    continue
                elif currLinkID != None:
                    self.addTraffic(currSrcAddr, currDstAddr, portsSet, octets, packets)

                currLinkID = linkID
                currSrcAddr = srcAddr
                currDstAddr = dstAddr
                portsSet = StringVector()
                portsSet.add(dstPort)
                octets = result.getInt('dOctets')
                packets = result.getInt('dPkts')

            if not dataFound:
                self.Framework.reportWarning("No data to process, please check if Host Resources jobs had already run")
            if currLinkID != None:
                self.addTraffic(currSrcAddr, currDstAddr, portsSet, octets, packets)
        finally:
            if result != None:
                try:
                    result.close
                except:
                    pass
            conn.close(st)
            conn.close()
コード例 #9
0
ファイル: sap.py プロジェクト: ddonnelly19/dd-git
 def _createServerTypeVector(self, serverTypes):
     vector = StringVector()
     for type_ in serverTypes:
         vector.add(type_)
     return vector
コード例 #10
0
ファイル: sap.py プロジェクト: deezeesms/dd-git
 def _createServerTypeVector(self, serverTypes):
     vector = StringVector()
     for type_ in serverTypes:
         vector.add(type_)
     return vector