def crawl(self, vm_desc, **kwargs):

        logger.debug('Crawling %s' % self.get_feature())

        if psvmi is None:
            raise NotImplementedError()
        else:
            (domain_name, kernel_version, distro, arch) = vm_desc
            # XXX: this has to be read from some cache instead of
            # instead of once per plugin/feature
            vm_context = psvmi.context_init(
                domain_name, domain_name, kernel_version, distro, arch)
            interfaces = self._crawl_interface_counters(vm_context)

        for (interface_name, curr_count) in interfaces:
            feature_key = '{0}-{1}'.format('interface', interface_name)
            cache_key = '{0}-{1}'.format('OUTVM', feature_key)

            (prev_count, prev_time) = self._cache_get_value(cache_key)
            self._cache_put_value(cache_key, curr_count)

            if prev_count and prev_time:
                d = time.time() - prev_time
                diff = [(a - b) / d for (a, b) in zip(curr_count,
                                                      prev_count)]
            else:

                # first measurement

                diff = [0] * 6

            feature_attributes = InterfaceFeature._make(diff)

            yield (feature_key, feature_attributes, 'interface')
Example #2
0
    def crawl(self, container_id, avoid_setns=False, **kwargs):

        logger.debug('Crawling %s for container %s' %
                     (self.get_feature(), container_id))

        container = DockerContainer(container_id)

        if avoid_setns:
            raise NotImplementedError('avoidsetns mode not implemented')
        else:
            interfaces = run_as_another_namespace(
                container.pid, ['net'], self._crawl_interface_counters)

        for (ifname, curr_count) in interfaces:
            feature_key = '{0}-{1}'.format('interface', ifname)

            cache_key = '{0}-{1}-{2}'.format(container.long_id, container.pid,
                                             feature_key)

            (prev_count, prev_time) = self._cache_get_value(cache_key)
            self._cache_put_value(cache_key, curr_count)

            if prev_count and prev_time:
                d = time.time() - prev_time
                diff = [(a - b) / d for (a, b) in zip(curr_count, prev_count)]
            else:

                # first measurement

                diff = [0] * 6

            feature_attributes = InterfaceFeature._make(diff)

            yield (feature_key, feature_attributes, 'interface')
    def crawl(self, **kwargs):

        logger.debug('Crawling %s' % self.get_feature())

        interfaces = self._crawl_interface_counters()

        for (ifname, curr_count) in interfaces:
            feature_key = '{0}-{1}'.format('interface', ifname)
            cache_key = '{0}-{1}'.format('INVM', feature_key)

            (prev_count, prev_time) = self._cache_get_value(cache_key)
            self._cache_put_value(cache_key, curr_count)

            if prev_count and prev_time:
                d = time.time() - prev_time
                diff = [(a - b) / d for (a, b) in zip(curr_count,
                                                      prev_count)]
            else:

                # first measurement

                diff = [0] * 6

            feature_attributes = InterfaceFeature._make(diff)

            yield (feature_key, feature_attributes, 'interface')
Example #4
0
    def crawl(self, **kwargs):

        logger.debug('Crawling %s' % self.get_feature())

        interfaces = self._crawl_interface_counters()

        for (ifname, curr_count) in interfaces:
            feature_key = '{0}-{1}'.format('interface', ifname)
            cache_key = '{0}-{1}'.format('INVM', feature_key)

            (prev_count, prev_time) = self._cache_get_value(cache_key)
            self._cache_put_value(cache_key, curr_count)

            if prev_count and prev_time:
                d = time.time() - prev_time
                diff = [(a - b) / d for (a, b) in zip(curr_count, prev_count)]
            else:

                # first measurement

                diff = [0] * 6

            feature_attributes = InterfaceFeature._make(diff)

            yield (feature_key, feature_attributes, 'interface')
    def crawl(self, container_id, avoid_setns=False, **kwargs):

        logger.debug("Crawling %s for container %s" % (self.get_feature(), container_id))

        container = DockerContainer(container_id)

        if avoid_setns:
            raise NotImplementedError("avoidsetns mode not implemented")
        else:
            interfaces = run_as_another_namespace(container.pid, ["net"], self._crawl_interface_counters)

        for (ifname, curr_count) in interfaces:
            feature_key = "{0}-{1}".format("interface", ifname)

            cache_key = "{0}-{1}-{2}".format(container.long_id, container.pid, feature_key)

            (prev_count, prev_time) = self._cache_get_value(cache_key)
            self._cache_put_value(cache_key, curr_count)

            if prev_count and prev_time:
                d = time.time() - prev_time
                diff = [(a - b) / d for (a, b) in zip(curr_count, prev_count)]
            else:

                # first measurement

                diff = [0] * 6

            feature_attributes = InterfaceFeature._make(diff)

            yield (feature_key, feature_attributes, "interface")
Example #6
0
    def crawl(self, vm_desc, **kwargs):

        logger.debug('Crawling %s' % self.get_feature())

        if psvmi is None:
            raise NotImplementedError()
        else:
            (domain_name, kernel_version, distro, arch) = vm_desc
            # XXX: this has to be read from some cache instead of
            # instead of once per plugin/feature
            vm_context = psvmi.context_init(domain_name, domain_name,
                                            kernel_version, distro, arch)
            interfaces = self._crawl_interface_counters(vm_context)

        for (interface_name, curr_count) in interfaces:
            feature_key = '{0}-{1}'.format('interface', interface_name)
            cache_key = '{0}-{1}'.format('OUTVM', feature_key)

            (prev_count, prev_time) = self._cache_get_value(cache_key)
            self._cache_put_value(cache_key, curr_count)

            if prev_count and prev_time:
                d = time.time() - prev_time
                diff = [(a - b) / d for (a, b) in zip(curr_count, prev_count)]
            else:

                # first measurement

                diff = [0] * 6

            feature_attributes = InterfaceFeature._make(diff)

            yield (feature_key, feature_attributes, 'interface')