Module: Falconz::APIs::System
- Included in:
- Client
- Defined in:
- lib/falconz/apis/system.rb
Instance Method Summary collapse
-
#backend ⇒ Hash
return information about configured backend nodes.
-
#environment_ids(refresh: false) ⇒ Object
list available environment IDs.
-
#environment_linux?(id) ⇒ Boolean
check if a given environment ID is a linux system.
-
#environment_windows?(id) ⇒ Boolean
check if a given environment ID is a windows system.
-
#environments ⇒ Object
return information about available execution environments www.hybrid-analysis.com/docs/api/v2#/System/get_system_environments.
-
#environments_busy_percentages ⇒ Object
return environments.
-
#find_environment_by_id(id) ⇒ Object
find an environment by an ID.
-
#in_progress ⇒ Object
get the in progress jobs www.hybrid-analysis.com/docs/api/v2#/System/get_system_in_progress.
-
#in_progress_count ⇒ Object
number of jobs currently being processed.
-
#number_of_environments ⇒ Object
return the number of environments in the system.
-
#number_of_seconds_since_last_update ⇒ Object
check the number of seconds since last update.
-
#system_heartbeat(wait = 15) ⇒ Object
return heartbeat.
-
#system_queue_size ⇒ Object
(also: #queue_size)
return information about system queue size.
-
#system_state ⇒ Object
a full system state query, including all available action scripts, environments, files in progress, etc.
-
#system_version ⇒ Object
return information about the instance version.
-
#total_submissions_in_system ⇒ Object
check the total submissions in the system www.hybrid-analysis.com/docs/api/v2#/System/get_system_total_submissions.
Instance Method Details
#backend ⇒ Hash
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
www.hybrid-analysis.com/docs/api/v2#/System/get_system_backend
84 85 86 |
# File 'lib/falconz/apis/system.rb', line 84 def backend get_request("/system/backend") end |
#environment_ids(refresh: false) ⇒ Object
list available environment IDs
111 112 113 114 115 116 117 |
# 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 |
#environment_linux?(id) ⇒ Boolean
check if a given environment ID is a linux system
144 145 146 147 148 149 |
# 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 |
#environment_windows?(id) ⇒ Boolean
check if a given environment ID is a windows system
136 137 138 139 140 141 |
# 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 |
#environments ⇒ Object
return information about available execution environments www.hybrid-analysis.com/docs/api/v2#/System/get_system_environments
90 91 92 93 94 95 |
# 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 |
#environments_busy_percentages ⇒ Object
return environments
120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# 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_environment_by_id(id) ⇒ Object
find an environment by an ID
103 104 105 106 107 108 |
# 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 |
#in_progress ⇒ Object
get the in progress jobs www.hybrid-analysis.com/docs/api/v2#/System/get_system_in_progress
42 43 44 45 46 47 48 49 50 51 52 |
# 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 |
#in_progress_count ⇒ Object
number of jobs currently being processed
56 57 58 |
# File 'lib/falconz/apis/system.rb', line 56 def in_progress_count get_request("/system/in-progress")["values"].count end |
#number_of_environments ⇒ Object
return the number of environments in the system
98 99 100 |
# File 'lib/falconz/apis/system.rb', line 98 def number_of_environments environments.count end |
#number_of_seconds_since_last_update ⇒ Object
check the number of seconds since last update
30 31 32 |
# File 'lib/falconz/apis/system.rb', line 30 def number_of_seconds_since_last_update system_heartbeat["number_of_seconds_since_last_update"] end |
#system_heartbeat(wait = 15) ⇒ Object
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
20 21 22 23 24 25 26 |
# 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 |
#system_queue_size ⇒ Object Also known as: queue_size
return information about system queue size
Example
client = Falconz.client.new
# print the system queue size to the screen
puts client.system_queue_size
191 192 193 194 195 196 197 198 |
# 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.)["code"] == 429 && @cached_queue_size return @cached_queue_size end raise error end |
#system_state ⇒ Object
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
154 155 156 |
# File 'lib/falconz/apis/system.rb', line 154 def system_state get_request("/system/state") end |
#system_version ⇒ Object
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"]
177 178 179 |
# File 'lib/falconz/apis/system.rb', line 177 def system_version get_request("/system/version") end |
#total_submissions_in_system ⇒ Object
check the total submissions in the system www.hybrid-analysis.com/docs/api/v2#/System/get_system_total_submissions
36 37 38 |
# File 'lib/falconz/apis/system.rb', line 36 def total_submissions_in_system get_request("/system/total-submissions")["value"] end |