コード例 #1
0
ファイル: MainForm.cs プロジェクト: utobe/QuickMon
        private void toolStripButtonConfigPack_Click(object sender, EventArgs e)
        {
            if (monitorPack != null)
            {
                Cursor.Current           = Cursors.WaitCursor;
                monitorPack.AbortPolling = true;
                DateTime abortStart = DateTime.Now;
                while (monitorPack.BusyPolling && abortStart.AddSeconds(3) > DateTime.Now)
                {
                    Cursor.Current = Cursors.WaitCursor;
                    System.Threading.Thread.Sleep(100);
                    Application.DoEvents();
                }
            }

            mainTimerEnabled         = false;
            mainRefreshTimer.Enabled = false;
            QuickMon.Management.MonitorPackManagement monitorPackManagement = new Management.MonitorPackManagement();
            if (monitorPackManagement.ShowMonitorPack(monitorPack) == System.Windows.Forms.DialogResult.OK)
            {
                CloseAllDetailWindows();
                Properties.Settings.Default.LastMonitorPack = monitorPackManagement.MonitorPackPath;
                LoadMonitorPack(Properties.Settings.Default.LastMonitorPack);
                try
                {
                    if (!backgroundWorkerRefresh.IsBusy)
                    {
                        Cursor.Current = Cursors.WaitCursor;
                        backgroundWorkerRefresh.RunWorkerAsync();
                    }
                }
                catch { }
            }
            mainTimerEnabled         = true;
            mainRefreshTimer.Enabled = true;
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: utobe/QuickMon
        static void Main(string[] args)
        {
            if (Properties.Settings.Default.NewVersion)
            {
                Properties.Settings.Default.Upgrade();
                Properties.Settings.Default.NewVersion = false;
                Properties.Settings.Default.Save();
            }

            MonitorPack monitorPack = new MonitorPack();

            if (args.Length > 0 && args[0].ToLower().EndsWith(".qmconfig"))
            {
                if (File.Exists(args[0]))
                {
                    monitorPack.Load(args[0]);
                }
            }
            else
            {
                if (Properties.Settings.Default.LastMonitorPackPath != null && File.Exists(Properties.Settings.Default.LastMonitorPackPath))
                {
                    monitorPack.Load(Properties.Settings.Default.LastMonitorPackPath);
                }
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            Management.MonitorPackManagement monitorPackManagement = new Management.MonitorPackManagement();
            if (monitorPackManagement.ShowMonitorPack(monitorPack) == DialogResult.OK)
            {
                Properties.Settings.Default.LastMonitorPackPath = monitorPackManagement.MonitorPackPath;
                Properties.Settings.Default.Save();
            }
        }
コード例 #3
0
        static void Main(string[] args)
        {
            bool   useBackgroundPolling = false;
            bool   showManagement       = false;
            bool   reportOnlyStates     = true;
            string currentPath          = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);

            string registeredAgentsPath               = currentPath;// +@"\RegisteredAgents.qmral";
            string pingAgentAssembly                  = currentPath + @"\QMPing.dll";
            string fileCountAgentAssembly             = currentPath + @"\QMFileCount.dll";
            string serviceStateAgentAssembly          = currentPath + @"\QMServiceState.dll";
            string bizTalkSuspendedCountAgentAssembly = currentPath + @"\QMBizTalkSuspendedCount.dll";
            string logFileAgentAssembly               = currentPath + @"\QMLogFile.dll";
            string configurationFile                  = currentPath + @"\workConfig.qmconfig";

            MonitorPack monitorPack = new MonitorPack();

            #region Agent registrations
            try
            {
                monitorPack.AgentsAssemblyPath = registeredAgentsPath;
            }
            catch
            {
                monitorPack.AgentRegistrations = new List <AgentRegistration>();
                monitorPack.AgentRegistrations.AddRange(new AgentRegistration[]
                {
                    new AgentRegistration()
                    {
                        Name         = "Ping",
                        AssemblyPath = pingAgentAssembly,
                        ClassName    = "QuickMon.Ping",
                        IsCollector  = true,
                        IsNotifier   = false
                    },
                    new AgentRegistration()
                    {
                        Name         = "FileCount",
                        AssemblyPath = fileCountAgentAssembly,
                        ClassName    = "QuickMon.FileCount",
                        IsCollector  = true,
                        IsNotifier   = false
                    },
                    new AgentRegistration()
                    {
                        Name         = "ServiceState",
                        AssemblyPath = serviceStateAgentAssembly,
                        ClassName    = "QuickMon.ServiceState",
                        IsCollector  = true,
                        IsNotifier   = false
                    },
                    new AgentRegistration()
                    {
                        Name         = "BizTalkSuspendedCount",
                        AssemblyPath = bizTalkSuspendedCountAgentAssembly,
                        ClassName    = "QuickMon.BizTalkSuspendedCount",
                        IsCollector  = true,
                        IsNotifier   = false
                    },
                    new AgentRegistration()
                    {
                        Name         = "LogFile",
                        AssemblyPath = logFileAgentAssembly,
                        ClassName    = "QuickMon.LogFile",
                        IsCollector  = false,
                        IsNotifier   = true
                    }
                }
                                                        );
                //SerializationUtils.SerializeXMLToFile<List<AgentRegistration>>(registeredAgentsFile, monitorPack.AgentRegistrations);
            }
            #endregion


            monitorPack.Load(configurationFile);

            if (useBackgroundPolling)
            {
                //monitorPack.RaiseAlert += new RaiseAlertDelegate(monitorPack_RaiseAlert);
                monitorPack.PollingFreq = 10000;
                monitorPack.StartPolling();
                Console.WriteLine("Press any key to stop polling");
                Console.ReadKey();
                monitorPack.IsPolling = false;
                Console.WriteLine("Done");
            }
            else if (showManagement)
            {
                Management.MonitorPackManagement monitorPackManagement = new Management.MonitorPackManagement();
                monitorPackManagement.ShowMonitorPack(monitorPack);
            }
            else if (reportOnlyStates)
            {
                ConsoleKeyInfo cki = new ConsoleKeyInfo(' ', ConsoleKey.Spacebar, false, false, false);
                monitorPack.RaiseCurrentState += new RaiseCurrentStateDelegate(monitorPack_RaiseCurrentState);
                while (cki.Key != ConsoleKey.Escape)
                {
                    Console.WriteLine(new string('-', 79));
                    MonitorStates globalState = monitorPack.RefreshStates();
                    Console.WriteLine("Global state: {0}", globalState);
                    Console.WriteLine("Last time: {0}", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                    Console.WriteLine(new string('-', 79));
                    Console.WriteLine("Press ESC to end");
                    cki = ConsoleHelper.ReadKeyWithTimeOut(20000);
                }
            }
            else
            {
                //monitorPack.RaiseAlert += new RaiseAlertDelegate(monitorPack_RaiseAlert);
                MonitorStates globalState = monitorPack.RefreshStates();
                Console.WriteLine(new string('-', 79));
                Console.WriteLine(string.Format("Current global state: {0}", globalState));
                string level = "  ";
                foreach (CollectorEntry ce in (from c in monitorPack.Collectors
                                               where c.ParentCollectorId.Length == 0
                                               select c))
                {
                    ShowCollectorEntryStatus(monitorPack.Collectors, ce, level);
                }
                Console.WriteLine("Press any key to continue or wait 30 seconds");
                ConsoleKeyInfo cki = ConsoleHelper.ReadKeyWithTimeOut(30000);
                if (cki.Key == ConsoleKey.S)
                {
                    monitorPack.Save(currentPath + @"\Test.qmconfig");
                }
            }
        }