Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature global notification handler #477

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

sni
Copy link
Contributor

@sni sni commented Sep 12, 2024

Add global notification handler in the same way as global event handlers. It adds 2 new
global options:

  • global_host_notification_handler=global-host-notify
  • global_service_notification_handler=global-service-notify

which will be run each time a normal notification would be considered. It does not require
contacts for hosts and services. If used it will also prevent warnings if hosts/services do
not have contacts set.
The global notification handlers do not have any contact macros set, because they are independent of contacts.

This PR also adds another global option:

  • log_global_notifications

This option can be used to suppress a log entry each time the global notification handler is run.

Finally this PR adds a new generic external command

  • LOG

It can be used to add custom log entries to the main naemon log file. For example to add the
actual notified contacts to the log file.

ex.:

printf "[%lu] LOG;SERVICE NOTIFICATION: test contact;testhost;test service;CRITICAL;notify-by-email;test message\n" `date +%s` >> .../tmp/run/naemon.cmd

which would add a log entry similar to a normal notification. The actual hosts/services/contacts and commands don't have to exist.

Or other notes like ex.:

printf "[%lu] LOG;SERVICE NOTE: testhost;event handler restarted service successfully\n" `date +%s` >> .../tmp/run/naemon.cmd

@sni sni force-pushed the feature_global_notification_handler branch from 08fc5e0 to 3674648 Compare September 13, 2024 06:59
global notification handler are like global event handler. They are fired each time
a notification would be sent out (regardless whether there is a contact or not)

    global_host_notification_handler=somecommand
    global_service_notification_handler=somecommand

global notification handler work like normal notifications, except they don't have contact
related macros set.
the global notification handler adds quite some noise to the log file, so
make it possible to disable it.
This generic LOG command can be used to add entries to the main logfile. It is
useful ex.: from a global notification handler to log the actual notified contacts.
@sni sni force-pushed the feature_global_notification_handler branch from 3674648 to d671fe1 Compare September 13, 2024 12:34
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.

1 participant