Exemple #1
0
        /// <summary>
        /// Setup counters for diagnostic monitor
        /// </summary>
        private void SetupCounters()
        {
            DiagnosticMonitorConfiguration diagnosticMonitorConfiguration = DiagnosticMonitor.GetDefaultInitialConfiguration();

            TraceConfig(diagnosticMonitorConfiguration);

            diagnosticMonitorConfiguration.PerformanceCounters.BufferQuotaInMB = 5;

            diagnosticMonitorConfiguration.PerformanceCounters.ScheduledTransferPeriod = TimeSpan.FromMinutes(1);

            // Use 30 seconds for the perf counter sample rate.
            TimeSpan perfSampleRate = TimeSpan.FromSeconds(30D);

            diagnosticMonitorConfiguration.PerformanceCounters.DataSources.Add(new PerformanceCounterConfiguration()
            {
                CounterSpecifier = @"\Memory\Available Bytes",
                SampleRate       = perfSampleRate
            });

            diagnosticMonitorConfiguration.PerformanceCounters.DataSources.Add(new PerformanceCounterConfiguration()
            {
                CounterSpecifier = @"\Processor(_Total)\% Processor Time",
                SampleRate       = perfSampleRate
            });

            // Apply the updated configuration to the diagnostic monitor.
            // The first parameter is for the connection string configuration setting.
            DiagnosticMonitor.Start("Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString", diagnosticMonitorConfiguration);
        }
Exemple #2
0
        public override bool OnStart()
        {
            DiagnosticMonitorConfiguration config = DiagnosticMonitor.GetDefaultInitialConfiguration();

            config.Logs.ScheduledTransferPeriod = TimeSpan.FromMinutes(1);
            config.DiagnosticInfrastructureLogs.ScheduledTransferPeriod         = TimeSpan.FromMinutes(1);
            config.DiagnosticInfrastructureLogs.ScheduledTransferLogLevelFilter = LogLevel.Error;
            DiagnosticMonitor.Start("DiagnosticsConnectionString", config);

            RoleEnvironment.Changing += RoleEnvironmentChanging;
            CloudStorageAccount.SetConfigurationSettingPublisher((configName, configSetter) =>
            {
                configSetter(RoleEnvironment.GetConfigurationSettingValue(configName));
                RoleEnvironment.Changed += (anotherSender, arg) =>
                {
                    if (arg.Changes.OfType <RoleEnvironmentConfigurationSettingChange>()
                        .Any((change) => (change.ConfigurationSettingName == configName)))
                    {
                        if (!configSetter(RoleEnvironment.GetConfigurationSettingValue(configName)))
                        {
                            RoleEnvironment.RequestRecycle();
                        }
                    }
                };
            });

            ChirpManager.Initialize();
            AvatarManager.Initialize();
            ResizeRequestManager.Initialize();

            return(base.OnStart());
        }
Exemple #3
0
        public override bool OnStart()
        {
            // To enable the AzureLocalStorageTraceListner, uncomment relevent section in the web.config
            DiagnosticMonitorConfiguration diagnosticConfig = DiagnosticMonitor.GetDefaultInitialConfiguration();

            diagnosticConfig.Directories.ScheduledTransferPeriod = TimeSpan.FromMinutes(1);
            diagnosticConfig.Directories.DataSources.Add(AzureLocalStorageTraceListener.GetLogDirectory());

            // For information on handling configuration changes
            // see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357.

            var startInfo = new ProcessStartInfo()
            {
                FileName  = "powershell.exe",
                Arguments = @"..\Startup\RoleStart.ps1",
                RedirectStandardOutput = true,
                UseShellExecute        = false
            };

            var writer  = new StreamWriter("out.txt");
            var process = Process.Start(startInfo);

            process.WaitForExit();
            writer.Write(process.StandardOutput.ReadToEnd());
            writer.Close();

            return(base.OnStart());
        }
Exemple #4
0
        public override bool OnStart()
        {
            RoleEnvironment.Changing += RoleEnvironmentChanging;

            DiagnosticMonitorConfiguration dmc = DiagnosticMonitor.GetDefaultInitialConfiguration();

            dmc.Logs.ScheduledTransferPeriod         = TimeSpan.FromSeconds(10);
            dmc.Logs.ScheduledTransferLogLevelFilter = LogLevel.Undefined;

            DiagnosticMonitor.Start("DiagnosticsConnectionString", dmc);

            Log.Info("Worker Role OnStart Entered");

            try
            {
                _endPoint = RoleEnvironment.CurrentRoleInstance.InstanceEndpoints["Raven"].IPEndpoint;

                MountCloudDrive();
                StartTheServer();

                Log.Info("Worker Role OnStart Exited");
            }
            catch (Exception ex)
            {
                Log.Error("Worker Role OnStart error: " + ex.Message);
            }

            return(base.OnStart());
        }
Exemple #5
0
        public override bool OnStart()
        {
            ServicePointManager.DefaultConnectionLimit = 12;
            TimeSpan timeToTransfer;

            //// IIS Log.
            timeToTransfer = TimeSpan.FromMinutes(5);
            //// LocalResource localResource = RoleEnvironment.GetLocalResource("IISLogs");

            //// DirectoryConfiguration dirConfig = new DirectoryConfiguration();
            //// dirConfig.Container = "wad-iis-logcontainer";
            //// dirConfig.DirectoryQuotaInMB = localResource.MaximumSizeInMegabytes;
            //// dirConfig.Path = localResource.RootPath;

            DiagnosticMonitorConfiguration diagMonitorConfig = DiagnosticMonitor.GetDefaultInitialConfiguration();

            //// diagMonitorConfig.Directories.ScheduledTransferPeriod = timeToTransfer;
            //// diagMonitorConfig.OverallQuotaInMB = 4080;
            //// diagMonitorConfig.Directories.DataSources.Add(dirConfig);

            //// Logging diagnostic information to WADLog storage table.
            timeToTransfer = TimeSpan.FromMinutes(5);
            diagMonitorConfig.Logs.ScheduledTransferPeriod         = timeToTransfer;
            diagMonitorConfig.Logs.ScheduledTransferLogLevelFilter = LogLevel.Verbose;

            //// Start diagnostic monitor.
            DiagnosticMonitor diagMonitor = DiagnosticMonitor.Start("Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString", diagMonitorConfig);

            return(base.OnStart());
        }
Exemple #6
0
        public override bool OnStart()
        {
            DiagnosticMonitorConfiguration dmc = DiagnosticMonitor.GetDefaultInitialConfiguration();

            dmc.Logs.ScheduledTransferPeriod         = TimeSpan.FromSeconds(1);
            dmc.Logs.ScheduledTransferLogLevelFilter = LogLevel.Verbose;

            DiagnosticMonitor.Start("Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString", dmc);

            return(base.OnStart());
            //// For information on handling configuration changes
            //// see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357.
            //System.Diagnostics.Trace.WriteLine("Entering OnStart in WebRole...");

            //var traceResource = RoleEnvironment.GetLocalResource("TraceFiles");
            //var config = DiagnosticMonitor.GetDefaultInitialConfiguration();
            //config.Directories.DataSources.Add(
            //    new DirectoryConfiguration
            //    {
            //        Path = traceResource.RootPath,
            //        Container = "traces",
            //        DirectoryQuotaInMB = 100
            //    });
            //config.Directories.ScheduledTransferPeriod = TimeSpan.FromMinutes(1);

            //DiagnosticMonitor.Start("Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString", config);

            //return true;

            //return base.OnStart();
        }
Exemple #7
0
        private void ScheduleTransfer(DiagnosticMonitorConfiguration dmc)
        {
            var transferPeriod = TimeSpan.FromMinutes(ScheduledTransferPeriod);

            dmc.Logs.ScheduledTransferPeriod            = transferPeriod;
            dmc.WindowsEventLog.ScheduledTransferPeriod = transferPeriod;
        }
Exemple #8
0
        public override bool OnStart()
        {
            // Set the maximum number of concurrent connections
            ServicePointManager.DefaultConnectionLimit = 12;

            TimeSpan tsMin = TimeSpan.FromMinutes(1);

            DiagnosticMonitorConfiguration dmc = DiagnosticMonitor.GetDefaultInitialConfiguration();

            // Transfer logs to storage every minute

            dmc.Logs.ScheduledTransferPeriod = tsMin;

            // Transfer verbose, critical, etc. logs

            dmc.Logs.ScheduledTransferLogLevelFilter = LogLevel.Undefined;
            DiagnosticMonitor.Start("Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString", dmc);

            // For information on handling configuration changes
            // see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357.

            CloudStorageAccount.SetConfigurationSettingPublisher(
                (a, b) => b(RoleEnvironment.GetConfigurationSettingValue(a)));

            return(base.OnStart());
        }
Exemple #9
0
        public override bool OnStart()
        {
            // Configure diagnostics
            // From: http://www.packtpub.com/article/digging-into-windows-azure-diagnostics-tutotial (sic),
            // need to add a diagnostics trace listener; (web.config is just for website tracing)
            Trace.Listeners.Add(new DiagnosticMonitorTraceListener());
            Trace.AutoFlush = true;
            Trace.TraceInformation("Error");

            // Set up to transfer to blob storage
            DiagnosticMonitorConfiguration diagnosticConfiguration = DiagnosticMonitor.GetDefaultInitialConfiguration();

            diagnosticConfiguration.Logs.ScheduledTransferPeriod = TimeSpan.FromMinutes(10);
            // don't need; if not specificed, will use overall quota (which is 4 GB)            diagnosticConfiguration.Logs.BufferQuotaInMB = 10;

            // Add the startup task logs directory, so the startup logs will get transferred to storage
            var dirConfig = new DirectoryConfiguration();

            dirConfig.Container = "wad-startuplogs-container";
            dirConfig.Path      = Path.Combine((new DirectoryInfo(".")).FullName, "startuplogs");
            Trace.TraceInformation("not sure why files not getting picked up: dirConfig = " + dirConfig.Path);
            diagnosticConfiguration.Directories.DataSources.Add(dirConfig);
            diagnosticConfiguration.Directories.ScheduledTransferPeriod = TimeSpan.FromMinutes(10);

            DiagnosticMonitor.Start("Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString", diagnosticConfiguration);

            // For information on handling configuration changes
            // see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357.

            return(base.OnStart());
        }
Exemple #10
0
        public override bool OnStart()
        {
            // Set the maximum number of concurrent connections
            ServicePointManager.DefaultConnectionLimit = 12;

            XmlConfigurator.Configure();
            ILog log = LogManager.GetLogger(typeof(WorkerRole));

            string wadConnectionString = "Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString";
            CloudStorageAccount            storageAccount = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue(wadConnectionString));
            RoleInstanceDiagnosticManager  roleInstanceDiagnosticManager = storageAccount.CreateRoleInstanceDiagnosticManager(RoleEnvironment.DeploymentId, RoleEnvironment.CurrentRoleInstance.Role.Name, RoleEnvironment.CurrentRoleInstance.Id);
            DiagnosticMonitorConfiguration config = roleInstanceDiagnosticManager.GetCurrentConfiguration();

            config.Logs.ScheduledTransferPeriod         = TimeSpan.FromMinutes(1D);
            config.Logs.ScheduledTransferLogLevelFilter = LogLevel.Undefined;
            config.DiagnosticInfrastructureLogs.ScheduledTransferLogLevelFilter = LogLevel.Warning;
            config.DiagnosticInfrastructureLogs.ScheduledTransferPeriod         = TimeSpan.FromMinutes(1D);
            config.Directories.ScheduledTransferPeriod = TimeSpan.FromMinutes(1D);

            roleInstanceDiagnosticManager.SetCurrentConfiguration(config);


            PhotoTaskManager.Instance.Start();
            RenderTaskManager.Instance.Start();
            ProfileTaskManager.Instance.Start();
            StatUpdate.Instance.Start();

            return(base.OnStart());
        }
        public override bool OnStart()
        {
            Trace.WriteLine("OrleansAzureSilos-OnStart called", "Information");

            Trace.WriteLine("OrleansAzureSilos-OnStart Initializing config", "Information");

            // Set the maximum number of concurrent connections
            ServicePointManager.DefaultConnectionLimit = 12;

            // For information on handling configuration changes see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357.
            RoleEnvironment.Changing += RoleEnvironmentChanging;

            Trace.WriteLine("OrleansAzureSilos-OnStart Initializing diagnostics", "Information");

            DiagnosticMonitorConfiguration diagConfig = ConfigureDiagnostics();

            // Start the diagnostic monitor.
            // The parameter references a connection string specified in the service configuration file
            // that indicates the storage account where diagnostic information will be transferred.
            // If the value of this setting is "UseDevelopmentStorage=true" then logs are written to development storage.
            DiagnosticMonitor.Start("Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString", diagConfig);

            Trace.WriteLine("OrleansAzureSilos-OnStart Starting Orleans silo", "Information");

            orleansAzureSilo = new OrleansAzureSilo();

            bool ok = base.OnStart();

            if (ok)
            {
                ok = orleansAzureSilo.Start(RoleEnvironment.DeploymentId, RoleEnvironment.CurrentRoleInstance);
            }
            Trace.WriteLine("OrleansAzureSilos-OnStart Orleans silo started ok=" + ok, "Information");
            return(ok);
        }
Exemple #12
0
        /// <summary>
        /// Performs initial configurarion for Windows Azure Diagnostics for the instance.
        /// </summary>
        private void ConfigureDiagnosticMonitor()
        {
            DiagnosticMonitorConfiguration diagnosticMonitorConfiguration = DiagnosticMonitor.GetDefaultInitialConfiguration();

            diagnosticMonitorConfiguration.DiagnosticInfrastructureLogs.ScheduledTransferLogLevelFilter = LogLevel.Verbose;
            diagnosticMonitorConfiguration.DiagnosticInfrastructureLogs.ScheduledTransferPeriod         = TimeSpan.FromMinutes(1d);

            diagnosticMonitorConfiguration.Directories.ScheduledTransferPeriod = TimeSpan.FromMinutes(1d);
            diagnosticMonitorConfiguration.Directories.BufferQuotaInMB         = 100;

            diagnosticMonitorConfiguration.Logs.ScheduledTransferPeriod         = TimeSpan.FromMinutes(1d);
            diagnosticMonitorConfiguration.Logs.ScheduledTransferLogLevelFilter = LogLevel.Verbose;

            diagnosticMonitorConfiguration.WindowsEventLog.DataSources.Add("Application!*");
            diagnosticMonitorConfiguration.WindowsEventLog.DataSources.Add("System!*");
            diagnosticMonitorConfiguration.WindowsEventLog.ScheduledTransferPeriod = TimeSpan.FromMinutes(1d);

            //PerformanceCounterConfiguration performanceCounterConfiguration = new PerformanceCounterConfiguration();
            //performanceCounterConfiguration.CounterSpecifier = @"\Processor(_Total)\% Processor Time";
            //performanceCounterConfiguration.SampleRate = System.TimeSpan.FromSeconds(10d);
            //diagnosticMonitorConfiguration.PerformanceCounters.DataSources.Add(performanceCounterConfiguration);

            //PerformanceCounterConfiguration performanceCounterConfigurationMem = new PerformanceCounterConfiguration();
            //performanceCounterConfigurationMem.CounterSpecifier = @"\Memory\% Committed Bytes In Use";
            //performanceCounterConfigurationMem.SampleRate = System.TimeSpan.FromSeconds(60d);
            //diagnosticMonitorConfiguration.PerformanceCounters.DataSources.Add(performanceCounterConfigurationMem);

            //diagnosticMonitorConfiguration.PerformanceCounters.ScheduledTransferPeriod = TimeSpan.FromMinutes(1d);

            DiagnosticMonitor.Start(WadConnectionString, diagnosticMonitorConfiguration);
        }
 /// <summary>
 /// By default all Windows events to the Application and System logs are stored in the Azure table storage
 /// Note: Decide here what Windows event logs you are interested in seeing, you can also filter out events
 /// </summary>
 /// <param name="diagnosticMonitorConfiguration"></param>
 void AddEventLoggingFromWindowsEventLog(DiagnosticMonitorConfiguration diagnosticMonitorConfiguration)
 {
     // Syntax: <channel>!XPath Query
     // See: http://msdn.microsoft.com/en-us/library/dd996910(VS.85).aspx
     diagnosticMonitorConfiguration.WindowsEventLog.DataSources.Add("Application!*");
     diagnosticMonitorConfiguration.WindowsEventLog.DataSources.Add("System!*");
 }
 private static LocalResource CreateLocalResource(DiagnosticMonitorConfiguration diagMonitorConfig)
 {
     LocalResource localResource = RoleEnvironment.GetLocalResource("CustomLogFiles");
     DirectoryConfiguration dirConfig = CreateDirectoryConfiguration(localResource);
     diagMonitorConfig.Directories.ScheduledTransferPeriod = TimeSpan.FromMinutes(1.0);
     diagMonitorConfig.Directories.DataSources.Add(dirConfig);
     return localResource;
 }
Exemple #15
0
 static void AddPerformanceCounter(DiagnosticMonitorConfiguration cfg, string counter, TimeSpan frequency)
 {
     cfg.PerformanceCounters.DataSources.Add(new PerformanceCounterConfiguration
     {
         CounterSpecifier = counter,
         SampleRate       = frequency
     });
 }
 /// <summary>
 /// Sets how often diagnostics data is transferred to the Azure table storage or blob storage
 /// Note: Change to a period that fits your need, commenting out one of these lines disables it
 /// </summary>
 /// <param name="diagnosticMonitorConfiguration"></param>
 void SetDiagnositcManagerScheduledTransferPeriods(DiagnosticMonitorConfiguration diagnosticMonitorConfiguration)
 {
     diagnosticMonitorConfiguration.Directories.ScheduledTransferPeriod     = TimeSpan.FromMinutes(5);
     diagnosticMonitorConfiguration.Logs.ScheduledTransferPeriod            = TimeSpan.FromMinutes(5);
     diagnosticMonitorConfiguration.WindowsEventLog.ScheduledTransferPeriod = TimeSpan.FromMinutes(5);
     diagnosticMonitorConfiguration.DiagnosticInfrastructureLogs.ScheduledTransferPeriod = TimeSpan.FromMinutes(5);
     diagnosticMonitorConfiguration.PerformanceCounters.ScheduledTransferPeriod          = TimeSpan.FromMinutes(5);
 }
Exemple #17
0
        private void ConfigureDiagnostics(DiagnosticMonitorConfiguration configuration)
        {
            configuration.Logs.ScheduledTransferLogLevelFilter = GetLevel();

            ScheduleTransfer(configuration);

            ConfigureWindowsEventLogsToBeTransferred(configuration);
        }
Exemple #18
0
 private static void ConfigureWindowsEventLogsToBeTransferred(DiagnosticMonitorConfiguration dmc)
 {
     var eventLogs = GetEventLogs().Split(';');
     foreach (var log in eventLogs)
     {
         dmc.WindowsEventLog.DataSources.Add(log);
     }
 }
Exemple #19
0
        private static void ConfigureWindowsEventLogsToBeTransferred(DiagnosticMonitorConfiguration dmc)
        {
            var eventLogs = GetEventLogs().Split(';');

            foreach (var log in eventLogs)
            {
                dmc.WindowsEventLog.DataSources.Add(log);
            }
        }
Exemple #20
0
        private void ConfigureDiagnostics(DiagnosticMonitorConfiguration configuration)
        {
            //set threshold to verbose, what gets logged is controled by the log4net level
            configuration.Logs.ScheduledTransferLogLevelFilter = LogLevel.Verbose;

            ScheduleTransfer(configuration);

            ConfigureWindowsEventLogsToBeTransferred(configuration);
        }
Exemple #21
0
        private static LocalResource CreateLocalResource(DiagnosticMonitorConfiguration diagMonitorConfig)
        {
            LocalResource          localResource = RoleEnvironment.GetLocalResource("CustomLogFiles");
            DirectoryConfiguration dirConfig     = CreateDirectoryConfiguration(localResource);

            diagMonitorConfig.Directories.ScheduledTransferPeriod = TimeSpan.FromMinutes(1.0);
            diagMonitorConfig.Directories.DataSources.Add(dirConfig);
            return(localResource);
        }
 public void UpdateAllInstanceDiagnostics(DiagnosticMonitorConfiguration config, string deploymentId, string roleName)
 {
     var deploymentDiagnosticManager = new DeploymentDiagnosticManager(this._connectionString, deploymentId);
     var instances = deploymentDiagnosticManager.GetRoleInstanceDiagnosticManagersForRole(roleName);
     foreach(var instance in instances)
     {
         instance.SetCurrentConfiguration(config);
     }
 }
 public void UpdateInstanceDiagnostics(DiagnosticMonitorConfiguration config, string deploymentId, string roleName, string instanceName)
 {
     var deploymentDiagnosticManager = new DeploymentDiagnosticManager(this._connectionString, deploymentId);
     var instance = deploymentDiagnosticManager.GetRoleInstanceDiagnosticManagersForRole(roleName)
         .FirstOrDefault(t => t.RoleInstanceId.Equals(instanceName, StringComparison.InvariantCultureIgnoreCase));
     if (instance != null)
     {
         instance.SetCurrentConfiguration(config);
     }
 }
Exemple #24
0
        public override bool OnStart()
        {
            // 启动AzureLocalStorageTraceListner, 在web.config取消相关节点
            DiagnosticMonitorConfiguration diagnosticConfig = DiagnosticMonitor.GetDefaultInitialConfiguration();

            diagnosticConfig.Directories.ScheduledTransferPeriod = TimeSpan.FromMinutes(1);
            diagnosticConfig.Directories.DataSources.Add(AzureLocalStorageTraceListener.GetLogDirectory());

            return(base.OnStart());
        }
Exemple #25
0
        public void UpdateAllInstanceDiagnostics(DiagnosticMonitorConfiguration config, string deploymentId, string roleName)
        {
            var deploymentDiagnosticManager = new DeploymentDiagnosticManager(this._connectionString, deploymentId);
            var instances = deploymentDiagnosticManager.GetRoleInstanceDiagnosticManagersForRole(roleName);

            foreach (var instance in instances)
            {
                instance.SetCurrentConfiguration(config);
            }
        }
Exemple #26
0
        private static void InitializeDiagnostics()
        {
            DiagnosticMonitorConfiguration diagMonitorConfig = DiagnosticMonitor.GetDefaultInitialConfiguration();
            LocalResource localResource = CreateLocalResource(diagMonitorConfig);

            diagMonitorConfig.Logs.ScheduledTransferPeriod = TimeSpan.FromMinutes(1.0);
            DiagnosticMonitor.Start("Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString", diagMonitorConfig);
            WebRoleErrorLoggingFilePath = Path.Combine(localResource.RootPath, "WorkerRoleErrors.log");
            Trace.Listeners.Add(new DiagnosticMonitorTraceListener());
        }
        /// <summary>
        /// Enables performance counters
        /// Note: PerformanceCounterConfiguration.CounterSpecifier is language specific and depends on your OS language.
        /// Note: For a complete list of possible PerformanceCounterConfiguration.CounterSpecifier values run "typeperf.exe /Q"
        /// </summary>
        /// <param name="diagnosticMonitorConfiguration"></param>
        void AddPerformanceCounterMonitoring(DiagnosticMonitorConfiguration diagnosticMonitorConfiguration)
        {
            var performanceCounterConfiguration =
                new PerformanceCounterConfiguration
            {
                CounterSpecifier = @"\Processor(*)\% Processor Time",
                SampleRate       = TimeSpan.FromSeconds(15)
            };

            diagnosticMonitorConfiguration.PerformanceCounters.DataSources.Add(performanceCounterConfiguration);
        }
Exemple #28
0
        public void UpdateInstanceDiagnostics(DiagnosticMonitorConfiguration config, string deploymentId, string roleName, string instanceName)
        {
            var deploymentDiagnosticManager = new DeploymentDiagnosticManager(this._connectionString, deploymentId);
            var instance = deploymentDiagnosticManager.GetRoleInstanceDiagnosticManagersForRole(roleName)
                           .FirstOrDefault(t => t.RoleInstanceId.Equals(instanceName, StringComparison.InvariantCultureIgnoreCase));

            if (instance != null)
            {
                instance.SetCurrentConfiguration(config);
            }
        }
        private void SetupDiagnostics()
        {
            Trace.WriteLine("Setting up diagnostics", "Information");

            DiagnosticMonitorConfiguration diagConfig = DiagnosticMonitor.GetDefaultInitialConfiguration();

            // Add performance counter monitoring for configured counters
            // Run typeperf.exe /q to query the counter list
            string perfCounterString = RoleEnvironment.GetConfigurationSettingValue("PerformanceCounters");

            if (!string.IsNullOrEmpty(perfCounterString))
            {
                IList <string> perfCounters = perfCounterString.Split(',').ToList();

                // Setup each counter specified in comma delimitered string
                foreach (string perfCounter in perfCounters)
                {
                    diagConfig.PerformanceCounters.DataSources.Add(
                        new PerformanceCounterConfiguration
                    {
                        CounterSpecifier = perfCounter,
                        SampleRate       = TimeSpan.FromSeconds(DefaultSampleRate)
                    }
                        );
                }

                // Update counter information in Azure every 30 seconds
                diagConfig.PerformanceCounters.ScheduledTransferPeriod = TimeSpan.FromMinutes(0.5);
            }

            diagConfig.DiagnosticInfrastructureLogs.ScheduledTransferPeriod = TimeSpan.FromMinutes(0.5);

            // Specify a logging level to filter records to transfer
            diagConfig.DiagnosticInfrastructureLogs.ScheduledTransferLogLevelFilter = LogLevel.Verbose;

            // Set scheduled transfer interval for user's Windows Azure Logs to 1 minute
            diagConfig.Logs.ScheduledTransferPeriod = TimeSpan.FromMinutes(5);

            diagConfig.Directories.ScheduledTransferPeriod = TimeSpan.FromMinutes(5);

            Microsoft.WindowsAzure.Diagnostics.CrashDumps.EnableCollection(true);


            //Event Logs
            // Add event collection from the Windows Event Log
            diagConfig.WindowsEventLog.DataSources.Add("System!*");
            diagConfig.WindowsEventLog.DataSources.Add("Application!*");
            diagConfig.WindowsEventLog.DataSources.Add("Security!*");


            // Start the diagnostic monitor with this custom configuration
            DiagnosticMonitor.Start("Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString", diagConfig);
        }
Exemple #30
0
 private void EnablePerfCounterCollection(DiagnosticMonitorConfiguration config)
 {
     config.PerformanceCounters.ScheduledTransferPeriod = TimeSpan.FromMinutes(1);
     // Performance counter path format:- PerfObject(ParentInstance/ObjectInstance#InstanceIndex)\Counter.
     // See the MSDN topic at http://msdn.microsoft.com/en-us/library/w8f5kw2e.aspx for more .NET performance counter
     // like '.NET CLR Exceptions', '.NET CLR Networking', '.NET CLR LocksAndThreads' etc.
     config.PerformanceCounters.DataSources.Add(new PerformanceCounterConfiguration()
     {
         CounterSpecifier = @"\.NET CLR Memory(_Global_)\*",
         SampleRate       = TimeSpan.FromSeconds(5)
     });
 }
 private static void ConfigurePerformanceCounters(DiagnosticMonitorConfiguration diagnostics, TimeSpan sampleRate)
 {
     var perfCounters = GetPerformanceCounters().Split(';');
     foreach(var pc in perfCounters.Select(x=>x.Trim()))
     {
         if (!String.IsNullOrEmpty(pc))
         {
             diagnostics.PerformanceCounters.DataSources.Add(
                 new PerformanceCounterConfiguration{CounterSpecifier = pc, SampleRate = sampleRate});
         }
     }
 }
Exemple #32
0
        public override bool OnStart()
        {
            // To enable the AzureLocalStorageTraceListner, uncomment relevent section in the web.config
            DiagnosticMonitorConfiguration diagnosticConfig = DiagnosticMonitor.GetDefaultInitialConfiguration();

            diagnosticConfig.Directories.ScheduledTransferPeriod = TimeSpan.FromMinutes(1);
            diagnosticConfig.Directories.DataSources.Add(AzureLocalStorageTraceListener.GetLogDirectory());

            HostEnvironment.Instance.Initialize(new AzureHostEnvironmentConfiguration());

            return(base.OnStart());
        }
Exemple #33
0
        public override bool OnStart()
        {
            try
            {
                // For information on handling configuration changes
                // see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357.

                DiagnosticMonitorConfiguration config = DiagnosticMonitor.GetDefaultInitialConfiguration();

                // Display information about the default configuration.
                ShowConfig(config);

                // Add in configuration settings for several performance counters.
                config.PerformanceCounters.ScheduledTransferPeriod = TimeSpan.FromMinutes(2D);

                config.PerformanceCounters.BufferQuotaInMB = 10;

                // Use 30 seconds for the perf counter sample rate.
                TimeSpan perfSampleRate = TimeSpan.FromSeconds(30D);

                config.PerformanceCounters.DataSources.Add(new PerformanceCounterConfiguration()
                {
                    CounterSpecifier = @"\Memory\Available Bytes",
                    SampleRate       = perfSampleRate
                });

                config.PerformanceCounters.DataSources.Add(new PerformanceCounterConfiguration()
                {
                    CounterSpecifier = @"\Processor(_Total)\% Processor Time",
                    SampleRate       = perfSampleRate
                });

                config.PerformanceCounters.DataSources.Add(new PerformanceCounterConfiguration()
                {
                    CounterSpecifier = @"\ASP.NET\Applications Running",
                    SampleRate       = perfSampleRate
                });

                // Display information about the changed configuration.
                ShowConfig(config);

                // Apply the updated configuration to the diagnostic monitor.
                // The first parameter is for the connection string configuration setting.
                DiagnosticMonitor.Start("Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString", config);
            }
            catch (Exception e)
            {
                Trace.WriteLine("Exception during WebRole1.OnStart: " + e.ToString());
                // Take other action as needed.
            }

            return(base.OnStart());
        }
Exemple #34
0
        public override bool OnStart()
        {
            string wadConnectionString = "Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString";

            RoleInstanceDiagnosticManager roleInstanceDiagnosticManager =
                CloudAccountDiagnosticMonitorExtensions.CreateRoleInstanceDiagnosticManager(RoleEnvironment.GetConfigurationSettingValue(wadConnectionString),
                                                                                            RoleEnvironment.DeploymentId, RoleEnvironment.CurrentRoleInstance.Role.Name,
                                                                                            RoleEnvironment.CurrentRoleInstance.Id);


            DiagnosticMonitorConfiguration config = roleInstanceDiagnosticManager.GetCurrentConfiguration();

            // should never be null, but this is a fallback in case it is. I recommend removing this in a production
            // deployment
            if (null == config)
            {
                config = DiagnosticMonitor.GetDefaultInitialConfiguration();
            }

            config.Logs.ScheduledTransferPeriod         = TimeSpan.FromMinutes(15);
            config.Logs.ScheduledTransferLogLevelFilter = Microsoft.WindowsAzure.Diagnostics.LogLevel.Undefined;
            config.DiagnosticInfrastructureLogs.ScheduledTransferLogLevelFilter = Microsoft.WindowsAzure.Diagnostics.LogLevel.Warning;
            config.DiagnosticInfrastructureLogs.ScheduledTransferPeriod         = TimeSpan.FromMinutes(15);
            config.Directories.ScheduledTransferPeriod = TimeSpan.FromMinutes(15);

            roleInstanceDiagnosticManager.SetCurrentConfiguration(config);
            System.Diagnostics.Trace.TraceInformation("Diagnostics Running");

            #region Setup CloudStorageAccount Configuration Setting Publisher

            // This code sets up a handler to update CloudStorageAccount instances when their corresponding
            // configuration settings change in the service configuration file.
            RoleEnvironment.Changed += (sender, arg) =>
            {
                var key = CloudConfigurationManager.GetSetting(arg.Changes.OfType <RoleEnvironmentConfigurationSettingChange>().ToString());
                if (arg.Changes.OfType <RoleEnvironmentConfigurationSettingChange>()
                    .Any((change) => (change.ConfigurationSettingName == key.ToString())))
                {
                    // The corresponding configuration setting has changed, propagate the value
                    RoleEnvironment.GetConfigurationSettingValue(key.ToString());
                    // {
                    // In this case, the change to the storage account credentials in the
                    // service configuration is significant enough that the role needs to be
                    // recycled in order to use the latest settings. (for example, the
                    // endpoint has changed)
                    RoleEnvironment.RequestRecycle();
                    //}
                }
            };
            //});
            #endregion
            return(base.OnStart());
        }
        ///// <summary>
        ///// configure the Role including the connection string
        ///// </summary>
        private void ConfigureDiagnostics()
        {
            DiagnosticMonitorConfiguration config = DiagnosticMonitor.GetDefaultInitialConfiguration();

            config.Logs.BufferQuotaInMB = 500;
            config.Logs.ScheduledTransferLogLevelFilter = Microsoft.WindowsAzure.Diagnostics.LogLevel.Information;
            config.Logs.ScheduledTransferPeriod         = TimeSpan.FromMinutes(1d);

            DiagnosticMonitor.Start(
                "Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString",
                config);
        }
Exemple #36
0
 private void ScheduleTransfer(DiagnosticMonitorConfiguration dmc)
 {
     var transferPeriod = TimeSpan.FromMinutes(ScheduledTransferPeriod);
     dmc.Logs.ScheduledTransferPeriod = transferPeriod;
     dmc.WindowsEventLog.ScheduledTransferPeriod = transferPeriod;
 }
Exemple #37
0
        private void ConfigureDiagnostics(DiagnosticMonitorConfiguration configuration)
        {
            //set threshold to verbose, what gets logged is controled by the log4net level
            configuration.Logs.ScheduledTransferLogLevelFilter = LogLevel.Verbose;

            ScheduleTransfer(configuration);

            ConfigureWindowsEventLogsToBeTransferred(configuration);
        }
Exemple #38
0
		private static void ConfigureWindowsEventLogsToBeTransferred(DiagnosticMonitorConfiguration dmc, string eventLogs)
		{
			var logs = eventLogs.Split(';');

		    foreach (var log in logs)
		    {
                if (!dmc.WindowsEventLog.DataSources.Contains(log))
                {
                    dmc.WindowsEventLog.DataSources.Add(log); 
                }
		    }
		}
        private void ConfigureDiagnostics(DiagnosticMonitorConfiguration configuration)
        {
            configuration.Logs.ScheduledTransferLogLevelFilter = GetLevel();

            ScheduleTransfer(configuration);

            ConfigureWindowsEventLogsToBeTransferred(configuration);
        }
        public void TraceConfig(DiagnosticMonitorConfiguration configuration)
        {
            if (configuration == null)
            {
                Trace.WriteLine("configuration is null");
                return;
            }
            try
            {
                // Display the general settings of the configuration
                Trace.WriteLine("*** General configuration settings ***");
                Trace.WriteLine("Config change poll interval: " + configuration.ConfigurationChangePollInterval);
                Trace.WriteLine("Overall quota in MB: " + configuration.OverallQuotaInMB);

                // Display the diagnostic infrastructure logs
                Trace.WriteLine("*** Diagnostic infrastructure settings ***");
                Trace.WriteLine("DiagnosticInfrastructureLogs buffer quota in MB: " + configuration.DiagnosticInfrastructureLogs.BufferQuotaInMB);
                Trace.WriteLine("DiagnosticInfrastructureLogs scheduled transfer log filter: " + configuration.DiagnosticInfrastructureLogs.ScheduledTransferLogLevelFilter);
                Trace.WriteLine("DiagnosticInfrastructureLogs transfer period: " + configuration.DiagnosticInfrastructureLogs.ScheduledTransferPeriod);

                // List the Logs info
                Trace.WriteLine("*** Logs configuration settings ***");
                Trace.WriteLine("Logs buffer quota in MB: " + configuration.Logs.BufferQuotaInMB);
                Trace.WriteLine("Logs scheduled transfer log level filter: " + configuration.Logs.ScheduledTransferLogLevelFilter);
                Trace.WriteLine("Logs transfer period: " + configuration.Logs.ScheduledTransferPeriod);

                // List the Directories info
                Trace.WriteLine("*** Directories configuration settings ***");
                Trace.WriteLine("Directories buffer quota in MB: " + configuration.Directories.BufferQuotaInMB);
                Trace.WriteLine("Directories scheduled transfer period: " + configuration.Directories.ScheduledTransferPeriod);
                int count = configuration.Directories.DataSources.Count, index;
                if (0 == count)
                {
                    Trace.WriteLine("No data sources for Directories");
                }
                else
                {
                    for (index = 0; index < count; index++)
                    {
                        Trace.WriteLine("Directories configuration data source:");
                        Trace.WriteLine("\tContainer: " + configuration.Directories.DataSources[index].Container);
                        Trace.WriteLine("\tDirectory quota in MB: " + configuration.Directories.DataSources[index].DirectoryQuotaInMB);
                        Trace.WriteLine("\tPath: " + configuration.Directories.DataSources[index].Path);
                        Trace.WriteLine("");
                    }
                }

                // List the event log info
                Trace.WriteLine("*** Event log configuration settings ***");
                Trace.WriteLine("Event log buffer quota in MB: " + configuration.WindowsEventLog.BufferQuotaInMB);
                count = configuration.WindowsEventLog.DataSources.Count;
                if (0 == count)
                {
                    Trace.WriteLine("No data sources for event log");
                }
                else
                {
                    for (index = 0; index < count; index++)
                    {
                        Trace.WriteLine("Event log configuration data source:" + configuration.WindowsEventLog.DataSources[index]);
                    }
                }
                Trace.WriteLine("Event log scheduled transfer log level filter: " + configuration.WindowsEventLog.ScheduledTransferLogLevelFilter);
                Trace.WriteLine("Event log scheduled transfer period: " + configuration.WindowsEventLog.ScheduledTransferPeriod.ToString());

                // List the performance counter info
                Trace.WriteLine("*** Performance counter configuration settings ***");
                Trace.WriteLine("Performance counter buffer quota in MB: " + configuration.PerformanceCounters.BufferQuotaInMB);
                Trace.WriteLine("Performance counter scheduled transfer period: " + configuration.PerformanceCounters.ScheduledTransferPeriod.ToString());
                count = configuration.PerformanceCounters.DataSources.Count;
                if (0 == count)
                {
                    Trace.WriteLine("No data sources for PerformanceCounters");
                }
                else
                {
                    for (index = 0; index < count; index++)
                    {
                        Trace.WriteLine("PerformanceCounters configuration data source:");
                        Trace.WriteLine("\tCounterSpecifier: " + configuration.PerformanceCounters.DataSources[index].CounterSpecifier);
                        Trace.WriteLine("\tSampleRate: " + configuration.PerformanceCounters.DataSources[index].SampleRate.ToString());
                        Trace.WriteLine("");
                    }
                }
            }

            catch (Exception e)
            {
                Trace.WriteLine("Exception during ShowConfig: " + e.ToString());
                // Take other action as needed.
            }
        }
Exemple #41
0
 static void AddPerformanceCounter(DiagnosticMonitorConfiguration cfg, string counter, TimeSpan frequency)
 {
     cfg.PerformanceCounters.DataSources.Add(new PerformanceCounterConfiguration
     {
         CounterSpecifier = counter,
         SampleRate = frequency
     });
 }
Exemple #42
0
		private static void ScheduleTransfer(DiagnosticMonitorConfiguration dmc, int transferPeriodMs)
		{
			var transferPeriod = TimeSpan.FromMilliseconds(transferPeriodMs);
			dmc.Logs.ScheduledTransferPeriod = transferPeriod;
			dmc.WindowsEventLog.ScheduledTransferPeriod = transferPeriod;
		}
Exemple #43
0
        public static void SetScheduledCountersStorage(ref DiagnosticMonitorConfiguration diagMonConf, int TransferPeriodmin, string CounterSpec, int sampleratesec)
        {
            //CounterSpec =  @"\Processor(*)\% Processor Time";

            PerformanceCounterConfiguration pcc = new PerformanceCounterConfiguration();
            pcc.CounterSpecifier = CounterSpec;
            pcc.SampleRate = TimeSpan.FromSeconds(sampleratesec);
            diagMonConf.PerformanceCounters.DataSources.Add(pcc);

            // For information on handling configuration changes
            // see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357.

            diagMonConf.PerformanceCounters.ScheduledTransferPeriod = TimeSpan.FromMinutes(TransferPeriodmin);
        }
Exemple #44
0
 public static void SetScheduledLogStorage(ref DiagnosticMonitorConfiguration diagMonConf, int TransferPeriodmin,LogLevel level)
 {
     diagMonConf.Logs.ScheduledTransferLogLevelFilter = level;
     diagMonConf.Logs.ScheduledTransferPeriod = TimeSpan.FromMinutes(TransferPeriodmin);
 }
Exemple #45
0
 static void ScheduleTransfer(DiagnosticMonitorConfiguration dmc)
 {
     var transferPeriod = TimeSpan.FromSeconds(GetScheduledTransferPeriod());
     //var transferPeriod = TimeSpan.FromMinutes(5);
     dmc.Logs.ScheduledTransferPeriod = transferPeriod;
     dmc.WindowsEventLog.ScheduledTransferPeriod = transferPeriod;
 }
Exemple #46
0
 static void AddEventSource(DiagnosticMonitorConfiguration cfg, string source)
 {
     cfg.WindowsEventLog.DataSources.Add(source);
 }
 private static void AddPerfCounter(DiagnosticMonitorConfiguration config, string name, double seconds)
 {
     var perfmon = new PerformanceCounterConfiguration();
     perfmon.CounterSpecifier = name;
     perfmon.SampleRate = System.TimeSpan.FromSeconds(seconds);
     config.PerformanceCounters.DataSources.Add(perfmon);
 }
 private void AddPerfCounters(DiagnosticMonitorConfiguration diagObj)
 {
     AddPerfCounter(diagObj, @"\LogicalDisk(*)\% Disk Read Time", 30);
     AddPerfCounter(diagObj, @"\LogicalDisk(*)\% Disk Write Time", 30);
     AddPerfCounter(diagObj, @"\LogicalDisk(*)\% Free Space", 30);
     AddPerfCounter(diagObj, @"\LogicalDisk(*)\Disk Read Bytes/sec", 30);
     AddPerfCounter(diagObj, @"\LogicalDisk(*)\Disk Write Bytes/sec", 30);
     AddPerfCounter(diagObj, @"\Memory\Available MBytes", 30);
     AddPerfCounter(diagObj, @"\Network Interface(*)\Bytes Received/sec", 30);
     AddPerfCounter(diagObj, @"\Network Interface(*)\Bytes Sent/sec", 30);
     AddPerfCounter(diagObj, @"\Processor(*)\% Processor Time", 30);
     AddPerfCounter(diagObj, @"\PhysicalDisk(*)\% Disk Read Time", 30);
     AddPerfCounter(diagObj, @"\PhysicalDisk(*)\% Disk Write Time", 30);
 }
Exemple #49
0
	    /// <summary>
		/// Starts azure diagnostics
		/// </summary>
		private static void StartAzureDiagnostics(DiagnosticMonitorConfiguration dmc)
		{
			Trace.Listeners.Add(new DiagnosticMonitorTraceListener());

	        var roleInstanceDiagnosticManager = GetRoleInstanceDiagnosticManager();

			roleInstanceDiagnosticManager.SetCurrentConfiguration(dmc);
		}