From ebe29427f90e9c4310e7d0ff077109241429c8ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Thu, 2 Jan 2014 15:01:01 +0100 Subject: [PATCH] slurm: Email-Benachrichtigung --- aufgabe5.2/slurm/slurm-mail | 37 ++++++++++++++++++++++++ aufgabe5.2/slurm/slurm.conf | 3 +- bericht/abschnitte/bat-konfiguration.tex | 2 ++ 3 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 aufgabe5.2/slurm/slurm-mail diff --git a/aufgabe5.2/slurm/slurm-mail b/aufgabe5.2/slurm/slurm-mail new file mode 100644 index 0000000..9182ef1 --- /dev/null +++ b/aufgabe5.2/slurm/slurm-mail @@ -0,0 +1,37 @@ +#!/usr/bin/env perl +use warnings; +use strict; +use 5.014; + +if ($#ARGV < 2) { + say "USAGE: $0 -s msg recipient '$#ARGV'"; + exit 1; +} + +sub escape { + my $arg = shift; + + $arg =~ s/'/'\\''/g; + return "'" . $arg . "'"; +} + +my $msg = escape $ARGV[1]; +my $recipient = escape $ARGV[2]; + +die "no job id passed via argv" unless $msg =~ /Job_id=(\d+)/; +my $id = $1; + +open my $job_fh, "/var/log/slurm/job_completions" + or die "Could not open slurms jobcompletion: $!"; +my @matches = grep /$id/, <$job_fh>; +close $job_fh; + +if ($#matches < 0) { + die "job id $id not found"; +} +$matches[0] =~ s/\s+/\n/g; +my $new_msg = $matches[0]; + +open my $mail, "| mail -s $msg $recipient"; +print $mail $new_msg; +close $mail; diff --git a/aufgabe5.2/slurm/slurm.conf b/aufgabe5.2/slurm/slurm.conf index 8858d4b..62a1782 100644 --- a/aufgabe5.2/slurm/slurm.conf +++ b/aufgabe5.2/slurm/slurm.conf @@ -14,7 +14,8 @@ ProctrackType=proctrack/cgroup ReturnToService=2 TaskPlugin=task/affinity UsePAM=1 - +MailProg=/usr/local/bin/slurm-mail + # TIMERS SlurmctldTimeout=300 SlurmdTimeout=300 diff --git a/bericht/abschnitte/bat-konfiguration.tex b/bericht/abschnitte/bat-konfiguration.tex index 13d6aa7..f4c8976 100644 --- a/bericht/abschnitte/bat-konfiguration.tex +++ b/bericht/abschnitte/bat-konfiguration.tex @@ -26,3 +26,5 @@ __EOF__ $ batch --mail-type=END --mail-user=$USER /tmp/myscript \end{lstlisting} +Um die geforderten Informationen in der Email wie verwendete Nodes, Start- und Endzeitpunkt verschicken zu können, +haben wir ein Skript geschrieben (siehe aufgabe5.2/slurm/slurm-mail).