mirror of
https://github.com/fluent/fluentd-ui.git
synced 2025-08-13 09:47:07 +02:00
Re-order methods
This commit is contained in:
parent
098f00b48d
commit
e82e81e234
@ -30,28 +30,6 @@ class Fluentd
|
|||||||
@extra_options = options
|
@extra_options = options
|
||||||
end
|
end
|
||||||
|
|
||||||
def errors_since(since = 1.day.ago)
|
|
||||||
errors = []
|
|
||||||
logged_errors do |error|
|
|
||||||
break if Time.parse(error[:subject]) < since
|
|
||||||
errors << error
|
|
||||||
end
|
|
||||||
errors
|
|
||||||
end
|
|
||||||
|
|
||||||
def recent_errors(limit = 3)
|
|
||||||
errors = []
|
|
||||||
logged_errors do |error|
|
|
||||||
errors << error
|
|
||||||
break if errors.length >= limit
|
|
||||||
end
|
|
||||||
errors
|
|
||||||
end
|
|
||||||
|
|
||||||
def last_error_message
|
|
||||||
recent_errors(1).first.try(:[], :subject) || ""
|
|
||||||
end
|
|
||||||
|
|
||||||
def pid_file
|
def pid_file
|
||||||
extra_options[:pid_file] || self.class.default_options[:pid_file]
|
extra_options[:pid_file] || self.class.default_options[:pid_file]
|
||||||
end
|
end
|
||||||
@ -89,11 +67,61 @@ class Fluentd
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def dryrun(file_path = nil)
|
||||||
|
dryrun!(file_path)
|
||||||
|
true
|
||||||
|
rescue ::Fluentd::Agent::ConfigError
|
||||||
|
false
|
||||||
|
end
|
||||||
|
|
||||||
|
def errors_since(since = 1.day.ago)
|
||||||
|
errors = []
|
||||||
|
logged_errors do |error|
|
||||||
|
break if Time.parse(error[:subject]) < since
|
||||||
|
errors << error
|
||||||
|
end
|
||||||
|
errors
|
||||||
|
end
|
||||||
|
|
||||||
|
def recent_errors(limit = 3)
|
||||||
|
errors = []
|
||||||
|
logged_errors do |error|
|
||||||
|
errors << error
|
||||||
|
break if errors.length >= limit
|
||||||
|
end
|
||||||
|
errors
|
||||||
|
end
|
||||||
|
|
||||||
|
def last_error_message
|
||||||
|
recent_errors(1).first.try(:[], :subject) || ""
|
||||||
|
end
|
||||||
|
|
||||||
def log
|
def log
|
||||||
return "" unless File.exists?(log_file)
|
return "" unless File.exists?(log_file)
|
||||||
File.read(log_file) # TODO: large log file
|
File.read(log_file) # TODO: large log file
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def log_tail(limit = nil)
|
||||||
|
return [] unless File.exists?(log_file)
|
||||||
|
|
||||||
|
limit = limit.to_i rescue 0
|
||||||
|
limit = limit.zero? ? Settings.default_log_tail_count : limit
|
||||||
|
io = File.open(log_file)
|
||||||
|
buf = []
|
||||||
|
reader = ::FileReverseReader.new(io)
|
||||||
|
reader.each_line do |line|
|
||||||
|
buf << line
|
||||||
|
break if buf.length >= limit
|
||||||
|
end
|
||||||
|
buf
|
||||||
|
end
|
||||||
|
|
||||||
|
def pid
|
||||||
|
return unless File.exists?(pid_file)
|
||||||
|
return if File.zero?(pid_file)
|
||||||
|
File.read(pid_file).to_i rescue nil
|
||||||
|
end
|
||||||
|
|
||||||
def config
|
def config
|
||||||
File.read(config_file)
|
File.read(config_file)
|
||||||
end
|
end
|
||||||
@ -113,33 +141,12 @@ class Fluentd
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def log_tail(limit = nil)
|
|
||||||
return [] unless File.exists?(log_file)
|
|
||||||
|
|
||||||
limit = limit.to_i rescue 0
|
|
||||||
limit = limit.zero? ? Settings.default_log_tail_count : limit
|
|
||||||
io = File.open(log_file)
|
|
||||||
buf = []
|
|
||||||
reader = ::FileReverseReader.new(io)
|
|
||||||
reader.each_line do |line|
|
|
||||||
buf << line
|
|
||||||
break if buf.length >= limit
|
|
||||||
end
|
|
||||||
buf
|
|
||||||
end
|
|
||||||
|
|
||||||
def configuration
|
def configuration
|
||||||
if File.exists? config_file
|
if File.exists? config_file
|
||||||
::Fluentd::Agent::Configuration.new(config_file)
|
::Fluentd::Agent::Configuration.new(config_file)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def pid
|
|
||||||
return unless File.exists?(pid_file)
|
|
||||||
return if File.zero?(pid_file)
|
|
||||||
File.read(pid_file).to_i rescue nil
|
|
||||||
end
|
|
||||||
|
|
||||||
def backup_files
|
def backup_files
|
||||||
Dir.glob(File.join("#{config_backup_dir}", "*.conf"))
|
Dir.glob(File.join("#{config_backup_dir}", "*.conf"))
|
||||||
end
|
end
|
||||||
@ -152,13 +159,6 @@ class Fluentd
|
|||||||
backup_files_in_old_order.reverse
|
backup_files_in_old_order.reverse
|
||||||
end
|
end
|
||||||
|
|
||||||
def dryrun(file_path = nil)
|
|
||||||
dryrun!(file_path)
|
|
||||||
true
|
|
||||||
rescue ::Fluentd::Agent::ConfigError
|
|
||||||
false
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def backup_running_config
|
def backup_running_config
|
||||||
|
Loading…
Reference in New Issue
Block a user