Collect hardware and software information from lab computers, respecting students' privacy.

Type of information to collect


  • System memory
  • Bash verion
  • JVM version
  • Operating system version (build/last update)

User base

  • OS X
  • Linux
  • FreeBSD

Type of information to avoid collecting

  • CPU serial number
  • Computer serial number (e.g. output of sudo lshw)
  • Network interface card MAC address

Method of delivery

  • Clients join the lab network and execute a Bash script as plain users (i.e. not root)


  • No backgrounding of processes
  • No installation of custom software outside distribution packages
  • No reading of any personal data, anywhere
  • No agents
  • No self-scheduling of re-execution at a later time/date
  • Script to be kept open-source, students can look at it at any time (full transparency)

Permissible to do

  • Block network access until the script has been run (notice: code that does this exists already, actually keeping the VLAN shut until the "report" has been sent back and validated.. no need to code this)
  • If only a user has 16GB of RAM, although that uniquely identifies him/her, that's fine

Example of acceptable commands

printf -v operating_system \
          'OS X v%s (build %s)' \
          $(sw_vers -productVersion) \
          $(sw_vers -buildVersion)


 local -r linux_kernel_version=$(uname -r)
 printf -v operating_system \
           'Linux (kernel %s)' \
 if [[ -f /etc/issue ]]; then
   operating_system+=" $(cat /etc/issue | sed 's/ \\n \\l//g')"


If this kind of script is available already somewhere else, a user profile "sanitised" not to contain any personally identifiable info, useful to a support centre, I have picked the wrong project. Much better to use an existing framework and direct my learner's energies somewhere else.

  • See fusioninventory which you can integrate into inventory platforms like glpi. fusioninventory can also work standalone. Mar 28, 2013 at 18:04
  • maybe you could have a look at /proc Mar 28, 2013 at 18:05
  • There's also ocs inventory (also generally for use with GLPI), but can run without.
    – phemmer
    Mar 28, 2013 at 18:32

4 Answers 4


The specific things you are asking for are simple enough to collect. I guess you are thinking of something more complex but unless you specify what I cannot speculate.

  • System memory

    $ free -h | gawk  '/Mem:/{print $2}'
  • Bash version

     $ bash --version | head -1 
     GNU bash, version 4.2.36(1)-release (x86_64-pc-linux-gnu)
     $ bash --version | head -1 | gawk '{print $4}'
  • JVM version

    $ java -version 2>&1 | head -1
    java version "1.6.0_24"
    $ java -version 2>&1 | head -1 | gawk '{print $NF}' | sed 's/"//g'

    The java -version command prints to standard error (STDERR), so in order to parse, we need to redirect STDERR to STDOUT. In bash, this is done by 2>&1.

  • Operating system version (build/last update)

    $ uname -vo
    #1 SMP Debian 3.2.32-1 GNU/Linux

    I'm not sure what you mean by last update. Update of what? The kernel? Any software?

If you combine all these into a bash script, you get:

#!/usr/bin/env bash
echo "RAM              : `free -h | awk  '/Mem:/{print $2}'`
Bash version     : `bash --version | head -1 | awk '{print $4}'`
Java version     : `java -version 2>&1 | head -1 | awk '{print $NF}' | sed 's/\"//g'`
Operating System : `uname -s`
OS version       : `uname -v`"

This simple script returns this output on my system:

RAM              : 7.8G
Bash version     : 4.2.36(1)-release
Java version     : 1.6.0_24
Operating System : Linux
OS version       : #1 SMP Debian 3.2.32-1

here is a list of commands that fit the criteria, dpkg only works for debian based systems though. In Mac/FreeBSD I am unsure what would be the best method but this should be a good start. None of these need to be installed in a fresh install of ubuntu.

This gives you a complete list of packages installed and there versions with a short description.

dpkg -l >> pkg.info

lshw in ubuntu has an option to exclude sensitive information

lshw -sanitize

This just shows the version information on ubuntu

lsb_release -a

The memory information


My recommendation is to make a script that saves all of this information into individual .info files then places them in a tar file for easy collection. after the "dpkg -l" you can put a pattern to match specific packages you want information for. "dpkg -p" shows you very detailed information about a specific package like "dpkg -p bash"


Check out systems like OCS. There are several around, ask Google for "hardware software inventory" or such. Cobbling up something yourself will break or be less than secure.


Chef, in addition to it's primary purpose of deploying software and configuration, also incidentally maintains a database of precisely the information you're looking for about the hardware on all of its clients.

If you want to get this information from a Chef client, without dealing with a Chef server, and then aggregate the info through some other process, then what you want is Ohai, which produces output something like this: https://gist.github.com/sparr/5265567

  • Is it designed to work well in terms of respecting people's privacy? Mar 28, 2013 at 18:07
  • @Robottinosino I added more details about how to get the info, along with an example. Chef explicitly tries to not put any info in that db that could be sensitive, but you'd be free to cut out any sections you want if, for example, the list of user accounts or home directories was considered private.
    – Sparr
    Mar 28, 2013 at 18:18
  • The cookbooks look amazing. I know no Ruby though and some things.. I found difficult. Puppet sounds more "natural" to me, would you advise against it? Why? Mar 29, 2013 at 4:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .