How we use Puppet to inventory our servers.
I think every sysadmin can relate to this, you’re in the kitchen getting a cup of coffee and your boss happens to walk in. You spend a couple of minutes having small talk but as soon as you’re done he drops the bomb. “Hey, could you send me a list of all the servers we have in our datacenter? Finance wants a list for insurance purposes, but I have an old copy … think you could update it and get it to me by the end of the day?” If you’re on top of your game you probably have it in a wiki or a fancy excel spreadsheet with bright color coded cells. Nope, not I, I totally forgot to add the last 20 servers I provisioned. I moved on to the next task, and that spreadsheet he was referring to has a timestamp that’s two months old.
Honestly, we’ve tried using both methods but it quickly gets outdated. Lack of time, lack of interest, you name it and our list includes servers that are no longer in production. It wouldn’t be an issue if we have 20 servers but our lab has over 80 hosts, both physical and virtual machines. Maintaining a list could get out of hand if our spreadsheet (or wiki) isn’t updated routinely when a new host is added or remove from our lab. The next time my boss asks me for an updated inventory list, I’ll send him the URL to our newly built dashboard. Here’s how I made it happen …
Gremlins, I found a family of gremlins who wanted to work as long as I didn’t call the exterminator on them. Nah, seriously I decided to re-do our Puppet environment in order to take advantage of “stored configuration.” With stored configuration, Puppet is able to save data into a database of your choice (SQLite, PostgreSQL or MySQL). “Inventory-ing” the server is possible by using a Ruby library called “Facter.” Since Facter is required by Puppet, I decided to take advantage of the information it obtains from the host after each run. Facter returns valuable information such as hostname, amount of memory, IP address and whether the host is a virtual or physical. All of this information and then some is stored inside a MySQL database.
Ok, so Puppet/Facter does the heavy lifting but how do I get this into a spreadsheet? I dont, I hate spreadsheets and I refuse to update cells and play with columns and rows. Instead, I used my PHP skills and created a customize dashboard that displays everything from hostname, IP, memory usage and rack location. If a server received an additional 2G of RAM, Puppet will update the value the next time it’s scheduled to run. It’s a win-win situation for everyone, I no longer have to worry about updating a wiki page and my boss doesn’t have to nag me for an updated list.





Hi,
you have wrote a beautiful piece of code, could you share it?
I’m a php man and Puppet user… and I have an outdated wiki
LoreLLo
6 Mar 11 at 5:54 pm edit_comment_link(__('Edit', 'sandbox'), ' ', ''); ?>
Sorry, I have no plans of releasing the code at this time.
sam
6 Mar 11 at 9:33 pm edit_comment_link(__('Edit', 'sandbox'), ' ', ''); ?>
I am looking to create something similar.
How are you grabbing your Nagios data? Screen scrape or hooking into Nagios itself?
What about the graphs, are you managing those manually or do you have another tool such as Cacti for graph management?
Any other tips?
CM
26 Jul 11 at 11:57 am edit_comment_link(__('Edit', 'sandbox'), ' ', ''); ?>
I should make a new blog post, but here’s some more information.
- Install ndoutils for Nagios so that it saves its data into a DB (i.e. MySQL).
- We use Ganglia for our graphs and the URL to each graph is static so it was easy to generate dynamic queries to produce the output.
- Save data from Puppet into a DB and you’ll be able to query for valuable system information.
Let me know if you have any other questions or need help.
sam
26 Jul 11 at 3:20 pm edit_comment_link(__('Edit', 'sandbox'), ' ', ''); ?>
Awesome nice looking GUI! All my respect to you. Would you provide this GUI to us?
sebastian
22 Aug 11 at 3:06 am edit_comment_link(__('Edit', 'sandbox'), ' ', ''); ?>
Very slick! I would love it if you released this code to the public.
chadm
1 Sep 11 at 2:51 pm edit_comment_link(__('Edit', 'sandbox'), ' ', ''); ?>
+1 on the hope that you’ll release the code. We have pretty well the same setup and are working on setting up a similar inventory system.
If anything, I’d be very interested in seeing your database schema. Did you pull Nagios, ganglia links, and facts to a aggregated datdbase, or pulling from separate DBs?
Shawn
7 Sep 11 at 3:50 pm edit_comment_link(__('Edit', 'sandbox'), ' ', ''); ?>
Nothing special with the DB schema. There’s no centralized DB that pulls from these different sources. I grab the info directly from my Nagios and Puppet servers.. The key is to get Puppet to run in stored config mode. As for ganglia, I was only concerned with the CPU, Load and Memory graphs and if you know the URL to the graphs, then it’s easy to modify the URL parameter to show whichever host you want to display.
sam
7 Sep 11 at 5:29 pm edit_comment_link(__('Edit', 'sandbox'), ' ', ''); ?>
+1 on the hope of you releasing the code. Perhaps you could convince your boss that it’s good PR for the company. And you can select a license that keeps you in control?
Raboo
14 Feb 12 at 5:06 am edit_comment_link(__('Edit', 'sandbox'), ' ', ''); ?>