Beispiel #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})
    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)
Beispiel #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})
Beispiel #4
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, ['Template Heartbeat'], ['Linux servers'])

            print 'Writing heartbeat to %s/%s' % (target['path'], myhb.filename)
            mm.write_metrics(myhb)
    def process_zabbix(target):
        """Process a Zabbix target

        Args:
            target: the config file portion for this specific target.

        Returns: None
        """

        mm = MetricManager(target['path'])
        zbxapi = SimpleZabbix(
            url=target['api_url'],
            user=target['api_user'],
            password=target['api_password'],
        )

        zbxsender = ZabbixSender(target['trapper_server'],
                                 target['trapper_port'])

        hostname = socket.gethostname()
        zmp = ZabbixMetricProcessor(mm,
                                    zbxapi,
                                    zbxsender,
                                    hostname,
                                    verbose=True)
        return zmp.process_zbx_metrics()
    def process_zagg(target):
        """Process a Zagg target

        Args:
            target: the config file portion for this specific target.

        Returns: None
        """

        verify = target.get('ssl_verify', False)

        if isinstance(verify, str):
            verify = (verify == 'True')

        mm = MetricManager(target['path'])
        zagg_conn = ZaggConnection(
            url=target['url'],
            user=target['user'],
            password=target['password'],
            ssl_verify=verify,
        )
        zc = ZaggClient(zagg_conn)

        zmp = ZaggMetricProcessor(mm, zc)
        zmp.process_metrics()
    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['name'])

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

            print 'Writing heartbeat to %s' % (target['name'])
            mm.write_metrics(myhb)
Beispiel #9
0
def process_metric():
    ''' Receive POSTs to the '/metric' URL endpoint and
        process/save them '''
    if request.method == 'POST':
        json = request.get_json()

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

        return jsonify({"success": True})

    else:
        flask_app.logger.error('Unexpectedly received non-POST request (GET?)')
        return jsonify({"success": False})
Beispiel #10
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})
Beispiel #11
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})