AnsweredAssumed Answered

Issues with Ruby Client and listing discovery connections

Question asked by pavedian on Jul 17, 2017
Latest reply on Jul 18, 2017 by pavedian
require 'yaml'
require 'nexpose'
require 'optparse'
include Nexpose
require 'text-table'
table = Text::Table.new
table.head = ['ID','NAME','ENGINE-ID','SOURCE','STATUS']
config_path = File.expand_path("nexpose.yaml", __FILE__)
config = YAML.load_file(config_path)
@host = config["hostname"]
@userid = config["username"]
@password = config["passwordkey"]
@port = config["port"]
nsc = Nexpose::Connection.new(@host, @userid, @password, @port)
begin
    nsc.login
    rescue ::Nexpose::APIError => err
    $stderr.puts("#{Time.now.strftime("%m/%d/%Y %H:%M:%S")}\tConnection failed: #{err.reason}")
    exit(1)
end
at_exit { nsc.logout }
discoveryc = nsc.list_discovery_connections()
discoveryc.each do |discovery|
table.rows << [discovery.id,discovery.name,discovery.engine_id,discovery.event_source,discovery.status]
end
puts table

 

Does anyone have an experience using list_discovery_connections?  I'm working on a script to alert me when a discovery connection has the status of disconnected.  It looks like 'engine_id' returns no value when using the ruby client.  When I use powershell with the API, I am able to return the engine_id properly.

 

Is it my script or the client?

 

Here is my output.

 

+----+------------+-----------+--------+-----------+
| ID |    NAME    | ENGINE-ID | SOURCE |  STATUS   |
+----+------------+-----------+--------+-----------+
| 86 | engine name |           |        | Connected |
| 68 | engine name |           |        | Connected |
| 56 | engine name |           |        | Connected |
| 67 | engine name |           |        | Connected |
| 66 | engine name |           |        | Connected |
| 65 | engine name |           |        | Connected |
| 80 | engine name |           |        | Connected |
| 79 | engine name |           |        | Connected |
| 64 | engine name |           |        | Connected |
| 82 | engine name |           |        | Connected |
| 90 | engine name |           |        | Connected |
| 91 | engine name |           |        | Connected |
| 63 | engine name |           |        | Connected |
| 88 | engine name |           |        | Connected |
| 61 | engine name |           |        | Connected |
| 51 | engine name |           |        | Connected |
| 60 | engine name |           |        | Connected |
| 83 | engine name |           |        | Connected |
| 54 | engine name |           |        | Connected |
| 89 | engine name |           |        | Connected |
| 85 | engine name |           |        | Connected |
| 87 | engine name |           |        | Connected |
| 48 | engine name |           |        | Connected |
| 47 | engine name |           |        | Connected |
| 77 | engine name |           |        | Connected |
| 58 | engine name |           |        | Connected |
| 57 | engine name |           |        | Connected |
| 1  | engine name |           |        | Connected |
+----+------------+-----------+--------+-----------+

Outcomes