Exemplo n.º 1
0
        private static async Task WriteDataToInfluxDb()
        {
            try
            {
                AIO_Values values = await FetchValuesFromAIO();

                //first the current data point
                bool success = await influxClient.CreateDatabaseAsync(influxDbName);  //create db if not exist

                if (success)
                {
                    await CreateRetentionPolicy();                                       // craete retention policy for minute data points if not exists

                    var point  = CreateInfluxSeries(values);                             //create the influx point
                    var result = await influxClient.PostPointAsync(influxDbName, point); //save the data point

                    Console.Write("Wrote point to influx db");
                }
                //Now the longterm data
                success = await influxClient.CreateDatabaseAsync(influxDbNameLongterm);  //create longeterm db if not exist

                if (success)
                {
                    await CreateRetentionPolicyLongterm();

                    MonthlyValues monthlyValues = await GetCurrentMonthAggregation();  //check if we already have aggregations for the last month and year
                    await InsertMonthlyValues(monthlyValues);
                }
            }
            catch (Exception ex)
            {
                Console.Write(ex.Message);
            }
        }
Exemplo n.º 2
0
        private static async Task <bool> VerifyDatabaseAsync(InfluxDBClient client, string DBName)
        {
            try
            {
                //verify DB exists, create if not
                var dbNames = await client.GetInfluxDBNamesAsync();

                if (dbNames.Contains(DBName))
                {
                    return(true);
                }
                else
                {
                    var filter = settings.FileFormat == FileFormats.Perfmon ? settings.PerfmonFile.Filter : settings.GenericFile.Filter;
                    if (filter == Filters.Measurement || filter == Filters.Field)
                    {
                        Logger.LogLine(LogLevel.Info, "Measurement/Field filtering is not applicable for new database!!");
                        filter = Filters.None;
                    }
                    return(await client.CreateDatabaseAsync(DBName));
                }
            }
            catch (Exception e)
            {
                Logger.LogLine(LogLevel.Info, "Unexpected exception of type {0} caught: {1}",
                               e.GetType(), e.Message);
            }
            return(false);
        }
Exemplo n.º 3
0
 public void DeleteInfluxDatabaseTest()
 {
     using (InfluxDBClient client = new InfluxDBClient(influxUrl, dbUName, dbpwd))
     {
         TimeMonitor.Watch(nameof(TestGetInfluxDBNames), () =>
         {
             client.CreateDatabaseAsync(dbName);
             var dbNames = client.GetInfluxDBNamesAsync().Result;
             var temp    = dbNames;
         }, output.WriteLine);
     }
 }
Exemplo n.º 4
0
        public async Task <InfluxDBClient> GetDatabaseClient()
        {
            InfluxDBClient client    = new InfluxDBClient(connectionString, user, password);
            List <string>  databases = await client.GetInfluxDBNamesAsync();

            if (!databases.Contains(DatabaseName))
            {
                await client.CreateDatabaseAsync(DatabaseName);
            }

            return(client);
        }
        public async Task TestDropDatabaseAsync()
        {
            var db     = "hara-kiri";
            var client = new InfluxDBClient(influxUrl, dbUName, dbpwd);
            var r      = await client.CreateDatabaseAsync(db);

            Assert.IsTrue(r, "CreateDatabaseAsync retunred false");
            var d = new InfluxDatabase(db);

            r = await client.DropDatabaseAsync(d);

            Assert.IsTrue(r && d.Deleted, "DropDatabaseAsync retunred false");
        }
Exemplo n.º 6
0
        public bool EnsureDatabase(string databaseName)
        {
            var dbs = _influxDbClient.GetInfluxDBNamesAsync().Result;

            if (dbs.Any(x => x.Equals(databaseName, StringComparison.InvariantCulture)))
            {
                _logger.Debug("Database {0} already exists. Nothing to do.", databaseName);
                return(false);
            }
            else
            {
                _logger.Info("Database {0} does not exists. DB will be created.", databaseName);
                return(_influxDbClient.CreateDatabaseAsync(databaseName).Result);
            }
        }
Exemplo n.º 7
0
        private static async Task <InfluxDBClient> GetClientAsync(InfluxerConfigSection settings)
        {
            var client  = new InfluxDBClient(settings.InfluxDB.InfluxUri, settings.InfluxDB.UserName, settings.InfluxDB.Password);
            var dbNames = await client.GetInfluxDBNamesAsync();

            if (dbNames.Contains(settings.InfluxDB.DatabaseName))
            {
                return(client);
            }
            else
            {
                await client.CreateDatabaseAsync(settings.InfluxDB.DatabaseName);

                return(client);
            }
        }
Exemplo n.º 8
0
        //const string invalidInfluxUrl = "http://xyzerty:8089";
        public static void Test()
        {
            try
            {
                var client = new InfluxDBClient(influxUrl, dbUName, dbpwd);

                bool isSuc = client.CreateDatabaseAsync(dbName).GetAwaiter().GetResult();

                long      timeStamp = DateTimeOffset.Now.ToUnixTimeMilliseconds();
                int       totalNum  = 10;
                Stopwatch sw        = new Stopwatch();
                sw.Start();

                Random rdm    = new Random();
                var    points = new List <IInfluxDatapoint>();
                for (int i = 0; i < totalNum; i++)
                {
                    var firstPoint = new InfluxDatapoint <double>();
                    firstPoint.Timestamp = Convert.ToInt64(timeStamp.ToString() + i.ToString().PadLeft(6, '0'));
                    firstPoint.Tags.Add("exchangecode", "okex");
                    firstPoint.Tags.Add("pair1", "btc");
                    firstPoint.Tags.Add("pair2", "usdt");

                    firstPoint.Fields.Add("o", DataGen.RandomDouble());
                    firstPoint.Fields.Add("h", DataGen.RandomDouble());
                    firstPoint.Fields.Add("l", DataGen.RandomDouble());
                    firstPoint.Fields.Add("c", DataGen.RandomDouble());
                    firstPoint.MeasurementName = measurementName;
                    firstPoint.Precision       = TimePrecision.Nanoseconds;
                    points.Add(firstPoint);
                }


                client.PostPointsAsync(dbName, points).GetAwaiter().GetResult();

                Console.WriteLine(string.Format("批量插入{0}条数据耗时:{1}毫秒", totalNum, sw.ElapsedMilliseconds));

                sw.Stop();
            }
            catch (Exception ex)
            {
                Console.WriteLine("error " + ex.Message);
            }
        }
        public async Task TestCreateDatabaseAsync()
        {
            try
            {
                var client = new InfluxDBClient(influxUrl, dbUName, dbpwd);
                var r      = await client.CreateDatabaseAsync(dbName);

                Assert.IsTrue(r, "CreateDatabaseAsync retunred false");
            }
            catch (InvalidOperationException e)
            {
                Assert.IsTrue(e.Message == "database already exists");
            }
            catch (Exception e)
            {
                Assert.Fail($"Unexpected exception of type {e.GetType()} caught: {e.Message}");
                return;
            }
        }
        public async Task TestDeletePointsAsync()
        {
            var measurement = "hara-kiri-half";
            var client      = new InfluxDBClient(influxUrl, dbUName, dbpwd);
            await client.CreateDatabaseAsync(dbName);

            var points = await CreateTestPoints(measurement, 10);

            points.Skip(5).Select(p => { p.Tags.Add("purge", "'yes'"); return(true); });
            var r = await client.PostPointsAsync(dbName, points);

            r = await client.DeletePointsAsync(
                new InfluxDatabase(dbName),
                new InfluxMeasurement(measurement),
                whereClause : new List <string>()
            {
                "purge = yes",
                $"time() > {DateTime.UtcNow.AddDays(-4).ToEpoch(TimePrecision.Hours)}"
            });

            Assert.IsTrue(r, "DropMeasurementAsync retunred false");
        }
Exemplo n.º 11
0
        /// <summary>
        /// 创建数据库和对应的数据保留策略
        /// </summary>
        /// <param name="dbName"></param>
        private async Task CreateDatabaseAndRetentionPolicyAsync(string dbName)
        {
            //新建数据库,如果数据库已存在也会成功
            _logger.LogDebug($"检查数据库 {dbName}");
            await influxClient.CreateDatabaseAsync(dbName);

            //新建保留策略
            string rpName = GenerateRpName(dbName);//生成约定的保留策略名称

            _logger.LogDebug($"检查保留策略 {rpName}");
            var rp = new InfluxRetentionPolicy()
            {
                Name      = rpName,
                DBName    = dbName,
                Duration  = TimeSpan.FromHours(_influxRetentionHours),
                IsDefault = true
            };

            if (!await influxClient.CreateRetentionPolicyAsync(rp))
            {
                throw new InvalidOperationException($"为 {dbName} 创建保留策略失败,策略名称:{rpName},保留时长:{_influxRetentionHours}小时");
            }
        }
 public async Task TestCreateDatabaseAsync_InvalidName()
 {
     var client = new InfluxDBClient(influxUrl, dbUName, dbpwd);
     var r      = await AssertEx.ThrowsAsync <InfluxDBException>(() => client.CreateDatabaseAsync(invalidDbName));
 }
Exemplo n.º 13
0
        static void Main(string[] args)
        {
            string sSource;
            string sLog;
            string sEvent;

            sSource = "AwesomeMiner2InfluxDb";
            sLog    = "Application";

            if (!EventLog.SourceExists(sSource))
            {
                EventLog.CreateEventSource(sSource, sLog);
            }

            try
            {
                var appSettings = ConfigurationManager.AppSettings;
                var host        = appSettings["Host"];
                var minerId     = appSettings["MinerId"];
                var url         = $"http://{host}/api/miners/{minerId}";
                var request     = WebRequest.Create(url);
                request.ContentType = "application/json; charset=utf-8";
                string text;
                var    response = (HttpWebResponse)request.GetResponse();
                Console.WriteLine("Reading json data from AwesomeMiner api");
                using (var sr = new StreamReader(response.GetResponseStream()))
                {
                    text = sr.ReadToEnd();
                }

                AwesomeInfo awesomeInfo = Newtonsoft.Json.JsonConvert.DeserializeObject <AwesomeInfo>(text);
                Console.WriteLine("Json received and parsed");
                var influxUrl    = appSettings["InfluxDbHost"];
                var influxDbName = appSettings["InfluxDbName"];

                Console.WriteLine($"Connecting to Influxdb @ {influxUrl} DBName: {influxDbName}");
                InfluxDBClient client = new InfluxDBClient($"http://{influxUrl}");
                client.CreateDatabaseAsync(influxDbName).Wait();
                var utcNow   = DateTime.UtcNow;
                var valMixed = new InfluxDatapoint <InfluxValueField>();
                valMixed.UtcTimestamp = utcNow;
                valMixed.Tags.Add("MinerId", awesomeInfo.id.ToString());
                valMixed.Tags.Add("Algo", awesomeInfo.coinInfo.displayName);
                valMixed.Tags.Add("Pool", awesomeInfo.poolList[0].name);
                var hashRate       = awesomeInfo.speedInfo.hashrate.Substring(0, awesomeInfo.speedInfo.hashrate.IndexOf(" "));
                var hashRateDouble = double.Parse(hashRate);
                valMixed.Fields.Add("HashRate", new InfluxValueField(hashRateDouble));
                var profitPerday    = double.Parse(awesomeInfo.coinInfo.profitPerDay.Substring(1));
                var profitPerMonth  = double.Parse(awesomeInfo.coinInfo.profitPerMonth.Substring(1));
                var revenuePerDay   = double.Parse(awesomeInfo.coinInfo.revenuePerDay.Substring(1));
                var revenuePerMonth = double.Parse(awesomeInfo.coinInfo.revenuePerMonth.Substring(1));
                valMixed.Fields.Add("ProfitPerDay", new InfluxValueField(profitPerday));
                valMixed.Fields.Add("ProfitPerMonth", new InfluxValueField(profitPerMonth));
                valMixed.Fields.Add("RevenuePerDay", new InfluxValueField(revenuePerDay));
                valMixed.Fields.Add("RevenuePerMonth", new InfluxValueField(revenuePerMonth));


                valMixed.MeasurementName = $"Miner.{awesomeInfo.id}";

                Console.WriteLine("Trying to write miner data to DB");
                client.PostPointAsync(influxDbName, valMixed).Wait();
                EventLog.WriteEntry(sSource, "Miner data written successfully", EventLogEntryType.Information);
                Console.WriteLine("Miner data written successfully");

                foreach (var gpuInfo in awesomeInfo.gpuList)
                {
                    var gpuToInflux = new InfluxDatapoint <InfluxValueField>();
                    gpuToInflux.UtcTimestamp = utcNow;
                    gpuToInflux.Tags.Add("GPUName", gpuInfo.name);
                    gpuToInflux.Fields.Add("Temperature", new InfluxValueField(gpuInfo.deviceInfo.temperature));
                    gpuToInflux.Fields.Add("FanPercent", new InfluxValueField(gpuInfo.deviceInfo.fanPercent));
                    gpuToInflux.Fields.Add("FanSpeed", new InfluxValueField(gpuInfo.deviceInfo.fanSpeed));
                    gpuToInflux.Fields.Add("GpuClock", new InfluxValueField(gpuInfo.deviceInfo.gpuClock));
                    gpuToInflux.Fields.Add("MemoryClock", new InfluxValueField(gpuInfo.deviceInfo.gpuMemoryClock));
                    var intensity = double.Parse(gpuInfo.deviceInfo.intensity);
                    gpuToInflux.Fields.Add("Intensity", new InfluxValueField(intensity));
                    var gpuHashrate       = gpuInfo.speedInfo.hashrate.Substring(0, gpuInfo.speedInfo.hashrate.IndexOf(" "));
                    var gpuHashrateDouble = double.Parse(gpuHashrate);
                    gpuToInflux.Fields.Add("Speed", new InfluxValueField(gpuHashrateDouble));

                    gpuToInflux.MeasurementName = gpuInfo.name.Replace(' ', '_');

                    Console.WriteLine("Trying to write GPU info to DB");
                    client.PostPointAsync(influxDbName, gpuToInflux).Wait();
                    Console.WriteLine("GPU info written successfully");
                }
            }
            catch (Exception e)
            {
                // Console.WriteLine(e);
                EventLog.WriteEntry(sSource, e.Message, EventLogEntryType.Error);
            }
        }
Exemplo n.º 14
0
        async public static Task Init()
        {
            int count2 = dataClass.countOfElements / 100;
            int count  = ((dataClass.countOfDays + 100) / 100);
            //====================================================================================Коннект в бд============
            string         nameDB = "Process";
            InfluxDBClient client = new InfluxDBClient("http://localhost:8086", "root", "root");
            await client.CreateDatabaseAsync(nameDB);

            InfluxDatabase name = new InfluxDatabase(nameDB);
            var            m    = await client.DropDatabaseAsync(name);

            await client.CreateDatabaseAsync(nameDB);

            for (int i = 0; i < dataClass.countOfDays; i++)
            {
                var valMixed1 = new InfluxDatapoint <InfluxValueField>();
                var valMixed2 = new InfluxDatapoint <InfluxValueField>();
                var valMixed3 = new InfluxDatapoint <InfluxValueField>();
                var valMixed4 = new InfluxDatapoint <InfluxValueField>();
                var valMixed5 = new InfluxDatapoint <InfluxValueField>();
                valMixed1.UtcTimestamp    = rmseClass.rmseDates[i].ToUniversalTime();
                valMixed2.UtcTimestamp    = rmseClass.rmseDates[i].ToUniversalTime();
                valMixed3.UtcTimestamp    = rmseClass.rmseDates[i].ToUniversalTime();
                valMixed4.UtcTimestamp    = rmseClass.rmseDates[i].ToUniversalTime();
                valMixed5.UtcTimestamp    = rmseClass.rmseDates[i].ToUniversalTime();
                valMixed1.MeasurementName = "RmseValuesForAlgOne";
                valMixed2.MeasurementName = "RmseValuesForAlgTwo";
                valMixed3.MeasurementName = "RmseValuesForAlgThree";
                valMixed4.MeasurementName = "RmseValuesForAlgFour";
                valMixed5.MeasurementName = "RmseValuesForAlgFive";
                double[] values = new double[5];
                values[0] = rmseClass.ValuesRMSE1[i];
                values[1] = rmseClass.ValuesRMSE2[i];
                values[2] = rmseClass.ValuesRMSE3[i];
                values[3] = rmseClass.ValuesRMSE4[i];
                values[4] = rmseClass.ValuesRMSE5[i];
                valMixed1.Fields.Add("value", new InfluxValueField(values[0]));
                valMixed2.Fields.Add("value", new InfluxValueField(values[1]));
                valMixed3.Fields.Add("value", new InfluxValueField(values[2]));
                valMixed4.Fields.Add("value", new InfluxValueField(values[3]));
                valMixed5.Fields.Add("value", new InfluxValueField(values[4]));
                var r = await client.PostPointAsync(nameDB, valMixed1);

                var s = await client.PostPointAsync(nameDB, valMixed2);

                var t = await client.PostPointAsync(nameDB, valMixed3);

                var u = await client.PostPointAsync(nameDB, valMixed4);

                var f = await client.PostPointAsync(nameDB, valMixed5);

                label.Text = $"Запись значений RMSE (Выполнено {i/count}%)";
            }
            for (int i = 0; i < dataClass.countOfElements; i++)
            {
                var valMixed6  = new InfluxDatapoint <InfluxValueField>();
                var valMixed7  = new InfluxDatapoint <InfluxValueField>();
                var valMixed8  = new InfluxDatapoint <InfluxValueField>();
                var valMixed9  = new InfluxDatapoint <InfluxValueField>();
                var valMixed10 = new InfluxDatapoint <InfluxValueField>();
                var valMixed11 = new InfluxDatapoint <InfluxValueField>();
                valMixed6.UtcTimestamp     = dataClass.famousDates[i].ToUniversalTime();
                valMixed7.UtcTimestamp     = dataClass.famousDates[i].ToUniversalTime();
                valMixed8.UtcTimestamp     = dataClass.famousDates[i].ToUniversalTime();
                valMixed9.UtcTimestamp     = dataClass.famousDates[i].ToUniversalTime();
                valMixed10.UtcTimestamp    = dataClass.famousDates[i].ToUniversalTime();
                valMixed11.UtcTimestamp    = dataClass.famousDates[i].ToUniversalTime();
                valMixed6.MeasurementName  = "ValuesOne";
                valMixed7.MeasurementName  = "ValuesTwo";
                valMixed8.MeasurementName  = "ValuesThree";
                valMixed9.MeasurementName  = "ValuesFour";
                valMixed10.MeasurementName = "ValuesFive";
                valMixed11.MeasurementName = "FamousValues";
                double[] values1 = new double[6];
                values1[0] = logicClass.ValuesLog1[i];
                values1[1] = logicClass.ValuesLog2[i];
                values1[2] = logicClass.ValuesLog3[i];
                values1[3] = logicClass.ValuesLog4[i];
                values1[4] = logicClass.ValuesLog5[i];
                values1[5] = dataClass.famousValues[i];
                valMixed6.Fields.Add("value", new InfluxValueField(values1[0]));
                valMixed7.Fields.Add("value", new InfluxValueField(values1[1]));
                valMixed8.Fields.Add("value", new InfluxValueField(values1[2]));
                valMixed9.Fields.Add("value", new InfluxValueField(values1[3]));
                valMixed10.Fields.Add("value", new InfluxValueField(values1[4]));
                valMixed11.Fields.Add("value", new InfluxValueField(values1[5]));
                var r1 = await client.PostPointAsync(nameDB, valMixed6);

                var s1 = await client.PostPointAsync(nameDB, valMixed7);

                var t1 = await client.PostPointAsync(nameDB, valMixed8);

                var u1 = await client.PostPointAsync(nameDB, valMixed9);

                var f1 = await client.PostPointAsync(nameDB, valMixed10);

                var f2 = await client.PostPointAsync(nameDB, valMixed11);

                label.Text = $"Запись значений алгоритмов (Выполнено {i/count2}%)";
            }
        }
Exemplo n.º 15
0
 /// <summary>
 /// Create new Databases
 /// </summary>
 /// <param name="dbname"></param>
 /// <returns></returns>
 public async Task <bool> CreateNewDatabase(string dbname)
 {
     return(await InfluxDBConnection.CreateDatabaseAsync(dbname));
 }
 public async Task TestCreateDatabaseAsync_InvalidName()
 {
     var client = new InfluxDBClient(influxUrl, dbUName, dbpwd);
     var r      = await client.CreateDatabaseAsync(invalidDbName);
 }
Exemplo n.º 17
0
        static void Main(string[] args)
        {
            string sSource;
            string sLog;
            string sEvent;

            sSource = "PoolWalletStatus2InfluxDb";
            sLog    = "Application";

            if (!EventLog.SourceExists(sSource))
            {
                EventLog.CreateEventSource(sSource, sLog);
            }

            var appSettings = ConfigurationManager.AppSettings;
            var btcAddress  = appSettings["BTCAddress"];


            var zpoolUrl     = ZpoolApiURL + btcAddress;
            var ahashpoolUrl = AhashpoolApiURL + btcAddress;
            var zergpoolUrl  = ZergpoolApiURL + btcAddress;

            var influxUrl    = appSettings["InfluxDbHost"];
            var influxDbName = appSettings["InfluxDbName"];

            var utcNow = DateTime.UtcNow;

            try
            {
                var request = WebRequest.Create(zpoolUrl);
                request.ContentType = "application/json; charset=utf-8";
                string text;
                var    response = (HttpWebResponse)request.GetResponse();

                using (var sr = new StreamReader(response.GetResponseStream()))
                {
                    text = sr.ReadToEnd();
                }

                ZpoolStatus zpoolStatus = Newtonsoft.Json.JsonConvert.DeserializeObject <ZpoolStatus>(text);

                Console.WriteLine("Json received and parsed");


                Console.WriteLine($"Connecting to Influxdb @ {influxUrl} DBName: {influxDbName}");
                InfluxDBClient client = new InfluxDBClient($"http://{influxUrl}");
                client.CreateDatabaseAsync(influxDbName).Wait();

                var valMixed = new InfluxDatapoint <InfluxValueField>();
                valMixed.UtcTimestamp = utcNow;
                valMixed.Tags.Add("BTC_Address", btcAddress);
                valMixed.Fields.Add("currency", new InfluxValueField(zpoolStatus.currency));
                valMixed.Fields.Add("unsold", new InfluxValueField(zpoolStatus.unsold));
                valMixed.Fields.Add("balance", new InfluxValueField(zpoolStatus.balance));
                valMixed.Fields.Add("total_unpaid", new InfluxValueField(zpoolStatus.unpaid));
                valMixed.Fields.Add("total_paid", new InfluxValueField(zpoolStatus.paid24h));
                valMixed.Fields.Add("total_earned", new InfluxValueField(zpoolStatus.total));

                valMixed.MeasurementName = "Zpool";

                Console.WriteLine("Trying to write zpool data to DB");
                client.PostPointAsync(influxDbName, valMixed).Wait();
            }
            catch (Exception e)
            {
                EventLog.WriteEntry(sSource, "Error while writing zpool data: " + e.Message, EventLogEntryType.Error);
            }
            try
            {
                var request = WebRequest.Create(ahashpoolUrl);
                request.ContentType = "application/json; charset=utf-8";
                string text;
                var    response = (HttpWebResponse)request.GetResponse();

                using (var sr = new StreamReader(response.GetResponseStream()))
                {
                    text = sr.ReadToEnd();
                }

                AhashPoolStatus ahashPoolStatus = Newtonsoft.Json.JsonConvert.DeserializeObject <AhashPoolStatus>(text);
                InfluxDBClient  client          = new InfluxDBClient($"http://{influxUrl}");
                client.CreateDatabaseAsync(influxDbName).Wait();
                var valMixed = new InfluxDatapoint <InfluxValueField>();
                valMixed = new InfluxDatapoint <InfluxValueField>();
                valMixed.UtcTimestamp = utcNow;
                valMixed.Tags.Add("BTC_Address", btcAddress);
                valMixed.Fields.Add("currency", new InfluxValueField(ahashPoolStatus.currency));
                valMixed.Fields.Add("unsold", new InfluxValueField(ahashPoolStatus.unsold));
                valMixed.Fields.Add("balance", new InfluxValueField(ahashPoolStatus.balance));
                valMixed.Fields.Add("total_unpaid", new InfluxValueField(ahashPoolStatus.total_unpaid));
                valMixed.Fields.Add("total_paid", new InfluxValueField(ahashPoolStatus.total_paid));
                valMixed.Fields.Add("total_earned", new InfluxValueField(ahashPoolStatus.total_earned));

                valMixed.MeasurementName = "Ahashpool";

                Console.WriteLine("Trying to write ahashpool data to DB");
                client.PostPointAsync(influxDbName, valMixed).Wait();
            }
            catch (Exception e)
            {
                EventLog.WriteEntry(sSource, "Error while writing ahashpool data: " + e.Message, EventLogEntryType.Error);
            }
            try {
                var request = WebRequest.Create(zergpoolUrl);
                request.ContentType = "application/json; charset=utf-8";
                string text;
                var    response = (HttpWebResponse)request.GetResponse();

                using (var sr = new StreamReader(response.GetResponseStream()))
                {
                    text = sr.ReadToEnd();
                }

                ZpoolStatus    zergpoolStatus = Newtonsoft.Json.JsonConvert.DeserializeObject <ZpoolStatus>(text);
                InfluxDBClient client         = new InfluxDBClient($"http://{influxUrl}");
                client.CreateDatabaseAsync(influxDbName).Wait();
                var valMixed = new InfluxDatapoint <InfluxValueField>();
                valMixed = new InfluxDatapoint <InfluxValueField>();
                valMixed.UtcTimestamp = utcNow;
                valMixed.Tags.Add("BTC_Address", btcAddress);
                valMixed.Fields.Add("currency", new InfluxValueField(zergpoolStatus.currency));
                valMixed.Fields.Add("unsold", new InfluxValueField(zergpoolStatus.unsold));
                valMixed.Fields.Add("balance", new InfluxValueField(zergpoolStatus.balance));
                valMixed.Fields.Add("total_unpaid", new InfluxValueField(zergpoolStatus.unpaid));
                valMixed.Fields.Add("total_paid", new InfluxValueField(zergpoolStatus.paid24h));
                valMixed.Fields.Add("total_earned", new InfluxValueField(zergpoolStatus.total));

                valMixed.MeasurementName = "Zergpool";

                Console.WriteLine("Trying to write zergpool data to DB");
                client.PostPointAsync(influxDbName, valMixed).Wait();
            }
            catch (Exception e)
            {
                EventLog.WriteEntry(sSource, e.Message, EventLogEntryType.Error);
            }
        }