Poor man's reporting


#1

I was trying to implement a poor mans chef reporting. I had the idea of
putting this in a recipe to be run first in the run list:

response = Net::HTTP.get_response(URI.parse(“
http://server?action=start&host=#{node.fqdn}”))

… and then putting this in a recipe to be run at the end of the run
list:

response = Net::HTTP.get_response(URI.parse(“
http://server?action=end&host=#{node.fqdn}”))

I would then write a simple web service that would listen and put entries
into a database. I noticed however that the URL to be called at the end of
the run is executed before resources that were notified with ‘delayed’ were
run, since they always run at the end of a chef run.

So… is there a way to execute something categorically at the end of a
chef run? I’ve tried reading the handler docs but I just can’t follow them.

Doug


#2

Chef Handlers are absolutely what you want.

Might be best to start with an existing handler and read through that code.
I find that the code can sometimes be even more informative than docs.

There are a couple of handlers listed on the Supermarket including the Chef
Elapsed Time Handler
https://supermarket.getchef.com/tools/20-chef-elapsed-time-handler.

Good luck!
Nathen

On Mon, Aug 18, 2014 at 5:17 PM, Douglas Garstang doug.garstang@gmail.com
wrote:

I was trying to implement a poor mans chef reporting. I had the idea of
putting this in a recipe to be run first in the run list:

response = Net::HTTP.get_response(URI.parse(“
http://server?action=start&host=#{node.fqdn}”))

… and then putting this in a recipe to be run at the end of the run
list:

response = Net::HTTP.get_response(URI.parse(“
http://server?action=end&host=#{node.fqdn}”))

I would then write a simple web service that would listen and put entries
into a database. I noticed however that the URL to be called at the end of
the run is executed before resources that were notified with ‘delayed’ were
run, since they always run at the end of a chef run.

So… is there a way to execute something categorically at the end of a
chef run? I’ve tried reading the handler docs but I just can’t follow them.

Doug


#3

chef server enterprise edition has this baked in. for hook at the end or
chef run , you can use report handlers or event handlers, any of those.

On Mon, Aug 18, 2014 at 2:17 PM, Douglas Garstang doug.garstang@gmail.com
wrote:

I was trying to implement a poor mans chef reporting. I had the idea of
putting this in a recipe to be run first in the run list:

response = Net::HTTP.get_response(URI.parse(“
http://server?action=start&host=#{node.fqdn}”))

… and then putting this in a recipe to be run at the end of the run
list:

response = Net::HTTP.get_response(URI.parse(“
http://server?action=end&host=#{node.fqdn}”))

I would then write a simple web service that would listen and put entries
into a database. I noticed however that the URL to be called at the end of
the run is executed before resources that were notified with ‘delayed’ were
run, since they always run at the end of a chef run.

So… is there a way to execute something categorically at the end of a
chef run? I’ve tried reading the handler docs but I just can’t follow them.

Doug


#4

You might look at this: https://github.com/theforeman/chef-handler-foreman

Never tried it myself, but sends the same basic reporting data that enterprise chef gets to a 3rd party reporting service (that you’ll need to set up and maintain).


Daniel DeLeo

On Monday, August 18, 2014 at 2:21 PM, Ranjib Dey wrote:

chef server enterprise edition has this baked in. for hook at the end or chef run , you can use report handlers or event handlers, any of those.

On Mon, Aug 18, 2014 at 2:17 PM, Douglas Garstang <doug.garstang@gmail.com (mailto:doug.garstang@gmail.com)> wrote:

I was trying to implement a poor mans chef reporting. I had the idea of putting this in a recipe to be run first in the run list:

response = Net::HTTP.get_response(URI.parse(“http://server?action=start&host=#{node.fqdn} (http://server?action=start&host=#{node.fqdn})”))

… and then putting this in a recipe to be run at the end of the run list:

response = Net::HTTP.get_response(URI.parse(“http://server?action=end&host=#{node.fqdn} (http://server?action=end&host=#{node.fqdn})”))

I would then write a simple web service that would listen and put entries into a database. I noticed however that the URL to be called at the end of the run is executed before resources that were notified with ‘delayed’ were run, since they always run at the end of a chef run.

So… is there a way to execute something categorically at the end of a chef run? I’ve tried reading the handler docs but I just can’t follow them.

Doug


#5

Another pretty awesome reporter is here:
https://supermarket.getchef.com/tools/chef-handler-datadog
/disclaimer: I work at Datadog. It’s awesome. :slight_smile:

-M

On Mon, Aug 18, 2014 at 5:36 PM, Daniel DeLeo dan@kallistec.com wrote:

You might look at this: https://github.com/theforeman/chef-handler-foreman

Never tried it myself, but sends the same basic reporting data that
enterprise chef gets to a 3rd party reporting service (that you’ll need to
set up and maintain).


Daniel DeLeo

On Monday, August 18, 2014 at 2:21 PM, Ranjib Dey wrote:

chef server enterprise edition has this baked in. for hook at the end or
chef run , you can use report handlers or event handlers, any of those.

On Mon, Aug 18, 2014 at 2:17 PM, Douglas Garstang <
doug.garstang@gmail.com (mailto:doug.garstang@gmail.com)> wrote:

I was trying to implement a poor mans chef reporting. I had the idea
of putting this in a recipe to be run first in the run list:

response = Net::HTTP.get_response(URI.parse(“
http://server?action=start&host=#{node.fqdn} (
http://server?action=start&host=#{node.fqdn})”))

… and then putting this in a recipe to be run at the end of the run
list:

response = Net::HTTP.get_response(URI.parse(“
http://server?action=end&host=#{node.fqdn} (
http://server?action=end&host=#{node.fqdn})”))

I would then write a simple web service that would listen and put
entries into a database. I noticed however that the URL to be called at the
end of the run is executed before resources that were notified with
’delayed’ were run, since they always run at the end of a chef run.

So… is there a way to execute something categorically at the end of
a chef run? I’ve tried reading the handler docs but I just can’t follow
them.

Doug