protected void btnRemove_Click(object sender, EventArgs e) { string categoryName = string.Empty; string counterName = string.Empty; string instanceName = string.Empty; foreach (GridViewRow row in gridPerfMon.Rows) { CheckBox cb = (CheckBox)row.FindControl("chkBoxNotify"); if (cb != null && cb.Checked) { Label lblCategory = row.FindControl("lblCategory") as Label; categoryName = lblCategory.Text; Label lblCounter = row.FindControl("lblCounter") as Label; counterName = lblCounter.Text; Label lblInstance = row.FindControl("lblInstance") as Label; instanceName = lblInstance.Text; try { BCCPerfCounterEntry entry = new BCCPerfCounterEntry(categoryName, instanceName, counterName); BCCPerfCounterDataAccess da = new BCCPerfCounterDataAccess(); da.PerformanceCounterEntryMarkedForDeletion(entry); new ActivityHelper().RaiseAuditEvent(this, lblCaption.Text, "removed '" + counterName + "'", 104); PopulateGrid(sortExpression, lastDirection); AddAnnoucement("You can also disable monitoring of Performance counters instead of removing them."); AddAnnoucement("The BCC agent takes 60 seconds to register changes to the performance counters for monitoring."); } catch (Exception ex) { DisplayError(ex.Message); } } } }
/// <summary> /// Display - Chart /// </summary> /// <param name="categoryName">Category Name</param> /// <param name="counterName">Counter Name</param> /// <param name="instanceName">Instance Name</param> /// <param name="numOfDataPoints">No of data points</param> private void DisplayChart(string categoryName, string counterName, string instanceName, int numOfDataPoints) { BCCPerfCounterDataAccess da = new BCCPerfCounterDataAccess(); List<BCCPerfCounterReportEntry> counterList = da.PerformanceCounterDataReport(categoryName, counterName, instanceName, 0); // Build the series. Series series = new Series(); series.Name = counterName + instanceName; series.ChartType = SeriesChartType.Point; series.LegendText = counterName; series.LegendToolTip = categoryName + " - " + counterName + "(" + instanceName + ")"; series.XValueType = ChartValueType.Time; series.YValueType = ChartValueType.Int32; series.IsValueShownAsLabel = true; series["DrawingStyle"] = "Emboss"; chartPerfCounter.Series.Add(series); foreach (BCCPerfCounterReportEntry entry in counterList) { chartPerfCounter.Series[0].Points.AddXY(String.Format("{0:T}", entry.ReportedDate), entry.PerformanceCounterValue); } while (this.chartPerfCounter.Series[0].Points.Count > numOfDataPoints) { chartPerfCounter.Series[0].Points.RemoveAt(0); } }
private void ActivatePerformanceCounters() { try { BCCPerfCounterMonitor perfCounterMonitor = null; BCCPerfCounterDataAccess da = new BCCPerfCounterDataAccess(); foreach (BCCPerfCounterEntry entry in da.PerformanceCounterEntryList()) { perfCounterMonitor = masterPerfCounterList.Find(item => item.PerfCounterEntry.ToString() == entry.ToString()); if (perfCounterMonitor != null) { if (!entry.IsEnabled || (entry.IsEnabled && entry.IsMarkedForDelete)) // Entry is disabled. { perfCounterMonitor.Stop(); masterPerfCounterList.Remove(perfCounterMonitor); WriteToEventLog("Perf counter removed for " + entry.ToString()); } } else { if (entry.IsEnabled) { perfCounterMonitor = new BCCPerfCounterMonitor(category, debugFlag, entry); perfCounterMonitor.Start(); masterPerfCounterList.Add(perfCounterMonitor); WriteToEventLog("Perf counter enabled for " + entry.ToString()); } } if (entry.IsMarkedForDelete) { da.RemovePerformanceCounterEntry(entry); WriteToEventLog("Perf counter deleted for " + entry.ToString()); } } } catch (Exception exception) { WriteToEventLog(exception.Message + exception.StackTrace); } }
private void PurgeControlCenterData() { try { int mdaDaysToKeep = 30; int pcdaDaysToKeep = 7; int webAuditDaysToKeep = 30; BCCManageConfigData configData = new BCCManageConfigData(); configData.Speedcode = BCC_AGENT_CONFIG_SPEEDCODE; configData.Query(); NameValuePairSet configSet = configData.ConfigurationData; foreach (NameValuePair nvPair in configSet) { if (nvPair.Name.Equals(BCCUIHelper.Constants.DAYS_TO_KEEP_PERFDATA)) { Int32.TryParse(nvPair.Value, out pcdaDaysToKeep); } else if (nvPair.Name.Equals(BCCUIHelper.Constants.DAYS_TO_KEEP_USRAVT)) { Int32.TryParse(nvPair.Value, out webAuditDaysToKeep); } else if (nvPair.Name.Equals(BCCUIHelper.Constants.DAYS_TO_KEEP_USRNTF)) { Int32.TryParse(nvPair.Value, out mdaDaysToKeep); } } BCCMonitoringDataAccess mda = new BCCMonitoringDataAccess(); mda.PurgeMonitoringData(mdaDaysToKeep); BCCPerfCounterDataAccess pcda = new BCCPerfCounterDataAccess(); pcda.PurgePerformanceCounterData(pcdaDaysToKeep); BCCWebAudit.PurgeWebAuditEvents(webAuditDaysToKeep); } catch (Exception exception) { WriteToEventLog(exception.Message + exception.StackTrace); } }
protected void gridPerfCounters_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName.Equals("Monitor")) { LinkButton lnkMonitor = e.CommandSource as LinkButton; if (lnkMonitor != null) { GridViewRow row = (GridViewRow)(lnkMonitor.NamingContainer); if (row != null) { string categoryName = row.Cells[0].Text; string counterName = row.Cells[3].Text; Label lblInstanceName = row.Cells[2].FindControl("lblInstanceName") as Label; string instanceName = lblInstanceName.Text; string logData = string.Format("setup '{0}::{1}' for monitoring", categoryName, counterName); BCCPerfCounterEntry entry = new BCCPerfCounterEntry(categoryName, instanceName, counterName); if (entry.PerfInstance != string.Empty) { BCCPerfCounterDataAccess dataAccess = new BCCPerfCounterDataAccess(); dataAccess.CreatePerformanceCounterEntry(entry); lnkMonitor.Text = "Added"; lnkMonitor.Enabled = false; } new ActivityHelper().RaiseAuditEvent(this, lblCaption.Text, logData, 303); } } } }