from cbagent.collectors import Collector


class EventingStats(Collector):

    COLLECTOR = "eventing_stats"

    def __init__(self, settings, test):
        super().__init__(settings)
        self.eventing_node = test.function_nodes[0]
        self.functions = test.functions

    def _get_processing_stats(self, function_name="perf-test1"):
        port = '25000'
        uri = "/getEventProcessingStats?name={}".format(function_name)
        samples = self.get_http(path=uri, server=self.eventing_node, port=port)
        return samples

    def sample(self):
        for name, function in self.functions.items():
            stats = self._get_processing_stats(function_name=name)
            if stats:
                self.update_metric_metadata(stats.keys(), bucket=name)
                self.store.append(stats, cluster=self.cluster,
                                  bucket=name, collector=self.COLLECTOR)

    def update_metadata(self):
        self.mc.add_cluster()

        for name, function in self.functions.items():
            self.mc.add_bucket(name)

from cbagent.collectors import Collector


class EventingStats(Collector):

    COLLECTOR = "eventing_stats"

    def __init__(self, settings, test):
        super().__init__(settings)
        self.eventing_node = test.function_nodes[0]
        self.functions = test.functions

    def _get_processing_stats(self, function_name="perf-test1"):
        port = '8096'
        uri = "/getEventProcessingStats?name={}".format(function_name)
        samples = self.get_http(path=uri, server=self.eventing_node, port=port)
        return samples

    def sample(self):
        for name, function in self.functions.items():
            stats = self._get_processing_stats(function_name=name)
            if stats:
                self.update_metric_metadata(stats.keys(), bucket=name)
                self.store.append(stats, cluster=self.cluster,
                                  bucket=name, collector=self.COLLECTOR)

    def update_metadata(self):
        self.mc.add_cluster()

        for name, function in self.functions.items():
            self.mc.add_bucket(name)

Fix port number for eventing stats
Fix port number for eventing stats

Change-Id: Ifaa7e9957f919febb1a297683077cd1c71c6aa9d
Reviewed-on: http://review.couchbase.org/84633
Tested-by: Build Bot <80754af91bfb6d1073585b046fe0a474ce868509@couchbase.com>
Reviewed-by: Mahesh Mandhare <f05f25073b6d9a2858c6a374b80c02d5a2bccf33@couchbase.com>
