module Splash::ConfigUtilities
module for Configuration utilities
moudle for Configuration utilities
moudle for Configuration utilities
moudle for Configuration utilities
Public Instance Methods
clean backend configured @param [Hash] options @option options [Symbol] :name the name of the backend (:redis, :file) @return [Hash] An Exiter
case hash (:quiet_exit or :configuration_error)
# File lib/splash/config/service.rb, line 16 def addservice(options = {}) local_service_file = search_file_in_gem "prometheus-splash", "templates/splashd.service" config = get_config self.extend Splash::Loggers log = get_logger log.info "Splashd Systemd Service installation" service_file = "splashd.service" systemd_path = "/etc/systemd/system" return { :case => :options_incompatibility, :more => "Systemd not avaible on this System" } if verify_folder({ :name => systemd_path}) == [:inexistant] log.item "Installing service file : #{service_file} in #{systemd_path}" if install_file source: local_service_file, target: "#{systemd_path}/#{service_file}", mode: "755", owner: config.user_root, group: config.group_root then return { :case => :quiet_exit, :more => "Splashd Systemd service installed" } else return { :case => :error_exit, :more => "Splashd Systemd service could not be installed" } end end
Sanitycheck action method for testing installation of Splash
@param [Hash] options @return [Hash] An Exiter
case hash (:splash_sanitycheck_success or :splash_sanitycheck_error)
# File lib/splash/config/sanitycheck.rb, line 15 def checkconfig(options ={}) self.extend Splash::Loggers log = get_logger log.info "Splash -> sanitycheck : " config = get_config full_res = 0 res = verify_file(name: CONFIG_FILE, mode: "644", owner: config.user_root, group: config.group_root) target = "Config file : #{CONFIG_FILE}" if res.empty? then log.ok target else log.ko target full_res =+ 1 log.flat " pbm => #{res.map {|p| p.to_s}.join(',')}" end target = "PID Path : #{config[:pid_path]}" res = verify_folder(name: config[:pid_path], mode: "755", owner: config.user_root, group: config.group_root) if res.empty? then log.ok target else log.ko target full_res =+ 1 log.flat " pbm => #{res.map {|p| p.to_s}.join(',')}" end target = "Trace Path : #{config[:trace_path]}" res = verify_folder(name: config[:trace_path], mode: "755", owner: config.user_root, group: config.group_root) if res.empty? then log.ok target else log.ko target full_res =+ 1 log.flat " pbm => #{res.map {|p| p.to_s}.join(',')}" end target = "Prometheus PushGateway Service running" if verify_service url: config.prometheus_pushgateway_url then log.ok target else log.ko target full_res =+ 1 end if full_res > 0 then log.error "#{full_res} errors occured" return { :case => :splash_sanitycheck_error } else return { :case => :splash_sanitycheck_success} end end
clean backend action method @param [Hash] options @option options [Symbol] :name the name of the backend (:redis, :file) @return [Hash] An Exiter
case hash (:quiet_exit or :configuration_error)
# File lib/splash/config/flush.rb, line 14 def flush_backend(options ={}) config = get_config self.extend Splash::Backends self.extend Splash::Loggers log = get_logger name = (options[:name])? options[:name].to_sym : :execution_trace log.info "Splash backend #{name.to_s} flushing" backend = get_backend name if backend.flush then return { :case => :quiet_exit, :more => "Splash backend #{name.to_s} flushed" } else return { :case => :configuration_error, :more => "Splash backend #{name.to_s} can't be flushed" } end end
Setup action method for installing Splash
@param [Hash] options @option options [Symbol] :preserve flag to preserve config file during setup @return [Hash] An Exiter
case hash (:splash_setup_success or :splash_setup_error)
# File lib/splash/config/setup.rb, line 16 def setupsplash(options = {}) conf_in_path = search_file_in_gem "prometheus-splash", "config/splash.yml" full_res = 0 puts "Splash -> setup : " unless options[:preserve] then print "* Installing Configuration file : #{CONFIG_FILE} : " # TODO TTY plateform if install_file source: conf_in_path, target: CONFIG_FILE, mode: "644", owner: user_root, group: group_root then puts "[OK]" else full_res =+ 1 puts "[KO]" end else puts "Config file preservation, verify your homemade templates." end config = get_config self.extend Splash::Loggers log = get_logger log.ok "Splash Initialisation" report_in_path = search_file_in_gem "prometheus-splash", "templates/report.txt" target = "Installing template file : #{config.execution_template_path}" if install_file source: report_in_path, target: config.execution_template_path, mode: "644", owner: config.user_root, group: config.group_root then log.ok target else full_res =+ 1 log.ko target end target = "Creating/Checking pid file path : #{config[:pid_path]}" if make_folder path: config[:pid_path], mode: "755", owner: config.user_root, group: config.group_root then log.ok target else full_res =+ 1 log.ko target end target = "Creating/Checking trace file path : #{config[:trace_path]} : " if make_folder path: config[:trace_path], mode: "755", owner: config.user_root, group: config.group_root then log.ok target else full_res =+ 1 log.ko target end if full_res > 0 then log.error "#{full_res} errors occured" return { :case => :splash_setup_error} else return { :case => :splash_setup_success } end end