Book Image

Puppet Reporting and Monitoring

By : Michael Duffy
Book Image

Puppet Reporting and Monitoring

By: Michael Duffy

Overview of this book

Table of Contents (16 chapters)
Puppet Reporting and Monitoring
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Preface

Puppet is possibly the fastest growing configuration management tool on the planet, and this is in no small part due to its combination of power and accessibility. From small five-node installations through to hugely complex cloud infrastructures that number thousands of nodes, Puppet has proven its ability to deliver on the promise of infrastructure as code. There have been a number of titles that cover its ability to create idempotent resources, manage services, and ensure that systems are configured correctly and maintained with little or no effort. Yet, none of these titles spend more than a chapter discussing its reporting features.

This is a shame; Puppet's reporting capability is one of its most overlooked yet powerful features. If used correctly, its built-in reporting abilities can give you stunning levels of detail about your infrastructure, from the amount of hardware used and networking details to details about how and when resources were changed. However, this is just the beginning. In this book, we are going to cover techniques that are simple to learn and that will allow you to use Puppet as a key part of your alerting systems, letting it bring your attention to important changes and even forming a simple-to-implement tripwire system. We're going to explore PuppetDB and learn why this is a fantastic source of information that you can use to not only explore the changes being applied to your systems, but also create an end-to-end repository of knowledge about your infrastructure. We're going to build custom dashboards to make this data accessible, and finally, we will look at the ways by which you can make Puppet not only report the changes, but also drive them.

What this book covers

Chapter 1, Setting Up Puppet for Reporting, will guide you through the simple steps to take your existing Puppet installation and make it report.

Chapter 2, Viewing Data in Dashboards, takes a look at the existing dashboards available for Puppet and how you can use them to report on your data.

Chapter 3, Introducing Report Processors, acquaints you with the engine that drives much of the Puppet reporting process—the report processor.

Chapter 4, Creating Your Own Report Processor, deals with creating your own report processor with custom e-mail alerts, MySQL storage, and integration with third-party products.

Chapter 5, Exploring PuppetDB, introduces PuppetDB, a fantastic and powerful system for report storage and analysis. In this chapter, we look at what PuppetDB is, how it's configured, and finally, how you can set it up in your own infrastructure.

Chapter 6, Retrieving Data with the PuppetDB API, explores the fantastically powerful API of PuppetDB; the API allows you to query your reports in a number of different ways. We're going to explore this API for functions that range from basic queries to advanced data integration.

Chapter 7, Writing Custom Reports with PuppetDB, deals with creating easy-to-use custom report applications.

Chapter 8, Creating Your Own Custom Dashboard, deals with creating an attractive and detailed custom dashboard using Dashing and PuppetDB.

Chapter 9, Looking Back and Looking Forward, takes a look at some of the more advanced ways in which you can use Puppet reporting to do everything from alerting to the orchestration of your infrastructure.

What you need for this book

The code and examples in this book have been designed for use with the following software:

  • Puppet 3.0 and higher versions

  • Ruby 1.9 and higher versions

Who this book is for

This book is designed for anyone who wants to learn more about the fundamental components of Puppet reporting. To get the most out of this book, you should already be familiar with Puppet and be comfortable with its major components such as the Puppet master and Puppet agent. You should also be comfortable with reading code, and in particular, you should be at least passingly familiar with Ruby. Finally, you should be happy working on the command line in the Linux/Unix flavor of your choice.

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "We can include other contexts through the use of the include directive."

A block of code is set as follows:

include puppet

Puppet::Reports::register_report(:myfirstreport) do
  desc "My very first report!"

  def process
    if self.status == 'failed'
      msg = "failed puppet run for #{self.host} #{self.status}
      File.open('./tmp/puppetpanic.txt', 'w') { | f | f.write(msg)}
    end
  end
end

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

metric_vals = {}

      self.metrics.each { |metric, data|
        data.values.each { |val|
          name = "#{val[1]} #{metric}"
          value = val[2]
          metric_vals[name] = value
        }
      }

Any command-line input or output is written as follows:

puppet module generate <username>-<modulename>

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "The Facts view is particularly useful as it not only lists each node with the associated fact value, but also presents it neatly in the form of a graph."

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to , and mention the book title via the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.