Ejemplo n.º 1
0
        /// <summary>
        /// 构造器
        /// </summary>
        private MonitorStatManager()
        {
            //--启动监控中心对外提供服务
            m_MonitorCenter = new MonitorCenter();
            m_MonitorCenter.Start();

            //--初始化监控统计数据结构
            m_MonitorStatData = new MonitorStatData();

            //--每隔60秒钟将监控数据保存到数据库中并清空
            m_TimerMonitorStatDataSave = new TimerX(x =>
            {
                SaveToDatabase(m_MonitorStatData);
                lock (m_TimerMonitorStatDataSave)
                {
                    m_MonitorStatData = new MonitorStatData();
                }
            }, null, 1000 * 60, 1000 * 60);

            //--每隔1秒钟对外发布一次监控统计数据
            m_TimerMonitorStatDataPublish = new TimerX(x =>
            {
                PublishMointorData(m_MonitorStatData);
            }, null, 1000, 1000);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 构造器
        /// </summary>
        private MonitorStatManager()
        {
            //--启动监控中心对外提供服务
            m_MonitorCenter = new MonitorCenter();
            m_MonitorCenter.Start();

            //--初始化监控统计数据结构
            m_MonitorStatData = new MonitorStatData();

            //--每隔60秒钟将监控数据保存到数据库中并清空
            m_TimerMonitorStatDataSave = new TimerX(x =>
            {
                SaveToDatabase(m_MonitorStatData);
                lock (m_TimerMonitorStatDataSave)
                {
                    m_MonitorStatData = new MonitorStatData();
                }

            }, null, 1000 * 60, 1000 * 60);

            //--每隔1秒钟对外发布一次监控统计数据
            m_TimerMonitorStatDataPublish = new TimerX(x =>
            {
                PublishMointorData(m_MonitorStatData);
            }, null, 1000, 1000);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// 将一分钟的统计数据序列化到数据库中
 /// </summary>
 /// <param name="msData"></param>
 private void SaveToDatabase(MonitorStatData msData)
 {
     List<ServiceMonitor> lstServiceMinute = msData.GetOneMinuteData();
     foreach (var item in lstServiceMinute)
     {
         item.Insert();
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// 将一分钟的统计数据序列化到数据库中
        /// </summary>
        /// <param name="msData"></param>
        private void SaveToDatabase(MonitorStatData msData)
        {
            List <ServiceMonitor> lstServiceMinute = msData.GetOneMinuteData();

            foreach (var item in lstServiceMinute)
            {
                item.Insert();
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 对外发布监控统计数据:1秒钟
        /// </summary>
        /// <param name="msData"></param>
        private void PublishMointorData(MonitorStatData msData)
        {
            Int32 second = DateTime.Now.Second;

            if (second > 0)
            {
                second--;               //--发布前一秒的数据
            }
            String data = XmlUtil.SaveXmlFromObj <List <ServiceMonitor> >(msData.GetOnSecondData(second));

            if (data.Length > 180)
            {
                XTrace.WriteLine("PublishMointorData:{0}", data);
            }

            m_MonitorCenter.Publish(data);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 对外发布监控统计数据:1秒钟
        /// </summary>
        /// <param name="msData"></param>
        private void PublishMointorData(MonitorStatData msData)
        {
            Int32 second = DateTime.Now.Second;
            if (second > 0) second--;   //--发布前一秒的数据

            String data = XmlUtil.SaveXmlFromObj<List<ServiceMonitor>>(msData.GetOnSecondData(second));

            if(data.Length > 180)
                XTrace.WriteLine("PublishMointorData:{0}", data);

            m_MonitorCenter.Publish(data);
        }