-
-
Save peelman/133ab70a7f55b08e7e77 to your computer and use it in GitHub Desktop.
Revisions
-
peelman revised this gist
Nov 11, 2015 . 2 changed files with 8 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,5 @@ ##Description Simple Dashing widget (and associated job) to display general puppetdb status. Pulled the API calls from [Puppetboard](https://github.com/puppet-community/puppetboard). WARNING: This only works if puppetdb is listening on HTTP. I have not gotten around to getting this to work with SSL client certificates yet. If you know how, please leave them at the comments below. This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -9,14 +9,21 @@ avg_resources_uri = '/metrics/v1/mbeans/puppetlabs.puppetdb.query.population:type=default,name=avg-resources-per-node' agg_eventcounts_uri = '/pdb/query/v4/aggregate-event-counts?query=%5B%22%3D%22%2C%22latest_report%3F%22%2Ctrue%5D&summarize_by=certname' one_hour_ago = (Time.now - 60*60).utc.iso8601 reported_in_uri = "/pdb/query/v4/nodes?query=%5B%22extract%22%2C%5B%5B%22function%22%2C%22count%22%5D%5D%2C%5B%22%3C%22%2C%22report_timestamp%22%2C%22#{one_hour_ago}%22%5D%5D" SCHEDULER.every '5m', :first_in => 0 do |job| num_nodes = JSON.parse(http.get(nodes_uri).body) num_resources = JSON.parse(http.get(resources_uri).body) avg_resource = JSON.parse(http.get(avg_resources_uri).body) agg_eventcounts = JSON.parse(http.get(agg_eventcounts_uri).body) unreported = JSON.parse(http.get(reported_in_uri).body).first['count'].to_i send_event('puppetdb_stats', { num_nodes: num_nodes['Value'], num_resources: num_resources['Value'], avg_resource: avg_resource['Value'].to_f.round(2), unreported: unreported, successes: agg_eventcounts.first['successes'], failures: agg_eventcounts.first['failures'] }) -
peelman revised this gist
Nov 11, 2015 . 4 changed files with 12 additions and 13 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,5 @@ ##Description Simple Dashing widget (and associated job) to display general puppetdb status. Pulled the api calls from [Nedap's Puppetboard](https://github.com/puppet-community/puppetboard). Excellent tool BTW. WARNING: This only works if puppetdb is listening on HTTP. I have not gotten around to getting this to work with SSL client certificates yet. If you know how, please leave them at the comments below. This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,4 @@ <h1 class="title" data-bind="title">Puppet Status</h1> <div class="row"> <div class="col"> <h2 class="success" data-bind="successes"></h2><span>with status change</span> This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,23 +3,23 @@ # Currently do not have this working with client side SSL, perhaps someone can help with that in the comments. http = Net::HTTP.new(host, port) nodes_uri = '/metrics/v1/mbeans/puppetlabs.puppetdb.query.population:type=default,name=num-nodes' resources_uri = '/metrics/v1/mbeans/puppetlabs.puppetdb.query.population:type=default,name=num-resources' avg_resources_uri = '/metrics/v1/mbeans/puppetlabs.puppetdb.query.population:type=default,name=avg-resources-per-node' agg_eventcounts_uri = '/pdb/query/v4/aggregate-event-counts?query=%5B%22%3D%22%2C%22latest_report%3F%22%2Ctrue%5D&summarize_by=certname' SCHEDULER.every '5m', :first_in => 0 do |job| num_nodes = JSON.parse(http.get(nodes_uri).body) num_resources = JSON.parse(http.get(resources_uri).body) avg_resource = JSON.parse(http.get(avg_resources_uri).body) agg_eventcounts = JSON.parse(http.get(agg_eventcounts_uri).body) send_event('puppetdb_stats', { num_nodes: num_nodes['Value'], num_resources: num_resources['Value'], avg_resource: avg_resource['Value'].to_f.round(2), successes: agg_eventcounts.first['successes'], failures: agg_eventcounts.first['failures'] }) end This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -13,7 +13,7 @@ h1 { text-transform: uppercase; letter-spacing: 4px; font-weight: 700; color: white; } -
bitflingr revised this gist
May 24, 2014 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,8 @@ ##Description Simple Dashing widget (and associated job) to display general puppetdb status. Pulled the api calls from [Nedap's Puppetboard](https://github.com/nedap/puppetboard). Excellent tool BTW. WARNING: This only works if puppetdb is listening on HTTP. I have not gotten around to getting this to work with SSL client certificates yet. If you know how, please leave them at the comments below. ##Screenshot <a href="http://imgur.com/iED9hm1"><img src="http://i.imgur.com/iED9hm1.png?1" title="Hosted by imgur.com"/></a> -
bitflingr revised this gist
May 24, 2014 . 1 changed file with 8 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -8,7 +8,14 @@ Simple Dashing widget (and associated job) to display general puppetdb status. None ##Usage To use this widget, copy puppetdb_stats.html, puppetdb_stats.coffee, and puppetdb_stats.scss into the /widgets/puppetdb_stats directory. Put the puppetdb_stats.rb file in your /jobs folder. Or you can do this the easy way and run the following in your dashing directory $> dashing install a49981b299dff184c04a create widgets/puppetdb_stats/puppetdb_stats.coffee create widgets/puppetdb_stats/puppetdb_stats.html create jobs/puppetdb_stats.rb create widgets/puppetdb_stats/puppetdb_stats.scss Don't forget to edit the Gemfile and run bundle install if needed. More information for this widget can be found at https://gist.github.com/a49981b299dff184c04a To include the widget in a dashboard, add the following snippet to the dashboard layout file: -
bitflingr created this gist
May 24, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,17 @@ ##Description Simple Dashing widget (and associated job) to display general puppetdb status. Pulled the api calls from [Nedap's Puppetboard](https://github.com/nedap/puppetboard). Excellent tool BTW. ##Screenshot <a href="http://imgur.com/iED9hm1"><img src="http://i.imgur.com/iED9hm1.png?1" title="Hosted by imgur.com"/></a> ##Dependencies None ##Usage To use this widget, copy puppetdb_stats.html, puppetdb_stats.coffee, and puppetdb_stats.scss into the /widgets/puppetdb_stats directory. Put the puppetdb_stats.rb file in your /jobs folder. To include the widget in a dashboard, add the following snippet to the dashboard layout file: <li data-row="1" data-col="1" data-sizex="2" data-sizey="1"> <div data-id="puppetdb_stats" data-view="PuppetdbStats"></div> </li> This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,9 @@ class Dashing.PuppetdbStats extends Dashing.Widget ready: -> # This is fired when the widget is done being rendered onData: (data) -> # Handle incoming data # You can access the html node of this widget with `@node` # Example: $(@node).fadeOut().fadeIn() will make the node flash each time data comes in. This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,22 @@ <h1>Puppet Status</h1> <div class="row"> <div class="col"> <h2 class="success" data-bind="successes"></h2><span>with status change</span> </div> <div class="col" style="float:right;"> <h2 class="failure" data-bind="failures"></h2><span>with status failed</span> </div> </div> <div class="row"> <div class="col" style="width: 33%;"> <h2 data-bind="num_nodes"></h2><span>Population</span> </div> <div class="col" style="float:left; width: 33%;"> <h2 data-bind="num_resources"></h2><span>Resources managed</span> </div> <div class="col" style="float:left; width: 33%;"> <h2 data-bind="avg_resource"></h2><span>Avg. resource/node</span> </div> </div> This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,25 @@ require 'net/http' require 'json' # Currently do not have this working with client side SSL, perhaps someone can help with that in the comments. host = 'YOUR_PUPPETDB_HOST_HERE' port = 'PORT_NUMBER' http = Net::HTTP.new(host, port) nodes_uri = '/v3/metrics/mbean/com.puppetlabs.puppetdb.query.population:type=default,name=num-nodes' resources_uri = '/v3/metrics/mbean/com.puppetlabs.puppetdb.query.population:type=default,name=num-resources' avg_resources_uri = '/v3/metrics/mbean/com.puppetlabs.puppetdb.query.population:type=default,name=avg-resources-per-node' agg_eventcounts_uri = '/v3/aggregate-event-counts?query=%5B%22%3D%22%2C%22latest-report%3F%22%2Ctrue%5D&summarize-by=certname' SCHEDULER.every '5m', :first_in => 0 do |job| num_nodes = JSON.parse(http.get(nodes_uri).body) num_resources = JSON.parse(http.get(resources_uri).body) avg_resource = JSON.parse(http.get(avg_resources_uri).body) agg_eventcounts = JSON.parse(http.get(agg_eventcounts_uri).body) send_event('puppetdb_stats', { num_nodes: num_nodes['Value'], num_resources: num_resources['Value'], avg_resource: avg_resource['Value'].to_f.round(2), successes: agg_eventcounts['successes'], failures: agg_eventcounts['failures'] }) end This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,36 @@ .widget-puppetdb-stats { .row { clear: both; padding: 10px 0 30px 0; position: relative; } .col { float: left; width: 50%; } h1 { text-transform: uppercase; font-size: 56px; font-weight: 700; color: white; } h2 { text-transform: uppercase; font-size: 48px; font-weight: 700; color: gray; } .success { color: green; } .failure { color: red; } }