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.