Allow some services to have public notifications and others private
authorAlex Dehnert <alex@dehnerts.com>
Mon, 9 Oct 2023 04:23:57 +0000 (04:23 +0000)
committerAlex Dehnert <alex@dehnerts.com>
Mon, 9 Oct 2023 04:33:50 +0000 (04:33 +0000)
conf.d/zephyr.cfg
local.d/adehnert-host.cfg
local.d/contacts.cfg

index 21db066a98bf6c31dddb26d08154f967a2ce69bc..d9c83e9754629851f1dd5163c95ac78ae0a64a85 100644 (file)
@@ -1,11 +1,16 @@
+# -n: Don't send pings
+# -d: Don't try to auth
+# -S: sender (use non-default to allow muting separately in e.g. Zulip)
+# -s: zsig
+
 # 'host-notify-by-zephyr' command definition
 define command{
         command_name    host-notify-by-zephyr
-        command_line    /usr/bin/printf "%b" "Host $HOSTSTATE$ $NOTIFICATIONTYPE$ alert for $HOSTNAME$!\n$HOSTOUTPUT$\n$LONGHOSTOUTPUT$" | /usr/bin/zwrite -d -s "Nagios" -i "nagios.$HOSTALIAS$" "$CONTACTADDRESS1$"
+        command_line    /usr/bin/printf "%b" "Host $HOSTSTATE$ $NOTIFICATIONTYPE$ alert for $HOSTNAME$!\n$HOSTOUTPUT$\n$LONGHOSTOUTPUT$" | /usr/bin/zwrite -n -d -S nagios-adehnert -s "Nagios" -c "$CONTACTEMAIL$" -i "nagios.$HOSTALIAS$" "$CONTACTADDRESS1$"
         }
 
 # 'notify-by-zephyr' command definition
 define command{
         command_name    notify-by-zephyr
-        command_line    /usr/bin/printf "%b" "$NOTIFICATIONTYPE$ alert - $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$\n$SERVICEOUTPUT$\n$LONGSERVICEOUTPUT$" | /usr/bin/zwrite -d -s "Nagios" -i "nagios.$HOSTALIAS$.$SERVICEDESC$" "$CONTACTADDRESS1$"
+        command_line    /usr/bin/printf "%b" "$NOTIFICATIONTYPE$ alert - $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$\n$SERVICEOUTPUT$\n$LONGSERVICEOUTPUT$" | /usr/bin/zwrite -n -d -S nagios-adehnert -s "Nagios" -c "$CONTACTEMAIL$" -i "nagios.$HOSTALIAS$.$SERVICEDESC$" "$CONTACTADDRESS1$"
         }
index 44db2002b5f803a888ebbd56d2f7be5c42fb0490..d22a1fd14056899c1c6407895c31c51c040c5d8b 100644 (file)
@@ -1,6 +1,7 @@
 define host{
        name            adehnert-host
        use             generic-host
+       contact_groups  adehnert-pub
        notification_interval 240
        max_check_attempts              5
        register        0
@@ -63,6 +64,7 @@ define service {
     hostgroup_name      adehnert-minions
     service_description SERVICES-ALL
     check_command       check_byssh_generic!check_services_all
+    contact_groups      adehnert-priv
 }
 
 define service {
index f15c7b5d45f83d56191fde09aec99ce9c76ecd8c..9d7b852c38aff501008d2ef8eaa168bb26b8cbd5 100644 (file)
@@ -10,6 +10,12 @@ define contactgroup {
         members                 adehnert-pub-zephyr
 }
 
+define contactgroup {
+        contactgroup_name       adehnert-priv
+        alias                   adehnert-priv
+        members                 adehnert-priv-zephyr
+}
+
 define contact {
         contact_name                    adehnert-pub-zephyr
         alias                           adehnert-pub-zephyr
@@ -20,6 +26,21 @@ define contact {
         service_notification_commands   notify-by-zephyr
         host_notification_commands      host-notify-by-zephyr
         email                           adehnert-auto
+        # Intentionally blank, so message is public
+        address1
+}
+
+
+define contact {
+        contact_name                    adehnert-priv-zephyr
+        alias                           adehnert-priv-zephyr
+        service_notification_period     24x7
+        host_notification_period        24x7
+        service_notification_options    w,u,c,r
+        host_notification_options       d,u,r
+        service_notification_commands   notify-by-zephyr
+        host_notification_commands      host-notify-by-zephyr
+        email                           message
         address1                        adehnert
 }