From af34cc269b8baafae18ef20ec3661db703fd6519 Mon Sep 17 00:00:00 2001 From: nook24 Date: Mon, 5 Feb 2024 17:10:18 +0100 Subject: [PATCH 1/6] Currently the documentation for CHANGE_CUSTOM_*_VAR is wrong. All example are shown with a leading underscore like "_SOMEVAR" which does not work. To change the value of the variable, the name does not have an underscore as prefix. Signed-off-by: nook24 --- .../developer/externalcommands/change_custom_contact_var.md | 3 ++- .../developer/externalcommands/change_custom_host_var.md | 3 ++- .../developer/externalcommands/change_custom_svc_var.md | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/documentation/developer/externalcommands/change_custom_contact_var.md b/documentation/developer/externalcommands/change_custom_contact_var.md index 2548212..b32d054 100644 --- a/documentation/developer/externalcommands/change_custom_contact_var.md +++ b/documentation/developer/externalcommands/change_custom_contact_var.md @@ -26,8 +26,9 @@ Changes the value of a custom contact variable. #!/bin/sh # This is a sample shell script showing how you can submit the CHANGE_CUSTOM_CONTACT_VAR command # to Naemon. Adjust variables to fit your environment as necessary. +# This will change value of the custom variable: $_CONTACTSOMEVAR$ -printf "[%lu] CHANGE_CUSTOM_CONTACT_VAR;naemonadmin;_SOMEVAR;some new value\n" `date +%s` > /var/lib/naemon/naemon.cmd +printf "[%lu] CHANGE_CUSTOM_CONTACT_VAR;naemonadmin;SOMEVAR;some new value\n" `date +%s` > /var/lib/naemon/naemon.cmd ``` diff --git a/documentation/developer/externalcommands/change_custom_host_var.md b/documentation/developer/externalcommands/change_custom_host_var.md index 20136e8..a14bbe3 100644 --- a/documentation/developer/externalcommands/change_custom_host_var.md +++ b/documentation/developer/externalcommands/change_custom_host_var.md @@ -26,8 +26,9 @@ Changes the value of a custom host variable. #!/bin/sh # This is a sample shell script showing how you can submit the CHANGE_CUSTOM_HOST_VAR command # to Naemon. Adjust variables to fit your environment as necessary. +# This will change value of the custom variable: $_HOSTSOMEVAR$ -printf "[%lu] CHANGE_CUSTOM_HOST_VAR;host1;_SOMEVAR;some new value\n" `date +%s` > /var/lib/naemon/naemon.cmd +printf "[%lu] CHANGE_CUSTOM_HOST_VAR;host1;SOMEVAR;some new value\n" `date +%s` > /var/lib/naemon/naemon.cmd ``` diff --git a/documentation/developer/externalcommands/change_custom_svc_var.md b/documentation/developer/externalcommands/change_custom_svc_var.md index 1507945..195b9f9 100644 --- a/documentation/developer/externalcommands/change_custom_svc_var.md +++ b/documentation/developer/externalcommands/change_custom_svc_var.md @@ -26,8 +26,9 @@ Changes the value of a custom service variable. #!/bin/sh # This is a sample shell script showing how you can submit the CHANGE_CUSTOM_SVC_VAR command # to Naemon. Adjust variables to fit your environment as necessary. +# This will change value of the custom variable: $_SERVICESOMEVAR$ -printf "[%lu] CHANGE_CUSTOM_SVC_VAR;host1;service1;_SOMEVAR;some new value\n" `date +%s` > /var/lib/naemon/naemon.cmd +printf "[%lu] CHANGE_CUSTOM_SVC_VAR;host1;service1;SOMEVAR;some new value\n" `date +%s` > /var/lib/naemon/naemon.cmd ``` From 79e717b6088294248cb50b2f92cdf17a2b277f16 Mon Sep 17 00:00:00 2001 From: nook24 Date: Mon, 5 Feb 2024 17:32:43 +0100 Subject: [PATCH 2/6] Update description of *PROBLEMID and *NOTIFICATIONID macros which are now UUIDv4 strings instead of integer counter values https://github.com/naemon/naemon-core/pull/447 Signed-off-by: nook24 --- documentation/usersguide/macrolist.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/documentation/usersguide/macrolist.md b/documentation/usersguide/macrolist.md index caa0a03..65d3287 100644 --- a/documentation/usersguide/macrolist.md +++ b/documentation/usersguide/macrolist.md @@ -888,11 +888,11 @@ macros consist of all uppercase characters and are enclosed in $ characte $HOSTPROBLEMID$ -A globally unique number associated with the host's current problem state. Every time a host (or service) transitions from an UP or OK state to a problem state, a global problem ID number is incremented by one (1). This macro will be non-zero if the host is currently a non-UP state. State transitions between non-UP states (e.g. DOWN to UNREACHABLE) do not cause this problem id to increase. If the host is currently in an UP state, this macro will be set to zero (0). Combined with event handlers, this macro could be used to automatically open trouble tickets when hosts first enter a problem state. +A globally unique UUIDv4 (e.g. 29304481-91eb-4a2f-8b6d-8858b4548741) associated with the host's current problem state. Every time a host (or service) transitions from an UP or OK state to a problem state, a global problem UUID is generated. This macro will be a UUID string if the host is currently a non-UP state. State transitions between non-UP states (e.g. DOWN to UNREACHABLE) do not cause this problem id to change. If the host is currently in an UP state, this macro will be set to an empty string. Combined with event handlers, this macro could be used to automatically open trouble tickets when hosts first enter a problem state. $LASTHOSTPROBLEMID$ -The previous (globally unique) problem number that was given to the host. Combined with event handlers, this macro could be used for automatically closing trouble tickets, etc. when a host recovers to an UP state. +The previous (globally unique) problem UUID that was given to the host. Combined with event handlers, this macro could be used for automatically closing trouble tickets, etc. when a host recovers to an UP state. $HOSTLATENCY$ @@ -1088,11 +1088,11 @@ macros consist of all uppercase characters and are enclosed in $ characte $SERVICEPROBLEMID$ -A globally unique number associated with the service's current problem state. Every time a service (or host) transitions from an OK or UP state to a problem state, a global problem ID number is incremented by one (1). This macro will be non-zero if the service is currently a non-OK state. State transitions between non-OK states (e.g. WARNING to CRITICAL) do not cause this problem id to increase. If the service is currently in an OK state, this macro will be set to zero (0). Combined with event handlers, this macro could be used to automatically open trouble tickets when services first enter a problem state. +A globally unique UUIDv4 (e.g. 39dbb346-f483-49fe-8211-feec8edf90ea) associated with the service's current problem state. Every time a service (or host) transitions from an OK or UP state to a problem state, a global problem UUID is generated. This macro will be a UUID if the service is currently a non-OK state. State transitions between non-OK states (e.g. WARNING to CRITICAL) do not cause this problem id to change. If the service is currently in an OK state, this macro will be set to an empty string. Combined with event handlers, this macro could be used to automatically open trouble tickets when services first enter a problem state. $LASTSERVICEPROBLEMID$ -The previous (globally unique) problem number that was given to the service. Combined with event handlers, this macro could be used for automatically closing trouble tickets, etc. when a service recovers to an OK state. +The previous (globally unique) problem UUID that was given to the service. Combined with event handlers, this macro could be used for automatically closing trouble tickets, etc. when a service recovers to an OK state. $SERVICELATENCY$ @@ -1368,7 +1368,7 @@ macros consist of all uppercase characters and are enclosed in $ characte $HOSTNOTIFICATIONID$ -A unique number identifying a host notification. Notification ID numbers are unique across both hosts and service notifications, so you could potentially use this unique number as a primary key in a notification database. Notification ID numbers should remain unique across restarts of the Naemon process, so long as you have state retention enabled. The notification ID number is incremented by one (1) each time a new host notification is sent out, and regardless of how many contacts are notified. +A unique UUIDv4 (e.g. 3a07d4f2-575e-413b-8166-9ccdd22d418a) identifying a host notification. Notification UUID strings are unique across both hosts and service notifications, so you could potentially use this unique string as a primary key in a notification database. Notification UUIDs should remain unique across restarts of the Naemon process, so long as you have state retention enabled. The notification UUID is generated each time a new host notification is sent out, and the same regardless of how many contacts are notified. $SERVICENOTIFICATIONNUMBER$ @@ -1376,7 +1376,7 @@ macros consist of all uppercase characters and are enclosed in $ characte $SERVICENOTIFICATIONID$ -A unique number identifying a service notification. Notification ID numbers are unique across both hosts and service notifications, so you could potentially use this unique number as a primary key in a notification database. Notification ID numbers should remain unique across restarts of the Naemon process, so long as you have state retention enabled. The notification ID number is incremented by one (1) each time a new service notification is sent out, and regardless of how many contacts are notified. +A unique UUIDv4 (e.g. cebd5487-538f-4f5b-87cc-8e18b4e2170c) identifying a service notification. Notification UUID strings are unique across both hosts and service notifications, so you could potentially use this unique string as a primary key in a notification database. Notification UUIDs should remain unique across restarts of the Naemon process, so long as you have state retention enabled. The notification UUID is generated each time a new service notification is sent out, and the same regardless of how many contacts are notified.
From 105542a2e7cf2af1d845a0c00ac4125f0b06395d Mon Sep 17 00:00:00 2001 From: nook24 Date: Mon, 5 Feb 2024 20:06:51 +0100 Subject: [PATCH 3/6] Add new macros to docs https://github.com/naemon/naemon-core/pull/447 Signed-off-by: nook24 --- documentation/usersguide/macrolist.md | 64 +++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/documentation/usersguide/macrolist.md b/documentation/usersguide/macrolist.md index 65d3287..4ece6e2 100644 --- a/documentation/usersguide/macrolist.md +++ b/documentation/usersguide/macrolist.md @@ -237,6 +237,22 @@ macros consist of all uppercase characters and are enclosed in $ characte $TOTALHOSTSERVICESCRITICAL$ YesYesYesYesYesYesYesYes + +$HOSTPROBLEMSTART$ +YesYesYesYesYesYesYesYes + + +$HOSTPROBLEMEND$ +YesYesYesYesYesYesYesYes + + +$HOSTPROBLEMDURATIONSEC$ +YesYesYesYesYesYesYesYes + + +$HOSTPROBLEMDURATION$ +YesYesYesYesYesYesYesYes +
Macro Name @@ -443,6 +459,22 @@ macros consist of all uppercase characters and are enclosed in $ characte $SERVICENOTES$ YesYesNoNoYesNoYesNo + +$SERVICEPROBLEMSTART$ +YesYesYesYesYesYesYesYes + + +$SERVICEPROBLEMEND$ +YesYesYesYesYesYesYesYes + + +$SERVICEPROBLEMDURATIONSEC$ +YesYesYesYesYesYesYesYes + + +$SERVICEPROBLEMDURATION$ +YesYesYesYesYesYesYesYes +
Macro Name @@ -1010,6 +1042,22 @@ macros consist of all uppercase characters and are enclosed in $ characte $TOTALHOSTSERVICESCRITICAL$ The total number of services associated with the host that are in a CRITICAL state. + +$HOSTPROBLEMSTART$ +This is a timestamp in time_t format (seconds since the UNIX epoch) indicating the time at which the host state changed into a non-Up state. + + +$HOSTPROBLEMEND$ +This is a timestamp in time_t format (seconds since the UNIX epoch) indicating the time at which the host state changed changed back into Up state. + + +$HOSTPROBLEMDURATIONSEC$ +The duration in seconds bettwen $HOSTPROBLEMSTART$ and $HOSTPROBLEMEND$. + + +$HOSTPROBLEMDURATION$ +The duration bettwen $HOSTPROBLEMSTART$ and $HOSTPROBLEMEND$ in a human readable format e.g.: 1d 10h 8m 35s +
Host Group Macros: 5 @@ -1194,6 +1242,22 @@ macros consist of all uppercase characters and are enclosed in $ characte $SERVICENOTES$ Notes for the service. This macro may contain other macros (e.g. $HOSTNAME$ or $SERVICESTATE$), which can be useful when you want to service-specific status information, etc. in the description + +$SERVICEPROBLEMSTART$ +This is a timestamp in time_t format (seconds since the UNIX epoch) indicating the time at which the service state changed into a non-Ok state. + + +$SERVICEPROBLEMEND$ +This is a timestamp in time_t format (seconds since the UNIX epoch) indicating the time at which the service state changed changed back into Ok state. + + +$SERVICEPROBLEMDURATIONSEC$ +The duration in seconds bettwen $SERVICEPROBLEMSTART$ and $SERVICEPROBLEMEND$. + + +$SERVICEPROBLEMDURATION$ +The duration bettwen $SERVICEPROBLEMSTART$ and $SERVICEPROBLEMEND$ in a human readable format e.g.: 1d 10h 8m 35s +
Service Group Macros: 6 From 133f285e768eef0a2403a30721be7b362eda2f33 Mon Sep 17 00:00:00 2001 From: nook24 Date: Tue, 6 Feb 2024 09:28:29 +0100 Subject: [PATCH 4/6] Add Dockerfile to build the site locally Signed-off-by: nook24 --- Dockerfile | 19 +++++++++++++++++++ README.md | 16 ++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..54db639 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,19 @@ +FROM alpine:3.19 + +# This is highly inspired from https://github.com/Starefossen/docker-github-pages +# Many thanks + +RUN apk --update add --virtual build_deps \ + build-base ruby-dev libc-dev linux-headers jekyll +RUN gem install --verbose --no-document github-pages bundler + +RUN mkdir -p /site + +WORKDIR /site + +EXPOSE 4000 + +CMD bundle exec jekyll serve --watch --force_polling -H 0.0.0.0 -P 4000 + +# docker build . -t naemon/docs +# docker run --rm -it -v "$PWD":/site -p "4000:4000" naemon/docs:latest \ No newline at end of file diff --git a/README.md b/README.md index 08ca53e..12b29e5 100644 --- a/README.md +++ b/README.md @@ -9,3 +9,19 @@ Install locally --------------- Read the online guide from github at: https://help.github.com/articles/setting-up-your-github-pages-site-locally-with-jekyll/ + + +Run locally using Docker +--------------- + +First build the Docker image which will contain Ruby, Jekyll and all the required dependencies +``` +docker build . -t naemon/docs +``` + +Now run the Docker container and navigate to `http://127.0.0.1:4000` in your browser. +The container watches for file changes and will automatically regenerate the website if needed. + +``` +docker run --rm -it -v "$PWD":/site -p "4000:4000" naemon/docs:latest +``` From 00d5847f266835c835bace699bd1c5fd7bb23772 Mon Sep 17 00:00:00 2001 From: nook24 Date: Tue, 6 Feb 2024 09:28:40 +0100 Subject: [PATCH 5/6] Add Dockerfile to build the site locally Signed-off-by: nook24 --- Dockerfile | 3 --- 1 file changed, 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 54db639..d76e732 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,6 +14,3 @@ WORKDIR /site EXPOSE 4000 CMD bundle exec jekyll serve --watch --force_polling -H 0.0.0.0 -P 4000 - -# docker build . -t naemon/docs -# docker run --rm -it -v "$PWD":/site -p "4000:4000" naemon/docs:latest \ No newline at end of file From c0e715de20add45b7f6f6afeea6bb29bf9701a51 Mon Sep 17 00:00:00 2001 From: nook24 Date: Tue, 6 Feb 2024 09:32:27 +0100 Subject: [PATCH 6/6] Fix typo in between Signed-off-by: nook24 --- documentation/usersguide/macrolist.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/documentation/usersguide/macrolist.md b/documentation/usersguide/macrolist.md index 4ece6e2..e8e0089 100644 --- a/documentation/usersguide/macrolist.md +++ b/documentation/usersguide/macrolist.md @@ -1052,11 +1052,11 @@ macros consist of all uppercase characters and are enclosed in $ characte $HOSTPROBLEMDURATIONSEC$ -The duration in seconds bettwen $HOSTPROBLEMSTART$ and $HOSTPROBLEMEND$. +The duration in seconds between $HOSTPROBLEMSTART$ and $HOSTPROBLEMEND$. $HOSTPROBLEMDURATION$ -The duration bettwen $HOSTPROBLEMSTART$ and $HOSTPROBLEMEND$ in a human readable format e.g.: 1d 10h 8m 35s +The duration between $HOSTPROBLEMSTART$ and $HOSTPROBLEMEND$ in a human readable format e.g.: 1d 10h 8m 35s
@@ -1252,11 +1252,11 @@ macros consist of all uppercase characters and are enclosed in $ characte $SERVICEPROBLEMDURATIONSEC$ -The duration in seconds bettwen $SERVICEPROBLEMSTART$ and $SERVICEPROBLEMEND$. +The duration in seconds between $SERVICEPROBLEMSTART$ and $SERVICEPROBLEMEND$. $SERVICEPROBLEMDURATION$ -The duration bettwen $SERVICEPROBLEMSTART$ and $SERVICEPROBLEMEND$ in a human readable format e.g.: 1d 10h 8m 35s +The duration between $SERVICEPROBLEMSTART$ and $SERVICEPROBLEMEND$ in a human readable format e.g.: 1d 10h 8m 35s