Module: ZabbixRubyClient::PluginBase
- Extended by:
- PluginBase
- Included in:
- PluginBase, ZabbixRubyClient::Plugins::Cpu, ZabbixRubyClient::Plugins::Disk, ZabbixRubyClient::Plugins::Load, ZabbixRubyClient::Plugins::Memory, ZabbixRubyClient::Plugins::Network, ZabbixRubyClient::Plugins::Nginx, ZabbixRubyClient::Plugins::Ovpn, ZabbixRubyClient::Plugins::Rabbitmq
- Defined in:
- lib/zabbix-ruby-client/plugin_base.rb
Instance Method Summary collapse
- #getline(file, pattern = false) ⇒ Object
- #getlines(file, pattern = false) ⇒ Object
- #httprequest(url) ⇒ Object
- #perform(command) ⇒ Object
Instance Method Details
permalink #getline(file, pattern = false) ⇒ Object
[View source]
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/zabbix-ruby-client/plugin_base.rb', line 13 def getline(file, pattern=false) if File.readable? file File.open(file,'r') do |f| f.each do |l| line = l.strip if pattern if Regexp.new(pattern).match line Log.debug "File #{file}: #{line}" return line end else return line end end end Log.warn "File #{file}: pattern \"#{pattern}\" not found." false else if File.file? file Log.error "File not readable: #{file}" else Log.error "File not found: #{file}" end false end end |
permalink #getlines(file, pattern = false) ⇒ Object
[View source]
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/zabbix-ruby-client/plugin_base.rb', line 40 def getlines(file, pattern=false) lines = [] if File.readable? file File.open(file,'r') do |f| f.each do |l| line = l.strip if pattern if Regexp.new(pattern).match line Log.debug "File #{file}: #{line}" lines << line end else lines << line end end end Log.warn "File #{file}: pattern \"#{pattern}\" not found." unless lines.count > 0 lines else if File.file? file Log.error "File not readable: #{file}" else Log.error "File not found: #{file}" end false end end |
permalink #httprequest(url) ⇒ Object
[View source]
7 8 |
# File 'lib/zabbix-ruby-client/plugin_base.rb', line 7 def httprequest(url) end |
permalink #perform(command) ⇒ Object
[View source]
10 11 |
# File 'lib/zabbix-ruby-client/plugin_base.rb', line 10 def perform(command) end |