コード例 #1
0
 private bool IsCollectorInLoggingCategory(string category, CollectorHost collectorHost)
 {
     if (category == "*") //don't bother further testing
     {
         return(true);
     }
     else if (category.StartsWith("*"))
     {
         string endsWith = category.Substring(1);
         if ((from s in collectorHost.Categories
              where s.EndsWith(endsWith, StringComparison.InvariantCultureIgnoreCase)
              select s).Count() > 0)
         {
             return(true);
         }
     }
     else if (category.EndsWith("*"))
     {
         string startsWith = category.Substring(0, category.Length - 1);
         if ((from s in collectorHost.Categories
              where s.StartsWith(startsWith, StringComparison.InvariantCultureIgnoreCase)
              select s).Count() > 0)
         {
             return(true);
         }
     }
     else if (collectorHost.Categories.Contains(category))
     {
         return(true);
     }
     return(false);
 }
コード例 #2
0
        private void LoggingCollectorEvent(string message, CollectorHost collectorHost)
        {
            bool allCollectors   = LoggingCollectorCategories == null || LoggingCollectorCategories.Count == 0;
            bool matchCategories = false;

            if (!allCollectors)
            {
                foreach (string category in LoggingCollectorCategories)
                {
                    if (IsCollectorInLoggingCategory(category, collectorHost))
                    {
                        matchCategories = true;
                        break;
                    }
                }

                //if (collectorHost.Categories != null && collectorHost.Categories.Count > 0)
                //{

                //    foreach(string cat in collectorHost.Categories)
                //        if (LoggingCollectorCategories.Contains(cat))
                //        {
                //            matchCategories = true;
                //            break;
                //        }
                //}
            }
            if (LoggingCollectorEvents && (allCollectors || matchCategories))
            {
                WriteLogging(message);
            }
        }
コード例 #3
0
 private void LoggingPollingOverridesTriggeredEvent(string message, CollectorHost collectorHost)
 {
     if (LoggingPollingOverridesTriggered)
     {
         WriteLogging(string.Format("Collector '{0}' encoutered polling override event: {1}", collectorHost.Name, message));
     }
 }
コード例 #4
0
ファイル: MonitorPack.cs プロジェクト: utobe/QuickMon
        private void ResetAllOverrides(CollectorHost parentCollector = null)
        {
            List <CollectorHost> collectors = null;

            if (parentCollector == null)
            {
                collectors = (from c in CollectorHosts
                              where c.ParentCollectorId.Length == 0
                              select c).ToList();
            }
            else
            {
                collectors = (from c in CollectorHosts
                              where c.ParentCollectorId == parentCollector.UniqueId
                              select c).ToList();
            }
            foreach (CollectorHost childCollector in collectors)
            {
                childCollector.MaxStateHistorySize = CollectorStateHistorySize;
                //Remote agent host
                childCollector.OverrideForceRemoteExcuteOnChildCollectors = false;
                childCollector.OverrideRemoteAgentHost        = false;
                childCollector.OverrideRemoteAgentHostAddress = "";
                childCollector.OverrideRemoteAgentHostPort    = GlobalConstants.DefaultRemoteHostPort;
                ResetAllOverrides(childCollector);
            }
        }
コード例 #5
0
ファイル: MonitorPackEvents.cs プロジェクト: utobe/QuickMon
 private void collectorHost_AllAgentsExecutionTime(CollectorHost collectorHost, long msTime)
 {
     if (CollectorHostAllAgentsExecutionTime != null)
     {
         CollectorHostAllAgentsExecutionTime(collectorHost, msTime);
     }
 }
コード例 #6
0
ファイル: MonitorPack.cs プロジェクト: utobe/QuickMon
        private void SetChildCollectorHostPollingOverrides(CollectorHost parentCollectorHost)
        {
            foreach (CollectorHost childCollector in (from c in CollectorHosts
                                                      where c.ParentCollectorId == parentCollectorHost.UniqueId
                                                      select c))
            {
                if (!childCollector.EnabledPollingOverride) //check that child does not have its own
                {
                    childCollector.OnlyAllowUpdateOncePerXSec = parentCollectorHost.OnlyAllowUpdateOncePerXSec;
                    //to make sure child collector does not miss the poll event
                    childCollector.LastStateUpdate = parentCollectorHost.LastStateUpdate;
                }
                else
                {
                    if (childCollector.OnlyAllowUpdateOncePerXSec < parentCollectorHost.OnlyAllowUpdateOncePerXSec)
                    {
                        childCollector.OnlyAllowUpdateOncePerXSec = parentCollectorHost.OnlyAllowUpdateOncePerXSec;
                        //to make sure child collector does not miss the poll event
                        childCollector.LastStateUpdate = parentCollectorHost.LastStateUpdate;
                    }
                }
                //force child settings permanently
                childCollector.EnabledPollingOverride = true;

                //Set grand children
                SetChildCollectorHostPollingOverrides(childCollector);
            }
        }
コード例 #7
0
ファイル: MonitorPackEvents.cs プロジェクト: utobe/QuickMon
 private void RaiseCollectorHostCalled(CollectorHost collectorHost)
 {
     if (CollectorHostCalled != null)
     {
         CollectorHostCalled(collectorHost);
     }
 }
コード例 #8
0
        private int GetItemIcon(CollectorHost collector)
        {
            int imageIndex = collectorNAstateImage;

            if (collector.CollectorAgents.Count == 0 || collector.CurrentState.State == CollectorState.None)
            {
                imageIndex = collectorFolderImage;
            }
            else if (!collector.Enabled || collector.CurrentState.State == CollectorState.Disabled)
            {
                imageIndex = collectorDisabled;
            }
            else if (collector.CurrentState.State == CollectorState.Error || collector.CurrentState.State == CollectorState.ConfigurationError)
            {
                imageIndex = collectorErrorStateImage1;
            }
            else if (collector.CurrentState.State == CollectorState.Warning)
            {
                imageIndex = collectorWarningStateImage1;
            }
            else if (collector.CurrentState.State == CollectorState.Good)
            {
                imageIndex = collectorGoodStateImage1;
            }
            else if (collector.CurrentState.State == CollectorState.NotInServiceWindow)
            {
                imageIndex = collectorOutOfServiceWindowstateImage;
            }
            return(imageIndex);
        }
コード例 #9
0
 /// <summary>
 /// When adding a new collector host manually or by editing it needs to be initialized for events, config vars, scripts etc.
 /// </summary>
 /// <param name="collectorHost"></param>
 public void AddCollectorHost(CollectorHost collectorHost)
 {
     collectorHost.ParentMonitorPack = this;
     SetCollectorHostEvents(collectorHost);
     //InitializeCollectorActionScripts(collectorHost);
     CollectorHosts.Add(collectorHost);
 }
コード例 #10
0
ファイル: CollectorHostEditor.cs プロジェクト: utobe/QuickMon
        private void CollectorHostEditor_Load(object sender, EventArgs e)
        {
            panelGeneralSettingsHeight = panelGeneralSettings.Height;
            panelAgentsHeight          = panelAgents.Height;
            panelPollingHeight         = panelPolling.Height;
            panelRemoteAgentHeight     = panelRemoteAgent.Height;
            panelRunAsHeight           = panelRunAs.Height;
            panelServiceWindowsHeight  = panelServiceWindows.Height;
            panelAlertingHeight        = panelAlerting.Height;
            panelVariablesHeight       = panelVariables.Height;
            panelActionScriptsHeight   = panelActionScripts.Height;

            cmdAgentsToggle_Click(null, null);
            cmdPollingToggle_Click(null, null);
            cmdRemoteAgentToggle_Click(null, null);
            cmdRunAsToggle_Click(null, null);
            cmdServiceWindowsToggle_Click(null, null);
            cmdAlertingToggle_Click(null, null);
            cmdVariablesToggle_Click(null, null);
            cmdActionScriptsToggle_Click(null, null);

            if (SelectedCollectorHost == null)
            {
                SelectedCollectorHost = new CollectorHost();
            }
        }
コード例 #11
0
ファイル: MonitorPackEvents.cs プロジェクト: utobe/QuickMon
 private void collectorHost_NoStateChanged(CollectorHost collectorHost)
 {
     if (CollectorHost_AlertRaised_NoStateChanged != null)
     {
         CollectorHost_AlertRaised_NoStateChanged(collectorHost);
     }
     SendNotifierAlert(AlertLevel.Debug, DetailLevel.Detail, collectorHost);
 }
コード例 #12
0
ファイル: MonitorPackEvents.cs プロジェクト: utobe/QuickMon
 private void collectorHost_AlertWarningState(CollectorHost collectorHost)
 {
     if (CollectorHost_AlertRaised_Warning != null)
     {
         CollectorHost_AlertRaised_Warning(collectorHost);
     }
     SendNotifierAlert(AlertLevel.Warning, DetailLevel.Detail, collectorHost);
 }
コード例 #13
0
ファイル: MonitorPackEvents.cs プロジェクト: utobe/QuickMon
 private void collectorHost_AlertGoodState(CollectorHost collectorHost)
 {
     if (CollectorHost_AlertRaised_Good != null)
     {
         CollectorHost_AlertRaised_Good(collectorHost);
     }
     SendNotifierAlert(AlertLevel.Info, DetailLevel.Detail, collectorHost);
 }
コード例 #14
0
ファイル: MonitorPackEvents.cs プロジェクト: utobe/QuickMon
        private void collectorHost_AlertErrorState(CollectorHost collectorHost)
        {
            if (CollectorHost_AlertRaised_Error != null)
            {
                CollectorHost_AlertRaised_Error(collectorHost);
            }

            SendNotifierAlert(AlertLevel.Error, DetailLevel.Detail, collectorHost);
        }
コード例 #15
0
ファイル: GlobalAgentHistory.cs プロジェクト: radtek/QuickMon
        private string GetCollectorPath(CollectorHost ch)
        {
            string collectorPath = "";

            foreach (CollectorHost pch in HostingMonitorPack.GetParentCollectorHostTree(ch))
            {
                collectorPath = pch.NameFormatted + "/" + collectorPath;
            }
            return(collectorPath + ch.NameFormatted);
        }
コード例 #16
0
 private void RaiseCollectorError(CollectorHost collector, string errorMessage)
 {
     try
     {
         OnCollectorError?.Invoke(collector, errorMessage);
     }
     catch (Exception ex)
     {
         System.Diagnostics.Trace.WriteLine(string.Format("Error in RaiseCollectorError: {0}", ex.Message));
     }
 }
コード例 #17
0
 private void removeCollectorToolStripMenuItem_Click(object sender, EventArgs e)
 {
     //List<CollectorHost> collectorsToBeRemoved = new List<CollectorHost>();
     foreach (ListViewItem lvi in lvwCollectorStates.SelectedItems)
     {
         CollectorHost collector = (CollectorHost)lvi.Tag;
         SelectedCollectors.Remove(collector);
         //collectorsToBeRemoved.Add(collector);
         LoadControls(true);
     }
 }
コード例 #18
0
        public static MonitorState GetCollectorHostState(CollectorHost entry, string hostAddressOverride, int portNumberOverride)
        {
            BasicHttpBinding myBinding  = new BasicHttpBinding();
            EndpointAddress  myEndpoint = new EndpointAddress(string.Format("http://{0}:{1}/QuickMonRemoteHost", hostAddressOverride, portNumberOverride));
            ChannelFactory <IRemoteCollectorHostService> myChannelFactory = new ChannelFactory <IRemoteCollectorHostService>(myBinding, myEndpoint);
            IRemoteCollectorHostService relay = myChannelFactory.CreateChannel();

            RemoteCollectorHost colReq = new RemoteCollectorHost();

            colReq.FromCollectorHost(entry);
            return(relay.GetState(colReq));
        }
コード例 #19
0
        public List <CollectorHost> GetParentCollectorHostTree(CollectorHost child)
        {
            List <CollectorHost> list          = new List <CollectorHost>();
            CollectorHost        currentParent = GetParentCollectorHost(child);

            while (currentParent != null)
            {
                list.Add(currentParent);
                currentParent = GetParentCollectorHost(currentParent);
            }
            return(list);
        }
コード例 #20
0
        public void ExportCollectorMetricsToCSV()
        {
            string outputPath     = CollectorMetricsExportPath;
            string outputFileName = Name.StringToSaveFileName() + DateTime.Now.Date.ToString("yyyyMMdd") + ".csv";

            if (outputPath.Length == 0)
            {
                if (MonitorPackPath != null && MonitorPackPath.Length > 0)
                {
                    outputPath = System.IO.Path.GetDirectoryName(MonitorPackPath);
                }
                else
                {
                    outputPath = System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
                }
                outputPath = System.IO.Path.Combine(outputPath, outputFileName);
            }
            else if (System.IO.Directory.Exists(outputPath))
            {
                outputPath = System.IO.Path.Combine(outputPath, outputFileName);
            }

            ////Get output directory
            //if (outputPath.Length == 0 || (!System.IO.Directory.Exists(outputPath) && !System.IO.File.Exists(outputPath)))
            //{
            //    if (MonitorPackPath != null && MonitorPackPath.Length > 0)
            //    {
            //        outputPath = System.IO.Path.GetDirectoryName(MonitorPackPath);
            //    }
            //    else
            //    {
            //        outputPath = System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            //    }
            //}
            //outputPath = System.IO.Path.Combine(outputPath, outputFileName);
            try
            {
                lock (collectorMetricsSyncLock)
                {
                    if (!System.IO.File.Exists(outputPath))
                    {
                        System.IO.File.WriteAllText(outputPath, CollectorHost.ExportHistoryToCSVHeaders());
                    }

                    System.IO.File.AppendAllText(outputPath, ExportCurrentCollectorMetricsToCSV());
                }
            }
            catch (Exception ex)
            {
                WriteLogging(string.Format("Error performing ExportCollectorMetricsToCSV: {0}", ex.Message));
                RaiseMonitorPackError(string.Format("Error performing ExportCollectorMetricsToCSV: {0}", ex.Message));
            }
        }
コード例 #21
0
        private GraphSeries SeriesFromCollector(CollectorHost collector, Color seriesColor, int lastXEntries)
        {
            GraphSeries series = null;

            if (txtTextFilter.Text.Trim().Length < 2 || collector.PathWithoutMP.ContainEx(txtTextFilter.Text))
            //if (txtTextFilter.Text.Trim().Length < 2 || collector.PathWithoutMP.ToLower().Contains(txtTextFilter.Text.ToLower()))
            {
                string stateValue = "";
                float  v          = 0;
                if (lastXEntries == 0)
                {
                    lastXEntries = collector.StateHistory.Count;
                }
                series = new GraphSeries(collector.PathWithoutMP, seriesColor);
                foreach (MonitorState agentState in (from hsm in collector.StateHistory
                                                     orderby hsm.Timestamp descending
                                                     select hsm).Take(lastXEntries))
                {
                    v          = 0;
                    stateValue = agentState.ReadFirstValue(false);
                    if (stateValue != null && float.TryParse(stateValue, out v))
                    {
                        series.Values.Add(new TimeValue()
                        {
                            Time = agentState.Timestamp, Value = v
                        });
                    }
                }
                v          = 0;
                stateValue = collector.CurrentState.ReadFirstValue(false);
                if (stateValue != null && float.TryParse(stateValue, out v))
                {
                    series.Values.Add(new TimeValue()
                    {
                        Time = collector.CurrentState.Timestamp, Value = v
                    });
                }
            }
            if (series != null && series.Values != null && series.Values.Count > 0)
            {
                return(series);
            }
            //else if (series.Values.Count ==1)
            //{
            //    series.Name += " (Not enough data)";
            //    return series;
            //}
            else
            {
                return(null);
            }
        }
コード例 #22
0
ファイル: MonitorPack.cs プロジェクト: utobe/QuickMon
        public List <CollectorHost> GetAllChildCollectorHosts(CollectorHost parentCE)
        {
            List <CollectorHost> list         = new List <CollectorHost>();
            List <CollectorHost> listChildren = new List <CollectorHost>();

            listChildren = GetChildCollectorHosts(parentCE);
            foreach (CollectorHost child in listChildren)
            {
                list.Add(child);
                list.AddRange(GetAllChildCollectorHosts(child));
            }
            return(list);
        }
コード例 #23
0
 private void LogCorrectiveScriptAction(CollectorHost collectorEntry, bool error)
 {
     collectorEntry.CurrentState.RawDetails += "\r\n" + string.Format("Due to an alert raised on the collector '{0}' the following corrective script was executed: '{1}'",
                                                                      collectorEntry.Name, error ? collectorEntry.CorrectiveScriptOnErrorPath : collectorEntry.CorrectiveScriptOnWarningPath);
     SendNotifierAlert(new AlertRaised()
     {
         Level       = error ? AlertLevel.Error : AlertLevel.Warning,
         DetailLevel = DetailLevel.Detail,
         RaisedFor   = collectorEntry
     });
     LoggingCorrectiveScriptRunEvent(string.Format("Due to an alert raised on the collector '{0}' the following corrective script was executed: '{1}'",
                                                   collectorEntry.Name, error ? collectorEntry.CorrectiveScriptOnErrorPath : collectorEntry.CorrectiveScriptOnWarningPath));
 }
コード例 #24
0
 private void LogRestorationScriptAction(CollectorHost collectorEntry)
 {
     collectorEntry.CurrentState.RawDetails += "\r\n" + string.Format("Due to an earlier alert raised on the collector '{0}' the following restoration script was executed: '{1}'",
                                                                      collectorEntry.Name, collectorEntry.RestorationScriptPath);
     SendNotifierAlert(new AlertRaised()
     {
         Level       = collectorEntry.PreviousState.State == CollectorState.Warning ? AlertLevel.Warning : AlertLevel.Error,
         DetailLevel = DetailLevel.Detail,
         RaisedFor   = collectorEntry
     });
     LoggingCorrectiveScriptRunEvent(string.Format("Due to an earlier alert raised on the collector '{0}' the following restoration script was executed: '{1}'",
                                                   collectorEntry.Name, collectorEntry.RestorationScriptPath));
 }
コード例 #25
0
ファイル: RemoteCollectorHost.cs プロジェクト: utobe/QuickMon
        public string ToCollectorHostXml()
        {
            string collectorAgentsXml = CollectorHost.GetRemoteCollectorAgentsConfigXml(Agents, AgentCheckSequence);

            return(CollectorHost.ToXml(UniqueId,
                                       Name,
                                       Enabled,
                                       ChildCheckBehaviour.OnlyRunOnSuccess,
                                       RunAsEnabled,
                                       RunAs,
                                       collectorAgentsXml
                                       ));
        }
コード例 #26
0
        /// <summary>
        /// When Initializing/reinitializing the scripts
        /// </summary>
        //public void InitializeCollectorActionScripts()
        //{
        //    foreach (CollectorHost collectorHost in CollectorHosts)
        //    {
        //        InitializeCollectorActionScripts(collectorHost);
        //    }
        //}
        //public void InitializeCollectorActionScripts(CollectorHost collectorHost)
        //{
        //    if (collectorHost != null && collectorHost.ActionScripts != null)
        //    {
        //        foreach(var collectorActionScript in collectorHost.ActionScripts)
        //        {
        //            ActionScript currentActionScript = (from acs in ActionScripts
        //                                                where acs.Id == collectorActionScript.MPId
        //                                                select acs).FirstOrDefault();
        //            if (currentActionScript != null)
        //                collectorActionScript.InitializeScript(currentActionScript);
        //        }
        //    }
        //}
        public CollectorHost GetParentCollectorHost(CollectorHost child)
        {
            CollectorHost selectedCH = null;

            if (CollectorHosts != null && child != null && child.ParentCollectorId != null && child.ParentCollectorId.Length > 0)
            {
                selectedCH = (from CollectorHost c in CollectorHosts
                              where c.UniqueId == child.ParentCollectorId
                              select c).FirstOrDefault();
            }

            return(selectedCH);
        }
コード例 #27
0
ファイル: QuickMonService.cs プロジェクト: utobe/QuickMon
        private void monitorPack_RaiseCollectorError(CollectorHost collectorHost, string errorMessage)
        {
            string lastCollectorDetails = "N/A";

            if (collectorHost != null && collectorHost.CurrentState != null)
            {
                lastCollectorDetails = collectorHost.CurrentState.ReadAllRawDetails();
            }

            EventLog.WriteEntry(Globals.ServiceEventSourceName, string.Format("Collector error\r\n" +
                                                                              "Collector name: {0}\r\n" +
                                                                              "Last details: {1}\r\n" +
                                                                              "Error details: {2}", collectorHost.Name, lastCollectorDetails, errorMessage), EventLogEntryType.Error, 2);
        }
コード例 #28
0
        public string ExportCollectorHistoryToCSV(bool addheader = true)
        {
            StringBuilder sb = new StringBuilder();

            if (addheader)
            {
                sb.Append(CollectorHost.ExportHistoryToCSVHeaders());
            }
            foreach (CollectorHost ch in CollectorHosts)
            {
                sb.Append(ch.ExportHistoryToCSV());
            }
            return(sb.ToString());
        }
コード例 #29
0
 private void LoggingServiceWindowEvent(CollectorHost collectorHost, bool entered)
 {
     if (LoggingServiceWindowEvents)
     {
         if (entered)
         {
             WriteLogging(string.Format("Collector '{0}' entered a service window.", collectorHost.Name));
         }
         else
         {
             WriteLogging(string.Format("Collector '{0}' exited a service window.", collectorHost.Name));
         }
     }
 }
コード例 #30
0
        public static System.Data.DataSet GetRemoteHostAllAgentDetails(CollectorHost entry, string hostAddressOverride, int portNumberOverride)
        {
            BasicHttpBinding myBinding = new BasicHttpBinding();

            myBinding.MaxReceivedMessageSize = 2147483647;
            EndpointAddress myEndpoint = new EndpointAddress(string.Format("http://{0}:{1}/QuickMonRemoteHost", hostAddressOverride, portNumberOverride));
            ChannelFactory <IRemoteCollectorHostService> myChannelFactory = new ChannelFactory <IRemoteCollectorHostService>(myBinding, myEndpoint);
            IRemoteCollectorHostService relay = myChannelFactory.CreateChannel();

            RemoteCollectorHost colReq = new RemoteCollectorHost();

            colReq.FromCollectorHost(entry);
            return(relay.GetCollectorHostDetails(colReq));
        }