Example #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("Percentage Free", typeof(double)));

                LinuxDiskSpaceCollectorConfig currentConfig = (LinuxDiskSpaceCollectorConfig)AgentConfig;
                foreach (LinuxDiskSpaceEntry entry in currentConfig.Entries)
                {
                    foreach (DiskInfoState diInfo in entry.GetDiskInfos())
                    {
                        dt.Rows.Add(entry.SSHConnection.ComputerName, diInfo.FileSystemInfo.Name, diInfo.FileSystemInfo.FreeSpacePerc);
                    }
                }
            }
            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);
        }
Example #2
0
        public override MonitorState RefreshState()
        {
            MonitorState returnState = new MonitorState();
            string       lastAction  = "";
            float        lowestVal   = 100;
            int          errors      = 0;
            int          warnings    = 0;
            int          success     = 0;

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

                    List <DiskInfoState> diss = entry.GetStates();
                    foreach (DiskInfoState 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.FileSystemInfo.Name,
                            State            = dis.State,
                            CurrentValue     = dis.FileSystemInfo.FreeSpacePerc,
                            CurrentValueUnit = "%"
                        }
                            );
                        if (lowestVal > dis.FileSystemInfo.FreeSpacePerc)
                        {
                            lowestVal = dis.FileSystemInfo.FreeSpacePerc;
                        }
                    }
                    returnState.ChildStates.Add(entryState);
                }
                returnState.CurrentValue = lowestVal;

                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);
        }
Example #3
0
 public LinuxDiskSpaceCollector()
 {
     AgentConfig = new LinuxDiskSpaceCollectorConfig();
 }