public void RefreshData()
        {
            Data.Enums.ReportType type = Data.Enums.ReportType.Text;
            if (csvCheckbutton.Checked)
            {
                type = Data.Enums.ReportType.CSV;
            }

            switch (currentReport)
            {
            case Report.Schedule:
                Task.Run(() => ReportHelpers.GetNextWeekScheduleReport(type, new TvmazeApi())).ContinueWith((task) => UpdateReport(task.Result));
                break;

            case Report.TopTen:
                UpdateReport(ReportHelpers.TopTenShowsReport(type));
                break;

            case Report.TopNetworks:
                UpdateReport(ReportHelpers.TopNetworksReport(type));
                break;

            case Report.ShowOverView:
                UpdateReport(ReportHelpers.ShowReport(type));
                break;

            case Report.Recommendations:
                UpdateReport(ReportHelpers.RecommendedShowsReport(selectedGenres.ToArray(), type));
                break;

            default:
                throw new NotSupportedException();
            }
        }
Exemple #2
0
        public override void ExecuteCommand()
        {
            AlertThresholds thresholdValues = new JavaScriptSerializer().Deserialize <AlertThresholds>(ReportHelpers.Load(StorageAccount, "Configuration.AlertThresholds.json", ContainerName));
            int             diff            = GetTotalPackageCountFromDatabase() - GetTotalPackageCountFromLucene();

            if (diff > thresholdValues.LuceneIndexLagAlertErrorThreshold || diff < -200) //Increasing the value for negative lag due to bug https://github.com/NuGet/NuGetGallery/issues/2328/. TBD : Make the threshold configurable.
            {
                new SendAlertMailTask
                {
                    AlertSubject = "Error: Search Service Alert activated for Lucene index lag",
                    Details      = string.Format("Delta between the packages between in database and lucene index is {0}. Error Threshold lag : {1} packages", diff.ToString(), thresholdValues.LuceneIndexLagAlertErrorThreshold),
                    AlertName    = "Error: Alert for LuceneIndexLag",
                    Component    = "SearchService",
                    Level        = "Error"
                }.ExecuteCommand();
            }
            else if (diff > thresholdValues.LuceneIndexLagAlertWarningThreshold)
            {
                new SendAlertMailTask
                {
                    AlertSubject = "Warning: Search Service Alert activated for Lucene index lag",
                    Details      = string.Format("Delta between the packages between in database and lucene index is {0}. Warning Threshold lag : {1} packages", diff.ToString(), thresholdValues.LuceneIndexLagAlertWarningThreshold),
                    AlertName    = "Warning: Alert for LuceneIndexLag",
                    Component    = "SearchService",
                    Level        = "Warning"
                }.ExecuteCommand();
            }

            ReportHelpers.AppendDatatoBlob(StorageAccount, "IndexingDiffCount" + string.Format("{0:MMdd}", DateTime.Now) + "HourlyReport.json", new Tuple <string, string>(string.Format("{0:HH-mm}", DateTime.Now), diff.ToString()), 24, ContainerName);
        }
Exemple #3
0
        }   // MaxStringLength_Test_Case


        private static void MergeNewItemsIntoArray_Tests ( )
        {
            int intTestNumber = MagicNumbers.ZERO;

            Console.WriteLine (
                SharedUtl4_TestStand.Properties.Resources.IDS_MERGENEWITEMSINTOARRAY_BEGIN ,
                Environment.NewLine );
            string strInitialMasterFile = Path.Combine (
                rs_strDataDirectory ,
                Properties.Settings.Default.MergeNewItemsIntoArray_Master );
            string strOutputFilenmetemplate = Properties.Settings.Default.MergeNewItemsIntoArray_Outputs;

            string strNewItemsListFileSpec = Properties.Settings.Default.MergeNewItemsIntoArray_Cases;
            int intMaxDigitsInCaseNumber = TestCaseMaxDigits ( strNewItemsListFileSpec );
            string strSummaryFileFQFN = Path.Combine (
                rs_strDataDirectory ,
                Properties.Settings.Default.MergeNewItemsIntoArray_Summary );
            string strOutputFileFQFN = null;
            string strInputFileName = null;
            string strReportLabels = MergeNewItemsIntoArray_Tester.ReportLabels.Replace (
				SpecialCharacters.TAB_CHAR ,
                SpecialCharacters.PIPE_CHAR );
            List<string> lstReportDetails = new List<string> ( );
            lstReportDetails.Add ( strReportLabels );

            string strReportDetailTemplate = ReportHelpers.DetailTemplateFromLabels (
                strReportLabels ,
                SpecialCharacters.PIPE_CHAR );
            foreach ( string strNewDataFile in Directory.GetFiles ( rs_strDataDirectory , strNewItemsListFileSpec , SearchOption.TopDirectoryOnly ) )
            {
                strInputFileName = SelectInputFle (
                    intTestNumber ,
                    strInitialMasterFile ,
                    strOutputFileFQFN );
                strOutputFileFQFN = MergeOutputFQFN (
                    strOutputFilenmetemplate ,
                    rs_strDataDirectory ,
                    intMaxDigitsInCaseNumber ,
                    ++intTestNumber );

                MergeNewItemsIntoArray_Tester mergetester = new MergeNewItemsIntoArray_Tester (
                    strInputFileName ,
                    strNewDataFile ,
                    strOutputFileFQFN ,
                    lstReportDetails ,
                    strReportDetailTemplate );
                MergeNewItemsIntoArray_Test_Case (
                    mergetester ,
                    ref intTestNumber );
            }   // foreach ( string strNewDataFile in Directory.GetFiles ( rs_strDataDirectory , strNewItemsListFileSpec , SearchOption.TopDirectoryOnly ) )

            string [ ] astrSummaryReport = new string [ lstReportDetails.Count ];
            lstReportDetails.CopyTo ( astrSummaryReport );
            File.WriteAllLines (
                strSummaryFileFQFN , 
                astrSummaryReport );
            Console.WriteLine (
                SharedUtl4_TestStand.Properties.Resources.IDS_MERGENEWITEMSINTOARRAY_END ,
                Environment.NewLine );
        }   // MergeNewItemsIntoArray_Tests
        private void CreateInstanceCountReport(XmlDocument doc)
        {
            XmlNodeList roleInstanceNodes = doc.GetElementsByTagName("RoleInstance", "http://schemas.microsoft.com/windowsazure");

            Console.WriteLine(roleInstanceNodes.Count);
            ReportHelpers.AppendDatatoBlob(StorageAccount, ServiceName + "InstanceCount" + string.Format("{0:MMdd}", DateTime.Now) + "HourlyReport.json", new Tuple <string, string>(string.Format("{0:HH-mm}", DateTime.Now), roleInstanceNodes.Count.ToString()), 24, ContainerName);
        }
        private string CreateTableForIISRequestsDistribution()
        {
            List <string> _dates = new List <string>();

            _dates.Add(Date);
            return(ReportHelpers.CreateTableForIISRequestsDistribution(StorageAccount, ContainerName, _dates));
        }
        private void CreateUserAgentReport(DirectoryInfo info)
        {
            string standardError  = string.Empty;
            string standardOutput = string.Empty;
            List <IISUserAgentDetails> userAgentDetails = new List <IISUserAgentDetails>();
            var content = ReportHelpers.Load(StorageAccount, "Configuration.IISUserAgent.json", ContainerName);
            List <IISUserAgentDetails> userAgents = new List <IISUserAgentDetails>();

            userAgents = new JavaScriptSerializer().Deserialize <List <IISUserAgentDetails> >(content);
            foreach (IISUserAgentDetails agent in userAgents)
            {
                string query        = string.Format(@"select count(*) from {0}\*{1}*.log WHERE cs(User-Agent) LIKE '{2}'", info.FullName, ReportDate, agent.UserAgent);
                int    requestCount = InvokeLogParserProcessForUserAgent(@"-i:IISW3C -o:CSV " + @"""" + query + @"""" + " -stats:OFF");
                int    avgTime      = 0;
                if (requestCount > 0)
                {
                    query   = string.Format(@"select avg(time-taken) from {0}\*{1}*.log WHERE cs(User-Agent) LIKE '{2}'", info.FullName, ReportDate, agent.UserAgent);
                    avgTime = InvokeLogParserProcessForUserAgent(@"-i:IISW3C -o:CSV " + @"""" + query + @"""" + " -stats:OFF");
                }
                userAgentDetails.Add(new IISUserAgentDetails(agent.UserAgentName, agent.UserAgent, avgTime, requestCount));
            }

            string blobName = "IISUserAgentDetails" + ReportDate + ".json";
            int    count    = 0;

            foreach (IISUserAgentDetails detail in userAgentDetails)
            {
                var json = new JavaScriptSerializer().Serialize(detail);
                ReportHelpers.AppendDatatoBlob(StorageAccount, blobName, new Tuple <string, string>(count.ToString(), json), userAgentDetails.Count, ContainerName);
                count++;
            }
        }
        public override void ExecuteCommand()
        {
            NetworkCredential nc      = new NetworkCredential(UserName, Password);
            WebRequest        request = WebRequest.Create("https://api.pingdom.com/api/2.0/checks");

            request.Credentials = nc;
            request.Headers.Add(AppKey);
            request.PreAuthenticate = true;
            request.Method          = "GET";
            WebResponse respose = request.GetResponse();

            using (var reader = new StreamReader(respose.GetResponseStream()))
            {
                JavaScriptSerializer js = new JavaScriptSerializer();
                var objects             = js.Deserialize <dynamic>(reader.ReadToEnd());
                foreach (var o in objects["checks"])
                {
                    List <Tuple <string, string> > summary = GetCheckSummaryAvgForSpecifiedTimeSpan(o["id"]);
                    JArray reportObject = ReportHelpers.GetJson(summary);
                    string checkAlias   = o["name"].ToString();
                    checkAlias = checkAlias.Replace(" ", ".");
                    checkAlias = checkAlias.Replace("(", "").Replace(")", "");
                    ReportHelpers.CreateBlob(StorageAccount, checkAlias + Frequency + "Report.json", ContainerName, "application/json", ReportHelpers.ToStream(reportObject));
                }
            }
        }
        private void CreateRestoreReportForVSTask()
        {
            string[] VsQuery = new JavaScriptSerializer().Deserialize <string[]>(ReportHelpers.Load(StorageAccount, "VsVersion.json", ContainerName));
            using (var sqlConnection = new SqlConnection(ConnectionString.ConnectionString))
            {
                using (var dbExecutor = new SqlExecutor(sqlConnection))
                {
                    sqlConnection.Open();
                    DateTime         date     = DateTime.UtcNow.AddDays(-LastNDays);
                    List <VsRequest> requests = new List <VsRequest>();
                    foreach (string each in VsQuery)
                    {
                        try
                        {
                            var request = dbExecutor.Query <Int32>(string.Format(sqlQueryForVSRestore, date.ToString("yyyy-MM-dd"), each)).SingleOrDefault();
                            requests.Add(new VsRequest("VS" + each, request.ToString()));
                        }

                        catch
                        {
                            requests.Add(new VsRequest("VS" + each, "0"));
                        }
                    }
                    var json = new JavaScriptSerializer().Serialize(requests);
                    ReportHelpers.CreateBlob(StorageAccount, "VsRestoreTrend" + LastNDays.ToString() + "Day.json", ContainerName, "application/json", ReportHelpers.ToStream(json));
                }
            }
        }
        private List <Tuple <string, string, double> > GetScenarioValuesFromBlob(string blobName, string containerName, int startTime, int endTime)
        {
            Dictionary <string, string> dict           = ReportHelpers.GetDictFromBlob(StorageAccount, blobName, containerName);
            List <IISRequestDetails>    requestDetails = new List <IISRequestDetails>();

            foreach (KeyValuePair <string, string> keyValuePair in dict)
            {
                int key = Convert.ToInt32(keyValuePair.Key.Replace(":", "").Replace("-", ""));

                if ((key >= startTime) && (key <= endTime))
                {
                    requestDetails.AddRange(new JavaScriptSerializer().Deserialize <List <IISRequestDetails> >(keyValuePair.Value));
                }
            }

            var requestGroups = requestDetails.GroupBy(item => item.ScenarioName);
            List <Tuple <string, string, double> > scenarios = new List <Tuple <string, string, double> >();

            foreach (IGrouping <string, IISRequestDetails> group in requestGroups)
            {
                if (group.Key.Contains("Over all requests"))
                {
                    LoadTestRequestPerHour = Convert.ToInt32((group.Average(item => item.RequestsPerHour)));
                    continue;
                }
                scenarios.Add(new Tuple <string, string, double>(group.Key, Convert.ToInt32((group.Average(item => item.RequestsPerHour) / LoadTestRequestPerHour) * 100) + "%", group.Average(item => item.AvgTimeTakenInMilliSeconds)));
            }
            return(scenarios);
        }
        private List <int> GetMetricValuesFromBlob(string blobName, string containerName, int startTime, int endTime)
        {
            Dictionary <string, string> dict = new Dictionary <string, string>();

            try
            {
                dict = ReportHelpers.GetDictFromBlob(StorageAccount, blobName, containerName);
            }
            catch (Exception) { }
            List <int> values = new List <int>();

            if (dict != null)
            {
                foreach (KeyValuePair <string, string> keyValuePair in dict)
                {
                    int key = Convert.ToInt32(keyValuePair.Key.Replace(":", "").Replace("-", ""));

                    if ((key >= startTime) && (key <= endTime))
                    {
                        values.Add(Convert.ToInt32(keyValuePair.Value));
                    }
                }
            }
            return(values);
        }
        private void CreateReportForDBCPUUsage()
        {
            List <Tuple <string, string> > usageDataPoints = new List <Tuple <string, string> >();
            var masterConnectionString = Util.GetMasterConnectionString(ConnectionString.ConnectionString);
            var currentDbName          = Util.GetDbName(ConnectionString.ConnectionString);

            using (var sqlConnection = new SqlConnection(masterConnectionString))
            {
                using (var dbExecutor = new SqlExecutor(sqlConnection))
                {
                    sqlConnection.Open();

                    List <DateTime> lastNTimeEntries = dbExecutor.Query <DateTime>(string.Format("select distinct Top(5) time from sys.resource_usage where database_name = '{0}' order by time desc", currentDbName.ToString())).ToList();
                    foreach (DateTime time in lastNTimeEntries)
                    {
                        Console.WriteLine("Time ..................." + time.ToString());
                        var usageSeconds = dbExecutor.Query <Int32>(string.Format("select Sum(usage_in_seconds) from sys.resource_usage where time = '{0}' AND database_name = '{1}'", time.ToString(), currentDbName)).SingleOrDefault();
                        usageDataPoints.Add(new Tuple <string, string>(String.Format("{0:HH:mm}", time.ToLocalTime()), usageSeconds.ToString()));
                    }
                }
                usageDataPoints.Reverse(); //reverse it as the array returned will have latest hour as first entry.
                JArray reportObject = ReportHelpers.GetJson(usageDataPoints);
                ReportHelpers.CreateBlob(StorageAccount, "DBCPUTime" + string.Format("{0:MMdd}", DateTime.Now) + ".json", ContainerName, "application/json", ReportHelpers.ToStream(reportObject));
            }
        }
Exemple #12
0
        public override void ExecuteCommand()
        {
            //Get the logs for the previous Hour as the current one is being used by Azure.
            string        DeploymentID  = new JavaScriptSerializer().Deserialize <string>(ReportHelpers.Load(StorageAccount, "DeploymentId_" + ServiceName + ".json", ContainerName));
            string        latestLogName = "u_ex" + string.Format("{0:yyMMddHH}", DateTime.UtcNow.AddHours(-1)) + ".log";
            DirectoryInfo info          = new System.IO.DirectoryInfo(Path.Combine(Environment.CurrentDirectory, latestLogName));

            //Downlog the logs for the last hour.
            while (RetryCount-- > 0)
            {
                try
                {
                    if (!Directory.Exists(info.FullName))
                    {
                        Directory.CreateDirectory(info.FullName);
                    }

                    int instanceCount = GetCurrentInstanceCountInGallery(); //get current instance count.
                    for (int i = 0; i < instanceCount; i++)
                    {
                        ReportHelpers.DownloadBlobToLocalFile(IISStorageAccount, DeploymentID + "/NuGetGallery/NuGetGallery_IN_" + i.ToString() + "/Web/W3SVC1273337584/" + latestLogName, Path.Combine(info.FullName, "IN" + i.ToString() + ".log"), "wad-iis-requestlogs");
                    }
                    break; // break if the operation succeeds without doing any retry.
                }
                catch (Exception e)
                {
                    Console.WriteLine(string.Format("Exception thrown while trying to create report : {0}", e.Message));
                }
            }
            //Create reports.
            CreateOverviewReport(info);
            CreateUriStemDetailedReport(info);
        }
        private int GetMetricCountFromBlob(string blobName)
        {
            string content = ReportHelpers.Load(StorageAccount, blobName, ContainerName);
            JArray jArray  = JArray.Parse(content);

            return(jArray.Count);
        }
        private void CreateDepolymentIdReport(XmlDocument doc)
        {
            XmlNodeList depolymentIdNode = doc.GetElementsByTagName("PrivateID", "http://schemas.microsoft.com/windowsazure");
            string      depolyId         = depolymentIdNode[0].InnerText;
            var         json             = new JavaScriptSerializer().Serialize(depolyId);

            ReportHelpers.CreateBlob(StorageAccount, "DeploymentId_" + ServiceName + ".json", ContainerName, "application/json", ReportHelpers.ToStream(json));
        }
        public void BuildFilterQuery_Basic( )
        {
            StructuredQuery query = ReportHelpers.BuildFilterQuery("Name='test'", new ReadiNow.Model.EntityRef("test:person"), false);

            Assert.That(query, Is.Not.Null);
            Assert.That(query.RootEntity, Is.Not.Null);
            Assert.That(query.RootEntity.Conditions.Count, Is.EqualTo(1));
        }
Exemple #16
0
        private void CreateReport_RecentPopularityDetail()
        {
            Log.Info("CreateReport_RecentPopularityDetail");

            Tuple <string[], List <object[]> > report = ExecuteSql("NuGetGallery.Operations.Scripts.DownloadReport_RecentPopularityDetail.sql");

            CreateBlob(RecentPopularityDetail + ".json", JsonContentType, ReportHelpers.ToJson(report));
        }
Exemple #17
0
        /// <summary>
        /// Creates report for Over all RequestsPerHour
        /// </summary>
        /// <param name="info"></param>
        private void CreateOverviewReport(DirectoryInfo info)
        {
            int    requestCount = GetDataForUriStem("%", "count (*)", info.FullName);
            string blobName     = "IISRequests" + string.Format("{0:MMdd}", DateTime.Now.AddHours(-1)) + ".json";
            Tuple <string, string> datapoint = new Tuple <string, string>(string.Format("{0:HH:00}", DateTime.Now.AddHours(-1)), requestCount.ToString());

            ReportHelpers.AppendDatatoBlob(StorageAccount, blobName, datapoint, 50, ContainerName);
        }
Exemple #18
0
        private void CreateReport_Last6Weeks()
        {
            Log.Info("CreateReport_Last6Weeks");

            Tuple <string[], List <object[]> > report = ExecuteSql("NuGetGallery.Operations.Scripts.DownloadReport_Last6Weeks.sql");

            CreateBlob(Last6Weeks + ".json", JsonContentType, ReportHelpers.ToJson(report));
        }
Exemple #19
0
        }   // BeginTest method


        /// <summary>
        /// Create a report of the contents of the deserialized response in
        /// <paramref name="timeSeriesDailyResponse"/>.
        /// </summary>
        /// <param name="timeSeriesDailyResponse">
        /// The populated TimeSeriesDailyResponse instance returned by the JSON
        /// deserializer.
        /// </param>
        internal static void ConsumeResponse (
            string pstrReportFileName ,
            TimeSeriesDailyResponse timeSeriesDailyResponse )
        {
            Console.WriteLine (
                Properties.Resources.MSG_RESPONSE_METADATA ,                    // Format control string
                new object [ ]
                {
                    timeSeriesDailyResponse.Meta_Data.Information ,             // Format item 0: Information   = {0}
                    timeSeriesDailyResponse.Meta_Data.Symbol ,                  // Format Item 1: Symbol        = {1}
                    timeSeriesDailyResponse.Meta_Data.LastRefreshed ,           // Format Item 2: LastRefreshed = {2}
                    timeSeriesDailyResponse.Meta_Data.OutputSize ,              // Format Item 3: OutputSize    = {3}
                    timeSeriesDailyResponse.Meta_Data.TimeZone ,                // Format Item 4: TimeZone      = {4}
                    timeSeriesDailyResponse.Time_Series_Daily.Length ,          // Format Item 5: Detail Count  = {5}
                    Environment.NewLine                                         // Format Item 6: Platform-dependent newline
                } );

            string strAbsoluteInputFileName = AssembleAbsoluteFileName ( pstrReportFileName );

            using ( StreamWriter swTimeSeriesDetail = new StreamWriter ( strAbsoluteInputFileName ,
                                                                         FileIOFlags.FILE_OUT_CREATE ,
                                                                         System.Text.Encoding.ASCII ,
                                                                         MagicNumbers.CAPACITY_08KB ) )
            {
                string strLabelRow = Properties.Resources.MSG_RESPONSE_DETAILS_LABELS.ReplaceEscapedTabsInStringFromResX ( );
                swTimeSeriesDetail.WriteLine ( strLabelRow );
                string strDetailRowFormatString = ReportHelpers.DetailTemplateFromLabels ( strLabelRow );

                for ( int intJ = ArrayInfo.ARRAY_FIRST_ELEMENT ;
                          intJ < timeSeriesDailyResponse.Time_Series_Daily.Length ;
                          intJ++ )
                {
                    Time_Series_Daily daily = timeSeriesDailyResponse.Time_Series_Daily [ intJ ];
                    swTimeSeriesDetail.WriteLine (
                        strDetailRowFormatString ,
                        new object [ ]
                        {
                            ArrayInfo.OrdinalFromIndex ( intJ ) ,               // Format Item 0: Item
                            Beautify ( daily.Activity_Date) ,                   // Format Item 1: Activity_Date
                            Beautify ( daily.Open ) ,                           // Format Item 2: Open
                            Beautify ( daily.High ) ,                           // Format Item 3: High
                            Beautify ( daily.Low ) ,                            // Format Item 4: Low
                            Beautify ( daily.Close ) ,                          // Format Item 5: Close
                            Beautify ( daily.AdjustedClose ) ,                  // Format Item 6: AdjustedClose
                            Beautify ( daily.Volume ) ,                         // Format Item 7: Volume
                            Beautify ( daily.DividendAmount ) ,                 // Format Item 8: DividendAmount
                            Beautify ( daily.SplitCoefficient )                 // Format Item 9: SplitCoefficient
                        } );
                }   // for ( int intJ = ArrayInfo.ARRAY_FIRST_ELEMENT ; intJ < timeSeriesDailyResponse.Time_Series_Daily.Length ; intJ++ )
            }   // using ( StreamWriter swTimeSeriesDetail = new StreamWriter ( strAbsoluteInputFileName , FileIOFlags.FILE_OUT_CREATE , System.Text.Encoding.ASCII , MagicNumbers.CAPACITY_08KB ) )

            Console.WriteLine (
                ShowFileDetails (                                               // Print the returned string.
                    Properties.Resources.FILE_LABEL_CONTENT_REPORT ,            // string pstrLabel
                    strAbsoluteInputFileName ,                                  // string pstrFileName
                    true ,                                                      // bool   pfPrefixWithNewline = false
                    false ) );                                                  // bool   pfSuffixWithNewline = true
        }   // private static void ConsumeResponse
        public async Task <IActionResult> Details(int id)
        {
            ViewData["Spider"] = await _spiderService.GetAll();

            var report = await _reportService.Get(id);

            await _reportService.IncrementReportViews(id);

            return(View(ReportHelpers.ConvertToView(report)));
        }
Exemple #21
0
        private void CreateEmptyPackageReport(string packageId)
        {
            Log.Info($"CreateEmptyPackageReport for {packageId}");

            // All blob names use lower case identifiers in the NuGet Gallery Azure Blob Storage

            string name = PackageReportDetailBaseName + packageId.ToLowerInvariant();

            CreateBlob(name + ".json", JsonContentType, ReportHelpers.ToStream(new JObject()));
        }
        public override void ExecuteCommand()
        {
            TableErrorLog        log      = new TableErrorLog(string.Format(ElmahAccountCredentials));
            List <ErrorLogEntry> entities = new List <ErrorLogEntry>();

            log.GetErrors(0, 500, entities); //retrieve n * LastNHours errors assuming a max of 500 errors per hour.
            int count = entities.Where(entity => entity.Error.Time.ToUniversalTime() > DateTime.UtcNow.AddHours(-1) && entity.Error.Time.ToUniversalTime() < DateTime.UtcNow).ToList().Count;

            ReportHelpers.AppendDatatoBlob(StorageAccount, "ErrorRate" + string.Format("{0:MMdd}", DateTime.Now) + ".json", new Tuple <string, string>(String.Format("{0:HH:mm}", DateTime.Now), count.ToString()), 50, ContainerName);
        }
        public async Task <IActionResult> Edit(int Id)
        {
            var reportModel = await _reportService.Get(Id);

            var reportView = ReportHelpers.ConvertToView(reportModel);

            ViewData["Spider"] = await _spiderService.GetAll();

            return(View(reportView));
        }
Exemple #24
0
		}   // LabelAndValue


		private static int ComputeLabelFieldWidth ( LabelAndValue [ ] pautpLabelAndValue )
		{
			List<string> lstAllLabels = new List<string> ( pautpLabelAndValue.Length );

			foreach ( LabelAndValue labelAndValue in pautpLabelAndValue )
			{
				lstAllLabels.Add ( labelAndValue.Label );
			}   // foreach ( LabelAndValue labelAndValue in pautpLabelAndValue )

			return ReportHelpers.MaxStringLength ( lstAllLabels );
		}   // private ComputeLabelFieldWidth Method
        private List <WorkInstanceDetail> GetWorkJobDetail()
        {
            List <WorkInstanceDetail> jobDetail = new List <WorkInstanceDetail>();
            var content = ReportHelpers.Load(StorageAccount, "WorkJobDetail.json", ContainerName);

            if (content != null)
            {
                jobDetail = new JavaScriptSerializer().Deserialize <List <WorkInstanceDetail> >(content);
            }
            return(jobDetail);
        }
        private int GetDownloadNumbersFromBlob(string blobName)
        {
            Dictionary <string, string> dict = ReportHelpers.GetDictFromBlob(StorageAccount, blobName, ContainerName);
            List <int> values = new List <int>();

            foreach (KeyValuePair <string, string> keyValuePair in dict)
            {
                values.Add(Convert.ToInt32(keyValuePair.Value));
            }
            return(values.Sum());
        }
        public override void ExecuteCommand()
        {
            X509Certificate cert    = X509Certificate.CreateFromCertFile(CertificateName);
            HttpWebRequest  request = (HttpWebRequest)WebRequest.Create(string.Format("https://management.core.windows.net/{0}/services/WATM/profiles/{1}/definitions", SubscriptionId, ProfileName));

            request.ClientCertificates.Add(cert);
            request.Headers.Add("x-ms-version: 2014-02-01");
            request.PreAuthenticate = true;
            request.Method          = "GET";
            var response = request.GetResponse();

            //Schema of the response would be as specified in http://msdn.microsoft.com/en-us/library/azure/hh758251.aspx
            using (var reader = new StreamReader(response.GetResponseStream()))
            {
                var responseContent = reader.ReadToEnd();
                Console.WriteLine(responseContent);

                var responseDoc = new XmlDocument();
                responseDoc.LoadXml(responseContent);
                var endpointNodes = responseDoc.GetElementsByTagName("Endpoint", "http://schemas.microsoft.com/windowsazure");
                //Endpoint Structure
                //<Endpoint >
                //    <DomainName>    Name                </DomainName>
                //    <Status>        Enabled             </Status>
                //    <Type>          CloudService        </Type>
                //    <Location>      North Central US    </Location>
                //    <MonitorStatus> Online              </MonitorStatus>
                //    <Weight>        1                   </Weight>
                //</Endpoint>

                var endpointValues = new List <Tuple <string, string> >();
                foreach (XmlNode endpointNode in endpointNodes)
                {
                    string endpointName   = endpointNode["DomainName"].InnerText;
                    string endpointStatus = endpointNode["MonitorStatus"].InnerText;
                    Console.WriteLine(string.Format("Endpoint name {0}, status {1}", endpointName, endpointStatus));
                    endpointValues.Add(Tuple.Create(endpointName, endpointStatus));
                    if (!endpointStatus.Equals("Online", StringComparison.OrdinalIgnoreCase))
                    {
                        new SendAlertMailTask
                        {
                            AlertSubject = string.Format("Error: Traffic manager endpoint alert activated for {0}", endpointName),
                            Details      = string.Format("The status of the endpoint {0} monitoring by traffic manager {1} is {2}", endpointName, ProfileName, endpointStatus),
                            AlertName    = "Error: Alert for TrafficManagerEndpoint",
                            Component    = "TrafficManager",
                            Level        = "Error"
                        }.ExecuteCommand();
                    }
                }
                JArray reportObject = ReportHelpers.GetJson(endpointValues);
                ReportHelpers.CreateBlob(StorageAccount, "TrafficManagerStatus.json", ContainerName, "application/json", ReportHelpers.ToStream(reportObject));
            }
        }
        //  for the initial release we will run New and Old reports in parallel
        //  (the difference is that new reports contain more details)
        //  then when we are happy with our new deployment we will drop the old

        private void CreatePackageReport(string packageId)
        {
            Log.Info(string.Format("CreatePackageReport for {0}", packageId));

            // All blob names use lower case identifiers in the NuGet Gallery Azure Blob Storage

            string name = PackageReportDetailBaseName + packageId.ToLowerInvariant();

            JObject report = CreateJsonContent(packageId);

            CreateBlob(name + ".json", JsonContentType, ReportHelpers.ToStream(report));
        }
Exemple #29
0
        public override void ExecuteCommand()
        {
            sqlQueryForDbAge = string.Format("select create_date from sys.databases where name = '{0}'", DbName);
            thresholdValues  = new JavaScriptSerializer().Deserialize <AlertThresholds>(ReportHelpers.Load(StorageAccount, "Configuration.AlertThresholds.json", ContainerName));
            List <Tuple <string, string> > jobOutputs = new List <Tuple <string, string> >();

            jobOutputs.Add(new Tuple <string, string>("SyncPackagesToFailoverDC", CheckLagBetweenDBAndBlob()));
            jobOutputs.Add(new Tuple <string, string>("ImportCompletionStatus", CheckForInCompleteDBImport()));
            JArray reportObject = ReportHelpers.GetJson(jobOutputs);

            ReportHelpers.CreateBlob(StorageAccount, "RunBackgroundCheckForFailoverDCReport.json", ContainerName, "application/json", ReportHelpers.ToStream(reportObject));
        }
        private void CreateReportForDataBaseEvents()
        {
            var masterConnectionString = Util.GetMasterConnectionString(ConnectionString.ConnectionString);
            var currentDbName          = Util.GetDbName(ConnectionString.ConnectionString);

            using (var sqlConnection = new SqlConnection(masterConnectionString))
            {
                using (var dbExecutor = new SqlExecutor(sqlConnection))
                {
                    sqlConnection.Open();

                    var usageSeconds = dbExecutor.Query <DatabaseEvent>(string.Format("select start_time, end_time,event_type,event_count,description from sys.event_log where start_time>='{0}' and start_time<='{1}' and database_name = '{2}' and severity = 2", DateTime.UtcNow.AddHours(-LastNHours).ToString("yyyy-MM-dd hh:mm:ss"), DateTime.UtcNow.ToString("yyyy-MM-dd hh:mm:ss"), currentDbName));
                    var json         = new JavaScriptSerializer().Serialize(usageSeconds);
                    ReportHelpers.CreateBlob(StorageAccount, "DBDetailed" + LastNHours.ToString() + "Hour.json", ContainerName, "application/json", ReportHelpers.ToStream(json));

                    var             throttlingEventCount = dbExecutor.Query <Int32>(string.Format("select count(*) from sys.event_log where start_time>='{0}' and start_time<='{1}' and database_name = '{2}' and (event_type Like 'throttling%' or event_type Like 'deadlock')", DateTime.UtcNow.AddHours(-1).ToString("yyyy-MM-dd hh:mm:ss"), DateTime.UtcNow.ToString("yyyy-MM-dd hh:mm:ss"), currentDbName)).SingleOrDefault();
                    var             additional_data      = dbExecutor.Query <string>(string.Format("select additional_data from sys.event_log where start_time>='{0}' and start_time<='{1}' and database_name = '{2}' and (event_type Like 'throttling%' or event_type Like 'deadlock')", DateTime.UtcNow.AddHours(-1).ToString("yyyy-MM-dd hh:mm:ss"), DateTime.UtcNow.ToString("yyyy-MM-dd hh:mm:ss"), currentDbName));
                    AlertThresholds thresholdValues      = new JavaScriptSerializer().Deserialize <AlertThresholds>(ReportHelpers.Load(StorageAccount, "Configuration.AlertThresholds.json", ContainerName));

                    StringBuilder sb = new StringBuilder();
                    foreach (string data in additional_data)
                    {
                        if (data != null)
                        {
                            sb.Append(data + "\n");
                        }
                    }
                    if (throttlingEventCount > thresholdValues.DatabaseThrottlingEventErrorThreshold && LastNHours == 1)
                    {
                        new SendAlertMailTask
                        {
                            AlertSubject = "Error: SQL Azure DB alert activated for throttling/deadlock event",
                            Details      = string.Format("Number of events exceeded threshold for DB throttling/deadlock events. Error Threshold count : {0}, events noticed in last hour : {1}, all additional data is {2}", thresholdValues.DatabaseThrottlingEventErrorThreshold, throttlingEventCount, sb.ToString()),
                            AlertName    = "Error: SQL Azure DB throttling/deadlock event",
                            Component    = "SQL Azure Database",
                            Level        = "Error"
                        }.ExecuteCommand();
                    }
                    else if (throttlingEventCount > thresholdValues.DatabaseThrottlingEventWarningThreshold && LastNHours == 1)
                    {
                        new SendAlertMailTask
                        {
                            AlertSubject = "Warning: SQL Azure DB alert activated for throttling/deadlock event",
                            Details      = string.Format("Number of events exceeded threshold for DB throttling/deadlock events. Warning Threshold count : {0}, events noticed in last hour : {1}, all additional data is {2}", thresholdValues.DatabaseThrottlingEventWarningThreshold, throttlingEventCount, sb.ToString()),
                            AlertName    = "Warning: SQL Azure DB throttling/deadlock event",
                            Component    = "SQL Azure Database",
                            Level        = "Warning"
                        }.ExecuteCommand();
                    }
                }
            }
        }