Exemple #1
0
    def runpreproccall(preproc, result, mtypes, ctx, mdata, description):

        data = []
        for i in xrange(result.contents.numpmid):
            data.append(numpy.array([pcpfast.pcpfastExtractValues(result, i, j, mtypes[i])
                                     for j in xrange(result.contents.get_numval(i))]))

        return preproc.process(float(result.contents.timestamp), data, description)
Exemple #2
0
    def runcallback(self, analytic, result, mtypes, ctx, mdata, metric_id_array):
        """ get the data and call the analytic """

        if self.indomcache == None:
            # First time through populate the indom cache
            self.indomcache = self.getindomdict(ctx, metric_id_array)
            if self.indomcache == None:
                # Unable to get indom information
                return False

        data = []
        description = []

        for i in xrange(result.contents.numpmid):
            ninstances = result.contents.get_numval(i)
            if ninstances < 0:
                logging.warning("%s %s ninstances = %s @ %s", mdata.nodename, analytic.name, ninstances, float(result.contents.timestamp))
                self.logerror(mdata.nodename, analytic.name, "get_numval() error")
                return False

            tmp = numpy.empty(ninstances, dtype=self.pcptypetonumpy(mtypes[i]))
            tmpnames = []
            tmpidx = numpy.empty(ninstances, dtype=long)

            for j in xrange(ninstances):
                pcpdata = pcpfast.pcpfastExtractValues(result, i, j, mtypes[i])
                tmp[j] = pcpdata[0]
                if pcpdata[1] > -1:
                    tmpidx[j] = pcpdata[1]
                    if pcpdata[1] not in self.indomcache[i]:
                        # indoms must have changed; rebuild the cache
                        self.indomcache = self.getindomdict(ctx, metric_id_array)
                        if self.indomcache == None:
                            return False
                    if pcpdata[1] not in self.indomcache[i]:
                        # Unable to get indom information for one of the instance domains
                        # Ignore this timestep, but carry on
                        logging.warning("%s %s missing indom @ %s", mdata.nodename, analytic.name, float(result.contents.timestamp))
                        self.logerror(mdata.nodename, analytic.name, "missing indom")
                        return True
                    tmpnames.append(self.indomcache[i][pcpdata[1]])

            data.append(tmp)
            description.append([tmpidx, tmpnames])

        try:
            retval = analytic.process(mdata, float(result.contents.timestamp), data, description)
            return retval
        except Exception as e:
            logging.exception("%s %s @ %s", self.job.job_id, analytic.name, float(result.contents.timestamp))
            self.logerror(mdata.nodename, analytic.name, str(e))
            return False
Exemple #3
0
    def runpreproccall(self, preproc, result, mtypes, ctx, mdata, metric_id_array):
        """ Call the pre-processor data processing function """

        description = self.getindomdict(ctx, metric_id_array)
        if description == None:
            return True

        data = []
        for i in xrange(result.contents.numpmid):
            data.append(numpy.array([pcpfast.pcpfastExtractValues(result, i, j, mtypes[i])
                                     for j in xrange(result.contents.get_numval(i))]))

        return preproc.process(float(result.contents.timestamp), data, description)
Exemple #4
0
    def runcallback(self, analytic, result, mtypes, ctx, mdata, description):

        data = []
        for i in xrange(result.contents.numpmid):
            data.append(numpy.array([pcpfast.pcpfastExtractValues(result, i, j, mtypes[i])[0]
                                     for j in xrange(result.contents.get_numval(i))]))

        try:
            retval = analytic.process(mdata, float(result.contents.timestamp), data, description)
            return retval
        except Exception as e:
            logging.exception("%s %s @ %s", self.job.job_id, analytic.name, float(result.contents.timestamp))
            self.logerror(mdata.nodename, analytic.name, str(e))
            return False
Exemple #5
0
    def runpreproccall(self, preproc, result, mtypes, ctx, mdata,
                       metric_id_array):
        """ Call the pre-processor data processing function """

        description = self.getindomdict(ctx, metric_id_array)
        if description == None:
            return True

        data = []
        for i in xrange(result.contents.numpmid):
            data.append(
                numpy.array([
                    pcpfast.pcpfastExtractValues(result, i, j, mtypes[i])
                    for j in xrange(result.contents.get_numval(i))
                ]))

        return preproc.process(float(result.contents.timestamp), data,
                               description)
Exemple #6
0
    def runcallback(self, analytic, result, mtypes, ctx, mdata,
                    metric_id_array):
        """ get the data and call the analytic """

        if self.indomcache == None:
            # First time through populate the indom cache
            self.indomcache = self.getindomdict(ctx, metric_id_array)
            if self.indomcache == None:
                # Unable to get indom information
                return False

        data = []
        description = []

        for i in xrange(result.contents.numpmid):
            ninstances = result.contents.get_numval(i)
            if ninstances < 0:
                logging.warning("%s %s ninstances = %s @ %s", mdata.nodename,
                                analytic.name, ninstances,
                                float(result.contents.timestamp))
                self.logerror(mdata.nodename, analytic.name,
                              "get_numval() error")
                return False

            tmp = numpy.empty(ninstances, dtype=self.pcptypetonumpy(mtypes[i]))
            tmpnames = []
            tmpidx = numpy.empty(ninstances, dtype=long)

            for j in xrange(ninstances):
                pcpdata = pcpfast.pcpfastExtractValues(result, i, j, mtypes[i])
                tmp[j] = pcpdata[0]
                if pcpdata[1] > -1:
                    tmpidx[j] = pcpdata[1]
                    if pcpdata[1] not in self.indomcache[i]:
                        # indoms must have changed; rebuild the cache
                        self.indomcache = self.getindomdict(
                            ctx, metric_id_array)
                        if self.indomcache == None:
                            return False
                    if pcpdata[1] not in self.indomcache[i]:
                        # Unable to get indom information for one of the instance domains
                        # Ignore this timestep, but carry on
                        logging.warning("%s %s missing indom @ %s",
                                        mdata.nodename, analytic.name,
                                        float(result.contents.timestamp))
                        self.logerror(mdata.nodename, analytic.name,
                                      "missing indom")
                        return True
                    tmpnames.append(self.indomcache[i][pcpdata[1]])

            data.append(tmp)
            description.append([tmpidx, tmpnames])

        try:
            self.rangechange.normalise_data(float(result.contents.timestamp),
                                            data)
            retval = analytic.process(mdata, float(result.contents.timestamp),
                                      data, description)
            return retval
        except Exception as e:
            logging.exception("%s %s @ %s", self.job.job_id, analytic.name,
                              float(result.contents.timestamp))
            self.logerror(mdata.nodename, analytic.name, str(e))
            return False