Page 1 of 2

[Solved] Service has no hosts and/or service_description

Posted: Wed May 14, 2014 5:25 pm
by jbruyet
Hey all, I'm in the process of moving my Nagios server from FreeBSD to CentOS and I've just hit a snag; I see that Nagios doesn't like the configuration of my templates.cfg file:

Code: Select all

Reading configuration data...
   Read main config file okay...
Error: Service has no hosts and/or service_description (config file '/usr/local/nagios/etc/objects/templates.cfg', starting on line 21)
   Error processing object config files!
All I did was copy templates.cfg over to my CentOS server. Here's the offending section starting at line 21:

Code: Select all

define service{
    name                            generic-service
    active_checks_enabled           1
    passive_checks_enabled          1
    parallelize_check               1
    obsess_over_service             1
    check_freshness                 0
    notifications_enabled           1
    event_handler_enabled           1
    flap_detection_enabled          1
    failure_prediction_enabled      1
    process_perf_data               1
    retain_status_information       1
    retain_nonstatus_information    1
    is_volatile                     0
    check_period                    24x7
    max_check_attempts              3
    normal_check_interval           10
    retry_check_interval            2
    contact_groups                  MailContacts
    notification_options            w,u,c,r
    notification_interval           60
    notification_period             24x7
    register                        1
    }
Can anyone see anything wrong with this file? I thought maybe it was configured but unused but all of my other config files like Win7.cfg and BE.cfg and WinServer.cfg all have the generic-service string in them:

Code: Select all

define service {
        use                     generic-service
        hostgroup               BackupExec
        service_description     Backup Exec Server
        check_command           check_nrpe!CheckServiceState -a ShowAll "Backup Exec Server"
}
Any ideas? Could a part of the problem be because I just jumped from 3.3.1 to 4.0.6?

Thanks,

Joe B

Re: Service has no hosts and/or service_description

Posted: Thu May 15, 2014 4:53 am
by kimjaggi
Hi Joe,

You might have to define host as well in templates for example If I want to monitor Switch -

In Template.cfg I should have : ""define host and define service""

Code: Select all

# Define a template for switches that we can reuse
define host{
        name                    generic-switch  ; The name of this host template
        use                     generic-host    ; Inherit default values from the generic-host template
        check_period            24x7            ; By default, switches are monitored round the clock
        check_interval          5               ; Switches are checked every 5 minutes
        retry_interval          1               ; Schedule host check retries at 1 minute intervals
        max_check_attempts      10              ; Check each switch 10 times (max)
        check_command           check-host-alive        ; Default command to check if routers are "alive"
        notification_period     24x7            ; Send notifications at any time
        notification_interval   30              ; Resend notifications every 30 minutes
        notification_options    d,r             ; Only send notifications for specific host states
        contact_groups          admins          ; Notifications get sent to the admins by default
        register                0               ; DONT REGISTER THIS - ITS JUST A TEMPLATE
        }

Code: Select all

# Generic service definition template - This is NOT a real service, just a template!

define service{
        name                            generic-service         ; The 'name' of this service template
        active_checks_enabled           1                       ; Active service checks are enabled
        passive_checks_enabled          1                       ; Passive service checks are enabled/accepted
        parallelize_check               1                       ; Active service checks should be parallelized (disabling this can lead to major performance problems)
        obsess_over_service             1                       ; We should obsess over this service (if necessary)
        check_freshness                 0                       ; Default is to NOT check service 'freshness'
        notifications_enabled           1                       ; Service notifications are enabled
        event_handler_enabled           1                       ; Service event handler is enabled
        flap_detection_enabled          1                       ; Flap detection is enabled
        process_perf_data               1                       ; Process performance data
        retain_status_information       1                       ; Retain status information across program restarts
        retain_nonstatus_information    1                       ; Retain non-status information across program restarts
        is_volatile                     0                       ; The service is not volatile
        check_period                    24x7                    ; The service can be checked at any time of the day
        max_check_attempts              3                       ; Re-check the service up to 3 times in order to determine its final (hard) state
        normal_check_interval           10                      ; Check the service every 10 minutes under normal conditions
        retry_check_interval            2                       ; Re-check the service every two minutes until a hard state can be determined
        contact_groups                  admins                  ; Notifications get sent out to everyone in the 'admins' group
        notification_options            w,u,c,r                 ; Send notifications about warning, unknown, critical, and recovery events
        notification_interval           60                      ; Re-notify about service problems every hour
        notification_period             24x7                    ; Notifications can be sent out at any time
         register                        0                      ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL SERVICE, JUST A TEMPLATE!
        }
and switch.cfg should have:

# Define the switch that we'll be monitoring

Code: Select all

define host{
        use             generic-switch           ; Inherit default values from a template
        host_name       HOST1                ; The name we're giving to this switch
        alias           Stack Serverroom         ; A longer name associated with the switch
        address         10.10.10.1               ; IP address of the switch
        hostgroups      switches
        }
# Create a new hostgroup for switches

Code: Select all

define hostgroup{
        hostgroup_name  switches                ; The name of the hostgroup
        alias           Network Switches        ; Long name of the group
        }
# Monitor uptime via SNMP

define service{

Code: Select all

        use                     generic-service ; Inherit values from a template
        host_name                   HOST1
        service_description      Uptime
        check_command           check_snmp!-C public -o sysUpTime.0
        }

Re: Service has no hosts and/or service_description

Posted: Thu May 15, 2014 9:38 am
by jbruyet
Hi kimjaggi, I haven't had to do that before in my other Nagios servers. Is this something new in 4.0.6? As I mentioned in my post all I'm doing is moving my files over from my FreeBSD server, and that server is still up and running. I know there will be some required tweaks but I was thinking more along the lines of path statements and such.

Thanks,

Joe B

Re: Service has no hosts and/or service_description

Posted: Thu May 15, 2014 9:46 am
by tmcdonald
Is there a reason you have that template set as "register 1"? Usually that should be 0 for a template and 1 for an actual object.

Re: Service has no hosts and/or service_description

Posted: Thu May 15, 2014 2:32 pm
by jbruyet
Hi tmcdonald, I just double-checked and that's the way I had it set up on my FreeBSD server. I have sections labeled Switches, Printers, Contacts, etc. I thought that 1 meant that it's active and 0 meant that Nagios will ignore it. I put these labels in the "use" section of my host definitions in my different .cfg files: Win7.cfg, WinServer.cfg, printer.cfg, Navitrans.cfg, etc. Am I doing something inherently wrong and just been getting away with it?

Thanks,

Joe B

Re: Service has no hosts and/or service_description

Posted: Thu May 15, 2014 2:37 pm
by tmcdonald
register 0 means Nagios will ignore it, yes, and register 1 means Nagios will check it. However if you make a template with register 1, it will have some missing fields. I think you were just getting away with it. Templates should always be register 0.

Re: Service has no hosts and/or service_description

Posted: Mon May 19, 2014 2:32 pm
by jbruyet
Hi tmcdonald, I've redone my configs and ran my check and it looks good:

Code: Select all

Checking misc settings...

Total Warnings: 9
Total Errors:   0

Things look okay - No serious problems were detected during the pre-flight check
The nine warnings are due to "...no default contacts...defined!"

NRPE appears to be working:

Code: Select all

[root@FreeNag objects]# /usr/local/nagios/libexec/check_nrpe -H 192.168.3.26
I (0.3.9.327 2011-08-16) seem to be doing fine...
BUT, my checks are getting the following errors:

Code: Select all

CHECK_NRPE: Error receiving data from daemon. 
Do you think the problem is with my Nagios server configs or with the NSClient on my servers?

Thanks,

Joe B

----------

Ok, I just found some check_nrpe2 command definitions in commands.cfg. They now read check_ nrpe and two of the three definitions have been commented out. I restarted Nagios and now I'm going to have some lunch and see if this problem won't take care of itself.

Thanks,

Joe B

Re: Service has no hosts and/or service_description

Posted: Mon May 19, 2014 3:23 pm
by jbruyet
Well ok then. I'm only checking my file servers and we're all green except for my snmp checks. Here's my service definition for uptime:

Code: Select all

define service {
        use                     generic-service
        hostgroup               Winserver_nrpegroup, DC_group
        service_description     System Uptime
        check_command           check_snmp!-C public -o 1.3.6.1.2.1.1.3.0
        contact_groups          PhoneContacts
        }
I know that's the correct OID because:

Code: Select all

[root@FreeNag objects]# snmpget -v 2c -c public 192.168.2.82 1.3.6.1.2.1.1.3.0
DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (303401) 0:50:34.01
And check_snmp is in my commands.cfg file:

Code: Select all

define command{
        command_name    check_snmp
        command_line    $USER1$/check_snmp -H $HOSTADDRESS$ $ARG1$
        }
I've been Googling this but everything I see is for other issues.

Thanks,

Joe B

Re: Service has no hosts and/or service_description

Posted: Tue May 20, 2014 9:45 am
by tmcdonald
What Status Information is displayed if you click the snmp service name?

Re: Service has no hosts and/or service_description

Posted: Tue May 20, 2014 11:27 am
by jbruyet
Hi tmcdonald, that was an excellent call. Here's the Status Information:

Code: Select all

Status Information:	(No output on stdout) stderr: execvp(/usr/local/nagios/libexec/check_snmp, ...) failed. errno is 2: No such file or directory
I checked under libexec and I see I'm missing the check_snmp command. I was under the impression that it was a part of the basic Nagios install. So, I'll go hit Google again and see how to get it installed.

Thanks,

Joe B