Feature #226
closedReturn OutofSync, Error Host list from Dashboard controller as YAML
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
Files
Updated by Ohad Levy over 14 years ago
any reason why not use the Query Interface instead?
Updated by Bash Shell over 14 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
Updated by Ohad Levy over 14 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?
Updated by Bash Shell over 14 years ago
- Status changed from New to Ready For Testing
- % Done changed from 0 to 100
Applied in changeset c030c794276e8d14b139b0710cb6ac1b5e167bb6.
Updated by Bash Shell over 14 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.
Updated by Ohad Levy over 14 years ago
- Status changed from Ready For Testing to Closed