From 31d0f8a92167f0e4ece6c830869d00f3d8d83b4a Mon Sep 17 00:00:00 2001
From: Simon Michnowicz <simon.michnowicz@monash.edu>
Date: Fri, 17 Jul 2020 14:59:17 +1000
Subject: [PATCH] updated with syslog 'logger' message

---
 roles/slurm-trigger/templates/node_down.sh.j2               | 6 +++++-
 .../slurm-trigger/templates/primary_slurmctld_failure.sh.j2 | 5 ++++-
 .../templates/primary_slurmctld_resumed_operation.sh.j2     | 6 +++++-
 3 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/roles/slurm-trigger/templates/node_down.sh.j2 b/roles/slurm-trigger/templates/node_down.sh.j2
index 679e18c7..dba68ecf 100644
--- a/roles/slurm-trigger/templates/node_down.sh.j2
+++ b/roles/slurm-trigger/templates/node_down.sh.j2
@@ -1,8 +1,12 @@
 #!/bin/bash
 # Notify the administrator of the failure using by e-mail
-echo "On `hostname`:`date`:`whoami`: slurm-trigger event for NODE_FAILURE: $*" | `which mail` -s "NODE FAILURE $*" {{ admin_email }}
+MESSAGE="On `hostname`:`date`:`whoami`: slurm-trigger event for NODE_FAILURE: $*"
+MAIL_HEADER="NODE FAILURE $*"
+echo "${MESSAGE}" | `which mail` -s "${MAIL_HEADER} FAILURE $*" {{ admin_email }}
 # Submit trigger for next primary slurmctld failure event
 TRIGGER_CMD="{{ slurm_dir }}/sbin/set_node_trigger.sh"
+#write to syslog
+logger "${MESSAGE}"
 
 FILE=/tmp/node_down.txt
 #COMMAND="su slurm -c $TRIGGER_CMD"
diff --git a/roles/slurm-trigger/templates/primary_slurmctld_failure.sh.j2 b/roles/slurm-trigger/templates/primary_slurmctld_failure.sh.j2
index 61747379..aa64f934 100644
--- a/roles/slurm-trigger/templates/primary_slurmctld_failure.sh.j2
+++ b/roles/slurm-trigger/templates/primary_slurmctld_failure.sh.j2
@@ -1,8 +1,11 @@
 #!/bin/bash
 # Notify the administrator of the failure using by e-mail
-echo "On `hostname`:`date`:`who`: slurm-trigger event for Primary_SLURMCTLD_FAILURE" | `which mail` -s Primary_SLURMCTLD_FAILURE {{ admin_email }} 
+MESSASGE="On `hostname`:`date`:`who`: slurm-trigger event for Primary_SLURMCTLD_FAILURE" 
+echo "${MESSAGE}" | `which mail` -s Primary_SLURMCTLD_FAILURE {{ admin_email }} 
 # Submit trigger for next primary slurmctld failure event
 TRIGGER_CMD="{{ slurm_dir }}/sbin/set_primary_slurmctld_failure_trigger.sh"
+#log to syslog
+logger "${MESSAGE}"
 
 FILE=/tmp/primary_down.txt
 #COMMAND="su slurm -c $TRIGGER_CMD"
diff --git a/roles/slurm-trigger/templates/primary_slurmctld_resumed_operation.sh.j2 b/roles/slurm-trigger/templates/primary_slurmctld_resumed_operation.sh.j2
index b8e6788b..e2a7ccb9 100644
--- a/roles/slurm-trigger/templates/primary_slurmctld_resumed_operation.sh.j2
+++ b/roles/slurm-trigger/templates/primary_slurmctld_resumed_operation.sh.j2
@@ -1,8 +1,12 @@
 #!/bin/bash
 # Notify the administrator of the failure using by e-mail
-echo "On `hostname`:`date`:`whoami`: slurm-trigger event for Primary_SLURMCTLD_RESUMED" | `which mail` -s Primary_SLURMCTLD_RESUMED {{ admin_email }} 
+MESSAGE="On `hostname`:`date`:`whoami`: slurm-trigger event for Primary_SLURMCTLD_RESUMED"
+echo "${MESSAGE}" | `which mail` -s Primary_SLURMCTLD_RESUMED {{ admin_email }} 
 # Submit trigger for next primary slurmctld failure event
 
+#write to syslog
+logger "${MESSAGE}"
+
 FILE=/tmp/primary_up.txt
 #COMMAND="su slurm -c {{ slurm_dir }}/sbin/set_primary_slurmctld_resumed_operation_trigger.sh"
 COMMAND="{{ slurm_dir }}/sbin/set_primary_slurmctld_resumed_operation_trigger.sh"
-- 
GitLab