Ticket 5295 - Advice on writing an epilog script
Summary: Advice on writing an epilog script
Status: RESOLVED INFOGIVEN
Alias: None
Product: Slurm
Classification: Unclassified
Component: Configuration (show other tickets)
Version: 17.02.8
Hardware: Linux Linux
: 4 - Minor Issue
Assignee: Felip Moll
QA Contact:
URL:
Depends on:
Blocks:
 
Reported: 2018-06-12 03:06 MDT by David Baker
Modified: 2018-06-25 10:02 MDT (History)
1 user (show)

See Also:
Site: OCF
Slinky Site: ---
Alineos Sites: ---
Atos/Eviden Sites: ---
Confidential Site: ---
Coreweave sites: ---
Cray Sites: ---
DS9 clusters: ---
Google sites: ---
HPCnow Sites: ---
HPE Sites: ---
IBM Sites: ---
NOAA SIte: ---
NoveTech Sites: ---
Nvidia HWinf-CS Sites: ---
OCF Sites: Southampton University
Recursion Pharma Sites: ---
SFW Sites: ---
SNIC sites: ---
Tzag Elita Sites: ---
Linux Distro: ---
Machine Name:
CLE Version:
Version Fixed:
Target Release: ---
DevPrio: ---
Emory-Cloud Sites: ---


Attachments

Note You need to log in before you can comment on or make changes to this ticket.
Description David Baker 2018-06-12 03:06:33 MDT
Hello,

This is hopefully a trivial question for someone. I am writing/modifying the slurmd Epilog script, and I am finding an odd effect when I ran the Epilog as part of a job. 

There is a perl script called "seff" to report on job efficiency. This script is actually part of the slurm-contrib rpm. I've taken a copy of this script and made a relatively minor modification to it. That is, I have replaced the following line...

printf("CPU Efficiency: %.2f%% of %s core-walltime\n", $cpu_eff, time2str($corewalltime));

with... (referencing the appropriate perl modules)

    if ($cpu_eff < 50) {
       printf color('bold red');
       printf("CPU Efficiency: %.2f%% of %s core-walltime\n", $cpu_eff, time2str($corewalltime));
       printf color('reset');
    } else {
       printf("CPU Efficiency: %.2f%% of %s core-walltime\n", $cpu_eff, time2str($corewalltime));
    }

When I test this script interactively it works as expected. If the CPU efficiency of a job is < 50% then the CPU Efficiency is written in  bold red. 

On the other hand, when I call seff in my Epilog script...

/bin/perl /local/software/slurm/bin/seff ${SLURM_JOB_ID} >>$stdout

I find that the script is executed, but all I see are the "raw codes" rather than the colour red. That is...

ESC[1;31mCPU Efficiency: 0.49% of 00:06:48 core-walltime
ESC[0mMemory Utilized: 0.00 MB (estimated maximum)

Is this something that you advise on, please?

Best regards,
David
Comment 1 Felip Moll 2018-06-13 08:56:44 MDT
Hi David,

Can you show me your full epilog script? Where do you expect that the output is written? ($stdout variable).

I would understand a task prolog writting to the stdout of the job, but where should the output with color go in this case?

For the task prolog it would be something like:

#!/bin/bash
echo -e "print \\033[48;5;95;38;5;214mHello Slurm\\033[0m" 

Can you try your approach with echo -e instead of adding seff in the middle?

echo -e "\\033[48;5;95;38;5;214mHello Slurm\\033[0m"

This code colors are interpreted by bash, depending on where you write and how you read them you will see the color or just the code.
Comment 2 Felip Moll 2018-06-25 10:02:01 MDT
Hi David,

I am closing this issue as "infogiven" since no response have been issued in the last 14 days.

Feel free to mark this bug as OPEN again if you need further assistance, or just open a new one.

Thanks
Felip