Page 1 of 1

Windows.cfg query

Posted: Wed Aug 12, 2015 3:24 am
by neworderfac33
Good morning,

In my windows,cfg, I have the following:

Code: Select all

define host{
        use             windows-server
        host_name       MYFIRSTHOSTNAME
        alias           Dev-Jenkins
        address         88.88.88.88
        hostgroups      windows-servers
}

define host{
        use             windows-server
        host_name       MYSECONDHOSTNAME
        alias           UAT-Jenkins
        address         99.99.99.99
        hostgroups      windows-servers
        }

define hostgroup{
        hostgroup_name  windows-servers
        alias           Jenkins Test Servers
}
I also have services defined as follows, which work correctly, providing information to the web interface and generating email alerts for both servers
Note that host_name is commented out.

Code: Select all

        define service{
        use                     generic-service
        #host_name               MYFIRSTHOSTNAME, MYSECONDHOSTNAME
        hostgroup_name          windows-servers
        service_description     Application - NSClient++
        check_command           check_nt!CLIENTVERSION
        }
If however, I uncomment host_name and comment hostgroup_name thus:

Code: Select all

define service{
        use                     generic-service
        host_name               MYFIRSTHOSTNAME, MYSECONDHOSTNAME
        #hostgroup_name          windows-servers
        service_description     Application - NSClient++
        check_command           check_nt!CLIENTVERSION
        }
when I attempt to verify, I get the following:

Reading configuration data...
Read main config file okay...
Error: Could not find any host matching 'MYSECONDHOSTNAME' (config file '/usr/local/nagios/etc/objects/windows.cfg', starting on line 32)
Error: Failed to expand host list 'MYFIRSTHOSTNAME' for service 'Application - NSClient++' (/usr/local/nagios/etc/objects/windows.cfg:32)
Error processing object config files!

As the hostnames work correctly when they're part of a hostgroup_name, why won't they work when specfied as host_name?

Thanks in advance for your assistance.

Pete

Re: Windows.cfg query

Posted: Wed Aug 12, 2015 7:01 am
by neworderfac33
Issue solved - it seems I must have had some rogue hidden characters separating "host_name" from the actual serverIDs.
Once i removed the lines and re-entered them manually, the verify ran OK.
I suspect I may have copied the services in from a document in Windows somewhere.
To anyone who DID take a look, thank you for your interest.

This thread can now be closed.

Pete

Re: Windows.cfg query

Posted: Wed Aug 12, 2015 9:34 am
by tmcdonald
For the record, this is likely what happened:

http://stackoverflow.com/questions/1250 ... -unix-usin

Personally I go the dos2unix route (you may have to yum install it, or whatever package manager you use). And the example in the article is weird - you do not type > before the command, that is just the command prompt they use.