-
Notifications
You must be signed in to change notification settings - Fork 63
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
Conversation
08fc5e0
to
3674648
Compare
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.
3674648
to
d671fe1
Compare
src/naemon/configuration.c
Outdated
@@ -1455,7 +1497,7 @@ int pre_flight_object_check(int *w, int *e) | |||
} | |||
|
|||
/* check to see if there is at least one contact/group */ | |||
if (temp_service->contacts == NULL && temp_service->contact_groups == NULL) { | |||
if (temp_service->contacts == NULL && temp_service->contact_groups == NULL && global_service_event_handler == NULL) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That should be probably global_service_notification_handler
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks, you are totally right
src/naemon/defaults.h
Outdated
@@ -47,6 +47,7 @@ | |||
#define DEFAULT_LOG_CURRENT_STATES 1 /* log current service and host states after rotating log */ | |||
#define DEFAULT_LOG_EXTERNAL_COMMANDS 1 /* log external commands */ | |||
#define DEFAULT_LOG_PASSIVE_CHECKS 1 /* log passive service checks */ | |||
#define DEFAULT_log_global_notifications 1 /* log global notifications */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we uppercase this please
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i am pretty sure it was uppercase initially :-) Will fix it again
src/naemon/logging.h
Outdated
@@ -39,6 +39,7 @@ | |||
|
|||
#define NSLOG_HOST_NOTIFICATION 524288 | |||
#define NSLOG_SERVICE_NOTIFICATION 1048576 | |||
#define NSLOG_EXT_CUSTOM 2097152 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please remove one \t
so all numbers line up nicely
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks aligned too me with ts=4. But i can replace all tabs in that file with spaces, but that'll be an extra commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/naemon/notifications.c
Outdated
free(nj); | ||
} | ||
|
||
/* @todo Handle nebmod stuff when getting results from workers */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this still relevant?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed it...
This is a new feature introduced by naemon/naemon-core#477 Signed-off-by: nook24 <[email protected]>
align constants with spaces
This pull request sets up GitHub code scanning for this repository. Once the scans have completed and the checks have passed, the analysis results for this pull request branch will appear on this overview. Once you merge this pull request, the 'Security' tab will show more code scanning analysis results (for example, for the default branch). Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results. For more information about GitHub code scanning, check out the documentation. |
Add global notification handler in the same way as global event handlers. It adds 2 new
global options:
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:
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
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.:
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.: