Exemplo n.º 1
0
        public static SystemUsage profile()
        {
            SystemUsage systemUsage = new SystemUsage();

            systemUsage.cpu      = CpuUsage.profile();
            systemUsage.memory   = MemoryUsage.profile();
            systemUsage.swap     = SwapUsage.profile();
            systemUsage.dateTime = DateTime.UtcNow;

            return(systemUsage);
        }
Exemplo n.º 2
0
        public static CpuUsage parse(List <string> str)
        {
            foreach (string s in str)
            {
                if (s.StartsWith("Average:"))
                {
                    CpuUsage       cpu        = new CpuUsage();
                    List <decimal> workingSet = s.Replace(",", ".").Split("     ").Where(x => decimal.TryParse(x.Trim(), out decimal d)).Select(x => decimal.Parse(x.Trim())).ToList();

                    cpu.user   = workingSet[0];
                    cpu.nice   = workingSet[1];
                    cpu.system = workingSet[2];
                    cpu.iowait = workingSet[3];
                    cpu.steal  = workingSet[4];
                    cpu.idle   = workingSet[5];

                    return(cpu);
                }
            }
            return(null);
        }
Exemplo n.º 3
0
 public static CpuUsage profile()
 {
     return(CpuUsage.parse("sar 1 4".Bash().Split("\n").ToList()));
 }
Exemplo n.º 4
0
 public static CpuUsage parse(string str)
 {
     return(CpuUsage.parse(str.Split('\n').ToList()));
 }