示例#1
0
 internal static SigarException FindException(Hyperic.Sigar.Sigar sigar, int errno)
 {
     if (errno == 20001)
     {
         return((SigarException) new SigarNotImplementedException(sigar, errno));
     }
     return(new SigarException(sigar, errno));
 }
        internal static NetInterfaceConfig NativeGet(Hyperic.Sigar.Sigar sigar, string name)
        {
            System.Type type  = typeof(NetInterfaceConfig);
            IntPtr      num   = Marshal.AllocHGlobal(Marshal.SizeOf(type));
            int         errno = NetInterfaceConfig.sigar_net_interface_config_get(sigar.sigar.Handle, name, num);

            if (errno != 0)
            {
                Marshal.FreeHGlobal(num);
                throw Hyperic.Sigar.Sigar.FindException(sigar, errno);
            }
            NetInterfaceConfig structure = (NetInterfaceConfig)Marshal.PtrToStructure(num, type);

            Marshal.FreeHGlobal(num);
            return(structure);
        }
示例#3
0
        internal static SysInfo NativeGet(Hyperic.Sigar.Sigar sigar)
        {
            Type   type  = typeof(SysInfo);
            IntPtr num   = Marshal.AllocHGlobal(Marshal.SizeOf(type));
            int    errno = SysInfo.sigar_sys_info_get(sigar.sigar.Handle, num);

            if (errno != 0)
            {
                Marshal.FreeHGlobal(num);
                throw Hyperic.Sigar.Sigar.FindException(sigar, errno);
            }
            SysInfo structure = (SysInfo)Marshal.PtrToStructure(num, type);

            Marshal.FreeHGlobal(num);
            return(structure);
        }
示例#4
0
        internal static Mem NativeGet(Hyperic.Sigar.Sigar sigar)
        {
            Type   type  = typeof(Mem);
            IntPtr num   = Marshal.AllocHGlobal(Marshal.SizeOf(type));
            int    errno = Mem.sigar_mem_get(sigar.sigar.Handle, num);

            if (errno != 0)
            {
                Marshal.FreeHGlobal(num);
                throw Hyperic.Sigar.Sigar.FindException(sigar, errno);
            }
            Mem structure = (Mem)Marshal.PtrToStructure(num, type);

            Marshal.FreeHGlobal(num);
            return(structure);
        }
示例#5
0
        internal static FileSystemUsage NativeGet(Hyperic.Sigar.Sigar sigar, string dirname)
        {
            Type   type  = typeof(FileSystemUsage);
            IntPtr num   = Marshal.AllocHGlobal(Marshal.SizeOf(type));
            int    errno = FileSystemUsage.sigar_file_system_usage_get(sigar.sigar.Handle, dirname, num);

            if (errno != 0)
            {
                Marshal.FreeHGlobal(num);
                throw Hyperic.Sigar.Sigar.FindException(sigar, errno);
            }
            FileSystemUsage structure = (FileSystemUsage)Marshal.PtrToStructure(num, type);

            Marshal.FreeHGlobal(num);
            return(structure);
        }
示例#6
0
 public SigarException(Hyperic.Sigar.Sigar sigar, int errno)
 {
     this.sigar = sigar;
     this.errno = errno;
 }
示例#7
0
 public SigarNotImplementedException(Hyperic.Sigar.Sigar sigar, int errno)
     : base(sigar, errno)
 {
 }