http://www.perlmonks.org?node_id=936467

doubledecker has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks

I'm writing a Perl script to gather hardware and OS configuration information. I would like to know what are the parameters I need to consider to include in my script. Basic things like

  1. OS
  2. OS version
  3. Bit Type
  4. Memory
  5. Speed of CPU
  6. No of CPU's
can anybody please expand the list of parameters to be include, it would be greatful.

Thanks

  • Comment on get hardware and OS configuration information

Replies are listed 'Best First'.
Re: get hardware and OS configuration information
by zentara (Archbishop) on Nov 07, 2011 at 12:08 UTC
Re: get hardware and OS configuration information
by Anonymous Monk on Nov 07, 2011 at 10:36 UTC
    man 8 hwinfo

    arch, bios, block, bluetooth, braille, bridge, camera, cdrom, chipcard, cpu, disk, dsl, dvb, fingerprint, floppy, framebuffer, gfxcard, hub, ide, isapnp, isdn, joystick, keyboard, memory, modem, monitor, mouse, netcard, network, partition, pci, pcmcia, pcmcia-ctrl, pppoe, printer, redasd, reallyall, scanner, scsi, smp, sound, storage-ctrl, sys, tape, tv, uml, usb, usb-ctrl, vbe, wlan, xen, zip

    man 1 dstat

    cpu24, load, mem, swap, vm, disk, net, cpufreq, net_packets, thermal, topbio, topio, topoom and many more

Re: get hardware and OS configuration information
by moritz (Cardinal) on Nov 07, 2011 at 10:53 UTC

    The parameters you need to consider depend on your application. What do you collect the data for? If the application is related to pure perl scripts or modules, most of these data points are not very important (but endianess might matter for pack/unpack)

    For other applications you surely want to know the architecture (i386/ARM/PowerPC/SPARC/ ...), the endianess, maybe libc vendor and version, $PATH and other env variables

Re: get hardware and OS configuration information
by anneli (Pilgrim) on Nov 07, 2011 at 10:35 UTC

    This really depends more on your purpose for the script! It would probably more useful to let your needs dictate what to include than a bunch of us on the 'net who don't know your requirements. :)

Re: get hardware and OS configuration information
by Anonymous Monk on Nov 07, 2011 at 11:42 UTC
    there exists many CPAN modules to access this type of information.
Re: get hardware and OS configuration information
by pvaldes (Chaplain) on Nov 07, 2011 at 23:44 UTC

    Upgraded and improved:

    use Sys::Info; use Sys::Info::Constants qw( :device_cpu ); my $info = Sys::Info->new; my $cpu = $info->device('CPU'); printf "\nWe have %s ", scalar $cpu->count; printf "%s-bit CPU", scalar $cpu->bitness; printf " %s\n", scalar $cpu->identify; printf "The CPU speed is: %s\n", scalar $cpu->speed; print "We are running a ",$^O", system\n";

    if you are in win you can also Use Win32::GetOSName(); Use Win32::GetOSVersion();