static void MainOLD(string[] args) { var cpuCounter = new PerformanceCounter(); cpuCounter.CategoryName = "Processor"; cpuCounter.CounterName = "% Processor Time"; cpuCounter.InstanceName = "_Total"; while (true) { Console.WriteLine(cpuCounter.NextValue()+"%"); System.Threading.Thread.Sleep(2000); } var _statsdClient = new Statsd.StatsdPipe("ec2-54-234-97-29.compute-1.amazonaws.com", 8125); int _increment = 1; while (true) { System.Threading.Thread.Sleep(100); Random r = new Random(); var _randomNumber = r.Next(15); if (_randomNumber >= 2) { _statsdClient.Increment("myapp.server1.200"); } if (_randomNumber == 3) { _statsdClient.Increment("myapp.server1.400"); } if (_randomNumber == 4) { _statsdClient.Increment("myapp.server1.500"); } Console.WriteLine(_increment); _increment++; if (_increment % 100 == 0) { Console.WriteLine("event"); _statsdClient.Increment("events.deploy.myapp"); } _statsdClient.Timing("noel.timmer2", 300 + _randomNumber); } }
static void MainOld2(string[] args) { var _appSettings = ConfigurationManager.AppSettings; var _metricsHostName = _appSettings["metricsHostName"]; var _metricsPort = int.Parse(_appSettings["metricsPort"]); var _metricsKeyPrefix = _appSettings["metricsKeyPrefix"]; var _statsdClient = new Statsd.StatsdPipe(_metricsHostName, _metricsPort); int _increment = 1; while (true) { System.Threading.Thread.Sleep(100); Random r = new Random(); var _randomNumber = r.Next(15); if (_randomNumber >= 2) { _statsdClient.Increment(string.Format("{0}.{1}", _metricsKeyPrefix, 200)); } if (_randomNumber == 3) { _statsdClient.Increment(string.Format("{0}.{1}", _metricsKeyPrefix, 400)); } if (_randomNumber == 4) { _statsdClient.Increment(string.Format("{0}.{1}", _metricsKeyPrefix, 500)); } Console.WriteLine(_increment); _increment++; if (_increment % 10 == 0) { Console.WriteLine(string.Format("{0}.deploy", _metricsKeyPrefix)); _statsdClient.Increment(string.Format("{0}.deploy", _metricsKeyPrefix)); } _statsdClient.Timing(string.Format("{0}.timer", _metricsKeyPrefix), 300 + _randomNumber); } }