system info in JSON

273 views
Skip to first unread message

Robert Citek

unread,
May 22, 2012, 8:14:41 AM5/22/12
to CWE-LUG, SLUUG general discussion
Hello all,

Is anyone aware of a shell script (e.g. bash or sh) that returns
system information as a JSON structure?

I need to survey a few dozen systems, collecting various bits of info
such as serial number, CPU, RAM, disk size and layout, etc. On
systems where I can install software, I usually use ohai, which
outputs system information in JSON, which is very easy to parse or
query. Unfortunately, on these particular systems I can only look.
So, no installing of software.

As a sample of what I am looking for, here's a bash function version
that outputs most of the same JSON as does ohai for the dmi portion:

system.json.dmidecode () {
cat <<eof
{
version: "$(dmidecode --version)",
bios: {
version: "$(dmidecode --string bios-version | xargs)",
release_date: "$(dmidecode --string bios-release-date)",
vendor: "$(dmidecode --string bios-vendor)"
},
system: {
manufacturer: "$(dmidecode --string system-manufacturer)",
serial_number: "$(dmidecode --string system-serial-number)",
},
}
eof
}

Thanks in advance for any pointers.

Regards,
- Robert
Reply all
Reply to author
Forward
0 new messages