示例#1
0
 private static void WriteRange(DataPointConfig dataPointConfig, DataPoint dataPoint)
 {
     DateTime start = dataPointConfig.StartDate;
     _tagCount = 0;
     while (start <= dataPointConfig.EndDate)
     {
         string msg = "put " + dataPoint.ToString();
         TsdbClient.Write(msg, dataPointConfig.TsdbHostName, dataPointConfig.TsdbPortNumber, true);
         start = start.AddMinutes(dataPointConfig.SamplingIntervalMinutes);
         dataPoint.Timestamp = start;
         dataPoint.Value = GetRandomMetric(dataPointConfig.MetricLow, dataPointConfig.MetricHigh);
         Console.SetCursorPosition(_consoleLeft, _consoleTop);
         Console.Write("Created data point # {0}", ++_tagCount);
     }
 }
示例#2
0
        static void Main(string[] args)
        {
            string fileName = ConfigurationManager.AppSettings["ConfigFileName"];
            if (fileName == null)
            {
                Console.WriteLine("Configuration file is missing; configure \"ConfigFileName\" in app.config");
                return;
            }
            string config = ConfigUtility.ReadFile(fileName);
            DataPointConfig dpc = JsonConvert.DeserializeObject<DataPointConfig>(config);

            dpc.SetDefaults();
            List<string> errors = null;
            if (!dpc.IsValid(ref errors))
            {
                foreach (string error in errors)
                {
                    Console.WriteLine(error);
                }
                return;
            }

            DataPoint dataPoint = new DataPoint();

            //compose tags
            string tagStr = ConfigurationManager.AppSettings["Tags"];

            dataPoint.Name = dpc.MetricName;
            dataPoint.Timestamp = dpc.StartDate;
            dataPoint.Value = GetRandomMetric(dpc.MetricLow, dpc.MetricHigh);
            dataPoint.Tags = dpc.Tags;
            _stopwatch.Start();
            WriteRange(dpc, dataPoint);
            _stopwatch.Stop();
            WriteSummary(dpc);
            Console.WriteLine("Press ENTER to exit");
            Console.ReadLine();
        }