Skip to content

Nmon Configuration for Server Monitoring

Sayantam Dey edited this page Aug 29, 2017 · 1 revision

Introduction

Monitoring performance of hosts (or any machine in the infrastructure) is another feature of Hailstorm. At the moment, only Nmon is supported and Hailstorm periodically collects CPU, Memory and Swap usage during the test run to correlate performance of servers with load tests.

Setup Nmon on Servers

Nmon is available for a wide variety of UNIX hosts and reports resource usage. If your targets are using Linux you can download Nmon for Linux and place it on the targets. 💡 If you have multiple targets, it is recommended to install the nmon utility at same path on all targets to simplify configuration.

You will also need to have SSH access to all the targets and need to setup public-key based SSH authentication. Once you have created the pairs, place the private key files in the project config directory. The private keys must have an extension .pem. If you have multiple targets, it is recommended to create a key-pair on one target and use the same key-pair on the other targets. That way you need only one private file to communicate with your targets.

Hailstorm configuration

If there is only one host to be monitored, the simplest configuration is:

Hailstorm.application.config do |config|
  # Target configuration
  config.monitors(:nmon) do |monitor|
    monitor.executable_path   = '/usr/bin/nmon'
    monitor.ssh_identity      = 'keecho'
    monitor.user_name         = 'jagga'
    monitor.sampling_interval = 5

    monitor.groups('Application Server') do |group|
      group.hosts('s01.hailstorm.com') # don't forget to put the host name in quotes!
    end
  end
end

The configuration for targets is done using the monitors property. Each monitor implements Nmon as a monitoring strategy. Within a monitor, you can define one or more groups. Each group has a role and one or more hosts (targets). Thus a monitor has many targets through groups.

Monitor properties

A monitor exposes the following properties:

  • executable_path: Path to nmon executable on targets.
  • ssh_identity: Name of SSH identity file. File must be present in project config directory
  • user_name: User name to access the target (via SSH)
  • sampling_interval: Interval (specified in seconds) between successive samplings, default is 10 seconds
  • active: If unspecified, a monitor is active by default. Set this to false to exclude hosts from performance metric collection

In addition, the monitor exposes a collection of groups.

Group properties

A group only exposes a single property role. The objective of a group is to group together different hosts performing the same function. A group exposes a collection of hosts.

Target properties

A target exposes the same properties as a monitor. Thus it is possible to override monitor level settings at a target level.

Complete example

config.monitors(:nmon) do |monitor|
  # default settings
  monitor.active            = true # if false, all hosts in this block will be ignored
  monitor.executable_path   = '/usr/bin/nmon'
  monitor.ssh_identity      = 'peen'
  monitor.user_name         = 'naani'
  monitor.sampling_interval = 5

  monitor.groups do |group|
    group.role = 'Web Server' # all web-servers go to this group
    group.hosts do |host|
      host.host_name = 'web01.example.com'
      host.executable_path = '/usr/local/bin/nmon' # overrides default setting for executable_path
      host.user_name = 'webmin' # overrides default setting for user_name
      host.sampling_interval = 10 # overrides default setting for sampling_interval
      host.active = false # disables target monitoring for this specific host
    end

    # add multiple hosts by separating them with a comma, don't forget to put each host within quotes!
    # the monitor settings apply to these hosts
    group.hosts('web02.example.com', 'web03.example.com')
  end

  monitor.groups do |group|
    group.role = 'Database' # another group for databases with host_name and user_name override
    group.hosts do |host|
      host.host_name = 'db01.example.com'
      host.user_name = 'dbmin'
    end
  end

  monitor.groups do |group|
    group.role = 'Message Queue' # another group for message queues with monitor settings
    group.hosts('queue01.example.com')
  end
end

# You can set up multiple monitor blocks, everything would be aggregated.
config.monitors(:nmon) do |monitor|
  monitor.executable_path   = '/usr/bin/nmon'
  monitor.ssh_identity      = 'papi'
  monitor.user_name         = 'elsa'
  monitor.sampling_interval = 5

  monitor.groups('Application Server') do |group|
    group.hosts('s01.hailstorm.com')
  end
end