Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to create a nagios_hostgroup if some hosts exists. For creating hosts in nagios I am using exported resources which I collect on the monitoring server.

How can I test that a exported nagios_host resource exists? I tried the following:

Nagios_host <<| |>>

if defined(Nagios_host['host_1']) and defined(Nagios_host['host_2']) {
  nagios_hostgroup { 'database_servers':
    alias   => 'My Hostgroup',
    members => 'host_1,host_2',

Any idea?

share|improve this question

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.