Example #1
0
    def metric(self, name):
        """Return the value of a metric.

        Performs a calculation on the metric across all HAProxy processes.
        The type of calculation is either sum or avg and defined in
        :data:`haproxyadmin.utils.METRICS_SUM` and
        :data:`haproxyadmin.utils.METRICS_AVG`.

        :param name: The name of the metric
        :type name: any of :data:`haproxyadmin.haproxy.SERVER_METRICS`
        :rtype: number, integer
        :raise: ``ValueError`` when a given metric is not found
        """
        if name not in SERVER_METRICS:
            raise ValueError("{} is not valid metric".format(name))

        metrics = [x.metric(name) for x in self._server_per_proc]
        # num_metrics = filter(None, map(converter, metrics))
        metrics[:] = (converter(x) for x in metrics)
        metrics[:] = (x for x in metrics if x is not None)

        return calculate(name, metrics)
Example #2
0
    def metric(self, name):
        """Return the value of a metric.

        Performs a calculation on the metric across all HAProxy processes.
        The type of calculation is either sum or avg and defined in
        :data:`haproxyadmin.utils.METRICS_SUM` and
        :data:`haproxyadmin.utils.METRICS_AVG`.

        :param name: metric name to retrieve
        :type name: any of :data:`haproxyadmin.haproxy.HAPROXY_METRICS`
        :return: value of the metric
        :rtype: ``integer``
        :raise: ``ValueError`` when a given metric is not found
        """
        if name not in HAPROXY_METRICS:
            raise ValueError("{} is not valid metric".format(name))

        metrics = [x.metric(name) for x in self._hap_processes]
        metrics[:] = (converter(x) for x in metrics)
        metrics[:] = (x for x in metrics if x is not None)

        return calculate(name, metrics)
Example #3
0
    def metric(self, name):
        """Return the value of a metric.

        Performs a calculation on the metric across all HAProxy processes.
        The type of calculation is either sum or avg and defined in
        :data:`haproxyadmin.utils.METRICS_SUM` and
        :data:`haproxyadmin.utils.METRICS_AVG`.

        :param name: The name of the metric
        :type name: any of :data:`haproxyadmin.haproxy.SERVER_METRICS`
        :rtype: number, integer
        :raise: ``ValueError`` when a given metric is not found
        """
        if name not in SERVER_METRICS:
            raise ValueError("{} is not valid metric".format(name))

        metrics = [x.metric(name) for x in self._server_per_proc]
        # num_metrics = filter(None, map(converter, metrics))
        metrics[:] = (converter(x) for x in metrics)
        metrics[:] = (x for x in metrics if x is not None)

        return calculate(name, metrics)
Example #4
0
    def metric(self, name):
        """Return the value of a metric.

        Performs a calculation on the metric across all HAProxy processes.
        The type of calculation is either sum or avg and defined in
        :data:`haproxyadmin.utils.METRICS_SUM` and
        :data:`haproxyadmin.utils.METRICS_AVG`.

        :param name: metric name to retrieve
        :type name: any of :data:`haproxyadmin.haproxy.HAPROXY_METRICS`
        :return: value of the metric
        :rtype: ``integer``
        :raise: ``ValueError`` when a given metric is not found
        """
        if name not in HAPROXY_METRICS:
            raise ValueError("{} is not valid metric".format(name))

        metrics = [x.metric(name) for x in self._hap_processes]
        metrics[:] = (converter(x) for x in metrics)
        metrics[:] = (x for x in metrics if x is not None)

        return calculate(name, metrics)
Example #5
0
    def metric(self, name):
        """Return the value of a metric.

        Performs a calculation on the metric across all HAProxy processes.
        The type of calculation is either sum or avg and defined in
        utils.METRICS_SUM and utils.METRICS_AVG.

        :param name: Name of the metric, any of BACKEND_METRICS
        :type name: ``string``
        :return: Value of the metric after the appropriate calculation
          has been performed.
        :rtype: number, either ``integer`` or ``float``.
        :raise: ValueError when a given metric is not found.
        """
        metrics = []
        if name not in BACKEND_METRICS:
            raise ValueError("{} is not valid metric".format(name))

        metrics = [x.metric(name) for x in self._backend_per_proc]
        metrics[:] = (converter(x) for x in metrics)
        metrics[:] = (x for x in metrics if x is not None)

        return calculate(name, metrics)
Example #6
0
    def metric(self, name):
        """Return the value of a metric.

        Performs a calculation on the metric across all HAProxy processes.
        The type of calculation is either sum or avg and defined in
        utils.METRICS_SUM and utils.METRICS_AVG.

        :param name: Name of the metric, any of BACKEND_METRICS
        :type name: ``string``
        :return: Value of the metric after the appropriate calculation
          has been performed.
        :rtype: number, either ``integer`` or ``float``.
        :raise: ValueError when a given metric is not found.
        """
        metrics = []
        if name not in BACKEND_METRICS:
            raise ValueError("{} is not valid metric".format(name))

        metrics = [x.metric(name) for x in self._backend_per_proc]
        metrics[:] = (converter(x) for x in metrics)
        metrics[:] = (x for x in metrics if x is not None)

        return calculate(name, metrics)