Beispiel #1
0
        public override List <System.Data.DataTable> GetDetailDataTables()
        {
            List <System.Data.DataTable> tables = new List <System.Data.DataTable>();

            System.Data.DataTable dt = new System.Data.DataTable();
            try
            {
                dt.Columns.Add(new System.Data.DataColumn("Computer", typeof(string)));
                dt.Columns.Add(new System.Data.DataColumn("File System", typeof(string)));
                dt.Columns.Add(new System.Data.DataColumn("Bytes/Sec", typeof(double)));

                LinuxNICCollectorConfig currentConfig = (LinuxNICCollectorConfig)AgentConfig;
                foreach (LinuxNICEntry entry in currentConfig.Entries)
                {
                    foreach (NICState diInfo in entry.GetNICInfos())
                    {
                        dt.Rows.Add(entry.SSHConnection.ComputerName, diInfo.NICInfo.Name, diInfo.NICInfo.RTxBytes);
                    }
                }
            }
            catch (Exception ex)
            {
                dt = new System.Data.DataTable("Exception");
                dt.Columns.Add(new System.Data.DataColumn("Text", typeof(string)));
                dt.Rows.Add(ex.ToString());
            }
            tables.Add(dt);
            return(tables);
        }
Beispiel #2
0
        public override MonitorState RefreshState()
        {
            MonitorState returnState = new MonitorState();
            string       lastAction  = "";
            long         highestVal  = 0;
            int          errors      = 0;
            int          warnings    = 0;
            int          success     = 0;

            try
            {
                LinuxNICCollectorConfig currentConfig = (LinuxNICCollectorConfig)AgentConfig;
                foreach (LinuxNICEntry entry in currentConfig.Entries)
                {
                    MonitorState entryState = new MonitorState()
                    {
                        ForAgent = entry.SSHConnection.ComputerName
                    };

                    List <NICState> diss = entry.GetStates();
                    foreach (NICState dis in diss)
                    {
                        if (dis.State == CollectorState.Error)
                        {
                            errors++;
                        }
                        else if (dis.State == CollectorState.Warning)
                        {
                            warnings++;
                        }
                        else
                        {
                            success++;
                        }
                        entryState.ChildStates.Add(
                            new MonitorState()
                        {
                            ForAgent         = dis.NICInfo.Name,
                            State            = dis.State,
                            CurrentValue     = dis.NICInfo.RTxBytes,
                            CurrentValueUnit = "Bytes"
                        }
                            );
                        if (highestVal < dis.NICInfo.RTxBytes)
                        {
                            highestVal = dis.NICInfo.RTxBytes;
                        }
                    }
                    returnState.ChildStates.Add(entryState);
                }

                returnState.CurrentValue     = highestVal;
                returnState.CurrentValueUnit = "Bytes (highest)";

                if (errors > 0 && warnings == 0 && success == 0) // any errors
                {
                    returnState.State = CollectorState.Error;
                }
                else if (errors > 0 || warnings > 0) //any warnings
                {
                    returnState.State = CollectorState.Warning;
                }
                else
                {
                    returnState.State = CollectorState.Good;
                }
            }
            catch (Exception ex)
            {
                returnState.RawDetails  = ex.Message;
                returnState.HtmlDetails = string.Format("<p><b>Last action:</b> {0}</p><blockquote>{1}</blockquote>", lastAction, ex.Message);
                returnState.State       = CollectorState.Error;
            }
            return(returnState);
        }
Beispiel #3
0
 public LinuxNICCollector()
 {
     AgentConfig = new LinuxNICCollectorConfig();
 }