Beispiel #1
0
        public void CompressTest()
        {
            for (int i = 0; i < 1000; i++)
            {
                byte[] buf = new byte[10000];
                var    rnd = new Random();
                rnd.NextBytes(buf);

                var input_stream  = new MemoryStream(buf);
                var output_stream = new MemoryStream();
                BZip2.Compress(input_stream, output_stream, true, 9);

                input_stream = new MemoryStream(output_stream.ToArray());
                var decompressed_stream = new MemoryStream();
                BZip2.Decompress(input_stream, decompressed_stream, true);

                var decompressed_bytes = decompressed_stream.ToArray();
                Assert.AreEqual(buf.Length, decompressed_bytes.Length);

                //for (int i = 0; i < buf.Length; i++)
                //{
                //    Assert.AreEqual(buf[i], decompressed_bytes[i]);
                //}
                Thread.Sleep(1);
                Console.WriteLine(MemInfo.GetCurProcessMem());
            }
        }
Beispiel #2
0
        public void CompressTest1()
        {
            for (int i = 0; i < 1000; i++)
            {
                byte[] buffer = new byte[1000];

                var rnd = new Random();
                rnd.NextBytes(buffer);


                var deflated = BZip2.Compress(buffer);
                var inflated = BZip2.Decompress(deflated);

                Assert.AreEqual(buffer.Length, inflated.Length);

                //for (var i = 0; i < buffer.Length; i++)
                //{
                //    Assert.AreEqual(buffer[i], inflated[i]);
                //}

                if (i % 100 == 0)
                {
                    Console.WriteLine(MemInfo.GetCurProcessMem());
                }
            }
        }
Beispiel #3
0
            public string DumpRanges()
            {
                StringWriter sw = new StringWriter();

                foreach (int ipi in sortedMemInfos)
                {
                    MemInfo p = memInfos[ipi];

                    if (p.cCommitted == 0 && p.cDecommitted == 0 && p.cReleased == 0 && p.cReserved == 0)
                    {
                        continue;
                    }

                    sw.WriteLine("Live ranges for {0}", ByteWindow.MakeString(p.processPid));
                    sw.WriteLine();
                    sw.WriteLine("RESERVED  ({0} ranges)", p.rsReserved.RangeCount);
                    sw.WriteLine();
                    sw.WriteLine(p.rsReserved.Dump());
                    sw.WriteLine();
                    sw.WriteLine("COMMITTED ({0} ranges)", p.rsCommitted.RangeCount);
                    sw.WriteLine();
                    sw.WriteLine(p.rsCommitted.Dump());
                    sw.WriteLine();
                }

                return(sw.ToString());
            }
Beispiel #4
0
            private void SortMemInfos()
            {
                sortedMemInfos = new int[memInfos.Length];

                for (int i = 0; i < sortedMemInfos.Length; i++)
                {
                    sortedMemInfos[i] = i;
                }

                Array.Sort <int>(sortedMemInfos, delegate(int i, int j)
                {
                    MemInfo a = memInfos[i];
                    MemInfo b = memInfos[j];

                    if (a.cbCommitted > b.cbCommitted)
                    {
                        return(-1);
                    }
                    if (a.cbCommitted < b.cbCommitted)
                    {
                        return(1);
                    }
                    return(0);
                }
                                 );
            }
    /// <summary>
    /// 俱乐部成员  申请信息返回
    /// </summary>
    /// <param name="message"></param>
    private void onClubMemInfoBack(NetworkMessage message)
    {
        GameData.CurrentClubInfo.ApplyMemList = new List <MemInfo>();
        bool bApply = message.readBool();

        if (bApply)                              //有申请信息
        {
            int ClubCount = message.readInt32(); //俱乐部个数
            for (int j = 0; j < ClubCount; j++)
            {
                uint   clubid   = message.readUInt32();
                string ClubName = message.readString();
                int    count    = message.readInt32(); //申请的人数

                for (int i = 0; i < count; i++)
                {
                    MemInfo info = new MemInfo();
                    info.ClubId   = clubid;
                    info.ClubName = ClubName;
                    info.Name     = message.readString();
                    info.Guid     = message.readUInt64();
                    info.HeadId   = message.readString();
                    GameData.CurrentClubInfo.ApplyMemList.Add(info);
                }
            }
            int count1 = message.readInt32(); //邀请信息
            GameData.CurrentClubInfo.InviteList = new List <MemInfo>();
            for (int i = 0; i < count1; i++)
            {
                MemInfo inviteM = new MemInfo();

                inviteM.Guid     = message.readUInt64(); //邀请人guid
                inviteM.Name     = message.readString(); //邀请人名字
                inviteM.ClubId   = message.readUInt32(); //俱乐部id
                inviteM.ClubName = message.readString(); //俱乐部名字

                GameData.CurrentClubInfo.InviteList.Add(inviteM);
            }
        }
        else
        {
            int count2 = message.readInt32(); //邀请信息
            GameData.CurrentClubInfo.InviteList = new List <MemInfo>();
            for (int i = 0; i < count2; i++)
            {
                MemInfo info = new MemInfo();
                info.Guid   = message.readUInt64();
                info.Name   = message.readString();
                info.ClubId = message.readUInt32(); //俱乐部id
                info.HeadId = message.readString();
                GameData.CurrentClubInfo.InviteList.Add(info);
            }
        }
        if (DzPanelMessage.Instance != null)
        {
            DzPanelMessage.Instance.CreatData();
        }
        UIManager.Instance.ShowUiPanel(UIPaths.PanelMessage, OpenPanelType.MinToMax);
    }
Beispiel #6
0
        public MemInfo GetMemoryInfo()
        {
            MemInfo mi = new MemInfo();

            Renci.SshNet.SshClient sshClient = SSHConnection.GetConnection();
            mi = MemInfo.FromCatProcMeminfo(sshClient);
            SSHConnection.CloseConnection();
            return(mi);
        }
Beispiel #7
0
 public void SetData(MemInfo info)
 {
     _menInfo = info;
     if (ManagerScene.Instance.currentSceneType != SceneType.Game)
     {
         _headTexture = transform.Find("Head").GetComponent <UITexture>();
         _nameLable   = transform.Find("Name").GetComponent <UILabel>();
         DownloadImage.Instance.Download(_headTexture, info.HeadId);
         _nameLable.text = info.Name;
     }
 }
Beispiel #8
0
        public override MonitorState GetCurrentState()
        {
            MonitorState currentState = new MonitorState()
            {
                ForAgent         = Description,
                State            = CollectorState.NotAvailable,
                CurrentValueUnit = "%"
            };

            try
            {
                MemInfo mi = new MemInfo();
                Renci.SshNet.SshClient sshClient = SSHConnection.GetConnection();
                mi = MemInfo.FromCatProcMeminfo(sshClient);
                SSHConnection.CloseConnection();
                double outputValue = 0;
                if (MemoryType == LinuxMemoryType.MemAvailable)
                {
                    outputValue = mi.AvailablePerc;
                    if (outputValue == 0 && mi.TotalKB > 0)
                    {
                        outputValue = (mi.FreeKB + mi.Buffers + mi.Cached) / mi.TotalKB;
                    }
                }
                else if (MemoryType == LinuxMemoryType.MemFree)
                {
                    outputValue = mi.FreePerc;
                }
                else
                {
                    outputValue = mi.SwapFreePerc;
                }
                currentState.CurrentValue = outputValue.ToString("0.0");
                if (ErrorValue >= outputValue)
                {
                    currentState.State = CollectorState.Error;
                }
                else if (WarningValue >= outputValue)
                {
                    currentState.State = CollectorState.Warning;
                }
                else
                {
                    currentState.State = CollectorState.Good;
                }
            }
            catch (Exception ex)
            {
                currentState.State      = CollectorState.Error;
                currentState.RawDetails = ex.Message;
            }
            return(currentState);
        }
Beispiel #9
0
        public static MemInfo Read(Stream stream)
        {
            if (stream == null)
            {
                throw new ArgumentNullException(nameof(stream));
            }

            using (var reader = new StreamReader(stream))
            {
                var result = new MemInfo();

                while (true)
                {
                    string line = reader.ReadLine();
                    if (string.IsNullOrWhiteSpace(line))
                    {
                        break;
                    }

                    string[] values = line.Split(Separators, StringSplitOptions.RemoveEmptyEntries);

                    if (values.Length < 2 || values.Length > 3)
                    {
                        throw new InvalidOperationException($"Invalid line in '{MemInfoFileName}'. Line: '{line}'.");
                    }

                    string name          = values[0].TrimEnd(':');
                    string valueAsString = values[1];
                    if (long.TryParse(valueAsString, out long value) == false)
                    {
                        throw new InvalidOperationException($"Invalid value in '{MemInfoFileName}'. Line: '{line}'. Value: '{valueAsString}'.");
                    }

                    SizeUnit unit = SizeUnit.Bytes;

                    if (values.Length == 3)
                    {
                        string unitAsString = values[2];
                        unit = unitAsString switch
                        {
                            "kB" => SizeUnit.Kilobytes,
                            _ => throw new InvalidOperationException($"Invalid unit in '{MemInfoFileName}'. Line: '{line}'. Unit: '{unitAsString}'.")
                        };
                    }

                    result.Set(name, value, unit);
                }

                return(result);
            }
        }
    }
Beispiel #10
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="info"></param>
 /// <param name="IsInvite">是否为邀请信息</param>
 public void SetValue(MemInfo info, bool IsInvite)
 {
     Invite        = IsInvite;
     this.infoData = info;
     DownloadImage.Instance.Download(HeadTexture, info.HeadId);
     if (Invite)//是邀请信息
     {
         DescLable.text = info.Name + " 邀请你加入 " + info.ClubName;
     }
     else
     {
         DescLable.text = info.Name + " 申请加入俱乐部 ";
     }
 }
Beispiel #11
0
 public void Reset()
 {
     for (int i = 0; i < memInfos.Length; i++)
     {
         if (memInfos[i] == null)
         {
             memInfos[i] = new MemInfo(trace.processes[i].processPid);
         }
         else
         {
             memInfos[i].Reset();
         }
     }
 }
Beispiel #12
0
            public string DumpMemoryPlots()
            {
                if (sortedMemInfos == null || sortedMemInfos.Length < 1)
                {
                    return("");
                }

                StringWriter sw = new StringWriter();

                sw.WriteLine();
                sw.WriteLine("VM PLOTS FOR SELECTED PROCESSES");
                sw.WriteLine();

                int count = 0;

                foreach (int ipi in sortedMemInfos)
                {
                    MemInfo p = memInfos[ipi];

                    if (p.cCommitted == 0 && p.cDecommitted == 0 && p.cReleased == 0 && p.cReserved == 0)
                    {
                        continue;
                    }

                    sw.WriteLine();
                    sw.WriteLine();

                    string xLabel = String.Format("Usage from {0}", ByteWindow.MakeString(p.processPid));
                    string yLabel = "Reserved Bytes";

                    sw.WriteLine(FormatOnePlot(memoryPlotRows, memoryPlotColumns, xLabel, yLabel, p.reservedDistribution));

                    sw.WriteLine();
                    sw.WriteLine();

                    xLabel = String.Format("Usage from {0}", ByteWindow.MakeString(p.processPid));
                    yLabel = "Committed Bytes";

                    sw.WriteLine(FormatOnePlot(memoryPlotRows, memoryPlotColumns, xLabel, yLabel, p.committedDistribution));

                    count++;

                    if (count >= 3)
                    {
                        break;
                    }
                }

                return(sw.ToString());
            }
Beispiel #13
0
        public CollectorState GetState(MemInfo mi)
        {
            CollectorState state = CollectorState.Good;

            if (ErrorValue >= GetMonitoredValue(mi))
            {
                state = CollectorState.Error;
            }
            else if (WarningValue >= GetMonitoredValue(mi))
            {
                state = CollectorState.Warning;
            }

            return(state);
        }
Beispiel #14
0
        public static InfoBuffer GetMemObjectInfo(Mem mem, MemInfo paramName, out ErrorCode error)
        {
            if (paramName == MemInfo.HostPtr) // Handle special case
            {
                IntPtr size = GetInfo(Cl.GetMemObjectInfo, mem, Cl.MemInfo.Size, out error).CastTo<IntPtr>();
                var buffer = new InfoBuffer(size);
                error = GetMemObjectInfo(mem, paramName, size, buffer, out size);
                if (error != ErrorCode.Success)
                    return InfoBuffer.Empty;

                return buffer;
            }

            return GetInfo(GetMemObjectInfo, mem, paramName, out error);
        }
Beispiel #15
0
        public static InfoBuffer GetMemObjectInfo(IMem mem, MemInfo paramName, out ErrorCode error)
        {
            if (paramName == MemInfo.HostPtr) // Handle special case
            {
                IntPtr size   = GetInfo(Cl.GetMemObjectInfo, mem, MemInfo.Size, out error).CastTo <IntPtr>();
                var    buffer = new InfoBuffer(size);
                error = GetMemObjectInfo(mem, paramName, size, buffer, out size);
                if (error != ErrorCode.Success)
                {
                    return(InfoBuffer.Empty);
                }

                return(buffer);
            }

            return(GetInfo(GetMemObjectInfo, mem, paramName, out error));
        }
 /// <summary>
 /// 设置信息
 /// </summary>
 /// <param name="Apply">是否为申请列表</param>
 public void SetValue(bool Apply, MemInfo data)
 {
     if (Apply)
     {
         AgreeBtn.gameObject.SetActive(true);
         RefuseBtn.gameObject.SetActive(true);
         RemoveBtn.gameObject.SetActive(false);
     }
     else
     {
         AgreeBtn.gameObject.SetActive(false);
         RefuseBtn.gameObject.SetActive(false);
         RemoveBtn.gameObject.SetActive(true);
     }
     this.MeminfoData = data;
     InitData();
 }
Beispiel #17
0
        public double GetMonitoredValue(MemInfo mi)
        {
            double outputValue = 0;

            if (LinuxMemoryType == Collectors.LinuxMemoryType.MemAvailable)
            {
                outputValue = mi.AvailablePerc;
                if (outputValue == 0)
                {
                    outputValue = (mi.FreeKB + mi.Buffers + mi.Cached) / mi.TotalKB;
                }
            }
            else if (LinuxMemoryType == Collectors.LinuxMemoryType.MemFree)
            {
                outputValue = mi.FreePerc;
            }
            else
            {
                outputValue = mi.SwapFreePerc;
            }
            return(outputValue);
        }
    /// <summary>
    /// 俱乐部信息返回
    /// </summary>
    /// <param name="obj"></param>
    private void onClubInfoBack(NetworkMessage message)
    {
        ClubInfo info = new ClubInfo();

        info.RoomConfigList     = new List <RoomConfig>();
        info.ActiveRoomInfoList = new List <ActiveRoomInfo>();
        info.HistoryDataList    = new List <HistoryData>();

        info.Id              = (int)message.readUInt32();
        info.ClubName        = message.readString();
        info.CreatorName     = message.readString();
        info.CreatorGuid     = message.readUInt64();
        info.CreatorPhoneNum = message.readString();
        info.Gold            = message.readInt64();
        info.creatPower      = (ClubCreatePower)message.readUInt8(); //开房权限
        info.PlayerCount     = message.readInt32();                  //俱乐部人数

        //所有的玩家信息 包括俱乐部群主 以及管理员
        info.AllMemList = new List <MemInfo>();
        int count = message.readInt32();

        for (int i = 0; i < count; i++)
        {
            MemInfo memInfo = new MemInfo();
            memInfo.Name      = message.readString();
            memInfo.Guid      = message.readUInt64();
            memInfo.HeadId    = message.readString();
            memInfo.Sex       = message.readUInt8();
            memInfo.Ip        = message.readString();
            memInfo.Adress    = message.readString();
            memInfo.PlayCount = message.readUInt32();

            info.AllMemList.Add(memInfo);
        }

        info.MemMasterList = new List <MemInfo>();//管理员
        int count1 = message.readInt32();

        for (int i = 0; i < count1; i++)
        {
            MemInfo masterInfo = new MemInfo();
            masterInfo.Name   = message.readString();
            masterInfo.Guid   = message.readUInt64();
            masterInfo.HeadId = message.readString();
            info.MemMasterList.Add(masterInfo);
        }

        //设置群主、管理员、普通会员数据
        info.NormalMemList = new List <MemInfo>();//玩家信息
        for (var i = 0; i < info.AllMemList.Count; i++)
        {
            var  data    = info.AllMemList[i];
            bool bNormal = true;
            if (data.Guid == info.CreatorGuid)
            {
                bNormal             = false;
                info.CreatorMemInfo = data;
            }
            else
            {
                for (var j = 0; j < info.MemMasterList.Count; j++)
                {
                    var data1 = info.MemMasterList[j];
                    if (data1.Guid == data.Guid)
                    {
                        bNormal = false;
                        info.MemMasterList[j] = data;
                    }
                }
            }
            if (bNormal)
            {
                info.NormalMemList.Add(data);
            }
        }

        GameData.CurrentClubInfo = info;//当前申请的俱乐部
        if (DzPanelMomentInfo.Instance != null && DzPanelMomentInfo.Instance.gameObject.activeSelf)
        {
            DzPanelMomentInfo.Instance.InitData();
        }
        UIManager.Instance.ShowUiPanel(UIPaths.PanelMomentInfo, OpenPanelType.MinToMax);
    }
Beispiel #19
0
 public static extern Error clGetMemObjectInfo(OpenCLMem memobj, MemInfo param_name, IntPtr param_value_size, IntPtr param_value, IntPtr param_value_size_ret);
Beispiel #20
0
 public static extern int VirtualQueryEx(IntPtr hProcess, IntPtr lpAddress, out MemInfo lpBuffer, uint dwLength);
Beispiel #21
0
 public void AddMember(MemInfo mi)
 {
     m_mems.Add(mi.Clone() as MemInfo);
 }
Beispiel #22
0
            public string Dump()
            {
                StringWriter sw = new StringWriter();

                SortMemInfos();

                sw.WriteLine("VM CHANGES IN THIS INTERVAL");
                sw.WriteLine();

                sw.WriteLine("{8,-35} {0,14} {1,14} {2,14} {3,14} {4,14} {5,14} {6,14} {7,14}",
                             "Reserved", "Count",
                             "Committed", "Count",
                             "Decomitt", "Count",
                             "Released", "Count",
                             "Process");

                sw.WriteLine("{8,-35} {0,14} {1,14} {2,14} {3,14} {4,14} {5,14} {6,14} {7,14}",
                             "---------", "-----",
                             "---------", "-----",
                             "--------", "-----",
                             "--------", "-----",
                             "-------");

                foreach (int ipi in sortedMemInfos)
                {
                    MemInfo p = memInfos[ipi];

                    if (p.cCommitted == 0 && p.cDecommitted == 0 && p.cReleased == 0 && p.cReserved == 0)
                    {
                        continue;
                    }

                    sw.WriteLine("{8,-35} {0,14:n0} {1,14:n0} {2,14:n0} {3,14:n0} {4,14:n0} {5,14:n0} {6,14:n0} {7,14:n0}"
                                 , p.cbReserved
                                 , p.cReserved
                                 , p.cbCommitted
                                 , p.cCommitted
                                 , p.cbDecommitted
                                 , p.cDecommitted
                                 , p.cbReleased
                                 , p.cReleased
                                 , ByteWindow.MakeString(p.processPid)
                                 );
                }

                sw.WriteLine();
                sw.WriteLine("VM ALLOCATED AT END OF THIS INTERVAL");
                sw.WriteLine();


                sw.WriteLine("{4,-35} {0,14} {1,14} {2,14} {3,14}",
                             "Reserved", "Ranges",
                             "Committed", "Ranges",
                             "Process");

                sw.WriteLine("{4,-35} {0,14} {1,14} {2,14} {3,14}",
                             "--------", "------",
                             "---------", "------",
                             "-------");

                foreach (int ipi in sortedMemInfos)
                {
                    MemInfo p = memInfos[ipi];

                    if (p.cCommitted == 0 && p.cDecommitted == 0 && p.cReleased == 0 && p.cReserved == 0)
                    {
                        continue;
                    }

                    sw.WriteLine("{4,-35} {0,14:n0} {1,14:n0} {2,14:n0} {3,14:n0}"
                                 , p.rsReserved.Count
                                 , p.rsReserved.RangeCount
                                 , p.rsCommitted.Count
                                 , p.rsCommitted.RangeCount
                                 , ByteWindow.MakeString(p.processPid)
                                 );
                }

                return(sw.ToString());
            }
Beispiel #23
0
 internal MonoInterface()
 {
     m_meminfo = new MemInfo();
 }
Beispiel #24
0
 public static extern ErrorCode GetMemObjectInfo(IntPtr memObj,
                                                 MemInfo paramName,
                                                 uint paramValueSize,
                                                 void *paramValue,
                                                 out uint paramValueSizeRet);
Beispiel #25
0
        private bool LoadObj(CConfig _cConfig, object _oObj)
        {
            Type ObjType = _oObj.GetType();// this.GetType();//.GetType();

            //PropertyInfo[] ObjPropInfo = ObjType.GetProperties();
            FieldInfo[] ObjFieldInfo = ObjType.GetFields();

            string sMemName;
            string sMemType;
            Type   MemType;

            string sValue;
            int    iTemp;
            double dTemp;
            string sTemp;
            bool   bTemp;

            foreach (FieldInfo MemInfo in ObjFieldInfo)
            {
                sMemName = MemInfo.Name;
                sMemType = MemInfo.FieldType.FullName;
                MemType  = MemInfo.FieldType;



                if (MemType == typeof(int))
                {
                    _cConfig.GetValue(ObjType.Name, sMemName, out sValue);
                    //struct는 콜바잉벨류라 박싱 언박싱을 해줘서 콜바이 레퍼런스로 교체.
                    iTemp = CConfig.StrToIntDef(sValue, 0);
                    MemInfo.SetValue(_oObj, iTemp);
                    Log.Trace(sMemName, sValue);
                }
                else if (MemType == typeof(bool))
                {
                    _cConfig.GetValue(ObjType.Name, sMemName, out sValue);
                    bTemp = CConfig.StrToBoolDef(sValue, false);
                    MemInfo.SetValue(_oObj, bTemp);
                    Log.Trace(sMemName, sValue);
                }
                else if (MemType == typeof(double))
                {
                    _cConfig.GetValue(ObjType.Name, sMemName, out sValue);
                    dTemp = CConfig.StrToDoubleDef(sValue, 0.0);
                    MemInfo.SetValue(_oObj, dTemp);
                    Log.Trace(sMemName, sValue);
                }
                else if (MemType == typeof(string))
                {
                    _cConfig.GetValue(ObjType.Name, sMemName, out sValue);
                    sTemp = sValue;
                    MemInfo.SetValue(_oObj, sTemp);
                    Log.Trace(sMemName, sValue);
                }
                else if (MemType == typeof(int[]))
                {
                    int[] iAray = (int[])MemInfo.GetValue(_oObj);

                    string sIndex;
                    for (int i = 0; i < iAray.Length; i++)
                    {
                        sIndex = string.Format("{0}({1})", sMemName, i);
                        _cConfig.GetValue(ObjType.Name, sIndex, out sValue);
                        iTemp    = CConfig.StrToIntDef(sValue, 0);
                        iAray[i] = iTemp;

                        Log.Trace(sIndex, iAray[i].ToString());
                    }
                }
                else if (MemType == typeof(bool[]))
                {
                    bool[] bAray = (bool[])MemInfo.GetValue(_oObj);

                    string sIndex;
                    for (int i = 0; i < bAray.Length; i++)
                    {
                        sIndex = string.Format("{0}({1})", sMemName, i);
                        _cConfig.GetValue(ObjType.Name, sIndex, out sValue);
                        bTemp    = CConfig.StrToBoolDef(sValue, false);
                        bAray[i] = bTemp;

                        Log.Trace(sIndex, bAray[i].ToString());
                    }
                }
                else if (MemType == typeof(double[]))
                {
                    double[] dAray = (double[])MemInfo.GetValue(_oObj);

                    string sIndex;
                    for (int i = 0; i < dAray.Length; i++)
                    {
                        sIndex = string.Format("{0}({1})", sMemName, i);
                        _cConfig.GetValue(ObjType.Name, sIndex, out sValue);
                        dTemp    = CConfig.StrToDoubleDef(sValue, 0);
                        dAray[i] = dTemp;

                        Log.Trace(sIndex, dAray[i].ToString());
                    }
                }
                else if (MemType == typeof(string[]))
                {
                    string[] sAray = (string[])MemInfo.GetValue(_oObj);

                    string sIndex;
                    for (int i = 0; i < sAray.Length; i++)
                    {
                        sIndex = string.Format("{0}({1})", sMemName, i);
                        _cConfig.GetValue(ObjType.Name, sIndex, out sValue);
                        //MemInfo.SetValue(_oObj,sValue);
                        sAray[i] = sValue;

                        Log.Trace(sIndex, sAray[i].ToString());
                    }
                }
            }


            return(true);
        }
Beispiel #26
0
        private bool SaveObj(CConfig _cConfig, object _oObj)
        {
            Type ObjType = _oObj.GetType();

            FieldInfo[] ObjFieldInfo = ObjType.GetFields();

            string sMemName;
            string sMemType;
            Type   MemType;
            object oTemp;

            string sValue = string.Empty;

            foreach (FieldInfo MemInfo in ObjFieldInfo)
            {
                sMemName = MemInfo.Name;
                sMemType = MemInfo.FieldType.FullName;
                MemType  = MemInfo.FieldType;

                if (MemType == typeof(int) ||
                    MemType == typeof(bool) ||
                    MemType == typeof(double) ||
                    MemType == typeof(string))
                {
                    oTemp = MemInfo.GetValue(_oObj);

                    if (oTemp != null)
                    {
                        sValue = MemInfo.GetValue(_oObj).ToString();
                    }
                    else
                    {
                        sValue = "";
                    }

                    _cConfig.SetValue(ObjType.Name, sMemName, sValue);
                    Log.Trace(sMemName, sValue);
                }
                else if (MemType == typeof(int[]))
                {
                    int[] iAray = (int[])MemInfo.GetValue(_oObj);

                    string sIndex;
                    for (int i = 0; i < iAray.Length; i++)
                    {
                        sIndex = string.Format("{0}({1})", sMemName, i);
                        _cConfig.SetValue(ObjType.Name, sIndex, iAray[i]);
                        Log.Trace(sIndex, iAray[i].ToString());
                    }
                }
                else if (MemType == typeof(bool[]))
                {
                    bool[] bAray = (bool[])MemInfo.GetValue(_oObj);

                    string sIndex;
                    for (int i = 0; i < bAray.Length; i++)
                    {
                        sIndex = string.Format("{0}({1})", sMemName, i);
                        _cConfig.SetValue(ObjType.Name, sIndex, bAray[i]);
                        Log.Trace(sIndex, bAray[i].ToString());
                    }
                }
                else if (MemType == typeof(double[]))
                {
                    double[] dAray = (double[])MemInfo.GetValue(_oObj);

                    string sIndex;
                    for (int i = 0; i < dAray.Length; i++)
                    {
                        sIndex = string.Format("{0}({1})", sMemName, i);
                        _cConfig.SetValue(ObjType.Name, sIndex, dAray[i]);
                        Log.Trace(sIndex, dAray[i].ToString());
                    }
                }
                else if (MemType == typeof(string[]))
                {
                    string[] sAray = (string[])MemInfo.GetValue(_oObj);

                    string sIndex;
                    for (int i = 0; i < sAray.Length; i++)
                    {
                        sIndex = string.Format("{0}({1})", sMemName, i);
                        _cConfig.SetValue(ObjType.Name, sIndex, sAray[i]);
                        Log.Trace(sIndex, sAray[i].ToString());
                    }
                }
            }
            return(true);
        }
 private static extern OpenCLErrorCode clGetMemObjectInfo(IntPtr memObj,
                                                    MemInfo paramName,
                                                    IntPtr paramValueSize,
                                                    IntPtr paramValue,
                                                    out IntPtr paramValueSizeRet);
Beispiel #28
0
 public extern static int clGetMemObjectInfo(
     IntPtr memobj,
     MemInfo param_name,
     IntPtr param_value_size,
     byte[] param_value,
     out IntPtr param_value_size_ret);
Beispiel #29
0
        /// <summary>
        /// Ottiene un Master valorizzato coi valori ottenuti direttamente dal sistema operativo
        /// Potrebbe non corrispondere al Master salvato
        /// Viene utilizzato per ottenere le differenze tra i parametri salvati e quelli effettivamente applicati
        /// </summary>
        /// <returns></returns>
        public static MachineStatus GetRunning()
        {
            //var STOPWATCH = new System.Diagnostics.Stopwatch();
            //STOPWATCH.Start();
            var master = new MachineStatus();

            master.Info.Uptime    = Uptime.Get();
            master.Info.CpuInfo   = CpuInfo.Get();
            master.Info.MemInfo   = MemInfo.Get();
            master.Info.Free      = Free.Get();
            master.Info.Losetup   = Losetup.Get();
            master.Info.DiskUsage = DiskUsage.Get();
            master.Info.Versions  = Versioning.Get();

            master.Host     = Hostnamectl.Get();
            master.TimeDate = new TimeDate()
            {
                Timezone = Timedatectl.Get().Timezone
            };
            master.Boot = new Boot();
            var modules     = Mod.Get();
            var bootModules = new SystemModule[modules.Length];

            for (var i = 0; i < modules.Length; i++)
            {
                bootModules[i] = new SystemModule()
                {
                    Module = modules[i].Module, Active = true
                };
            }
            master.Boot.Modules           = bootModules;
            master.Boot.Services          = cmds.Systemctl.GetAll();
            master.Boot.Parameters        = Sysctl.Get();
            master.Users.SystemUsers      = Passwd.Get();
            master.Users.ApplicativeUsers = new ApplicativeUser[] { new ApplicativeUser()
                                                                    {
                                                                        Active = true, Type = AuthenticationType.simple, Id = "master", Claims = new[] { SHA.Generate("master") }
                                                                    } };

            master.Network.KnownDns          = Dns.GetResolv();
            master.Network.KnownHosts        = Dns.GetHosts();
            master.Network.KnownNetworks     = Dns.GetNetworks();
            master.Network.Bridges           = Brctl.Get();
            master.Network.Bonds             = Bond.Get();
            master.Network.NetworkInterfaces = cmds.Network.Get();
            master.Network.RoutingTables     = Route.GetRoutingTable();
            master.Network.Routing           = Route.Get();

            master.NsSwitch = NS.Switch.Get();

            master.Storage.Mounts       = Mount.Get();
            master.Storage.Zpools       = Zpool.GetPools();
            master.Storage.ZfsDatasets  = Zfs.GetDatasets();
            master.Storage.ZfsSnapshots = Zfs.GetSnapshots();

            master.Services.Ssh.PublicKey     = Ssh.GetRootPublicKey();
            master.Services.Ssh.PrivateKey    = Ssh.GetRootPrivateKey();
            master.Services.Ssh.AuthorizedKey = Ssh.GetAuthorizedKey();

            master.Services.Virsh.Domains = Virsh.GetDomains();

            //ConsoleLogger.Log($"[conf] loaded running conf ({STOPWATCH.ElapsedMilliseconds})");
            return(master);
        }
Beispiel #30
0
 internal extern static unsafe int GetMemObjectInfo(IntPtr memobj, MemInfo param_name, IntPtr param_value_size, IntPtr param_value, [OutAttribute] IntPtr *param_value_size_ret);
Beispiel #31
0
            public void ProcessMemRecord(ETWLineReader l, ByteWindow b, MemEffect memeffect)
            {
                // empty the net effect of this record
                memeffect.released = memeffect.reserved = memeffect.committed = memeffect.decommitted = 0;

                int interval = (int)((l.t - l.t0) / (double)(l.t1 - l.t0) * memoryPlotColumns);

                // the above can overflow because time ranges might be out of order so clamp any overflows
                // also we have to handle the case where l.t == l.t1 which would otherwise overflow
                if (interval < 0)
                {
                    interval = 0;
                }

                if (interval >= memoryPlotColumns)
                {
                    interval = memoryPlotColumns - 1;
                }

                bT.Assign(b, fldProcessNamePID).Trim();
                int idProcess = trace.atomsProcesses.Lookup(bT);

                // bogus process, disregard
                if (idProcess == -1)
                {
                    return;
                }

                MemInfo p = memInfos[idProcess];

                var rsReserved  = p.rsReserved;
                var rsCommitted = p.rsCommitted;

                ulong addrBase = b.GetHex(fldMemBaseAddr);
                ulong addrEnd  = b.GetHex(fldMemEndAddr);

                b.Field(fldFlags).Trim();

                if (l.idType == idAlloc)
                {
                    if (b.StartsWith(byReserveCommit))
                    {
                        memeffect.reserved = rsReserved.AddRange(addrBase, addrEnd);
                        p.cbReserved      += memeffect.reserved;
                        p.reservedDistribution[interval] += (long)memeffect.reserved;
                        if (memeffect.reserved != 0)
                        {
                            p.cReserved++;
                        }

                        memeffect.committed = rsCommitted.AddRange(addrBase, addrEnd);
                        p.cbCommitted      += memeffect.committed;
                        p.committedDistribution[interval] += (long)memeffect.committed;
                        if (memeffect.committed != 0)
                        {
                            p.cCommitted++;
                        }
                    }
                    else if (b.StartsWith(byReserve))
                    {
                        memeffect.reserved = rsReserved.AddRange(addrBase, addrEnd);
                        p.cbReserved      += memeffect.reserved;
                        p.reservedDistribution[interval] += (long)memeffect.reserved;
                        if (memeffect.reserved != 0)
                        {
                            p.cReserved++;
                        }
                    }
                    else if (b.StartsWith(byCommit))
                    {
                        memeffect.committed = rsCommitted.AddRange(addrBase, addrEnd);
                        p.cbCommitted      += memeffect.committed;
                        p.committedDistribution[interval] += (long)memeffect.committed;
                        if (memeffect.committed != 0)
                        {
                            p.cCommitted++;
                        }
                    }
                }

                if (l.idType == idFree)
                {
                    if (b.StartsWith(byRelease))
                    {
                        memeffect.decommitted              = rsCommitted.RemoveRange(addrBase, addrEnd);
                        p.cbDecommitted                   += memeffect.decommitted;
                        p.committedDistribution[interval] -= (long)memeffect.decommitted;
                        if (memeffect.decommitted != 0)
                        {
                            p.cDecommitted++;
                        }

                        memeffect.released = rsReserved.RemoveRange(addrBase, addrEnd);
                        p.cbReleased      += memeffect.released;
                        p.reservedDistribution[interval] -= (long)memeffect.released;
                        if (memeffect.released != 0)
                        {
                            p.cReleased++;
                        }
                    }
                    else if (b.StartsWith(byDecommit))
                    {
                        memeffect.decommitted              = rsCommitted.RemoveRange(addrBase, addrEnd);
                        p.cbDecommitted                   += memeffect.decommitted;
                        p.committedDistribution[interval] -= (long)memeffect.decommitted;
                        if (memeffect.decommitted != 0)
                        {
                            p.cDecommitted++;
                        }
                    }
                }
            }
Beispiel #32
0
 public static Error clGetMemObjectInfo(OpenCLMem memobj, MemInfo param_name, IntPtr param_value_size, IntPtr param_value, IntPtr param_value_size_ret)
 {
     Console.WriteLine("Calling Error clGetMemObjectInfo(OpenCLMem memobj, MemInfo param_name, IntPtr param_value_size, IntPtr param_value, IntPtr param_value_size_ret)");
     return default(Error);
 }
 public static OpenCLErrorCode GetMemObjectInfo(IMemoryObject memObj,
                                          MemInfo paramName,
                                          IntPtr paramValueSize,
                                          InfoBuffer paramValue,
                                          out IntPtr paramValueSizeRet)
 {
     return clGetMemObjectInfo((memObj as IHandleData).Handle, paramName, paramValueSize, paramValue.Address, out paramValueSizeRet);
 }
Beispiel #34
0
 internal extern static unsafe ErrorCode GetMemObjectInfo(IntPtr memobj, MemInfo param_name, IntPtr param_value_size, IntPtr param_value, [Out] IntPtr *param_value_size_ret);
Beispiel #35
0
		public extern static int clGetMemObjectInfo (
			IntPtr memobj,
			MemInfo param_name,
			IntPtr param_value_size,
			byte[] param_value,
			out IntPtr param_value_size_ret);
Beispiel #36
0
 internal extern static unsafe int GetMemObjectInfo(IntPtr memobj, MemInfo param_name, IntPtr param_value_size, IntPtr param_value, [OutAttribute] IntPtr* param_value_size_ret);