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/sh
/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.
3 Likes
Hello,
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?
Tried on Linux Debian and Raspbian
Both ended up with this in the Overview:
/etc/snmp/hardware: 2: Syntax error: "(" unexpected
Just my 2 cents, just toying around while I try to fix my temp sensor…
You copy pasted wrong. Try again.
Looks like RPi OS (Bookworm-lite) has decided to change the output of /proc/cpuinfo. The script no longer gives the correct hardware description. Looks like we need to get it elsewhere.
processor : 0
BogoMIPS : 38.40
Features : fp asimd evtstrm crc32 cpuid
CPU implementer : 0x41
CPU architecture: 8
CPU variant : 0x0
CPU part : 0xd03
CPU revision : 4
processor : 1
BogoMIPS : 38.40
Features : fp asimd evtstrm crc32 cpuid
CPU implementer : 0x41
CPU architecture: 8
CPU variant : 0x0
CPU part : 0xd03
CPU revision : 4
processor : 2
BogoMIPS : 38.40
Features : fp asimd evtstrm crc32 cpuid
CPU implementer : 0x41
CPU architecture: 8
CPU variant : 0x0
CPU part : 0xd03
CPU revision : 4
processor : 3
BogoMIPS : 38.40
Features : fp asimd evtstrm crc32 cpuid
CPU implementer : 0x41
CPU architecture: 8
CPU variant : 0x0
CPU part : 0xd03
CPU revision : 4
Revision : a22082
Serial : 00000000xxxxxxx
Model : Raspberry Pi 3 Model B Rev 1.2
What used to be on Bullseye
processor : 0
model name : ARMv7 Processor rev 4 (v7l)
BogoMIPS : 76.80
Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xd03
CPU revision : 4
processor : 1
model name : ARMv7 Processor rev 4 (v7l)
BogoMIPS : 76.80
Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xd03
CPU revision : 4
processor : 2
model name : ARMv7 Processor rev 4 (v7l)
BogoMIPS : 76.80
Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xd03
CPU revision : 4
processor : 3
model name : ARMv7 Processor rev 4 (v7l)
BogoMIPS : 76.80
Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xd03
CPU revision : 4
Hardware : BCM2835
Revision : a22082
Serial : 00000000xxxxxxx
Model : Raspberry Pi 3 Model B Rev 1.2