Ejemplo n.º 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)));

                LinuxDiskIOCollectorConfig currentConfig = (LinuxDiskIOCollectorConfig)AgentConfig;
                foreach (LinuxDiskIOEntry entry in currentConfig.Entries)
                {
                    foreach (DiskIOState diInfo in entry.GetDiskInfos())
                    {
                        dt.Rows.Add(entry.SSHConnection.ComputerName, diInfo.DiskInfo.Name, diInfo.DiskInfo.BytesReadWritePerSec);
                    }
                }
            }
            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);
        }
Ejemplo n.º 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
            {
                LinuxDiskIOCollectorConfig currentConfig = (LinuxDiskIOCollectorConfig)AgentConfig;
                foreach (LinuxDiskIOEntry entry in currentConfig.Entries)
                {
                    MonitorState entryState = new MonitorState()
                    {
                        ForAgent = entry.SSHConnection.ComputerName
                    };

                    List <DiskIOState> diss = entry.GetStates();
                    foreach (DiskIOState 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.DiskInfo.Name,
                            State            = dis.State,
                            CurrentValue     = dis.DiskInfo.BytesReadWritePerSec,
                            CurrentValueUnit = "Bytes/Sec"
                        }
                            );
                        if (highestVal < dis.DiskInfo.BytesReadWritePerSec)
                        {
                            highestVal = dis.DiskInfo.BytesReadWritePerSec;
                        }
                    }
                    returnState.ChildStates.Add(entryState);
                }
                returnState.CurrentValue     = highestVal;
                returnState.CurrentValueUnit = "Bytes/Sec (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);
        }
Ejemplo n.º 3
0
 public LinuxDiskIOCollector()
 {
     AgentConfig = new LinuxDiskIOCollectorConfig();
 }