Last updated at Wed, 27 Sep 2017 14:19:43 GMT

Here's a walk-through of a Ruby script that uses the nexpose gem to add and configure your Nexpose Scan Engines.

This script configures the Dynamic Scan Pool feature. A Scan Engine pool is a group of shared Scan Engines that can be bound to a site so that the load is distributed evenly across the shared engines. The feature can only be managed through the API.

You'll need familiarity with Ruby to understand the script. I've inserted explanations as comments (marked in blue) in the code below. Values that you'll need to modify for your specific environment are in green. Please note that pairing of engines must still be done manually.

#!/usr/bin/env ruby
require 'rubygems'
require 'nexpose'
include Nexpose
require 'pp'

Wrap the call to catch exceptions.


Create a connection to the Nexpose instance and log in.

  @nsc ='', 'nxadmin', 'supersecret', 3780)


Adds a new Cleveland Engine.

This is only necessary if the engine does not already exist.

  engine =
  engine.address = '' = 'Cleveland Engine'

Define the pool. Can be instantiated with just a name.

  pool ='Midwest Pool')

Add engines to the pool by name.

  pool.add('Cleveland Engine')

OK to add already existing engines.

  pool.add('Chicago Engine')

Then create the pool on the server with our new configuration.


Get a listing of all engine pools now on the server.

  list = EnginePoolSummary.listing(@nsc)

  list.each do |summary|

Print out the existing pools to the screen.

    puts summary


This overwrites our pool variable with what's returned.

    pool =,, summary.scope)

Load in the details from the server.

This pulls the configuration into our pool variable.


Print out the configuration to the screen.

  puts 'Pool loaded from server:'

  puts pool


Adds new St Louis Engine.

  engine =

  engine.address = '' = 'St Louis Engine'

Now update the pool to include the new engine.

  pool.add('St Louis Engine')


Reload the details from the server


  puts pool


Know what? I've changed my mind. Delete the pool.

This only works if you have the ID of the pool correctly set, done in the load_details call above.


rescue ::Nexpose::APIError => e

  $stderr.puts("Connection failed: #{e.reason}")