Better linux hardware strings

So I was looking for better hardware descriptions.
On some platforms, this gives good output:
extend hardware '/bin/cat /sys/devices/virtual/dmi/id/product_name'
extend manufacturer '/bin/cat /sys/devices/virtual/dmi/id/sys_vendor'

But others do not.

I repurposed a script to get some nicer output:

/usr/bin/awk -F": " '/^model name/ { mod=$2 } /^cpu MHz/ { mhz=$2 } /^cpu core/ {core=$2} /^flags/ { virt="No Virtualisation";match($0,"svm");if (RSTART!=0) { virt="SVM-Virtualisation" };match($0,"vmx");if (RSTART!=0) { virt="VMX-Virtualisation" } } /^Mem:/ {split($2,arr," ");tot=arr[1];free=arr[2]} END { printf "%s %s core(s) %s %sB Memory\n",mod,core,virt,tot }' /proc/cpuinfo <(/usr/bin/free -mh)

then make it executable and set this in your snmpd.conf
extend hardware /etc/snmp/hardware

Giving a much nicer output. Feel free to tweak. Try to avoid something that will change often, otherwise it will pollute your eventlog.

1 Like


On some servers, I do not have a /sys/devices/virtual/dmi; on others, the two files are empty.

I’m not fluent in awk and can not debug your script, but here is a strange result:

Raspberry Pi Model B Plus Rev 1.2: does not show core value

ARMv6-compatible processor rev 7 (v6l) core(s) 477MiB Memory

On an Intel VMWare or Xen host, I have “No Virtualisation” in the result, does it means it’s not a VM ? Or does it means it can not host a VM?