Пример #1
0
    def getHosts(self, hostgroup):

        #self.host_counter = self.host_counter + 1

        hosts = {}

        for hostname, status, output in self.hoststatusDefinitions:         
 
            if hostname not in hostgroup.hostObjectIds:

                continue

            host = Host(hostname)
            host.setResult(Result(status, output))
            hosts[hostname] = host

        for hostname, description, status, output in self.servicestatusDefinitions:

            if hostname not in hostgroup.hostObjectIds:

                continue
            
            host = Host(hostname)

            service = Service(description)
            service.setResult(Result(status, output))
            hosts[hostname].addService(service)

        return hosts.values();
    def getHosts(self, group):

        #self.host_counter = self.host_counter + 1

        hosts = {}

        for hostname, status, output in self.hoststatusDefinitions:         
 
            if hostname not in group.hostObjectIds:

                continue

            host = Host(hostname)
            host.setResult(Result(status, output))
            hosts[hostname] = host

        for hostname, description, status, output in self.servicestatusDefinitions:

            if hostname not in group.hostObjectIds: continue
            if isinstance(group, Servicegroup) and description not in group.hostServiceObjectIds[hostname]: continue
            
            host = Host(hostname)

            service = Service(description)
            service.setResult(Result(status, output))
            hosts[hostname].addService(service)

        return hosts.values();
    def getHosts(self, group):

        #self.host_counter = self.host_counter + 1

        reString = '^' + '$|^'.join(group.hostObjectIds) + '$'
        queryString = "GET hosts\nColumns: host_name plugin_output state\nFilter: host_name ~ " + reString + "\n"
        lines = self.query(queryString)

        hosts = {}

        for line in lines:

            columns = line.split(';')
            hostname = columns[0]
            output = columns[1]
            status = int(columns[2])

            host = Host(hostname)
            host.setResult(Result(status, output))
            hosts[hostname] = host

        reString = '^' + '$|^'.join(group.hostObjectIds) + '$'
        queryString = "GET services\nColumns: host_name description plugin_output state\nFilter: host_name ~ " + reString + "\n"
        if isinstance(group, Servicegroup):

            descriptions = []
            for hostname in group.hostObjectIds:

                descriptions = descriptions + group.hostServiceObjectIds[
                    hostname]
            reString = '^' + '$|^'.join(descriptions) + '$'
            queryString = queryString + "Filter: description ~ " + reString + "\n"
        lines = self.query(queryString)

        for line in lines:

            columns = line.split(';')
            hostname = columns[0]
            description = columns[1]
            output = columns[2]
            status = int(columns[3])

            service = Service(description)
            service.setResult(Result(status, output))
            hosts[hostname].addService(service)

        return hosts.values()
    def getHosts(self, group):

        #self.host_counter = self.host_counter + 1

        reString = '^' + '$|^'.join(group.hostObjectIds) + '$'
        queryString = "GET hosts\nColumns: host_name plugin_output state\nFilter: host_name ~ " + reString + "\n"
        lines = self.query(queryString)

        hosts = {}

        for line in lines:

            columns = line.split(';')
            hostname = columns[0]
            output = columns[1]
            status = int(columns[2])

            host = Host(hostname)
            host.setResult(Result(status, output))
            hosts[hostname] = host

        reString = '^' + '$|^'.join(group.hostObjectIds) + '$'
        queryString = "GET services\nColumns: host_name description plugin_output state\nFilter: host_name ~ " + reString + "\n"
        if isinstance(group, Servicegroup):

            descriptions = []
            for hostname in group.hostObjectIds:

                descriptions = descriptions + group.hostServiceObjectIds[hostname]
            reString = '^' + '$|^'.join(descriptions) + '$'
            queryString = queryString + "Filter: description ~ " + reString + "\n" 
        lines = self.query(queryString)

        for line in lines:

            columns = line.split(';')
            hostname = columns[0]
            description = columns[1]
            output = columns[2]
            status = int(columns[3])

            service = Service(description)
            service.setResult(Result(status, output))
            hosts[hostname].addService(service)

        return hosts.values();
Пример #5
0
        hosts = {}
        regexp = 'hoststatus'+' \{([\S\s]*?)\}'
        pat = re.compile(regexp,re.DOTALL)
        definitions = pat.findall(content)

        for definition in definitions:

            hostname = self.getDirective(definition,"host_name").strip()

            if hostgroup == None or hostname in hostgroup.hostObjectIds:

                status = int(self.getDirective(definition,"current_state").strip())
                output = self.getDirective(definition,"plugin_output").strip()
                host = Host(hostname)
                host.setResult(Result(status, output))
                hosts[hostname] = host

        # get services

        services = {}
        regexp = 'servicestatus'+' \{([\S\s]*?)\}'
        pat = re.compile(regexp, re.DOTALL)
        definitions = pat.findall(content)

        for definition in definitions:

            hostname = self.getDirective(definition,"host_name").strip()

            if hostgroup == None or hostname in hostgroup.hostObjectIds: