Hi,

> Am 17.10.2018 um 19:50 schrieb Nelson Kick <[email protected]>:
> 
> Is there any way to add variables to the standard “beas” mail?  Would like to 
> add
> additional info to this list… if possible, like SGE_O_PATH or other env 
> variables.
>  
> Job 114054 (STDIN) Complete
> User             = user
> Queue            = queue
> Host             = node01
> Start Time       = 10/17/2018 10:46:39
> End Time         = 10/17/2018 10:48:19
> User Time        = 00:00:00
> System Time      = 00:00:00
> Wallclock Time   = 00:01:40
> CPU              = 00:00:00
> Max vmem         = 237.992M
> Exit Status      = 0

Yes, it's possible. But there are several steps involved. First one has to 
realize, that these emails are send from the exechost, after the job left the 
exechost already. Hence nothing is left there to peek at. For me the most 
important items were the context variables, but feel free to add additonal ones 
(hence they will appear as being context variables simply when you add 
"foobar=baz" to the generated file). So, the steps are:

a) create a directory /var/spool/sge/context where the sgeadmin can write at. 
For me this locations was the logical choice, as we have local spool 
directories to lower the NFS traffic anyway, but it could also be the default 
location of the spool directories.


b) we need a script, which will run at the start of a job as prolog and under 
the sgeadmin account:

#!/bin/sh -p
#
# This script saves some information in the /var/spool/sge/context area to be
# retrieved later on when generating the email about the job completion.
#

export PATH=/usr/local/bin:/bin:/usr/bin
. /usr/sge/default/common/settings.sh

if [ "${SGE_TASK_ID}" != "undefined" ]; then
    JOB_ID=${JOB_ID}.${SGE_TASK_ID}
fi

#
# Attach the list of granted nodes to the job context.
# (This only works, if it's not an array job.)
#

if [ "${SGE_TASK_ID}" = "undefined" ]; then
    if [ "${NSLOTS:-1}" -eq 1 ]; then
       qalter -ac NODES=$(hostname):1 $JOB_ID > /dev/null
    else
       qalter -ac NODES=$(awk '{slots[$1]+=$2} END { for (host in slots) { 
printf entry?"+":""; printf host":"slots[host]; entry=1 }}' ${PE_HOSTFILE}) 
${JOB_ID} > /dev/null
    fi
fi

#
# Record all context variables in the /var/spool/sge/context/$JOB_ID file to
# have access to it also after the job has finished.
#

if [ -d /var/spool/sge/context -a -w /var/spool/sge/context ]; then
    qstat -j ${JOB_ID} | sed -n -e "/^context/{s/^context: 
*//;s/,/\n/g;s/;/,/g;p}" > /var/spool/sge/context/${JOB_ID}
fi

#
# Be sure to exit with 0, even when the grep wasn't successful.
#

exit 0


c) this script must be defined in the SGE configuration with: qconf -mconf

prolog                       sgeadmin@/usr/sge/cluster/busybox env -u \
                             LD_LIBRARY_PATH -u LD_PRELOAD -u IFS \
                             /usr/sge/cluster/context.sh

Using busybox here is a safety measure, as a sneaky user could set some 
variables to get something executed as sgeadmin this way. As you might notice, 
I store all the custom scripts for SGE in /usr/sge/cluster, but this could be 
any location.


d) we need a custom mail-wrapper script, which will read the just written file 
and retrieve the necessary information

I will post this shortly. I wonder to post two scripts, as ours include in the 
current version also the ability to attach the last 1 MiB of the output file to 
the sent email, so that the users can check the result of the computation even 
without login into the cluster.


e) this mail-wrapper script needs again to be defined with: qconf -mconf

mailer                       /usr/sge/cluster/mailer.sh

-- Reuti


_______________________________________________
users mailing list
[email protected]
https://gridengine.org/mailman/listinfo/users

Reply via email to