Ravn::Tactical::ServiceV1::

Diagnostics module

:nocov:

Public Class Methods

included( app )

Add mission-related routes to the given app.

   # File lib/ravn/tactical/service_v1/diagnostics.rb
19 def self::included( app )
20     super
21 
22     self.log.info "Mounting diagnostic endpoints."
23     self.mount( app )
24 end
mount( app )

Mount diagnostic endpoints in the given app.

   # File lib/ravn/tactical/service_v1/diagnostics.rb
28 def self::mount( app )
29     app.hash_branch( :v1, 'diagnostics' ) do |r|
30 
31         # /api/v1/diagnostics
32         r.is do
33 
34             r.get( &self.method(:get_diagnostics) )
35 
36         end
37 
38     end
39 end

Public Instance Methods

get_diagnostics()

Fetch compute pack diagnostics.

   # File lib/ravn/tactical/service_v1/diagnostics.rb
43 def get_diagnostics
44     data = {}
45 
46     data[:checklist] = self.get_diagnostics_checklist
47     data[:versions] = self.get_version_diagnostics
48     data[:missions] = self.get_mission_stats
49     data[:nodes] = self.get_node_stats
50 
51     return data
52 end
get_diagnostics_checklist()

Return a Hash of various checks run on the compute pack and their status.

   # File lib/ravn/tactical/service_v1/diagnostics.rb
56 def get_diagnostics_checklist
57     return {
58         bde_running: Ravn::Tactical::Diagnostics.bde_running?,
59         executor_running: Ravn::Tactical::Diagnostics.executor_running?,
60         broker_interface: Ravn::Tactical::Diagnostics.broker_interface_exists?,
61     }
62 end
get_mission_stats()

Return an overview of missions on the compute pack.

   # File lib/ravn/tactical/service_v1/diagnostics.rb
76 def get_mission_stats
77     missions = Ravn::Tactical::Mission.all
78 
79     return {
80         count: missions.size,
81         names: missions.map( &:name ),
82         current: Ravn::BDE.mission_config_path.basename('.yml'),
83     }
84 end
get_node_stats()

Return a table of information about the node.

   # File lib/ravn/tactical/service_v1/diagnostics.rb
88 def get_node_stats
89     return {
90         count: Ravn::Tactical::Node.undeleted.count,
91         is_control: Ravn::Tactical.is_control_node?,
92         is_set_up: Ravn::Tactical.is_set_up?,
93     }
94 end
get_version_diagnostics()

Return a Hash of software versions

   # File lib/ravn/tactical/service_v1/diagnostics.rb
66 def get_version_diagnostics
67     return {
68         ravn: Ravn::VERSION,
69         ravn_bde: Ravn::BDE::VERSION,
70         ravn_tactical: Ravn::Tactical::VERSION,
71     }
72 end