Exemple #1
0
        protected override void OnExit(ExitEventArgs e)
        {
            ServiceMonitor.StopAll();
            var result = EngineService.Default.AppClosed();

            base.OnExit(e);
        }
Exemple #2
0
        public FormMain()
        {
            InitializeComponent();

            _svcMonitor = new ServiceMonitor("TsManager");
            _svcMonitor.AppendEnabledWhenStarted(tsmiStop, false);
            _svcMonitor.AppendEnabledWhenStarted(tsbStop, false);
            _svcMonitor.AppendEnabledWhenStarted(tsmiRestart, true);
            _svcMonitor.AppendEnabledWhenStopped(tsmiStart);
            _svcMonitor.AppendEnabledWhenStopped(tsbStart);
            _svcMonitor.AppendStatus(tsslServiceStatus);
            _svcMonitor.StartMonitor();

            _logicLoader = new AMCSLogicLoader(TsGlobalConst.GetACMSLogicDirectory());

            LoadGUISettings();
            LoadSettings();
            BuildTreeFromSettings();

            _eventsViewLink = new ListedEventsViewLink(lvLog, _appSettings.FilterSettings,
                                                       _appSettings.LogColumns, true);

            _eventsViewLink.AddCommandItem(tsmiReloadEvents, EventsViewCommand.Update);
            _eventsViewLink.AddCommandItem(toolStripButton1, EventsViewCommand.Update);
            _eventsViewLink.AddCommandItem(tsmiDetails, EventsViewCommand.Details);
            _eventsViewLink.AddCommandItem(tsmiViewFilter, EventsViewCommand.Filter);
            _eventsViewLink.SourceConnector = new LogConnector(tsslUpdateProgress);
            _eventsViewLink.Update();
        }
Exemple #3
0
        /// <summary>
        /// Загрузка параметров формы
        /// </summary>
        private void LoadFormSettings()
        {
            _formSettings = GenericSerializer.Deserialize <ConfiguratorFormSettings>(
                DeviceManager.GetDeviceManagerDirectory() + "\\Configurator.xml");

            Location            = _formSettings.Location;
            Size                = _formSettings.Size;
            propertyGrid.Height = _formSettings.PropertiesHeight;
            pnlConfig.Width     = _formSettings.ConfigWidth;
            splitContainer1.SplitterDistance = _formSettings.DetailedViewHeight;

            _eventsViewLink = new ListedEventsViewLink(lvLog, _formSettings.Filter,
                                                       _formSettings.Columns, true);

            _eventsViewLink.AddCommandItem(miRefresh, EventsViewCommand.Update);
            _eventsViewLink.AddCommandItem(btnRefresh, EventsViewCommand.Update);
            _eventsViewLink.AddCommandItem(cmiRefresh, EventsViewCommand.Update);
            _eventsViewLink.AddCommandItem(miDetails, EventsViewCommand.Details);
            _eventsViewLink.AddCommandItem(miFilter, EventsViewCommand.Filter);
            _eventsViewLink.AddCommandItem(btnFilter, EventsViewCommand.Filter);
            _eventsViewLink.AddCommandItem(cmiFilter, EventsViewCommand.Filter);
            _eventsViewLink.AddDetailedViewControl(textBox1);
            _eventsViewLink.SourceConnector = new LogConnector(tsslEventsReloadProgress);
            _eventsViewLink.Update();

            _srvMonitor = new ServiceMonitor("POSDeviceManager", 500);
            _srvMonitor.AppendStatus(lbSvcStatus, "Text");
            _srvMonitor.AppendEnabledWhenStarted(btnSvcStop, false);
            _srvMonitor.AppendEnabledWhenStarted(miSvcStop, false);
            _srvMonitor.AppendEnabledWhenStarted(miSvcRestart, true);
            _srvMonitor.AppendEnabledWhenStopped(btnSvcStart);
            _srvMonitor.AppendEnabledWhenStopped(miSvcStart);
            _srvMonitor.StartMonitor();
        }
Exemple #4
0
        /// <summary>
        /// 接收一条审计记录
        /// </summary>
        /// <param name="?"></param>
        public void Push(AuditBusiness ab)
        {
            String serviceName = ab.ServiceName;

            ServiceMonitor[]     serviceMonitorArray;
            MonitorStatDimension msDimension = GetMonitorStatDimension(ab);

            //--如果统计中没有相应维度的数据,则创建
            if (msDimension == null)
            {
                serviceMonitorArray = new ServiceMonitor[60];
                msDimension         = new MonitorStatDimension()
                {
                    ServiceName    = ab.ServiceName,
                    BindingAddress = ab.BindingAddress,
                    MethodName     = ab.RowMethodName
                };
                m_ServiceMonitor.Add(msDimension, serviceMonitorArray);
            }
            else
            {
                serviceMonitorArray = m_ServiceMonitor[msDimension];
            }

            RecordItem(ab, serviceMonitorArray);
        }
Exemple #5
0
        private static void TestMonitoringService()
        {
            ServiceMonitor serviceMonitor = new ServiceMonitor();
            serviceMonitor.AttachNotifer(new MailService());
            serviceMonitor.AttachNotifer(new SmsService());

            serviceMonitor.LastEvent = "Sql server service has been stoped unexpectly !!!";
        }
 /// <summary>
 /// Uninstall all registered windows services.
 /// </summary>
 public void Uninstall()
 {
     if (null == ServiceMonitor)
     {
         return;
     }
     ServiceMonitor.UninstallAll();
 }
Exemple #7
0
 public void UpdateModel(ServiceMonitor monitor)
 {
     monitor.Id            = Id;
     monitor.ApplicationId = ApplicationId;
     monitor.ServerId      = ServerId;
     monitor.ServiceId     = ServiceId;
     monitor.Status        = Status;
     monitor.RunDate       = RunDate;
     monitor.CreatedBy     = CreatedBy;
 }
Exemple #8
0
        private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            if (e.ExceptionObject is Exception)
            {
                Logger.Singleton.Error(((Exception)e.ExceptionObject).Message);
            }

            ServiceMonitor.StopAll();
            var result = EngineService.Default.AppClosed();
        }
Exemple #9
0
 public ServiceMonitorViewModel(ServiceMonitor monitor)
 {
     ServerId      = monitor.ServerId;
     Id            = monitor.Id;
     Status        = monitor.Status;
     ServiceId     = monitor.ServiceId;
     ApplicationId = monitor.ApplicationId;
     RunDate       = monitor.RunDate;
     CreatedBy     = monitor.CreatedBy;
 }
Exemple #10
0
        /// <summary>
        /// 获取到一分钟的汇总数据
        /// </summary>
        /// <returns></returns>
        public List <ServiceMonitor> GetOneMinuteData()
        {
            List <ServiceMonitor> lstServiceMinute = new List <ServiceMonitor>();

            foreach (var item in m_ServiceMonitor)
            {
                ServiceMonitor smOneMinute = null;

                for (int i = 0; i < 60; i++)
                {
                    ServiceMonitor sm = item.Value[i];
                    if (sm == null)
                    {
                        continue;
                    }

                    if (smOneMinute == null)
                    {
                        smOneMinute = sm;
                    }
                    else
                    {
                        smOneMinute.CallSuccessNum  += sm.CallSuccessNum;
                        smOneMinute.CallFailureNum  += sm.CallFailureNum;
                        smOneMinute.CallLevel1Num   += sm.CallLevel1Num;
                        smOneMinute.CallLevel2Num   += sm.CallLevel2Num;
                        smOneMinute.CallLevel3Num   += sm.CallLevel3Num;
                        smOneMinute.InBytes         += sm.InBytes;
                        smOneMinute.OutBytes        += sm.OutBytes;
                        smOneMinute.CallHitCacheNum += sm.CallHitCacheNum;
                        smOneMinute.CallQueueNum    += sm.CallQueueNum;

                        if (smOneMinute.TpsPeak < sm.TpsPeak)
                        {
                            smOneMinute.TpsPeak = sm.TpsPeak;
                        }
                    }
                }

                if (smOneMinute != null)
                {
                    lstServiceMinute.Add(smOneMinute);
                }
            }

            return(lstServiceMinute);
        }
Exemple #11
0
        void OnClosing(Window window)
        {
            ServiceMonitor.StopAll();

            if (!NodeMonitor.Default.Set_NetIsActive)
            {
                NetWorkService.Default.SetNetworkActive(true);
                System.Threading.Thread.Sleep(1000);
            }

            while (NodeMonitor.Default.PortInUse() || NodeMonitor.Default.PortInUse_TCP())
            {
                var result = EngineService.Default.AppClosed();
                System.Threading.Thread.Sleep(500);
            }
            Environment.Exit(1);
        }
        public ActionResult BillPayments2Services([Bind(Include = "ServiceId,ServiceName,CreatedBy,RunDate,ServerId,Status,ApplicationId")] ServiceMonitorViewModel model)
        {
            var sv = Common.Helpers.parameters.BP2;

            Session["SelectedApplication"] = sv;
            Session["ServerId"]            = servicesRepository.GetServerId(sv);
            Session["ServerIP"]            = servicesRepository.GetServerIp(sv);
            Session["Services"]            = servicesRepository.GetApplicationServices(sv);
            Session["Authority"]           = servicesRepository.GetAuthority(sv);
            Session["Username"]            = servicesRepository.GetSuperUsername(sv);
            Session["Password"]            = servicesRepository.GetSuperUserPassword(sv);

            var servicemonitor = new ServiceMonitor();

            servicesRepository.SaveServicesInfo(servicemonitor);
            return(RedirectToAction("ServiceStatus"));
        }
        protected override void before_each()
        {
            base.before_each();
            service_dependencies = new List <ServiceDependency>();
            dependency_1_monitor = Substitute.For <IMonitor>();
            dependency_1_monitor.Info.Returns(new MonitorInfo("FakeDb", "Database", "Db1", "Db2"));

            dependency_2_monitor = Substitute.For <IMonitor>();
            dependency_2_monitor.Info.Returns(new MonitorInfo("FakeQueue", "Queue", "Queue1", "Queue3", "Queue4"));

            service_dependency_1 = new ServiceDependency(dependency_1_monitor);
            service_dependency_2 = new ServiceDependency(dependency_2_monitor);

            service_monitor      = null;
            overall_availability = null;
            the_status           = new ServiceMonitor.Status();
        }
Exemple #14
0
        static void Main(string[] args)
        {
            var monitor = new ServiceMonitor();

            monitor.ServiceUp   += b => Console.WriteLine($"ServiceUP:   {b.ID} {b.MachineName} {b.Version}\n             {b.ServiceUri}");
            monitor.ServiceDown += b => Console.WriteLine($"ServiceDOWN: {b.ID} {b.MachineName} {b.Version}\n             {b.ServiceUri}");
            monitor.Start();

            string id = Guid.NewGuid().ToString("N").Substring(0, 4);

            monitor.RegisterService(id, "MyService", $"http://{Environment.MachineName}/{id}/Myservice");

            Console.WriteLine("this ID=" + id);
            Console.WriteLine("Press enter to exit:");
            Console.WriteLine();
            Console.ReadLine();
        }
Exemple #15
0
        public void SaveServicesInfo(ServiceMonitor entity)
        {
            List <ServiceMonitor> ServiceInfo = new List <ServiceMonitor>();

            ServiceInfo = GetServicesStatus();

            foreach (var si in ServiceInfo)
            {
                entity.ServiceId     = si.ServiceId;
                entity.Status        = si.Status;
                entity.ServiceName   = si.ServiceName;
                entity.RunDate       = DateTime.Now;
                entity.CreatedBy     = "Admin";
                entity.ServerId      = Convert.ToInt32(HttpContext.Current.Session["ServerId"]);
                entity.ApplicationId = Convert.ToInt32(HttpContext.Current.Session["SelectedApplication"]);
                appEntities.ServiceMonitors.Add(entity);
                appEntities.SaveChanges();
            }
        }
Exemple #16
0
        public void AddServiceMonitor(ServiceMonitor entity)
        {
            var AppId = Convert.ToInt32(HttpContext.Current.Session["AppId"]);

            List <string> services = (from c in appEntities.Services
                                      where c.ApplicationId == AppId
                                      select c.ServiceName).ToList();

            foreach (var service in services)
            {
                if (Helpers.IsServiceRunning(service))
                {
                    entity.RunDate   = DateTime.Now;
                    entity.CreatedBy = "Admin";
                    appEntities.ServiceMonitors.Add(entity);
                    appEntities.SaveChanges();
                }
            }
        }
        public void ServiceRepopulate(ServiceMonitor serviceMonitor)
        {
            servicesTest = ServiceController.GetServices(serviceMonitor.Server);
            servicesServiceListView.Items.Clear();

            foreach (ServiceController sc in servicesTest)
            {
                servicesServiceListView.Items.Add(new ListViewItem(new[] { sc.DisplayName, sc.Status.ToString() }));
            }
            alreadyPopulated = true;

            servicesPickedServicesTestDataUpdateFreqTextBox.Text =
                            serviceMonitor.UpdateFrequency.ToString();
            servicesAutomaticRestartServiceCheckBox.Checked = serviceMonitor.AutomaticRestart;
            foreach (Service s in serviceMonitor.Services)
            {
                servicesPickedServicesListView.Items.Add(
                    new ListViewItem(new[] { s.ServiceName, s.GoodStatus.ToString() }));
            }
        }
 public ServiceMonitor GetServiceMonitor()
 {
     ServiceMonitor serviceMonitor = new ServiceMonitor
                                   {
                                       FriendlyName = FriendlyName,
                                       Server = IpOrHostName,
                                       UpdateFrequency = //NOTE: make UpdateFrequency fields a masked textbox
                                           Convert.ToInt32(
                                               servicesPickedServicesTestDataUpdateFreqTextBox.Text),
                                       AutomaticRestart =
                                           servicesAutomaticRestartServiceCheckBox.Checked
                                   };
     foreach(ListViewItem lvi in servicesPickedServicesListView.Items)
     {
         Service s = new Service(lvi.SubItems[0].Text);
         s.GoodStatus = (ServiceStatus)Enum.Parse(typeof (ServiceStatus), lvi.SubItems[1].Text);
         serviceMonitor.Services.Add(s);
     }
     return serviceMonitor;
 }
        public async Task Invoke(HttpContext httpContext, ServiceMonitor monitor)
        {
            monitor.OnRequestStart(httpContext);

            Stopwatch stopwatch = new Stopwatch();
            stopwatch.Start();
            try
            {
                await _next(httpContext);
            }
            catch (Exception ex)
            {
                monitor.OnRequestException(httpContext, ex);
                throw;
            }
            finally
            {
                stopwatch.Stop();
                monitor.OnRequestStop(httpContext, stopwatch.Elapsed);
            }
        }
Exemple #20
0
        public List <ServiceMonitor> GetServicesStatus()
        {
            List <ServiceMonitor> serviceinfo = new List <ServiceMonitor>();

            List <string> services = (List <string>)HttpContext.Current.Session["Services"];

            try
            {
                foreach (var service in services)
                {
                    var serviceIds = (from c in appEntities.Services
                                      where c.ShortName == service
                                      select c.ServiceId).ToList();

                    var svc = new ServiceMonitor();

                    svc.Status      = Helpers.GetServiceState(service).ToString();
                    svc.ServiceName = service;

                    foreach (var svcId in serviceIds)
                    {
                        svc.ServiceId = svcId;
                    }

                    serviceinfo.Add(svc);
                }
            }

            catch (Exception ex)
            {
                ExceptionLogger.SendErrorToText(ex);
            }


            return(serviceinfo);
        }
        public ActionResult QueryService([Bind(Include = "ServiceId,ServiceName,CreatedBy,RunDate,ServerId,Status,ApplicationId")] ServiceMonitorViewModel model)
        {
            if (!ModelState.IsValid)
            {
                servicesRepository.GetApps(model);
                return(View(model));
            }

            var selectedValue = Request.Form["ApplicationId"].ToString();
            var sv            = Convert.ToInt32(selectedValue);

            Session["SelectedApplication"] = sv;
            Session["ServerId"]            = servicesRepository.GetServerId(sv);
            Session["ServerIP"]            = servicesRepository.GetServerIp(sv);
            Session["Services"]            = servicesRepository.GetApplicationServices(sv);
            Session["Authority"]           = servicesRepository.GetAuthority(sv);
            Session["Username"]            = servicesRepository.GetSuperUsername(sv);
            Session["Password"]            = servicesRepository.GetSuperUserPassword(sv);

            var servicemonitor = new ServiceMonitor();

            servicesRepository.SaveServicesInfo(servicemonitor);
            return(RedirectToAction("Index"));
        }
 public List <ServiceMonitor> GetAllByServiceAndMethodToday(String serviceName, String methodName)
 {
     return(ServiceMonitor.FindAllByServiceAndMethodToday(serviceName, methodName));
 }
Exemple #23
0
        /// <summary>
        /// 记录一条监控日志,统计维度已经在Push方法中划分好了
        /// </summary>
        /// <param name="ab"></param>
        /// <param name="serviceMonitorArray"></param>
        private void RecordItem(AuditBusiness ab, ServiceMonitor[] serviceMonitorArray)
        {
            // DateTime serviceBeginTime = DateTime.ParseExact(ab.ServiceBeginTime, "yyyy-MM-dd HH:mm:ss.ffffff", null);
            DateTime       monitorStamp   = DateTime.Now;
            Int32          second         = monitorStamp.Second;
            ServiceMonitor serviceMonitor = serviceMonitorArray[second];


            //XTrace.WriteLine("第{0}秒记录。", second);

            if (serviceMonitor == null)
            {
                serviceMonitor = new ServiceMonitor()
                {
                    OID               = Guid.NewGuid().ToString(),
                    ServiceName       = ab.ServiceName,
                    MethodName        = ab.RowMethodName,
                    MonitorStamp      = monitorStamp,
                    ConsumerIP        = ab.ConsumerIP,
                    BindingAddress    = ab.BindingAddress,
                    CallSuccessNum    = (ab.Status == 1) ? 1 : 0,
                    CallFailureNum    = (ab.Status == 1) ? 0 : 1,
                    CallLevel1Num     = (ab.InvokeTimeSpan > 20 && ab.InvokeTimeSpan < 100) ? 1 : 0,
                    CallLevel2Num     = (ab.InvokeTimeSpan > 100 && ab.InvokeTimeSpan < 200) ? 1 : 0,
                    CallLevel3Num     = (ab.InvokeTimeSpan > 200) ? 1 : 0,
                    CallHitCacheNum   = ab.IsCache,
                    InBytes           = ab.InBytes,
                    OutBytes          = ab.OutBytes,
                    TpsPeak           = 1,
                    CallQueueNum      = ab.IsQueue,
                    MaxInovkeTimeSpan = ab.InvokeTimeSpan,
                    BusinessID        = ab.BusinessID
                };
                serviceMonitorArray[second] = serviceMonitor;
            }
            else
            {
                if (ab.Status == 1)
                {
                    serviceMonitor.CallSuccessNum++;
                }
                else
                {
                    serviceMonitor.CallFailureNum++;
                }

                if (ab.InvokeTimeSpan > 200)
                {
                    serviceMonitor.CallLevel3Num++;
                }
                else if (ab.InvokeTimeSpan > 100 && ab.InvokeTimeSpan <= 200)
                {
                    serviceMonitor.CallLevel2Num++;
                }
                else if (ab.InvokeTimeSpan > 20 && ab.InvokeTimeSpan <= 100)
                {
                    serviceMonitor.CallLevel1Num++;
                }

                serviceMonitor.InBytes         += ab.InBytes;
                serviceMonitor.OutBytes        += ab.OutBytes;
                serviceMonitor.CallHitCacheNum += ab.IsCache;
                serviceMonitor.CallQueueNum    += ab.IsQueue;
                serviceMonitor.TpsPeak++;

                if (ab.InvokeTimeSpan > serviceMonitor.MaxInovkeTimeSpan)
                {
                    serviceMonitor.MaxInovkeTimeSpan = ab.InvokeTimeSpan;
                }
            }
        }
 public List <ServiceMonitor> GetInvokeTopService(String businessID)
 {
     return(ServiceMonitor.GetInvokeTopService(businessID));
 }
 public IMonitor GetCommonMonitor()
 {
     switch(_commonType)
     {
         case CommonMonitorType.CpuUsage:
             PfcMonitor cpuUsage = new PfcMonitor
                                       {
                                           FriendlyName = addServerValidIpMonitorName2.Text,
                                           Category = _commonPfcCounter.CategoryName,
                                           Counter = _commonPfcCounter.CounterName,
                                           Instance = _commonPfcCounter.InstanceName,
                                           ThresholdWarning = commonCpuWarningTextBox.Text,
                                           ThresholdPanic = commonCpuCriticalTextBox.Text,
                                           ThresholdBreachCount = 1,
                                           ThresholdLessThan = commonCpuGtLtLabel.Text == "<" ? true : false,
                                           Server = addServerValidIpIpTextBox2.Text,
                                           UpdateFrequency =
                                               Convert.ToInt32(commonMonitorTestDataUpdateFreqTextBox.Text),
                                           Common = true
                                       };
             return cpuUsage;
         case CommonMonitorType.HddUsage:
             PfcMonitor hddUsage = new PfcMonitor
                                       {
                                           FriendlyName = addServerValidIpMonitorName2.Text,
                                           Category = _commonPfcCounter.CategoryName,
                                           Counter = _commonPfcCounter.CounterName,
                                           Instance = _commonPfcCounter.InstanceName,
                                           ThresholdWarning = commonHddWarningTextBox.Text,
                                           ThresholdPanic = commonHddCriticalTextBox.Text,
                                           ThresholdBreachCount = 1,
                                           ThresholdLessThan = commonHddGtLtLabel.Text == "<" ? true : false,
                                           Server = addServerValidIpIpTextBox2.Text,
                                           UpdateFrequency =
                                               Convert.ToInt32(commonMonitorTestDataUpdateFreqTextBox.Text),
                                           Common = true
                                       };
             return hddUsage;
         case CommonMonitorType.MemoryUsage:
             WmiMonitor memoryUsage = new WmiMonitor
                                          {
                                              FriendlyName = addServerValidIpMonitorName2.Text,
                                              ThresholdWarning = commonMemoryWarningTextBox.Text,
                                              ThresholdPanic = commonMemoryCriticalTextBox.Text,
                                              ThresholdBreachCount = 1,
                                              ThresholdLessThan =
                                                  commonMemoryGtLtLabel.Text == "<" ? true : false,
                                              Server = addServerValidIpIpTextBox2.Text,
                                              UpdateFrequency =
                                                  Convert.ToInt32(commonMonitorTestDataUpdateFreqTextBox.Text),
                                              WmiType =
                                                  commonMemoryUsageTypeDdl.Text == "% In Use"
                                                      ? WmiType.MemoryUsage
                                                      : WmiType.MemoryFree,
                                              Common = true
                                          };
             return memoryUsage;
         case CommonMonitorType.ProcessState:
             PfcMonitor processState = new PfcMonitor
                                           {
                                               FriendlyName = addServerValidIpMonitorName2.Text,
                                               Category = _commonPfcCounter.CategoryName,
                                               Counter = _commonPfcCounter.CounterName,
                                               Instance = _commonPfcCounter.InstanceName,
                                               ThresholdWarning = commonProcessStateWarningTextBox.Text,
                                               ThresholdPanic = commonProcessStateCriticalTextBox.Text,
                                               ThresholdBreachCount = 1,
                                               ThresholdLessThan =
                                                   commonProcessStateGtLtLabel.Text == "<" ? true : false,
                                               Server = addServerValidIpIpTextBox2.Text,
                                               UpdateFrequency =
                                                   Convert.ToInt32(commonMonitorTestDataUpdateFreqTextBox.Text),
                                               Common = true
                                           };
             return processState;
         case CommonMonitorType.ServiceState:
             ServiceMonitor serviceState = new ServiceMonitor
                                               {
                                                   FriendlyName = addServerValidIpMonitorName2.Text,
                                                   Server = addServerValidIpIpTextBox2.Text,
                                                   UpdateFrequency =
                                                       Convert.ToInt32(
                                                           commonMonitorTestDataUpdateFreqTextBox.Text),
                                                   AutomaticRestart = false,
                                                   Common = true
                                               };
             serviceState.Services.Add(new Service(_commonServiceState.ServiceName));
             return serviceState;
         case CommonMonitorType.SwapFileUsage:
             PfcMonitor swapFileUsage = new PfcMonitor
                                            {
                                                FriendlyName = addServerValidIpMonitorName2.Text,
                                                Category = _commonPfcCounter.CategoryName,
                                                Counter = _commonPfcCounter.CounterName,
                                                Instance = _commonPfcCounter.InstanceName,
                                                ThresholdWarning = commonSwapFileWarningTextBox.Text,
                                                ThresholdPanic = commonSwapFileCriticalTextBox.Text,
                                                ThresholdBreachCount = 1,
                                                ThresholdLessThan =
                                                    commonSwapFileGtLtLabel.Text == "<" ? true : false,
                                                Server = addServerValidIpIpTextBox2.Text,
                                                UpdateFrequency =
                                                    Convert.ToInt32(commonMonitorTestDataUpdateFreqTextBox.Text),
                                                Common = true
                                            };
             return swapFileUsage;
     }
     return null;
 }
Exemple #26
0
 private void Current_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
 {
     Logger.Singleton.Error(e.Exception.Message);
     ServiceMonitor.StopAll();
     var result = EngineService.Default.AppClosed();
 }
        protected override async Task OnInitializedAsync()
        {
            string operationName = JournalService.FetchUnknownJournals();

            unsubscriber = ServiceMonitor.Subscribe("UnknownJournals", this);
        }
Exemple #28
0
        /// <summary>
        /// 接收一条审计记录
        /// </summary>
        /// <param name="?"></param>
        public void Push(AuditBusiness ab)
        {
            String serviceName = ab.ServiceName;
            ServiceMonitor[] serviceMonitorArray;
            MonitorStatDimension msDimension = GetMonitorStatDimension(ab);

            //--如果统计中没有相应维度的数据,则创建
            if (msDimension == null)
            {
                serviceMonitorArray = new ServiceMonitor[60];
                msDimension = new MonitorStatDimension()
                {
                    ServiceName = ab.ServiceName,
                    BindingAddress = ab.BindingAddress,
                    MethodName = ab.RowMethodName
                };
                m_ServiceMonitor.Add(msDimension, serviceMonitorArray);
            }
            else
            {
                serviceMonitorArray = m_ServiceMonitor[msDimension];
            }

            RecordItem(ab, serviceMonitorArray);
        }
        void Refresh()
        {
            JournalServiceStatusOperationName = JournalService.FetchApiStatus();

            ServiceMonitor.Subscribe(JournalServiceStatusOperationName, this);
        }
 private void a_service_monitor()
 {
     service_monitor = new ServiceMonitor(service_name, service_dependencies.ToArray());
 }
Exemple #31
0
 private void Current_Exit(object sender, ExitEventArgs e)
 {
     ServiceMonitor.StopAll();
     var result = EngineService.Default.AppClosed();
 }
 private void getting_service_availability()
 {
     service_monitor      = new ServiceMonitor(service_name, service_dependencies.ToArray());
     overall_availability = service_monitor.Availability();
 }
 public List <ServiceMonitor> GetMonitorServiceStatic()
 {
     return(ServiceMonitor.GetMonitorServiceStatic());
 }
 private void getting_status()
 {
     service_monitor = new ServiceMonitor(service_name, service_dependencies.ToArray());
     the_status      = service_monitor.GetStatus();
 }
Exemple #35
0
        /// <summary>
        /// 记录一条监控日志,统计维度已经在Push方法中划分好了
        /// </summary>
        /// <param name="ab"></param>
        /// <param name="serviceMonitorArray"></param>
        private void RecordItem(AuditBusiness ab, ServiceMonitor[] serviceMonitorArray)
        {
           // DateTime serviceBeginTime = DateTime.ParseExact(ab.ServiceBeginTime, "yyyy-MM-dd HH:mm:ss.ffffff", null);
            DateTime monitorStamp = DateTime.Now;
            Int32 second = monitorStamp.Second;
            ServiceMonitor serviceMonitor = serviceMonitorArray[second];


            //XTrace.WriteLine("第{0}秒记录。", second);

            if (serviceMonitor == null)
            {
                serviceMonitor = new ServiceMonitor(){
                    OID = Guid.NewGuid().ToString(),
                    ServiceName = ab.ServiceName,
                    MethodName = ab.RowMethodName,
                    MonitorStamp = monitorStamp,
                    ConsumerIP = ab.ConsumerIP,
                    BindingAddress = ab.BindingAddress,
                    CallSuccessNum = (ab.Status == 1) ? 1 : 0,
                    CallFailureNum =  (ab.Status == 1) ? 0 : 1,
                    CallLevel1Num = (ab.InvokeTimeSpan > 20 && ab.InvokeTimeSpan < 100) ? 1 : 0,
                    CallLevel2Num = (ab.InvokeTimeSpan > 100 && ab.InvokeTimeSpan < 200) ? 1 : 0,
                    CallLevel3Num = (ab.InvokeTimeSpan > 200) ? 1 : 0,
                    CallHitCacheNum = ab.IsCache,
                    InBytes = ab.InBytes,
                    OutBytes = ab.OutBytes,
                    TpsPeak = 1,
                    CallQueueNum = ab.IsQueue,
                    MaxInovkeTimeSpan = ab.InvokeTimeSpan,
                    BusinessID = ab.BusinessID
                };
                serviceMonitorArray[second] = serviceMonitor;
            }
            else
            {
                if (ab.Status == 1)
                    serviceMonitor.CallSuccessNum++;
                else
                    serviceMonitor.CallFailureNum++;

                if (ab.InvokeTimeSpan > 200)
                    serviceMonitor.CallLevel3Num++;
                else if (ab.InvokeTimeSpan > 100 && ab.InvokeTimeSpan <= 200)
                    serviceMonitor.CallLevel2Num++;
                else if(ab.InvokeTimeSpan > 20 && ab.InvokeTimeSpan <= 100)
                    serviceMonitor.CallLevel1Num++;

                serviceMonitor.InBytes += ab.InBytes;
                serviceMonitor.OutBytes += ab.OutBytes;
                serviceMonitor.CallHitCacheNum += ab.IsCache;
                serviceMonitor.CallQueueNum += ab.IsQueue;
                serviceMonitor.TpsPeak++;

                if (ab.InvokeTimeSpan > serviceMonitor.MaxInovkeTimeSpan)
                    serviceMonitor.MaxInovkeTimeSpan = ab.InvokeTimeSpan;
            }
        }