module Falconz::APIs::System
Public Instance Methods
return information about configured backend nodes
Example¶ ↑
client = Falconz.client.new backend_information = client.backend # example of accessing specific information from hash puts backend_information["version"] # all the keys in the hash puts backend_information.keys # count the number of backend nodes puts backend_information["nodes"].count # you can get hell'a fancy client.backend["nodes"].map { |node| node["environments"].map { |e| [e["architecture"], e["analysis_mode"]] } }.flatten(1).uniq.each do |arch, mode| puts "The " + arch + " architecture supports " + mode + " level analysis." end
@return [Hash] all the information about the system backend www.hybrid-analysis.com/docs/api/v2#/System/get_system_backend
# File lib/falconz/apis/system.rb, line 84 def backend get_request("/system/backend") end
list available environment IDs
# File lib/falconz/apis/system.rb, line 111 def environment_ids(refresh: false) if refresh or @environment_ids.nil? @environment_ids = environments.map { |env| env["id"] } end return @environment_ids unless block_given? @environment_ids.each { |env| yield id } end
check if a given environment ID is a linux system
# File lib/falconz/apis/system.rb, line 144 def environment_linux?(id) env = find_environment_by_id(id) return nil if env.nil? return true if env["architecture"] == "LINUX" false end
check if a given environment ID is a windows system
# File lib/falconz/apis/system.rb, line 136 def environment_windows?(id) env = find_environment_by_id(id) return nil if env.nil? return true if env["architecture"] == "WINDOWS" false end
return information about available execution environments www.hybrid-analysis.com/docs/api/v2#/System/get_system_environments
# File lib/falconz/apis/system.rb, line 90 def environments return get_request("/system/environments") unless block_given? get_request("/system/environments").each do |environment| yield environment end end
return environments
# File lib/falconz/apis/system.rb, line 120 def environments_busy_percentages envs = {} environments do |env| if env["busy_virtual_machines"] == 0 || env["total_virtual_machines"] == 0 envs[env["id"]] = 0 else envs[env["id"]] = env["busy_virtual_machines"].to_f / env["total_virtual_machines"] end end return envs unless block_given? envs.each do |k, v| yield v k end end
find an environment by an ID
# File lib/falconz/apis/system.rb, line 103 def find_environment_by_id(id) id = id.to_i environments do |env| return env if env["id"] == id end end
get the in progress jobs www.hybrid-analysis.com/docs/api/v2#/System/get_system_in_progress
# File lib/falconz/apis/system.rb, line 42 def in_progress jobs = get_request("/system/in-progress")["values"].map do |job| kv = {} kv[:hash], kv[:environment] = job.split(":") kv end return jobs unless block_given? jobs.each do |job| yield job end end
number of jobs currently being processed @see in_progress
# File lib/falconz/apis/system.rb, line 56 def in_progress_count get_request("/system/in-progress")["values"].count end
return the number of environments in the system
# File lib/falconz/apis/system.rb, line 98 def number_of_environments environments.count end
check the number of seconds since last update @see system_heartbeat
# File lib/falconz/apis/system.rb, line 30 def number_of_seconds_since_last_update system_heartbeat["number_of_seconds_since_last_update"] end
return heartbeat
Example¶ ↑
client = Falconz.client.new client.system_heartbeat do |response| # do something with the response puts response.to_json end
Example without Block Syntax¶ ↑
client = Falconz.client.new response = client.system_heartbeat
www.hybrid-analysis.com/docs/api/v2#/System/get_system_heartbeat
# File lib/falconz/apis/system.rb, line 20 def system_heartbeat(wait = 15) return get_request("/system/heartbeat") unless block_given? while true yield get_request("/system/heartbeat") sleep wait end end
return information about system queue size
Example¶ ↑
client = Falconz.client.new # print the system queue size to the screen puts client.system_queue_size
www.reverse.it/docs/api/v2#/System/get_system_queue_size
# File lib/falconz/apis/system.rb, line 191 def system_queue_size @cached_queue_size = get_request("/system/queue-size")["value"] rescue => error if JSON.parse(error.message)["code"] == 429 && @cached_queue_size return @cached_queue_size end raise error end
a full system state query, including all available action scripts, environments, files in progress, etc. www.reverse.it/docs/api/v2#/System/get_system_state
# File lib/falconz/apis/system.rb, line 154 def system_state get_request("/system/state") end
return information about the instance version
Example¶ ↑
client = Falconz.client.new # get system version info, as a hash version_info = client.system_version # => {"instance"=>"8.0-5305cf9", "sandbox"=>"8.10", "api"=>"2.1.5"} # iterate over each lil'bit of information version_info.each do |name, value| puts name + " " + value end # you can also access the information directly puts "found API version " + version_info["api"]
www.reverse.it/docs/api/v2#/System/get_system_version
# File lib/falconz/apis/system.rb, line 177 def system_version get_request("/system/version") end
check the total submissions in the system www.hybrid-analysis.com/docs/api/v2#/System/get_system_total_submissions
# File lib/falconz/apis/system.rb, line 36 def total_submissions_in_system get_request("/system/total-submissions")["value"] end