NagiosEnterprises / nagioscore

Nagios Core
GNU General Public License v2.0
1.53k stars 445 forks source link

Possible reasons for Service has no hosts and/or service_description error , when its not missing. #933

Closed gsg-git closed 9 months ago

gsg-git commented 10 months ago

Hello! I am trying to use older nagios config files and the last problem the test skript has with an single service template file and its the same error if i add a name or a host group or both. I have no idea whant the problem could be. Heres the code:

define service {
    name                            passiv_service          ; The 'name' of this service template
    service_description             passiv_service-description-03112023
    active_checks_enabled           0                       ; Active service checks are enabled
    passive_checks_enabled          1                       ; Passive service checks are enabled/accepted
    parallelize_check               1                       ; Active service checks should be parallelized
    obsess_over_service             1                       ; We should obsess over this service (if necessary)
    check_freshness                 1                   ; Default is to NOT check service 'freshness'
    freshness_threshold             30
    notifications_enabled           1                       ; Service notifications are enabled
    event_handler_enabled           1                       ; Service event handler is enabled
    flap_detection_enabled          1                       ; Flap detection is enabled
#   failure_prediction_enabled      1                       ; Failure prediction is enabled                OLD SERVEICE HAD TO BE DEACTIVATED
    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              1                       ; Re-check the service up to 3 times in order to determine its final (hard) state
}

Full Error: Error: Service has no hosts and/or service_description (config file '/usr/local/nagios/gs-cfg/__passiv.cfg', starting on line 1)

Thank you for any hint!

gsg-git commented 10 months ago

I experimented a litte with the file and if i uncomment everything but the name and description and add it at the end the error is still at line 1 - whick confuses me a lot now - the error is the same when i create a new file. I use notepad++ and the codec is UTF 8

n5047c commented 10 months ago

Hello @gsg-git.

if this is service template, then there is a missing variable definition register 0.

sawolf commented 10 months ago

I agree with @n5047c, but I'll also recommend that you start a thread on our Support Forums, as there are more community members over there who will be able to help you.

gsg-git commented 9 months ago

@n5047c Thank you! Its an old template copy from Nagios core 3.0.6 we have not updated for way too long. I tried to copy the config into a newer version 4 first then the last 3 and got an error with the config which doesnt lead to ans logical sense. The script told there where an issue at a line where just old commented out entrys where - i hope this could be helpful and i con finally continue. It took me for a test to add the config files to the least nagios 3 version at least a week of fixing without progress. I think i contact the forum how i could manage in the best timeconsuming way my project.

Thank you!