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

                LinuxMemoryCollectorConfig currentConfig = (LinuxMemoryCollectorConfig)AgentConfig;
                foreach (LinuxMemoryEntry entry in currentConfig.Entries)
                {
                    Linux.MemInfo memInfo = entry.GetMemoryInfo();
                    double        percVal = memInfo.AvailablePerc;
                    if (percVal == 0)
                    {
                        percVal = memInfo.FreePerc;
                    }
                    dt.Rows.Add(entry.SSHConnection.ComputerName, percVal);
                }
            }
            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  = "";
            double       lowestVal   = 100;
            int          errors      = 0;
            int          warnings    = 0;
            int          success     = 0;

            try
            {
                LinuxMemoryCollectorConfig currentConfig = (LinuxMemoryCollectorConfig)AgentConfig;
                foreach (LinuxMemoryEntry entry in currentConfig.Entries)
                {
                    Linux.MemInfo  memInfo      = entry.GetMemoryInfo();
                    double         percVal      = entry.GetMonitoredValue(memInfo);
                    CollectorState currentState = entry.GetState(memInfo);
                    if (currentState == CollectorState.Error)
                    {
                        errors++;
                    }
                    else if (currentState == CollectorState.Warning)
                    {
                        warnings++;
                    }
                    else
                    {
                        success++;
                    }
                    returnState.ChildStates.Add(
                        new MonitorState()
                    {
                        ForAgent         = entry.SSHConnection.ComputerName,
                        State            = currentState,
                        CurrentValue     = percVal,
                        CurrentValueUnit = "%"
                    });
                    if (lowestVal > percVal)
                    {
                        lowestVal = percVal;
                    }
                }
                returnState.CurrentValue     = lowestVal;
                returnState.CurrentValueUnit = "% (lowest value)";

                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 LinuxMemoryCollector()
 {
     AgentConfig = new LinuxMemoryCollectorConfig();
 }