Project

General

Profile

Feature #226

Return OutofSync, Error Host list from Dashboard controller as YAML

Added by Bash Shell about 9 years ago. Updated about 9 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Web Interface
Target version:
Difficulty:
Triaged:
No
Bugzilla link:
Pull request:
Team Backlog:
Fixed in Releases:
Found in Releases:

Description

It is helpful to retrieve the OutofSync Host list via YAML.

This list can be copied easily from the browser or can be retrieved via wget as input to a script.

The script can then use ssh/func/mcollective etc to login and check why the host is Out of Sync (or in Error and restart puppet if necessary)

A patch for OutofSync against "develop" is attached.

diff --git a/app/controllers/dashboard_controller.rb b/app/controllers/dashboard_controller.rb
index 3bf6384..e0e81cb 100644
--- a/app/controllers/dashboard_controller.rb
+++ b/app/controllers/dashboard_controller.rb
@@ -20,10 +20,16 @@ class DashboardController < ApplicationController
   end

   def OutOfSync
-    hosts = Host.out_of_sync.paginate(:page => params[:page], :order => 'last_report DESC')
-    render :partial => "hosts/minilist", :layout => true, :locals => {
-      :hosts => hosts,
-      :header => "Hosts which didnt run puppet in the last #{SETTINGS[:puppet_interval]} minutes" }
+    respond_to do |format|
+      format.html {
+      hosts = Host.out_of_sync.paginate(:page => params[:page], :order => 'last_report DESC')
+         render :partial => "hosts/minilist", :layout => true, :locals => {
+                :hosts => hosts,
+                :header => "Hosts which didnt run puppet in the last #{SETTINGS[:puppet_interval]} minutes" }
+      }
+      oos_list = Host.out_of_sync.each {|host| host.name<<"\n"}
+      format.yml { render :text => oos_list }
+    end
   end

   private

dashboard_oos_yaml.patch dashboard_oos_yaml.patch 1.09 KB Bash Shell, 04/28/2010 11:32 PM
dash226.patch dash226.patch 2.58 KB Bash Shell, 05/02/2010 07:05 AM

Associated revisions

Revision c030c794 (diff)
Added by Bash Shell about 9 years ago

fixes #226 - Return OutofSync, Error Host list from Dashboard controller as YAML

History

#1 Updated by Bash Shell about 9 years ago

Any suggestions on how to improve this?

#2 Updated by Ohad Levy about 9 years ago

any reason why not use the Query Interface instead?

#3 Updated by Bash Shell about 9 years ago

Heres the git diff against latest develop:

diff --git a/app/controllers/dashboard_controller.rb b/app/controllers/dashboard_controller.rb
index 4ce8041..8e9e8c8 100644
--- a/app/controllers/dashboard_controller.rb
+++ b/app/controllers/dashboard_controller.rb
@@ -22,11 +22,16 @@ class DashboardController < ApplicationController
   end

   def OutOfSync
-    @search = Host.out_of_sync.search(params[:search])
-    hosts = @search.paginate :page => params[:page]
-    render :partial => "hosts/minilist", :layout => true, :locals => {
-      :hosts => hosts,
-      :header => "Hosts which didnt run puppet in the last #{SETTINGS[:puppet_interval]} minutes" }
+    respond_to do |format|
+      format.html {
+      @search = Host.out_of_sync.search(params[:search])
+      hosts = @search.paginate :page => params[:page]
+         render :partial => "hosts/minilist", :layout => true, :locals => {
+                :hosts => hosts,
+                :header => "Hosts which didnt run puppet in the last #{SETTINGS[:puppet_interval]} minutes" }
+      }
+      format.yml { render :text => Host.out_of_sync.search(params[:search]).map(&:name).to_yaml }
+    end
   end

   private

#4 Updated by Ohad Levy about 9 years ago

  • Category set to Web Interface
  • Assignee set to Bash Shell
  • Target version set to 0.1-5

do you have the patch in github - or can you supply it via git format patch (so we keep the authorship of the patch)

additionally, I would make a small change:

    @search = Host.out_of_sync.search(params[:search])
    respond_to do |format|
      format.html {
      hosts = @search.paginate :page => params[:page]
         render :partial => "hosts/minilist", :layout => true, :locals => {
                :hosts => hosts,
                :header => "Hosts which didnt run puppet in the last #{SETTINGS[:puppet_interval]} minutes" }
      }
      format.yml { render :text => @search.map(&:name).to_yaml }
    end
  end

what about other actions? or only out of sync hosts are interesting?

#6 Updated by Bash Shell about 9 years ago

  • Status changed from New to Ready For Testing
  • % Done changed from 0 to 100

#7 Updated by Bash Shell about 9 years ago

I was thinking, that the Errors page returns Hosts with recent Reports only.

Wouldn't it be more useful to return ALL Hosts with Errors? (In both yml and html)

Same for Active.

#8 Updated by Ohad Levy about 9 years ago

  • Status changed from Ready For Testing to Closed

Also available in: Atom PDF