Method: Zabbix::Monitor#check_uri

Defined in:
lib/zmonitor.rb

#check_uriObject



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/zmonitor.rb', line 29

def check_uri()
  uri_path = File.expand_path("~/.zmonitor-server")
  if File.exists?(uri_path)
    uri = File.open(uri_path).read()
  else
    puts "Where is your Zabbix located? (please include https/http - for example, https://localhost)"
    uri = "#{STDIN.gets.chomp()}/api_jsonrpc.php"
    f = File.new(uri_path, "w+")
    f.write(uri)
    f.close
  end
  #if uri !=~ /^https?:\/\/.*\/api_jsonrpc\.php/
    #puts "The URI we're using is invalid, sir. Resetting..."
    #check_uri()
  #end
  #puts "Okay, using #{uri}."
  raise EmptyFileError.new('URI is empty for some reason', uri_path) if uri == '' || uri.nil?
  return uri
end