Пример #1
0
    def post(self, request, *args, **kwargs):
        """
        implementation of the REST GET method
        """
        new_metric = UniqueMetric.from_request(request.data)
        mymm = MetricManager('/tmp/metrics')
        mymm.write_metrics(new_metric)

        return Response({"success": True})
Пример #2
0
    def add_heartbeat(self, heartbeat, host=None):
        """ create a heartbeat unique metric to send to zagg """

        if not host:
            host = self.host

        hb_metric = UniqueMetric.create_heartbeat(host,
                                                  heartbeat.templates,
                                                  heartbeat.hostgroups,
                                                 )
        self.unique_metrics.append(hb_metric)
Пример #3
0
    def post(self, request, *args, **kwargs):
        """
        implementation of the REST GET method
        """

        config_file = '/etc/openshift_tools/zagg_server.yaml'
        config = yaml.load(file(config_file))

        for target in config['targets']:
            new_metric = UniqueMetric.from_request(request.data)
            mymm = MetricManager(target['path'])
            mymm.write_metrics(new_metric)

        return Response({"success": True})
    def run(self):
        """Runs through each defined target in the config file and sends a heartbeat

        Args: None
        Returns: None
        """
        for target in self.config["targets"]:
            mm = MetricManager(target["path"])

            hostname = socket.gethostname()
            myhb = UniqueMetric.create_heartbeat(hostname, self.config["templates"], self.config["hostgroups"])

            print "Writing heartbeat to %s/%s" % (target["path"], myhb.filename)
            mm.write_metrics(myhb)
    def run(self):
        """Runs through each defined target in the config file and sends a heartbeat

        Args: None
        Returns: None
        """
        for target in self.config['targets']:
            mm = MetricManager(target['path'])

            hostname = socket.gethostname()
            myhb = UniqueMetric.create_heartbeat(hostname, ['Template Heartbeat'], ['Linux servers'])

            print 'Writing heartbeat to %s/%s' % (target['path'], myhb.filename)
            mm.write_metrics(myhb)
Пример #6
0
def process_metric():
    ''' Receive POSTs to the '/metric' URL endpoint and
        process/save them '''
    if request.method == 'POST':
        config_file = '/etc/openshift_tools/zagg_server.yaml'
        config = yaml.load(file(config_file))

        json = request.get_json()

        for target in config['targets']:
            new_metric = UniqueMetric.from_request(json)
            mymm = MetricManager(target['path'])
            mymm.write_metrics(new_metric)

        return jsonify({"success": True})

    else:
        flask_app.logger.error('Unexpectedly received non-POST request (GET?)')
        return jsonify({"success": False})