Exemplo n.º 1
0
        private void Execute()
        {
            if (options.RunAsServer)
            {
                options.IoOptions.DurationInMinutes = 0; // should indicate run until stoped
                using (var manager = new MonitoringManager(options))
                {
                    manager.Register(new DiskIoPerformanceMonitor(options));
                    manager.Register(new MemoryPerformanceMonitor(options));
                    manager.Register(new CpuPerformanceMonitoring(options));
                    manager.Register(new DiskQueuePerformanceMonitor(options));
                    MonitoringManager.MonitorManager = manager;
                    using (WebApp.Start <MonitorHost>("http://localhost:9091/"))
                    {
                        Console.WriteLine("Running as server, listening to port 9091.\nPress any key to stop...");
                        Console.ReadLine();
                    }
                }
                return;
            }

            if (options.Action.HasFlag(MonitorActions.DiskIo))
            {
                using (var monitor = new DiskIoPerformanceMonitor(options))
                    monitor.Start();
            }
        }
Exemplo n.º 2
0
        public object MonitorIO()
        {
            var options    = new MonitorOptions();
            var nvc        = HttpUtility.ParseQueryString(Request.RequestUri.Query);
            var proccessId = nvc["process-id"];
            int pid;

            if (!string.IsNullOrEmpty(proccessId))
            {
                if (!int.TryParse(proccessId, out pid))
                {
                    throw new BadRequestException(string.Format("Could not parse pid: {0}", proccessId));
                }
                options.ProcessId = pid;
            }
            else
            {
                var proc = Process.GetProcessesByName("Raven.Server");
                if (proc.Length != 1)
                {
                    throw new BadRequestException("More than one raven server is up and no pid was provided.");
                }
                options.ProcessId = proc[0].Id;
            }
            options.Action = MonitorActions.DiskIo;
            var serverUrl = nvc["server-url"];

            if (string.IsNullOrEmpty(serverUrl))
            {
                serverUrl = "http://localhost:8080/";
            }
            try
            {
                WebRequest.Create(serverUrl + "build/version").GetResponse().Close();
            }
            catch (Exception)
            {
                throw new BadRequestException("Could not verify raven server url.");
            }
            options.ServerUrl = serverUrl;
            var durationStr       = nvc["duration"];
            int durationInMinutes = 1;

            if (!string.IsNullOrEmpty(durationStr))
            {
                int.TryParse(durationStr, out durationInMinutes);
            }
            options.IoOptions.DurationInMinutes = durationInMinutes;
            Task.Factory.StartNew(() =>
            {
                using (var monitor = new DiskIoPerformanceMonitor(options))
                    monitor.Start();
            });
            return(options);
        }