forked from OleHolmNielsen/Slurm_tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
notify_nodes_drained
executable file
·36 lines (29 loc) · 965 Bytes
/
notify_nodes_drained
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/bash
# Slurm trigger script for nodes in failing states
#
# MUST be executed by the slurm user, consistent with:
# scontrol show config | grep SlurmUser
# Configure these variables for your system:
slurm_user=slurm
slurm_notify=root
my_mail=/usr/bin/mailx
# Select the node state as one of: down,drained,fail,up (see "man strigger")
my_state=drained
# This will make the trigger permanent:
# my_flags="--flags=PERM"
# Check that we run as the slurm user
if test "`id -nu`" != "$slurm_user"
then
echo ERROR: The strigger command must be executed by the $slurm_user user
exit -1
fi
# Commands to be run for notification
function my_tasks() {
# Print node info
sinfo -lRN
# Submit trigger for next event ($0 = this script)
echo Setting new trigger --node --$my_state --program=$0
strigger --set --node --$my_state --program=$0 $my_flags
}
# Notify Slurm administrator of node state
my_tasks 2>&1 | $my_mail -s "Nodes $my_state: $@" $slurm_notify