Facter facts for PCI devices

We are in the process of building the configuration for our monitoring system from exported resources (more on that in the future). To accomplish one of the checks we needed a way to identify the brand of RAID controller in our physical servers. The best way to do this is facter.

We’ve written some custom facts before, but never facts for hardware. We could have taken the lazy route and use lspci -m | awk -F '" "' '/RAID/ { print $2 }'. But maybe we need more hardware facts in the future. So we built a script that parses the output of lspci -vmmk and builds a multidimensional hash for it.

We then iterate over the hash and add facts for every RAID controller we find. Because we have a hash of all the data from lspci, we can add facts for every type of controller on the PCI bus by adding a regex, a counter (there may be more than one controller of a certain type) and a factname (with embedded counter).

We are releasing this script in the hope that it will be useful to somebody. Installation is breeze: Just add pci_devices.rb to your puppet module in module_name/lib/facter and start using it.

The code is on github. If you have any improvements or questions, send us a pull request or a ticket.

*Image source: https://unsplash.com/photos/xekxE_VR0Ec

Tags: , , ,

Leave a Reply

Kumina helps companies innovate with the power of open source software. As specialists in managed IT operations since 2007, our mission is simple: building and managing the perfectly tailored technical infrastructures that allow our clients to thrive.

With fully managed solutions, we help our customers unlock the full potential of the cloud and Kubernetes. Our team also supports organisations with IT consulting and Kubernetes training courses. Learn more about our services or get in touch, we would love to hear about your business and projects.