Find the answer to your Linux question:
Results 1 to 6 of 6
Hello, How can i get linux system information? on windows i used this script Code: var wbemFlagReturnImmediately = 0x10; var wbemFlagForwardOnly = 0x20; //create fileSystem object var fso = new ...
  1. #1
    Just Joined!
    Join Date
    May 2008
    Posts
    14

    How to get linux system information?

    Hello, How can i get linux system information?

    on windows i used this script
    Code:
    var wbemFlagReturnImmediately = 0x10;
    var wbemFlagForwardOnly = 0x20;
    
    
    //create fileSystem object
    var fso = new ActiveXObject("Scripting.FileSystemObject"); 
    
    //create BasicComputerInformation.properties to keep basic computer information
    var writer = fso.CreateTextFile("BasicComputerInformation.properties", true); 
    
    var objWMIService = GetObject("winmgmts:\\\\.\\root\\CIMV2");
    var colItems = objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystem", "WQL",
     wbemFlagReturnImmediately | wbemFlagForwardOnly);
    
     var enumItems = new Enumerator(colItems);
     for (; !enumItems.atEnd(); enumItems.moveNext()) {
     var objItem = enumItems.item();
    
     writer.WriteLine("AdminPasswordStatus = " + objItem.AdminPasswordStatus);
     writer.WriteLine("AutomaticResetBootOption = " + objItem.AutomaticResetBootOption);
     writer.WriteLine("AutomaticResetCapability = " + objItem.AutomaticResetCapability);
     writer.WriteLine("BootOptionOnLimit = " + objItem.BootOptionOnLimit);
     writer.WriteLine("BootOptionOnWatchDog = " + objItem.BootOptionOnWatchDog);
     writer.WriteLine("BootROMSupported = " + objItem.BootROMSupported);
     writer.WriteLine("BootupState = " + objItem.BootupState);
     writer.WriteLine("Caption = " + objItem.Caption);
     writer.WriteLine("ChassisBootupState = " + objItem.ChassisBootupState);
     writer.WriteLine("CreationClassName = " + objItem.CreationClassName);
     writer.WriteLine("CurrentTimeZone = " + objItem.CurrentTimeZone);
     writer.WriteLine("DaylightInEffect = " + objItem.DaylightInEffect);
     writer.WriteLine("Description = " + objItem.Description);
     writer.WriteLine("Domain = " + objItem.Domain);
     writer.WriteLine("DomainRole = " + objItem.DomainRole);
     writer.WriteLine("EnableDaylightSavingsTime = " + objItem.EnableDaylightSavingsTime);
     writer.WriteLine("FrontPanelResetStatus = " + objItem.FrontPanelResetStatus);
     writer.WriteLine("InfraredSupported = " + objItem.InfraredSupported);
     try { writer.WriteLine("InitialLoadInfo = " + (objItem.InitialLoadInfo.toArray()).join(",")); }
     catch(e) { writer.WriteLine("InitialLoadInfo = null"); }
     writer.WriteLine("InstallDate = " + objItem.InstallDate);
     writer.WriteLine("KeyboardPasswordStatus = " + objItem.KeyboardPasswordStatus);
     writer.WriteLine("LastLoadInfo = " + objItem.LastLoadInfo);
     writer.WriteLine("Manufacturer = " + objItem.Manufacturer);
     writer.WriteLine("Model = " + objItem.Model);
     writer.WriteLine("Name = " + objItem.Name);
     writer.WriteLine("NameFormat = " + objItem.NameFormat);
     writer.WriteLine("NetworkServerModeEnabled = " + objItem.NetworkServerModeEnabled);
     writer.WriteLine("NumberOfProcessors = " + objItem.NumberOfProcessors);
     try { writer.WriteLine("OEMLogoBitmap = " + (objItem.OEMLogoBitmap.toArray()).join(",")); }
     catch(e) { writer.WriteLine("OEMLogoBitmap = null"); }
     try { writer.WriteLine("OEMStringArray = " + (objItem.OEMStringArray.toArray()).join(",")); }
     catch(e) { writer.WriteLine("OEMStringArray = null"); }
     writer.WriteLine("PartOfDomain = " + objItem.PartOfDomain);
     writer.WriteLine("PauseAfterReset = " + objItem.PauseAfterReset);
     try { writer.WriteLine("PowerManagementCapabilities = " + (objItem.PowerManagementCapabilities.toArray()).join(",")); }
     catch(e) { writer.WriteLine("PowerManagementCapabilities = null"); }
     writer.WriteLine("PowerManagementSupported = " + objItem.PowerManagementSupported);
     writer.WriteLine("PowerOnPasswordStatus = " + objItem.PowerOnPasswordStatus);
     writer.WriteLine("PowerState = " + objItem.PowerState);
     writer.WriteLine("PowerSupplyState = " + objItem.PowerSupplyState);
     writer.WriteLine("PrimaryOwnerContact = " + objItem.PrimaryOwnerContact);
     writer.WriteLine("PrimaryOwnerName = " + objItem.PrimaryOwnerName);
     writer.WriteLine("ResetCapability = " + objItem.ResetCapability);
     writer.WriteLine("ResetCount = " + objItem.ResetCount);
     writer.WriteLine("ResetLimit = " + objItem.ResetLimit);
     try { writer.WriteLine("Roles = " + (objItem.Roles.toArray()).join(",")); }
     catch(e) { writer.WriteLine("Roles = null"); }
     writer.WriteLine("Status = " + objItem.Status);
     try { writer.WriteLine("SupportContactDescription = " + (objItem.SupportContactDescription.toArray()).join(",")); }
     catch(e) { writer.WriteLine("SupportContactDescription = null"); }
     writer.WriteLine("SystemStartupDelay = " + objItem.SystemStartupDelay);
     try { writer.WriteLine("SystemStartupOptions = " + (objItem.SystemStartupOptions.toArray()).join(",")); }
     catch(e) { writer.WriteLine("SystemStartupOptions = null"); }
     writer.WriteLine("SystemStartupSetting = " + objItem.SystemStartupSetting);
     writer.WriteLine("SystemType = " + objItem.SystemType);
     writer.WriteLine("ThermalState = " + objItem.ThermalState);
     writer.WriteLine("TotalPhysicalMemory = " + objItem.TotalPhysicalMemory);
     writer.WriteLine("UserName = " + objItem.UserName);
     writer.WriteLine("WakeUpType = " + objItem.WakeUpType);
     writer.WriteLine("Workgroup = " + objItem.Workgroup);
     writer.WriteLine();
     }
    
    // close file 
    writer.Close();
    Anyone have solution please tell me.
    Thank.

  2. #2
    Linux Engineer GNU-Fan's Avatar
    Join Date
    Mar 2008
    Posts
    935
    Phew, these information is widely scattered across the system, but you should find most of it in the /proc directory Linux.com :: Discover the possibilities of the /proc directory, in the /etc/ directory and with the hostname command.
    Debian GNU/Linux -- You know you want it.

  3. #3
    drl
    drl is offline
    Linux Engineer drl's Avatar
    Join Date
    Apr 2006
    Location
    Saint Paul, MN, USA / CentOS, Debian, Solaris, SuSE
    Posts
    1,117
    Hi.

    This is a list of things and places I try ... cheers, drl
    Code:
    Commands and files to help with hardware, versions, etc.
    
    cat /etc/debian_version
    version-of-distro       # local utility
    cat /proc/cpuinfo
    cat /proc/meminfo
    cat /var/log/installer/hardware-summary         # (Debian lenny)
    arch
    mach
    machid
    dmesg
    free
    hardinfo
    hwinfo
    lshw
    lspci -vv
    lsusb
    uname -r
    system_profiler         # OS X
    Welcome - get the most out of the forum by reading forum basics and guidelines: click here.
    90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
    We look forward to helping you with the challenge of the other 10%.
    ( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )

  4. #4
    Just Joined!
    Join Date
    May 2008
    Posts
    14
    Thanks,
    One question, There are C/C++/Python API to do this?

  5. #5
    Just Joined!
    Join Date
    Oct 2008
    Posts
    2
    This is a real anwser:
    I making a program that need system information, I googled a lot of places looking for something different that parcing /proc information, opening coreapps and other system libraries I found this (cuts from my code):
    #include <sys/sysinfo.h> //< library

    utsname sn;
    uname(&sn);
    System_vars *sf;
    sf = &SYSTEM_info;
    int days, hours, mins;

    struct sysinfo sys_info;

    if(sysinfo(&sys_info) != 0)
    cout << "Unable to get some sysinfo";
    else {

    // Uptime
    sf->up_days = sys_info.uptime / 86400;
    sf->up_hours = (sys_info.uptime / 3600)-(sf->up_days * 24);
    sf->up_minutes = (sys_info.uptime / 60)-(sf->up_days * 1440)-(sf->up_hours * 60);
    sf->up_seconds = sys_info.uptime &#37; 60;

    // Load Averages for 1,5 and 15 minutes //needs to be rounded

    cout << "\nLoad Avgs: 1min(" << sys_info.loads[0] << ") 5min(" << sys_info.loads[1] << ") 15min(" << sys_info.loads[2] << ")";

    // Total and free ram.
    cout << "\nTotal Ram: " << sys_info.totalram / 1024 / 1024 << " Mb, Free: " << sys_info.freeram / 1024 / 1024 << " Mb";

    // Shared and buffered ram.
    cout << "\nShared Ram: " << sys_info.sharedram / 1024 / 1024;
    cout << "\nBuffered Ram: " << sys_info.bufferram / 1024 / 1024;

    // Swap space
    cout << "\nTotal Swap: " << sys_info.totalswap / 1024 / 1024 << " Mb Free: " << sys_info.freeswap / 1024 / 1024 << " MB";

    // Number of processes currently running.
    cout << "\nNumber of processes: " << sys_info.procs;
    cout << "\n procs " << get_nprocs();
    cout << "\n procs " << get_nprocs_conf();
    cout << "\nmem unit " << sys_info.mem_unit;

    // kernel info:

    sn.nodename
    sn.machine
    sn.sysname
    sn.release
    sn.version
    sn.machine
    for hard drives I found:
    statfs64("/", &fs); give u the root partition info u can use it with different partitions on your system
    to get the list of mounted partitions read /etc/mtab

    I looking for more information but loot of things are easy to be get from the /proc

    Good look

  6. #6
    oz
    oz is offline
    forum.guy
    Join Date
    May 2004
    Location
    arch linux
    Posts
    18,096
    You can get quite a bit with the dmidecode command, too:

    Code:
    dmidecode | more
    Note that you might need root permissions to access.
    oz

    new members/users: read this first | new member faq
    no private messages requesting computer support - post them on the forums!
    please use the "report post" button to alert our forum admins to problematic posts rather than responding to them yourself.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...