The oarsub
command provides an option to send notifications of job events.
Quoting oarsub
manual page, the –notify
option works as follows:
--notify <TXT> Specify a notification method (mail or command to execute). Ex: --notify "mail:name@domain.com" --notify "exec:/path/to/script args" args are job_id,job_name,TAG,comment TAG can be: - RUNNING : when the job is launched - END : when the job is finished normally - ERROR : when the job is finished abnormally - INFO : used when oardel is called on the job - SUSPENDED : when the job is suspended - RESUMING : when the job is resumed By default all TAGs are triggered. It is possible to specify which TAGs must be triggered. Ex: --notify "[END,ERROR]mail:name@domain.com" --notify "[RUNNING]mail:name@domain.com" --notify "[RUNNING,END,ERROR]exec:/path/to/script args"
Using the exec
command, we can setup notification using other means than emails, e.g. xmpp (jabber), …
We can use the sendxmpp
command line XMPP client, to get notification as jabber instant messages.
To do so, we add the following script in our PATH
:
#!/bin/bash MY_ADDRESS="my.name@jabber.fr" # or for gmail: # MY_ADDRESS="firstname.lastname@gmail.com" job_id=$1 job_name=$2 TAG=$3 comment=$4 sendxmpp $MY_ADDRESS <<EOF Job $job_id ($job_name) $TAG on My Cluster: $comment EOF
sendxmpp
will have to authenticate itself to a jabber server, with credentials set in our ~/.sendxmpprc
(see the manual page of sendxmpprc
). We need to have a dedicated jabber user (different from the one we use to get the notification) to send the message, but that's not very expensive.
Assuming that the script is stored in /home/myself/bin/jabber.sh
, we can use it with:
$ oarsub --notify "exec:/home/myself/bin/jabber.sh" ...