Skip to content

Host and service check specific timeouts#525

Merged
sni merged 8 commits intonaemon:masterfrom
inqrphl:host-and-service-check-specific-timeouts
Feb 28, 2026
Merged

Host and service check specific timeouts#525
sni merged 8 commits intonaemon:masterfrom
inqrphl:host-and-service-check-specific-timeouts

Conversation

@inqrphl
Copy link
Copy Markdown

@inqrphl inqrphl commented Feb 25, 2026

This PR adds timeout overrides to host/service checks.

Previously, host and service checks each used a global timeout. Users could not change this timeout per host or (more likely) per service. The defaults were 30 seconds for host timeouts and 60 seconds for service timeouts.

Add a field to host/service definitions named 'check_timeout' , which is used as an override.

src/naemon/xodtemplate.h/c

add field 'check_timeout' & 'have_check_timeout' to xodtemplate_host_struct & xodtemplate_service_struct

xodtemplate_begin_object_definition is used to construct the template , set check_timeout to the global host/service timeout values by default.

src/naemon/objects_service.h/c and object_host

add field 'check_timeout' to the service definition, and add the accompanying 'has_check_timeout' that other fields have. Do not exactly understand what it is for, and do not access it in the rest of the PR.

print 'check_timeout' on the fcache_service/host as well

src/naemon/checks.h

add field 'timeout' to the check_result. This is not necessarily needed for logic, but I think that is a good addition for two reasons:

  • First, it already has a flag 'early_timeout' that will be set if the check timed out. update_host_state_post_check function checks if it timed out, but not with which value.

  • Second, the timeout used might have custom values now. It does not necessarily have to be either of the two global values: service_check_timeout / host_check_timeout. It can be directly saved as a value, taken from a template or a macro etc.

check_result is used in handle_async(host|service)_check_result functions for the broker_(host|service)_check functions, directly getting the saved timeout from check_result might be useful for some use cases. Maybe thruk can use it somehow? @sni

src/naemon/check_host / service

on the run_async_(host|service)_check instead of using the global values, just use the check_timeout from the service/host check now. Does not matter if it was unchanged or not after it was initialized with the global value.

there is also a check_for_orphaned_hosts handler, where the timeout has to be determined again during iteration of all hosts.

src/naemon/commands.c > service_command_handler

no changes here. not registering any commands here to change check_timeout dynamically.

src/naemon/xrddefault.c > xrddefault_read_state_information

no changes here either. this is responsible for printing modified attributes, and we do not modify check_timeout during runtime with a service command

For maintainers:

  • Update information in the naemon docs, if required I can also do that. https://github.com/naemon/naemon.github.io
  • Overriding the default value is an optional functionality and the default behavior does not change. But there might be users who put check_timeout in host/service definitions, and they will be effected accidentally. Have to warn them in the changelog.

I can sign the comments if necessary. Please quash before merging.

Ahmet Oeztuerk added 6 commits February 24, 2026 16:47
the constructor assigns the global timeouts, which gets overwritten by the config parser if 'check_timeout' is given
… initialize them to 0 anymore.

logically the timeout cannot be 0
@sni
Copy link
Copy Markdown
Contributor

sni commented Feb 26, 2026

Looks good. Could you please have a look at the failed test case. Probably just missing the new values. Also it would be nice to add a Changelog entry in the NEWS file and also adding the new attribute to the docs on the website.

Ahmet Oeztuerk added 2 commits February 27, 2026 10:09
add check_timeout field to service and host definitions
mention host / service check timeout overrides
@sni sni merged commit eecfb11 into naemon:master Feb 28, 2026
4 checks passed
@nook24 nook24 mentioned this pull request Mar 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants