public void Enqueue(Point[] points)
        {
            foreach (var config in _configBusiness.OpenDatabaseConfig())
            {
                IFormatter formatter;
                try
                {
                    var agent = _influxDbAgentLoader.GetAgent(config);
                    var agentInfo = agent.GetAgentInfo();
                    formatter = agentInfo.Item1;
                    _outputMessage("Send to " + config.Url + " ver " + agentInfo.Item2, OutputLevel.Information);
                }
                catch (InvalidOperationException)
                {
                    var ifx = new InfluxDb("http://influx-capacitor.com", "-", "-", InfluxVersion.v09x);
                    formatter = ifx.GetFormatter();
                    _outputMessage("Unknown client version, simulation output for version " + ifx.GetClientVersion() + ".", OutputLevel.Warning);
                }

                foreach (var point in points)
                {
                    _outputMessage(formatter.PointToString(point), OutputLevel.Information);
                }
            }
        }
Example #2
0
        public KafkaAgent(Uri[] kafkaServers)
        {
            var options = new KafkaOptions(kafkaServers);
            _router = new BrokerRouter(options);

            var influxDbClient = new InfluxDb("http://localhost", "reapadda", "qwerty", InfluxVersion.v09x);
            _formatter = influxDbClient.GetFormatter();
        }
Example #3
0
        public InfluxDbAgent(IDatabaseConfig databaseConfig)
        {
            _databaseConfig = databaseConfig;

            Uri result;
            if (!Uri.TryCreate(_databaseConfig.Url, UriKind.Absolute, out result))
            {
                var exp = new InvalidOperationException("Unable to parse provided connection as url.");
                exp.Data.Add("Url", databaseConfig.Url);
                throw exp;
            }

            try
            {
                _influxDb = new InfluxDb(_databaseConfig.Url, _databaseConfig.Username, _databaseConfig.Password, InfluxVersion.Auto);
            }
            catch (Exception exception)
            {
                var exp = new InvalidOperationException("Could not establish a connection to the database.", exception);
                exp.Data.Add("Url", databaseConfig.Url);
                exp.Data.Add("Username", databaseConfig.Username);
                throw exp;
            }
        }
 public InfluxDbProviderV8()
 {
     _influxDbClient = new InfluxDb(_influxDbUri, _influxDbUserName, _influxDbPassword);
 }
Example #5
0
    void SendBatch()
    {
        std::stringstream batchedData;
        MetricData data;
        bool firstLoop = true;
        while (_queuedData.Dequeue(data))
        {
            if (!firstLoop)
                batchedData << "\n";

            batchedData << data.Category;
            if (!_realmName.empty())
                batchedData << ",realm=" << _realmName;

            batchedData << " ";

            switch (data.Type)
            {
                case METRIC_DATA_VALUE:
                    batchedData << "value=" << data.Value;
                    break;
                case METRIC_DATA_EVENT:
                    batchedData << "title=\"" << data.Title << "\",text=\"" << data.Text << "\"";
                    break;
            }

            batchedData << " ";

            batchedData << std::to_string(duration_cast<nanoseconds>(data.Timestamp.time_since_epoch()).count());

            firstLoop = false;
            delete data;
        }

        // Check if there's any data to send
        if (batchedData.tellp() == std::streampos(0))
        {
            ScheduleSend();
            return;
        }

        if (!_dataStream.good() && !Connect())
            return;

        var blah = new InfluxDB.Net.InfluxDb(_hostname, "root", "root", InfluxDB.Net.Enums.InfluxVersion.v010x);
        InfluxDB.Net.Models.Serie b = new InfluxDB.Net.Models.Serie();
        b.Columns
        _dataStream.UploadString( << "POST " << "/write?db=" << _databaseName << " HTTP/1.1\r\n";
        _dataStream << "Host: " << _hostname << ":" << _port << "\r\n";
        _dataStream << "Accept: */*\r\n";
        _dataStream << "Content-Type: application/octet-stream\r\n";
        _dataStream << "Content-Transfer-Encoding: binary\r\n";

        _dataStream << "Content-Length: " << std::to_string(batchedData.tellp()) << "\r\n\r\n";
        _dataStream << batchedData.rdbuf();

        std::string http_version;
        _dataStream >> http_version;
        unsigned int status_code = 0;
        _dataStream >> status_code;
        if (status_code != 204)
        {
            TC_LOG_ERROR("metric", "Error sending data, returned HTTP code: %u", status_code);
        }

        // Read and ignore the status description
        std::string status_description;
        std::getline(_dataStream, status_description);
        // Read headers
        std::string header;
        while (std::getline(_dataStream, header) && header != "\r")
        {
            if (header == "Connection: close\r")
                _dataStream.close();
        }

        ScheduleSend();
    }
Example #6
-1
        public InfluxDbAgent(string url, string databaseName, string userName, string password, TimeSpan? requestTimeout, InfluxVersion influxVersion = InfluxVersion.Auto)
        {
            _databaseName = databaseName;
            _userName = userName;
            _password = password;

            Uri result;
            if (!Uri.TryCreate(url, UriKind.Absolute, out result))
            {
                var exp = new InvalidOperationException("Unable to parse provided connection as url.");
                exp.Data.Add("Url", url);
                throw exp;
            }

            try
            {
                _influxDb = new InfluxDb(url, userName, password, influxVersion, requestTimeout);
            }
            catch (Exception exception)
            {
                var exp = new InvalidOperationException("Could not establish a connection to the database.", exception);
                exp.Data.Add("Url", url);
                exp.Data.Add("Username", userName);
                throw exp;
            }
        }